google_firestore1/
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 and manage your Google Cloud Datastore data
20    Datastore,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27            Scope::Datastore => "https://www.googleapis.com/auth/datastore",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::Datastore
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Firestore related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_firestore1 as firestore1;
53/// use firestore1::api::GoogleFirestoreAdminV1Field;
54/// use firestore1::{Result, Error};
55/// # async fn dox() {
56/// use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67///     .with_native_roots()
68///     .unwrap()
69///     .https_only()
70///     .enable_http2()
71///     .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75///     secret,
76///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77///     yup_oauth2::client::CustomHyperClientBuilder::from(
78///         hyper_util::client::legacy::Client::builder(executor).build(connector),
79///     ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83///     hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86///     hyper_rustls::HttpsConnectorBuilder::new()
87///         .with_native_roots()
88///         .unwrap()
89///         .https_or_http()
90///         .enable_http2()
91///         .build()
92/// );
93/// let mut hub = Firestore::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = GoogleFirestoreAdminV1Field::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.projects().databases_collection_groups_fields_patch(req, "name")
103///              .update_mask(FieldMask::new::<&str>(&[]))
104///              .doit().await;
105///
106/// match result {
107///     Err(e) => match e {
108///         // The Error enum provides details about what exactly happened.
109///         // You can also just use its `Debug`, `Display` or `Error` traits
110///          Error::HttpError(_)
111///         |Error::Io(_)
112///         |Error::MissingAPIKey
113///         |Error::MissingToken(_)
114///         |Error::Cancelled
115///         |Error::UploadSizeLimitExceeded(_, _)
116///         |Error::Failure(_)
117///         |Error::BadRequest(_)
118///         |Error::FieldClash(_)
119///         |Error::JsonDecodeError(_, _) => println!("{}", e),
120///     },
121///     Ok(res) => println!("Success: {:?}", res),
122/// }
123/// # }
124/// ```
125#[derive(Clone)]
126pub struct Firestore<C> {
127    pub client: common::Client<C>,
128    pub auth: Box<dyn common::GetToken>,
129    _user_agent: String,
130    _base_url: String,
131    _root_url: String,
132}
133
134impl<C> common::Hub for Firestore<C> {}
135
136impl<'a, C> Firestore<C> {
137    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Firestore<C> {
138        Firestore {
139            client,
140            auth: Box::new(auth),
141            _user_agent: "google-api-rust-client/7.0.0".to_string(),
142            _base_url: "https://firestore.googleapis.com/".to_string(),
143            _root_url: "https://firestore.googleapis.com/".to_string(),
144        }
145    }
146
147    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
148        ProjectMethods { hub: self }
149    }
150
151    /// Set the user-agent header field to use in all requests to the server.
152    /// It defaults to `google-api-rust-client/7.0.0`.
153    ///
154    /// Returns the previously set user-agent.
155    pub fn user_agent(&mut self, agent_name: String) -> String {
156        std::mem::replace(&mut self._user_agent, agent_name)
157    }
158
159    /// Set the base url to use in all requests to the server.
160    /// It defaults to `https://firestore.googleapis.com/`.
161    ///
162    /// Returns the previously set base url.
163    pub fn base_url(&mut self, new_base_url: String) -> String {
164        std::mem::replace(&mut self._base_url, new_base_url)
165    }
166
167    /// Set the root url to use in all requests to the server.
168    /// It defaults to `https://firestore.googleapis.com/`.
169    ///
170    /// Returns the previously set root url.
171    pub fn root_url(&mut self, new_root_url: String) -> String {
172        std::mem::replace(&mut self._root_url, new_root_url)
173    }
174}
175
176// ############
177// SCHEMAS ###
178// ##########
179/// Defines an aggregation that produces a single result.
180///
181/// This type is not used in any activity, and only used as *part* of another schema.
182///
183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
184#[serde_with::serde_as]
185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
186pub struct Aggregation {
187    /// Optional. Optional name of the field to store the result of the aggregation into. If not provided, Firestore will pick a default name following the format `field_`. For example: ``` AGGREGATE COUNT_UP_TO(1) AS count_up_to_1, COUNT_UP_TO(2), COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) OVER ( ... ); ``` becomes: ``` AGGREGATE COUNT_UP_TO(1) AS count_up_to_1, COUNT_UP_TO(2) AS field_1, COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) AS field_2 OVER ( ... ); ``` Requires: * Must be unique across all aggregation aliases. * Conform to document field name limitations.
188    pub alias: Option<String>,
189    /// Average aggregator.
190    pub avg: Option<Avg>,
191    /// Count aggregator.
192    pub count: Option<Count>,
193    /// Sum aggregator.
194    pub sum: Option<Sum>,
195}
196
197impl common::Part for Aggregation {}
198
199/// The result of a single bucket from a Firestore aggregation query. The keys of `aggregate_fields` are the same for all results in an aggregation query, unlike document queries which can have different fields present for each result.
200///
201/// This type is not used in any activity, and only used as *part* of another schema.
202///
203#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
204#[serde_with::serde_as]
205#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
206pub struct AggregationResult {
207    /// The result of the aggregation functions, ex: `COUNT(*) AS total_docs`. The key is the alias assigned to the aggregation function on input and the size of this map equals the number of aggregation functions in the query.
208    #[serde(rename = "aggregateFields")]
209    pub aggregate_fields: Option<HashMap<String, Value>>,
210}
211
212impl common::Part for AggregationResult {}
213
214/// An array value.
215///
216/// This type is not used in any activity, and only used as *part* of another schema.
217///
218#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
219#[serde_with::serde_as]
220#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
221pub struct ArrayValue {
222    /// Values in the array.
223    pub values: Option<Vec<Value>>,
224}
225
226impl common::Part for ArrayValue {}
227
228/// Average of the values of the requested field. * Only numeric values will be aggregated. All non-numeric values including `NULL` are skipped. * If the aggregated values contain `NaN`, returns `NaN`. Infinity math follows IEEE-754 standards. * If the aggregated value set is empty, returns `NULL`. * Always returns the result as a double.
229///
230/// This type is not used in any activity, and only used as *part* of another schema.
231///
232#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
233#[serde_with::serde_as]
234#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
235pub struct Avg {
236    /// The field to aggregate on.
237    pub field: Option<FieldReference>,
238}
239
240impl common::Part for Avg {}
241
242/// The request for Firestore.BatchGetDocuments.
243///
244/// # Activities
245///
246/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
247/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
248///
249/// * [databases documents batch get projects](ProjectDatabaseDocumentBatchGetCall) (request)
250#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
251#[serde_with::serde_as]
252#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
253pub struct BatchGetDocumentsRequest {
254    /// The names of the documents to retrieve. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. The request will fail if any of the document is not a child resource of the given `database`. Duplicate names will be elided.
255    pub documents: Option<Vec<String>>,
256    /// The fields to return. If not set, returns all fields. If a document has a field that is not present in this mask, that field will not be returned in the response.
257    pub mask: Option<DocumentMask>,
258    /// Starts a new transaction and reads the documents. Defaults to a read-only transaction. The new transaction ID will be returned as the first response in the stream.
259    #[serde(rename = "newTransaction")]
260    pub new_transaction: Option<TransactionOptions>,
261    /// Reads documents as they were at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
262    #[serde(rename = "readTime")]
263    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
264    /// Reads documents in a transaction.
265    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
266    pub transaction: Option<Vec<u8>>,
267}
268
269impl common::RequestValue for BatchGetDocumentsRequest {}
270
271/// The streamed response for Firestore.BatchGetDocuments.
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [databases documents batch get projects](ProjectDatabaseDocumentBatchGetCall) (response)
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct BatchGetDocumentsResponse {
283    /// A document that was requested.
284    pub found: Option<Document>,
285    /// A document name that was requested but does not exist. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
286    pub missing: Option<String>,
287    /// The time at which the document was read. This may be monotically increasing, in this case the previous documents in the result stream are guaranteed not to have changed between their read_time and this one.
288    #[serde(rename = "readTime")]
289    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
290    /// The transaction that was started as part of this request. Will only be set in the first response, and only if BatchGetDocumentsRequest.new_transaction was set in the request.
291    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
292    pub transaction: Option<Vec<u8>>,
293}
294
295impl common::ResponseResult for BatchGetDocumentsResponse {}
296
297/// The request for Firestore.BatchWrite.
298///
299/// # Activities
300///
301/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
302/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
303///
304/// * [databases documents batch write projects](ProjectDatabaseDocumentBatchWriteCall) (request)
305#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
306#[serde_with::serde_as]
307#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
308pub struct BatchWriteRequest {
309    /// Labels associated with this batch write.
310    pub labels: Option<HashMap<String, String>>,
311    /// The writes to apply. Method does not apply writes atomically and does not guarantee ordering. Each write succeeds or fails independently. You cannot write to the same document more than once per request.
312    pub writes: Option<Vec<Write>>,
313}
314
315impl common::RequestValue for BatchWriteRequest {}
316
317/// The response from Firestore.BatchWrite.
318///
319/// # Activities
320///
321/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
322/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
323///
324/// * [databases documents batch write projects](ProjectDatabaseDocumentBatchWriteCall) (response)
325#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
326#[serde_with::serde_as]
327#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
328pub struct BatchWriteResponse {
329    /// The status of applying the writes. This i-th write status corresponds to the i-th write in the request.
330    pub status: Option<Vec<Status>>,
331    /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
332    #[serde(rename = "writeResults")]
333    pub write_results: Option<Vec<WriteResult>>,
334}
335
336impl common::ResponseResult for BatchWriteResponse {}
337
338/// The request for Firestore.BeginTransaction.
339///
340/// # Activities
341///
342/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
343/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
344///
345/// * [databases documents begin transaction projects](ProjectDatabaseDocumentBeginTransactionCall) (request)
346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
347#[serde_with::serde_as]
348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
349pub struct BeginTransactionRequest {
350    /// The options for the transaction. Defaults to a read-write transaction.
351    pub options: Option<TransactionOptions>,
352}
353
354impl common::RequestValue for BeginTransactionRequest {}
355
356/// The response for Firestore.BeginTransaction.
357///
358/// # Activities
359///
360/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
361/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
362///
363/// * [databases documents begin transaction projects](ProjectDatabaseDocumentBeginTransactionCall) (response)
364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
365#[serde_with::serde_as]
366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
367pub struct BeginTransactionResponse {
368    /// The transaction that was started.
369    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
370    pub transaction: Option<Vec<u8>>,
371}
372
373impl common::ResponseResult for BeginTransactionResponse {}
374
375/// A sequence of bits, encoded in a byte array. Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only exception is the last byte, which may store 8 _or fewer_ bits. The `padding` defines the number of bits of the last byte to be ignored as "padding". The values of these "padding" bits are unspecified and must be ignored. To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`. To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`. To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`. To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`. To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`. The "size" of a `BitSequence` (the number of bits it contains) is calculated by this formula: `(bitmap.length * 8) - padding`.
376///
377/// This type is not used in any activity, and only used as *part* of another schema.
378///
379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
380#[serde_with::serde_as]
381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
382pub struct BitSequence {
383    /// The bytes that encode the bit sequence. May have a length of zero.
384    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
385    pub bitmap: Option<Vec<u8>>,
386    /// The number of bits of the last byte in `bitmap` to ignore as "padding". If the length of `bitmap` is zero, then this value must be `0`. Otherwise, this value must be between 0 and 7, inclusive.
387    pub padding: Option<i32>,
388}
389
390impl common::Part for BitSequence {}
391
392/// A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter). The bloom filter hashes the entries with MD5 and treats the resulting 128-bit hash as 2 distinct 64-bit hash values, interpreted as unsigned integers using 2's complement encoding. These two hash values, named `h1` and `h2`, are then used to compute the `hash_count` hash values using the formula, starting at `i=0`: h(i) = h1 + (i * h2) These resulting values are then taken modulo the number of bits in the bloom filter to get the bits of the bloom filter to test for the given entry.
393///
394/// This type is not used in any activity, and only used as *part* of another schema.
395///
396#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
397#[serde_with::serde_as]
398#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
399pub struct BloomFilter {
400    /// The bloom filter data.
401    pub bits: Option<BitSequence>,
402    /// The number of hashes used by the algorithm.
403    #[serde(rename = "hashCount")]
404    pub hash_count: Option<i32>,
405}
406
407impl common::Part for BloomFilter {}
408
409/// A selection of a collection, such as `messages as m1`.
410///
411/// This type is not used in any activity, and only used as *part* of another schema.
412///
413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
414#[serde_with::serde_as]
415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
416pub struct CollectionSelector {
417    /// When false, selects only collections that are immediate children of the `parent` specified in the containing `RunQueryRequest`. When true, selects all descendant collections.
418    #[serde(rename = "allDescendants")]
419    pub all_descendants: Option<bool>,
420    /// The collection ID. When set, selects only collections with this ID.
421    #[serde(rename = "collectionId")]
422    pub collection_id: Option<String>,
423}
424
425impl common::Part for CollectionSelector {}
426
427/// The request for Firestore.Commit.
428///
429/// # Activities
430///
431/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
432/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
433///
434/// * [databases documents commit projects](ProjectDatabaseDocumentCommitCall) (request)
435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
436#[serde_with::serde_as]
437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
438pub struct CommitRequest {
439    /// If set, applies all writes in this transaction, and commits it.
440    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
441    pub transaction: Option<Vec<u8>>,
442    /// The writes to apply. Always executed atomically and in order.
443    pub writes: Option<Vec<Write>>,
444}
445
446impl common::RequestValue for CommitRequest {}
447
448/// The response for Firestore.Commit.
449///
450/// # Activities
451///
452/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
453/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
454///
455/// * [databases documents commit projects](ProjectDatabaseDocumentCommitCall) (response)
456#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
457#[serde_with::serde_as]
458#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
459pub struct CommitResponse {
460    /// The time at which the commit occurred. Any read with an equal or greater `read_time` is guaranteed to see the effects of the commit.
461    #[serde(rename = "commitTime")]
462    pub commit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
463    /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
464    #[serde(rename = "writeResults")]
465    pub write_results: Option<Vec<WriteResult>>,
466}
467
468impl common::ResponseResult for CommitResponse {}
469
470/// A filter that merges multiple other filters using the given operator.
471///
472/// This type is not used in any activity, and only used as *part* of another schema.
473///
474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
475#[serde_with::serde_as]
476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
477pub struct CompositeFilter {
478    /// The list of filters to combine. Requires: * At least one filter is present.
479    pub filters: Option<Vec<Filter>>,
480    /// The operator for combining multiple filters.
481    pub op: Option<String>,
482}
483
484impl common::Part for CompositeFilter {}
485
486/// Count of documents that match the query. The `COUNT(*)` aggregation function operates on the entire document so it does not require a field reference.
487///
488/// This type is not used in any activity, and only used as *part* of another schema.
489///
490#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
491#[serde_with::serde_as]
492#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
493pub struct Count {
494    /// Optional. Optional constraint on the maximum number of documents to count. This provides a way to set an upper bound on the number of documents to scan, limiting latency, and cost. Unspecified is interpreted as no bound. High-Level Example: ``` AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); ``` Requires: * Must be greater than zero when present.
495    #[serde(rename = "upTo")]
496    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
497    pub up_to: Option<i64>,
498}
499
500impl common::Part for Count {}
501
502/// A position in a query result set.
503///
504/// This type is not used in any activity, and only used as *part* of another schema.
505///
506#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
507#[serde_with::serde_as]
508#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
509pub struct Cursor {
510    /// If the position is just before or just after the given values, relative to the sort order defined by the query.
511    pub before: Option<bool>,
512    /// The values that represent a position, in the order they appear in the order by clause of a query. Can contain fewer values than specified in the order by clause.
513    pub values: Option<Vec<Value>>,
514}
515
516impl common::Part for Cursor {}
517
518/// A Firestore document. Must not exceed 1 MiB - 4 bytes.
519///
520/// # Activities
521///
522/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
523/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
524///
525/// * [databases documents create document projects](ProjectDatabaseDocumentCreateDocumentCall) (request|response)
526/// * [databases documents get projects](ProjectDatabaseDocumentGetCall) (response)
527/// * [databases documents patch projects](ProjectDatabaseDocumentPatchCall) (request|response)
528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
529#[serde_with::serde_as]
530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
531pub struct Document {
532    /// Output only. The time at which the document was created. This value increases monotonically when a document is deleted then recreated. It can also be compared to values from other documents and the `read_time` of a query.
533    #[serde(rename = "createTime")]
534    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
535    /// The document's fields. The map keys represent field names. Field names matching the regular expression `__.*__` are reserved. Reserved field names are forbidden except in certain documented contexts. The field names, represented as UTF-8, must not exceed 1,500 bytes and cannot be empty. Field paths may be used in other contexts to refer to structured fields defined here. For `map_value`, the field path is represented by a dot-delimited (`.`) string of segments. Each segment is either a simple field name (defined below) or a quoted field name. For example, the structured field `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be represented by the field path `` foo.`x&y` ``. A simple field name contains only characters `a` to `z`, `A` to `Z`, `0` to `9`, or `_`, and must not start with `0` to `9`. For example, `foo_bar_17`. A quoted field name starts and ends with `` ` `` and may contain any character. Some characters, including `` ` ``, must be escaped using a `\`. For example, `` `x&y` `` represents `x&y` and `` `bak\`tik` `` represents `` bak`tik ``.
536    pub fields: Option<HashMap<String, Value>>,
537    /// The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
538    pub name: Option<String>,
539    /// Output only. The time at which the document was last changed. This value is initially set to the `create_time` then increases monotonically with each change to the document. It can also be compared to values from other documents and the `read_time` of a query.
540    #[serde(rename = "updateTime")]
541    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
542}
543
544impl common::RequestValue for Document {}
545impl common::ResponseResult for Document {}
546
547/// A Document has changed. May be the result of multiple writes, including deletes, that ultimately resulted in a new value for the Document. Multiple DocumentChange messages may be returned for the same logical change, if multiple targets are affected.
548///
549/// This type is not used in any activity, and only used as *part* of another schema.
550///
551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
552#[serde_with::serde_as]
553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
554pub struct DocumentChange {
555    /// The new state of the Document. If `mask` is set, contains only fields that were updated or added.
556    pub document: Option<Document>,
557    /// A set of target IDs for targets that no longer match this document.
558    #[serde(rename = "removedTargetIds")]
559    pub removed_target_ids: Option<Vec<i32>>,
560    /// A set of target IDs of targets that match this document.
561    #[serde(rename = "targetIds")]
562    pub target_ids: Option<Vec<i32>>,
563}
564
565impl common::Part for DocumentChange {}
566
567/// A Document has been deleted. May be the result of multiple writes, including updates, the last of which deleted the Document. Multiple DocumentDelete messages may be returned for the same logical delete, if multiple targets are affected.
568///
569/// This type is not used in any activity, and only used as *part* of another schema.
570///
571#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
572#[serde_with::serde_as]
573#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
574pub struct DocumentDelete {
575    /// The resource name of the Document that was deleted.
576    pub document: Option<String>,
577    /// The read timestamp at which the delete was observed. Greater or equal to the `commit_time` of the delete.
578    #[serde(rename = "readTime")]
579    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
580    /// A set of target IDs for targets that previously matched this entity.
581    #[serde(rename = "removedTargetIds")]
582    pub removed_target_ids: Option<Vec<i32>>,
583}
584
585impl common::Part for DocumentDelete {}
586
587/// A set of field paths on a document. Used to restrict a get or update operation on a document to a subset of its fields. This is different from standard field masks, as this is always scoped to a Document, and takes in account the dynamic nature of Value.
588///
589/// This type is not used in any activity, and only used as *part* of another schema.
590///
591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
592#[serde_with::serde_as]
593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
594pub struct DocumentMask {
595    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
596    #[serde(rename = "fieldPaths")]
597    pub field_paths: Option<Vec<String>>,
598}
599
600impl common::Part for DocumentMask {}
601
602/// A Document has been removed from the view of the targets. Sent if the document is no longer relevant to a target and is out of view. Can be sent instead of a DocumentDelete or a DocumentChange if the server can not send the new value of the document. Multiple DocumentRemove messages may be returned for the same logical write or delete, if multiple targets are affected.
603///
604/// This type is not used in any activity, and only used as *part* of another schema.
605///
606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
607#[serde_with::serde_as]
608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
609pub struct DocumentRemove {
610    /// The resource name of the Document that has gone out of view.
611    pub document: Option<String>,
612    /// The read timestamp at which the remove was observed. Greater or equal to the `commit_time` of the change/delete/remove.
613    #[serde(rename = "readTime")]
614    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
615    /// A set of target IDs for targets that previously matched this document.
616    #[serde(rename = "removedTargetIds")]
617    pub removed_target_ids: Option<Vec<i32>>,
618}
619
620impl common::Part for DocumentRemove {}
621
622/// A transformation of a document.
623///
624/// This type is not used in any activity, and only used as *part* of another schema.
625///
626#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
627#[serde_with::serde_as]
628#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
629pub struct DocumentTransform {
630    /// The name of the document to transform.
631    pub document: Option<String>,
632    /// The list of transformations to apply to the fields of the document, in order. This must not be empty.
633    #[serde(rename = "fieldTransforms")]
634    pub field_transforms: Option<Vec<FieldTransform>>,
635}
636
637impl common::Part for DocumentTransform {}
638
639/// A target specified by a set of documents names.
640///
641/// This type is not used in any activity, and only used as *part* of another schema.
642///
643#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
644#[serde_with::serde_as]
645#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
646pub struct DocumentsTarget {
647    /// The names of the documents to retrieve. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. The request will fail if any of the document is not a child resource of the given `database`. Duplicate names will be elided.
648    pub documents: Option<Vec<String>>,
649}
650
651impl common::Part for DocumentsTarget {}
652
653/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
654///
655/// # Activities
656///
657/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
658/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
659///
660/// * [databases backup schedules delete projects](ProjectDatabaseBackupScheduleDeleteCall) (response)
661/// * [databases collection groups indexes delete projects](ProjectDatabaseCollectionGroupIndexDeleteCall) (response)
662/// * [databases documents delete projects](ProjectDatabaseDocumentDeleteCall) (response)
663/// * [databases documents rollback projects](ProjectDatabaseDocumentRollbackCall) (response)
664/// * [databases operations cancel projects](ProjectDatabaseOperationCancelCall) (response)
665/// * [databases operations delete projects](ProjectDatabaseOperationDeleteCall) (response)
666/// * [databases user creds delete projects](ProjectDatabaseUserCredDeleteCall) (response)
667/// * [locations backups delete projects](ProjectLocationBackupDeleteCall) (response)
668#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
669#[serde_with::serde_as]
670#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
671pub struct Empty {
672    _never_set: Option<bool>,
673}
674
675impl common::ResponseResult for Empty {}
676
677/// The request for Firestore.ExecutePipeline.
678///
679/// # Activities
680///
681/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
682/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
683///
684/// * [databases documents execute pipeline projects](ProjectDatabaseDocumentExecutePipelineCall) (request)
685#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
686#[serde_with::serde_as]
687#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
688pub struct ExecutePipelineRequest {
689    /// Execute the pipeline in a new transaction. The identifier of the newly created transaction will be returned in the first response on the stream. This defaults to a read-only transaction.
690    #[serde(rename = "newTransaction")]
691    pub new_transaction: Option<TransactionOptions>,
692    /// Execute the pipeline in a snapshot transaction at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
693    #[serde(rename = "readTime")]
694    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
695    /// A pipelined operation.
696    #[serde(rename = "structuredPipeline")]
697    pub structured_pipeline: Option<StructuredPipeline>,
698    /// Run the query within an already active transaction. The value here is the opaque transaction ID to execute the query in.
699    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
700    pub transaction: Option<Vec<u8>>,
701}
702
703impl common::RequestValue for ExecutePipelineRequest {}
704
705/// The response for Firestore.Execute.
706///
707/// # Activities
708///
709/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
710/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
711///
712/// * [databases documents execute pipeline projects](ProjectDatabaseDocumentExecutePipelineCall) (response)
713#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
714#[serde_with::serde_as]
715#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
716pub struct ExecutePipelineResponse {
717    /// The time at which the results are valid. This is a (not strictly) monotonically increasing value across multiple responses in the same stream. The API guarantees that all previously returned results are still valid at the latest `execution_time`. This allows the API consumer to treat the query if it ran at the latest `execution_time` returned. If the query returns no results, a response with `execution_time` and no `results` will be sent, and this represents the time at which the operation was run.
718    #[serde(rename = "executionTime")]
719    pub execution_time: Option<chrono::DateTime<chrono::offset::Utc>>,
720    /// Query explain stats. This is present on the **last** response if the request configured explain to run in 'analyze' or 'explain' mode in the pipeline options. If the query does not return any results, a response with `explain_stats` and no `results` will still be sent.
721    #[serde(rename = "explainStats")]
722    pub explain_stats: Option<ExplainStats>,
723    /// An ordered batch of results returned executing a pipeline. The batch size is variable, and can even be zero for when only a partial progress message is returned. The fields present in the returned documents are only those that were explicitly requested in the pipeline, this includes those like `__name__` and `__update_time__`. This is explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument` RPCs which always return such fields even when they are not specified in the `mask`.
724    pub results: Option<Vec<Document>>,
725    /// Newly created transaction identifier. This field is only specified as part of the first response from the server, alongside the `results` field when the original request specified ExecuteRequest.new_transaction.
726    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
727    pub transaction: Option<Vec<u8>>,
728}
729
730impl common::ResponseResult for ExecutePipelineResponse {}
731
732/// Execution statistics for the query.
733///
734/// This type is not used in any activity, and only used as *part* of another schema.
735///
736#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
737#[serde_with::serde_as]
738#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
739pub struct ExecutionStats {
740    /// Debugging statistics from the execution of the query. Note that the debugging stats are subject to change as Firestore evolves. It could include: { "indexes_entries_scanned": "1000", "documents_scanned": "20", "billing_details" : { "documents_billable": "20", "index_entries_billable": "1000", "min_query_cost": "0" } }
741    #[serde(rename = "debugStats")]
742    pub debug_stats: Option<HashMap<String, serde_json::Value>>,
743    /// Total time to execute the query in the backend.
744    #[serde(rename = "executionDuration")]
745    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
746    pub execution_duration: Option<chrono::Duration>,
747    /// Total billable read operations.
748    #[serde(rename = "readOperations")]
749    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
750    pub read_operations: Option<i64>,
751    /// Total number of results returned, including documents, projections, aggregation results, keys.
752    #[serde(rename = "resultsReturned")]
753    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
754    pub results_returned: Option<i64>,
755}
756
757impl common::Part for ExecutionStats {}
758
759/// A digest of all the documents that match a given target.
760///
761/// This type is not used in any activity, and only used as *part* of another schema.
762///
763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
764#[serde_with::serde_as]
765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
766pub struct ExistenceFilter {
767    /// The total count of documents that match target_id. If different from the count of documents in the client that match, the client must manually determine which documents no longer match the target. The client can use the `unchanged_names` bloom filter to assist with this determination by testing ALL the document names against the filter; if the document name is NOT in the filter, it means the document no longer matches the target.
768    pub count: Option<i32>,
769    /// The target ID to which this filter applies.
770    #[serde(rename = "targetId")]
771    pub target_id: Option<i32>,
772    /// A bloom filter that, despite its name, contains the UTF-8 byte encodings of the resource names of ALL the documents that match target_id, in the form `projects/{project_id}/databases/{database_id}/documents/{document_path}`. This bloom filter may be omitted at the server's discretion, such as if it is deemed that the client will not make use of it or if it is too computationally expensive to calculate or transmit. Clients must gracefully handle this field being absent by falling back to the logic used before this field existed; that is, re-add the target without a resume token to figure out which documents in the client's cache are out of sync.
773    #[serde(rename = "unchangedNames")]
774    pub unchanged_names: Option<BloomFilter>,
775}
776
777impl common::Part for ExistenceFilter {}
778
779/// Explain metrics for the query.
780///
781/// This type is not used in any activity, and only used as *part* of another schema.
782///
783#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
784#[serde_with::serde_as]
785#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
786pub struct ExplainMetrics {
787    /// Aggregated stats from the execution of the query. Only present when ExplainOptions.analyze is set to true.
788    #[serde(rename = "executionStats")]
789    pub execution_stats: Option<ExecutionStats>,
790    /// Planning phase information for the query.
791    #[serde(rename = "planSummary")]
792    pub plan_summary: Option<PlanSummary>,
793}
794
795impl common::Part for ExplainMetrics {}
796
797/// Explain options for the query.
798///
799/// This type is not used in any activity, and only used as *part* of another schema.
800///
801#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
802#[serde_with::serde_as]
803#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
804pub struct ExplainOptions {
805    /// Optional. Whether to execute this query. When false (the default), the query will be planned, returning only metrics from the planning stages. When true, the query will be planned and executed, returning the full query results along with both planning and execution stage metrics.
806    pub analyze: Option<bool>,
807}
808
809impl common::Part for ExplainOptions {}
810
811/// Pipeline explain stats. Depending on the explain options in the original request, this can contain the optimized plan and / or execution stats.
812///
813/// This type is not used in any activity, and only used as *part* of another schema.
814///
815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
816#[serde_with::serde_as]
817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
818pub struct ExplainStats {
819    /// The format depends on the `output_format` options in the request. Currently there are two supported options: `TEXT` and `JSON`. Both supply a `google.protobuf.StringValue`.
820    pub data: Option<HashMap<String, serde_json::Value>>,
821}
822
823impl common::Part for ExplainStats {}
824
825/// A filter on a specific field.
826///
827/// This type is not used in any activity, and only used as *part* of another schema.
828///
829#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
830#[serde_with::serde_as]
831#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
832pub struct FieldFilter {
833    /// The field to filter by.
834    pub field: Option<FieldReference>,
835    /// The operator to filter by.
836    pub op: Option<String>,
837    /// The value to compare to.
838    pub value: Option<Value>,
839}
840
841impl common::Part for FieldFilter {}
842
843/// A reference to a field in a document, ex: `stats.operations`.
844///
845/// This type is not used in any activity, and only used as *part* of another schema.
846///
847#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
848#[serde_with::serde_as]
849#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
850pub struct FieldReference {
851    /// A reference to a field in a document. Requires: * MUST be a dot-delimited (`.`) string of segments, where each segment conforms to document field name limitations.
852    #[serde(rename = "fieldPath")]
853    pub field_path: Option<String>,
854}
855
856impl common::Part for FieldReference {}
857
858/// A transformation of a field of the document.
859///
860/// This type is not used in any activity, and only used as *part* of another schema.
861///
862#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
863#[serde_with::serde_as]
864#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
865pub struct FieldTransform {
866    /// Append the given elements in order if they are not already present in the current field value. If the field is not an array, or if the field does not yet exist, it is first set to the empty array. Equivalent numbers of different types (e.g. 3L and 3.0) are considered equal when checking if a value is missing. NaN is equal to NaN, and Null is equal to Null. If the input contains multiple equivalent values, only the first will be considered. The corresponding transform_result will be the null value.
867    #[serde(rename = "appendMissingElements")]
868    pub append_missing_elements: Option<ArrayValue>,
869    /// The path of the field. See Document.fields for the field path syntax reference.
870    #[serde(rename = "fieldPath")]
871    pub field_path: Option<String>,
872    /// Adds the given value to the field's current value. This must be an integer or a double value. If the field is not an integer or double, or if the field does not yet exist, the transformation will set the field to the given value. If either of the given value or the current field value are doubles, both values will be interpreted as doubles. Double arithmetic and representation of double values follow IEEE 754 semantics. If there is positive/negative integer overflow, the field is resolved to the largest magnitude positive/negative integer.
873    pub increment: Option<Value>,
874    /// Sets the field to the maximum of its current value and the given value. This must be an integer or a double value. If the field is not an integer or double, or if the field does not yet exist, the transformation will set the field to the given value. If a maximum operation is applied where the field and the input value are of mixed types (that is - one is an integer and one is a double) the field takes on the type of the larger operand. If the operands are equivalent (e.g. 3 and 3.0), the field does not change. 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and zero input value is always the stored value. The maximum of any numeric value x and NaN is NaN.
875    pub maximum: Option<Value>,
876    /// Sets the field to the minimum of its current value and the given value. This must be an integer or a double value. If the field is not an integer or double, or if the field does not yet exist, the transformation will set the field to the input value. If a minimum operation is applied where the field and the input value are of mixed types (that is - one is an integer and one is a double) the field takes on the type of the smaller operand. If the operands are equivalent (e.g. 3 and 3.0), the field does not change. 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and zero input value is always the stored value. The minimum of any numeric value x and NaN is NaN.
877    pub minimum: Option<Value>,
878    /// Remove all of the given elements from the array in the field. If the field is not an array, or if the field does not yet exist, it is set to the empty array. Equivalent numbers of the different types (e.g. 3L and 3.0) are considered equal when deciding whether an element should be removed. NaN is equal to NaN, and Null is equal to Null. This will remove all equivalent values if there are duplicates. The corresponding transform_result will be the null value.
879    #[serde(rename = "removeAllFromArray")]
880    pub remove_all_from_array: Option<ArrayValue>,
881    /// Sets the field to the given server value.
882    #[serde(rename = "setToServerValue")]
883    pub set_to_server_value: Option<String>,
884}
885
886impl common::Part for FieldTransform {}
887
888/// A filter.
889///
890/// This type is not used in any activity, and only used as *part* of another schema.
891///
892#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
893#[serde_with::serde_as]
894#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
895pub struct Filter {
896    /// A composite filter.
897    #[serde(rename = "compositeFilter")]
898    pub composite_filter: Option<CompositeFilter>,
899    /// A filter on a document field.
900    #[serde(rename = "fieldFilter")]
901    pub field_filter: Option<FieldFilter>,
902    /// A filter that takes exactly one argument.
903    #[serde(rename = "unaryFilter")]
904    pub unary_filter: Option<UnaryFilter>,
905}
906
907impl common::Part for Filter {}
908
909/// Nearest Neighbors search config. The ordering provided by FindNearest supersedes the order_by stage. If multiple documents have the same vector distance, the returned document order is not guaranteed to be stable between queries.
910///
911/// This type is not used in any activity, and only used as *part* of another schema.
912///
913#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
914#[serde_with::serde_as]
915#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
916pub struct FindNearest {
917    /// Required. The distance measure to use, required.
918    #[serde(rename = "distanceMeasure")]
919    pub distance_measure: Option<String>,
920    /// Optional. Optional name of the field to output the result of the vector distance calculation. Must conform to document field name limitations.
921    #[serde(rename = "distanceResultField")]
922    pub distance_result_field: Option<String>,
923    /// Optional. Option to specify a threshold for which no less similar documents will be returned. The behavior of the specified `distance_measure` will affect the meaning of the distance threshold. Since DOT_PRODUCT distances increase when the vectors are more similar, the comparison is inverted. * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold` * For DOT_PRODUCT: `WHERE distance >= distance_threshold`
924    #[serde(rename = "distanceThreshold")]
925    pub distance_threshold: Option<f64>,
926    /// Required. The number of nearest neighbors to return. Must be a positive integer of no more than 1000.
927    pub limit: Option<i32>,
928    /// Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.
929    #[serde(rename = "queryVector")]
930    pub query_vector: Option<Value>,
931    /// Required. An indexed vector field to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.
932    #[serde(rename = "vectorField")]
933    pub vector_field: Option<FieldReference>,
934}
935
936impl common::Part for FindNearest {}
937
938/// Represents an unevaluated scalar expression. For example, the expression `like(user_name, "%alice%")` is represented as: ``` name: "like" args { field_reference: "user_name" } args { string_value: "%alice%" } ```
939///
940/// This type is not used in any activity, and only used as *part* of another schema.
941///
942#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
943#[serde_with::serde_as]
944#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
945pub struct Function {
946    /// Optional. Ordered list of arguments the given function expects.
947    pub args: Option<Vec<Value>>,
948    /// Required. The name of the function to evaluate. **Requires:** * must be in snake case (lower case with underscore separator).
949    pub name: Option<String>,
950    /// Optional. Optional named arguments that certain functions may support.
951    pub options: Option<HashMap<String, Value>>,
952}
953
954impl common::Part for Function {}
955
956/// A Backup of a Cloud Firestore Database. The backup contains all documents and index configurations for the given database at a specific point in time.
957///
958/// # Activities
959///
960/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
961/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
962///
963/// * [locations backups get projects](ProjectLocationBackupGetCall) (response)
964#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
965#[serde_with::serde_as]
966#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
967pub struct GoogleFirestoreAdminV1Backup {
968    /// Output only. Name of the Firestore database that the backup is from. Format is `projects/{project}/databases/{database}`.
969    pub database: Option<String>,
970    /// Output only. The system-generated UUID4 for the Firestore database that the backup is from.
971    #[serde(rename = "databaseUid")]
972    pub database_uid: Option<String>,
973    /// Output only. The timestamp at which this backup expires.
974    #[serde(rename = "expireTime")]
975    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
976    /// Output only. The unique resource name of the Backup. Format is `projects/{project}/locations/{location}/backups/{backup}`.
977    pub name: Option<String>,
978    /// Output only. The backup contains an externally consistent copy of the database at this time.
979    #[serde(rename = "snapshotTime")]
980    pub snapshot_time: Option<chrono::DateTime<chrono::offset::Utc>>,
981    /// Output only. The current state of the backup.
982    pub state: Option<String>,
983    /// Output only. Statistics about the backup. This data only becomes available after the backup is fully materialized to secondary storage. This field will be empty till then.
984    pub stats: Option<GoogleFirestoreAdminV1Stats>,
985}
986
987impl common::ResponseResult for GoogleFirestoreAdminV1Backup {}
988
989/// A backup schedule for a Cloud Firestore Database. This resource is owned by the database it is backing up, and is deleted along with the database. The actual backups are not though.
990///
991/// # Activities
992///
993/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
994/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
995///
996/// * [databases backup schedules create projects](ProjectDatabaseBackupScheduleCreateCall) (request|response)
997/// * [databases backup schedules get projects](ProjectDatabaseBackupScheduleGetCall) (response)
998/// * [databases backup schedules patch projects](ProjectDatabaseBackupSchedulePatchCall) (request|response)
999#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1000#[serde_with::serde_as]
1001#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1002pub struct GoogleFirestoreAdminV1BackupSchedule {
1003    /// Output only. The timestamp at which this backup schedule was created and effective since. No backups will be created for this schedule before this time.
1004    #[serde(rename = "createTime")]
1005    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1006    /// For a schedule that runs daily.
1007    #[serde(rename = "dailyRecurrence")]
1008    pub daily_recurrence: Option<GoogleFirestoreAdminV1DailyRecurrence>,
1009    /// Output only. The unique backup schedule identifier across all locations and databases for the given project. This will be auto-assigned. Format is `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
1010    pub name: Option<String>,
1011    /// At what relative time in the future, compared to its creation time, the backup should be deleted, e.g. keep backups for 7 days. The maximum supported retention period is 14 weeks.
1012    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1013    pub retention: Option<chrono::Duration>,
1014    /// Output only. The timestamp at which this backup schedule was most recently updated. When a backup schedule is first created, this is the same as create_time.
1015    #[serde(rename = "updateTime")]
1016    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1017    /// For a schedule that runs weekly on a specific day.
1018    #[serde(rename = "weeklyRecurrence")]
1019    pub weekly_recurrence: Option<GoogleFirestoreAdminV1WeeklyRecurrence>,
1020}
1021
1022impl common::RequestValue for GoogleFirestoreAdminV1BackupSchedule {}
1023impl common::ResponseResult for GoogleFirestoreAdminV1BackupSchedule {}
1024
1025/// Information about a backup that was used to restore a database.
1026///
1027/// This type is not used in any activity, and only used as *part* of another schema.
1028///
1029#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1030#[serde_with::serde_as]
1031#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1032pub struct GoogleFirestoreAdminV1BackupSource {
1033    /// The resource name of the backup that was used to restore this database. Format: `projects/{project}/locations/{location}/backups/{backup}`.
1034    pub backup: Option<String>,
1035}
1036
1037impl common::Part for GoogleFirestoreAdminV1BackupSource {}
1038
1039/// The request for FirestoreAdmin.BulkDeleteDocuments. When both collection_ids and namespace_ids are set, only documents satisfying both conditions will be deleted. Requests with namespace_ids and collection_ids both empty will be rejected. Please use FirestoreAdmin.DeleteDatabase instead.
1040///
1041/// # Activities
1042///
1043/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1044/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1045///
1046/// * [databases bulk delete documents projects](ProjectDatabaseBulkDeleteDocumentCall) (request)
1047#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1048#[serde_with::serde_as]
1049#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1050pub struct GoogleFirestoreAdminV1BulkDeleteDocumentsRequest {
1051    /// Optional. IDs of the collection groups to delete. Unspecified means all collection groups. Each collection group in this list must be unique.
1052    #[serde(rename = "collectionIds")]
1053    pub collection_ids: Option<Vec<String>>,
1054    /// Optional. Namespaces to delete. An empty list means all namespaces. This is the recommended usage for databases that don't use namespaces. An empty string element represents the default namespace. This should be used if the database has data in non-default namespaces, but doesn't want to delete from them. Each namespace in this list must be unique.
1055    #[serde(rename = "namespaceIds")]
1056    pub namespace_ids: Option<Vec<String>>,
1057}
1058
1059impl common::RequestValue for GoogleFirestoreAdminV1BulkDeleteDocumentsRequest {}
1060
1061/// The request message for FirestoreAdmin.CloneDatabase.
1062///
1063/// # Activities
1064///
1065/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1066/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1067///
1068/// * [databases clone projects](ProjectDatabaseCloneCall) (request)
1069#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1070#[serde_with::serde_as]
1071#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1072pub struct GoogleFirestoreAdminV1CloneDatabaseRequest {
1073    /// Required. The ID to use for the database, which will become the final component of the database's resource name. This database ID must not be associated with an existing database. This value should be 4-63 characters. Valid characters are /a-z-/ with first character a letter and the last a letter or a number. Must not be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. "(default)" database ID is also valid if the database is Standard edition.
1074    #[serde(rename = "databaseId")]
1075    pub database_id: Option<String>,
1076    /// Optional. Encryption configuration for the cloned database. If this field is not specified, the cloned database will use the same encryption configuration as the source database, namely use_source_encryption.
1077    #[serde(rename = "encryptionConfig")]
1078    pub encryption_config: Option<GoogleFirestoreAdminV1EncryptionConfig>,
1079    /// Required. Specification of the PITR data to clone from. The source database must exist. The cloned database will be created in the same location as the source database.
1080    #[serde(rename = "pitrSnapshot")]
1081    pub pitr_snapshot: Option<GoogleFirestoreAdminV1PitrSnapshot>,
1082    /// Optional. Immutable. Tags to be bound to the cloned database. The tags should be provided in the format of `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
1083    pub tags: Option<HashMap<String, String>>,
1084}
1085
1086impl common::RequestValue for GoogleFirestoreAdminV1CloneDatabaseRequest {}
1087
1088/// The CMEK (Customer Managed Encryption Key) configuration for a Firestore database. If not present, the database is secured by the default Google encryption key.
1089///
1090/// This type is not used in any activity, and only used as *part* of another schema.
1091///
1092#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1093#[serde_with::serde_as]
1094#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1095pub struct GoogleFirestoreAdminV1CmekConfig {
1096    /// Output only. Currently in-use [KMS key versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions). During [key rotation](https://cloud.google.com/kms/docs/key-rotation), there can be multiple in-use key versions. The expected format is `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
1097    #[serde(rename = "activeKeyVersion")]
1098    pub active_key_version: Option<Vec<String>>,
1099    /// Required. Only keys in the same location as this database are allowed to be used for encryption. For Firestore's nam5 multi-region, this corresponds to Cloud KMS multi-region us. For Firestore's eur3 multi-region, this corresponds to Cloud KMS multi-region europe. See https://cloud.google.com/kms/docs/locations. The expected format is `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
1100    #[serde(rename = "kmsKeyName")]
1101    pub kms_key_name: Option<String>,
1102}
1103
1104impl common::Part for GoogleFirestoreAdminV1CmekConfig {}
1105
1106/// The configuration options for using CMEK (Customer Managed Encryption Key) encryption.
1107///
1108/// This type is not used in any activity, and only used as *part* of another schema.
1109///
1110#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1111#[serde_with::serde_as]
1112#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1113pub struct GoogleFirestoreAdminV1CustomerManagedEncryptionOptions {
1114    /// Required. Only keys in the same location as the database are allowed to be used for encryption. For Firestore's nam5 multi-region, this corresponds to Cloud KMS multi-region us. For Firestore's eur3 multi-region, this corresponds to Cloud KMS multi-region europe. See https://cloud.google.com/kms/docs/locations. The expected format is `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
1115    #[serde(rename = "kmsKeyName")]
1116    pub kms_key_name: Option<String>,
1117}
1118
1119impl common::Part for GoogleFirestoreAdminV1CustomerManagedEncryptionOptions {}
1120
1121/// Represents a recurring schedule that runs every day. The time zone is UTC.
1122///
1123/// This type is not used in any activity, and only used as *part* of another schema.
1124///
1125#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1126#[serde_with::serde_as]
1127#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1128pub struct GoogleFirestoreAdminV1DailyRecurrence {
1129    _never_set: Option<bool>,
1130}
1131
1132impl common::Part for GoogleFirestoreAdminV1DailyRecurrence {}
1133
1134/// A Cloud Firestore Database.
1135///
1136/// # Activities
1137///
1138/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1139/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1140///
1141/// * [databases create projects](ProjectDatabaseCreateCall) (request)
1142/// * [databases get projects](ProjectDatabaseGetCall) (response)
1143/// * [databases patch projects](ProjectDatabasePatchCall) (request)
1144#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1145#[serde_with::serde_as]
1146#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1147pub struct GoogleFirestoreAdminV1Database {
1148    /// The App Engine integration mode to use for this database.
1149    #[serde(rename = "appEngineIntegrationMode")]
1150    pub app_engine_integration_mode: Option<String>,
1151    /// Optional. Presence indicates CMEK is enabled for this database.
1152    #[serde(rename = "cmekConfig")]
1153    pub cmek_config: Option<GoogleFirestoreAdminV1CmekConfig>,
1154    /// The concurrency control mode to use for this database. If unspecified in a CreateDatabase request, this will default based on the database edition: Optimistic for Enterprise and Pessimistic for all other databases.
1155    #[serde(rename = "concurrencyMode")]
1156    pub concurrency_mode: Option<String>,
1157    /// Output only. The timestamp at which this database was created. Databases created before 2016 do not populate create_time.
1158    #[serde(rename = "createTime")]
1159    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1160    /// Immutable. The edition of the database.
1161    #[serde(rename = "databaseEdition")]
1162    pub database_edition: Option<String>,
1163    /// State of delete protection for the database.
1164    #[serde(rename = "deleteProtectionState")]
1165    pub delete_protection_state: Option<String>,
1166    /// Output only. The timestamp at which this database was deleted. Only set if the database has been deleted.
1167    #[serde(rename = "deleteTime")]
1168    pub delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1169    /// Output only. The earliest timestamp at which older versions of the data can be read from the database. See [version_retention_period] above; this field is populated with `now - version_retention_period`. This value is continuously updated, and becomes stale the moment it is queried. If you are using this value to recover data, make sure to account for the time from the moment when the value is queried to the moment when you initiate the recovery.
1170    #[serde(rename = "earliestVersionTime")]
1171    pub earliest_version_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1172    /// This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
1173    pub etag: Option<String>,
1174    /// Optional. The Firestore API data access mode to use for this database. If not set on write: - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition. - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
1175    #[serde(rename = "firestoreDataAccessMode")]
1176    pub firestore_data_access_mode: Option<String>,
1177    /// Output only. Background: Free tier is the ability of a Firestore database to use a small amount of resources every day without being charged. Once usage exceeds the free tier limit further usage is charged. Whether this database can make use of the free tier. Only one database per project can be eligible for the free tier. The first (or next) database that is created in a project without a free tier database will be marked as eligible for the free tier. Databases that are created while there is a free tier database will not be eligible for the free tier.
1178    #[serde(rename = "freeTier")]
1179    pub free_tier: Option<bool>,
1180    /// Output only. The key_prefix for this database. This key_prefix is used, in combination with the project ID ("~") to construct the application ID that is returned from the Cloud Datastore APIs in Google App Engine first generation runtimes. This value may be empty in which case the appid to use for URL-encoded keys is the project_id (eg: foo instead of v~foo).
1181    #[serde(rename = "keyPrefix")]
1182    pub key_prefix: Option<String>,
1183    /// The location of the database. Available locations are listed at https://cloud.google.com/firestore/docs/locations.
1184    #[serde(rename = "locationId")]
1185    pub location_id: Option<String>,
1186    /// Optional. The MongoDB compatible API data access mode to use for this database. If not set on write, the default value is DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always DATA_ACCESS_MODE_DISABLED for Standard Edition.
1187    #[serde(rename = "mongodbCompatibleDataAccessMode")]
1188    pub mongodb_compatible_data_access_mode: Option<String>,
1189    /// The resource name of the Database. Format: `projects/{project}/databases/{database}`
1190    pub name: Option<String>,
1191    /// Whether to enable the PITR feature on this database.
1192    #[serde(rename = "pointInTimeRecoveryEnablement")]
1193    pub point_in_time_recovery_enablement: Option<String>,
1194    /// Output only. The database resource's prior database ID. This field is only populated for deleted databases.
1195    #[serde(rename = "previousId")]
1196    pub previous_id: Option<String>,
1197    /// Immutable. The default Realtime Updates mode to use for this database.
1198    #[serde(rename = "realtimeUpdatesMode")]
1199    pub realtime_updates_mode: Option<String>,
1200    /// Output only. Information about the provenance of this database.
1201    #[serde(rename = "sourceInfo")]
1202    pub source_info: Option<GoogleFirestoreAdminV1SourceInfo>,
1203    /// Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing"
1204    pub tags: Option<HashMap<String, String>>,
1205    /// The type of the database. See https://cloud.google.com/datastore/docs/firestore-or-datastore for information about how to choose.
1206    #[serde(rename = "type")]
1207    pub type_: Option<String>,
1208    /// Output only. The system-generated UUID4 for this Database.
1209    pub uid: Option<String>,
1210    /// Output only. The timestamp at which this database was most recently updated. Note this only includes updates to the database resource and not data contained by the database.
1211    #[serde(rename = "updateTime")]
1212    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1213    /// Output only. The period during which past versions of data are retained in the database. Any read or query can specify a `read_time` within this window, and will read the state of the database at that time. If the PITR feature is enabled, the retention period is 7 days. Otherwise, the retention period is 1 hour.
1214    #[serde(rename = "versionRetentionPeriod")]
1215    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1216    pub version_retention_period: Option<chrono::Duration>,
1217}
1218
1219impl common::RequestValue for GoogleFirestoreAdminV1Database {}
1220impl common::ResponseResult for GoogleFirestoreAdminV1Database {}
1221
1222/// The request for FirestoreAdmin.DisableUserCreds.
1223///
1224/// # Activities
1225///
1226/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1227/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1228///
1229/// * [databases user creds disable projects](ProjectDatabaseUserCredDisableCall) (request)
1230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1231#[serde_with::serde_as]
1232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1233pub struct GoogleFirestoreAdminV1DisableUserCredsRequest {
1234    _never_set: Option<bool>,
1235}
1236
1237impl common::RequestValue for GoogleFirestoreAdminV1DisableUserCredsRequest {}
1238
1239/// The request for FirestoreAdmin.EnableUserCreds.
1240///
1241/// # Activities
1242///
1243/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1244/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1245///
1246/// * [databases user creds enable projects](ProjectDatabaseUserCredEnableCall) (request)
1247#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1248#[serde_with::serde_as]
1249#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1250pub struct GoogleFirestoreAdminV1EnableUserCredsRequest {
1251    _never_set: Option<bool>,
1252}
1253
1254impl common::RequestValue for GoogleFirestoreAdminV1EnableUserCredsRequest {}
1255
1256/// Encryption configuration for a new database being created from another source. The source could be a Backup or a PitrSnapshot.
1257///
1258/// This type is not used in any activity, and only used as *part* of another schema.
1259///
1260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1261#[serde_with::serde_as]
1262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1263pub struct GoogleFirestoreAdminV1EncryptionConfig {
1264    /// Use Customer Managed Encryption Keys (CMEK) for encryption.
1265    #[serde(rename = "customerManagedEncryption")]
1266    pub customer_managed_encryption: Option<GoogleFirestoreAdminV1CustomerManagedEncryptionOptions>,
1267    /// Use Google default encryption.
1268    #[serde(rename = "googleDefaultEncryption")]
1269    pub google_default_encryption: Option<GoogleFirestoreAdminV1GoogleDefaultEncryptionOptions>,
1270    /// The database will use the same encryption configuration as the source.
1271    #[serde(rename = "useSourceEncryption")]
1272    pub use_source_encryption: Option<GoogleFirestoreAdminV1SourceEncryptionOptions>,
1273}
1274
1275impl common::Part for GoogleFirestoreAdminV1EncryptionConfig {}
1276
1277/// The request for FirestoreAdmin.ExportDocuments.
1278///
1279/// # Activities
1280///
1281/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1282/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1283///
1284/// * [databases export documents projects](ProjectDatabaseExportDocumentCall) (request)
1285#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1286#[serde_with::serde_as]
1287#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1288pub struct GoogleFirestoreAdminV1ExportDocumentsRequest {
1289    /// IDs of the collection groups to export. Unspecified means all collection groups. Each collection group in this list must be unique.
1290    #[serde(rename = "collectionIds")]
1291    pub collection_ids: Option<Vec<String>>,
1292    /// An empty list represents all namespaces. This is the preferred usage for databases that don't use namespaces. An empty string element represents the default namespace. This should be used if the database has data in non-default namespaces, but doesn't want to include them. Each namespace in this list must be unique.
1293    #[serde(rename = "namespaceIds")]
1294    pub namespace_ids: Option<Vec<String>>,
1295    /// The output URI. Currently only supports Google Cloud Storage URIs of the form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional Google Cloud Storage namespace path. When choosing a name, be sure to consider Google Cloud Storage naming guidelines: https://cloud.google.com/storage/docs/naming. If the URI is a bucket (without a namespace path), a prefix will be generated based on the start time.
1296    #[serde(rename = "outputUriPrefix")]
1297    pub output_uri_prefix: Option<String>,
1298    /// The timestamp that corresponds to the version of the database to be exported. The timestamp must be in the past, rounded to the minute and not older than earliestVersionTime. If specified, then the exported documents will represent a consistent view of the database at the provided time. Otherwise, there are no guarantees about the consistency of the exported documents.
1299    #[serde(rename = "snapshotTime")]
1300    pub snapshot_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1301}
1302
1303impl common::RequestValue for GoogleFirestoreAdminV1ExportDocumentsRequest {}
1304
1305/// Represents a single field in the database. Fields are grouped by their “Collection Group”, which represent all collections in the database with the same ID.
1306///
1307/// # Activities
1308///
1309/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1310/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1311///
1312/// * [databases collection groups fields get projects](ProjectDatabaseCollectionGroupFieldGetCall) (response)
1313/// * [databases collection groups fields patch projects](ProjectDatabaseCollectionGroupFieldPatchCall) (request)
1314#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1315#[serde_with::serde_as]
1316#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1317pub struct GoogleFirestoreAdminV1Field {
1318    /// The index configuration for this field. If unset, field indexing will revert to the configuration defined by the `ancestor_field`. To explicitly remove all indexes for this field, specify an index config with an empty list of indexes.
1319    #[serde(rename = "indexConfig")]
1320    pub index_config: Option<GoogleFirestoreAdminV1IndexConfig>,
1321    /// Required. A field name of the form: `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` A field path can be a simple field name, e.g. `address` or a path to fields within `map_value` , e.g. `address.city`, or a special field path. The only valid special field is `*`, which represents any field. Field paths can be quoted using `` ` `` (backtick). The only character that must be escaped within a quoted field path is the backtick character itself, escaped using a backslash. Special characters in field paths that must be quoted include: `*`, `.`, `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters. Examples: `` `address.city` `` represents a field named `address.city`, not the map key `city` in the field `address`. `` `*` `` represents a field named `*`, not any field. A special `Field` contains the default indexing settings for all fields. This field's resource name is: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*` Indexes defined on this `Field` will be applied to all fields which do not have their own `Field` index configuration.
1322    pub name: Option<String>,
1323    /// The TTL configuration for this `Field`. Setting or unsetting this will enable or disable the TTL for documents that have this `Field`.
1324    #[serde(rename = "ttlConfig")]
1325    pub ttl_config: Option<GoogleFirestoreAdminV1TtlConfig>,
1326}
1327
1328impl common::RequestValue for GoogleFirestoreAdminV1Field {}
1329impl common::ResponseResult for GoogleFirestoreAdminV1Field {}
1330
1331/// An index that stores vectors in a flat data structure, and supports exhaustive search.
1332///
1333/// This type is not used in any activity, and only used as *part* of another schema.
1334///
1335#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1336#[serde_with::serde_as]
1337#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1338pub struct GoogleFirestoreAdminV1FlatIndex {
1339    _never_set: Option<bool>,
1340}
1341
1342impl common::Part for GoogleFirestoreAdminV1FlatIndex {}
1343
1344/// The configuration options for using Google default encryption.
1345///
1346/// This type is not used in any activity, and only used as *part* of another schema.
1347///
1348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1349#[serde_with::serde_as]
1350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1351pub struct GoogleFirestoreAdminV1GoogleDefaultEncryptionOptions {
1352    _never_set: Option<bool>,
1353}
1354
1355impl common::Part for GoogleFirestoreAdminV1GoogleDefaultEncryptionOptions {}
1356
1357/// The request for FirestoreAdmin.ImportDocuments.
1358///
1359/// # Activities
1360///
1361/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1362/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1363///
1364/// * [databases import documents projects](ProjectDatabaseImportDocumentCall) (request)
1365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1366#[serde_with::serde_as]
1367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1368pub struct GoogleFirestoreAdminV1ImportDocumentsRequest {
1369    /// IDs of the collection groups to import. Unspecified means all collection groups that were included in the export. Each collection group in this list must be unique.
1370    #[serde(rename = "collectionIds")]
1371    pub collection_ids: Option<Vec<String>>,
1372    /// Location of the exported files. This must match the output_uri_prefix of an ExportDocumentsResponse from an export that has completed successfully. See: google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix.
1373    #[serde(rename = "inputUriPrefix")]
1374    pub input_uri_prefix: Option<String>,
1375    /// An empty list represents all namespaces. This is the preferred usage for databases that don't use namespaces. An empty string element represents the default namespace. This should be used if the database has data in non-default namespaces, but doesn't want to include them. Each namespace in this list must be unique.
1376    #[serde(rename = "namespaceIds")]
1377    pub namespace_ids: Option<Vec<String>>,
1378}
1379
1380impl common::RequestValue for GoogleFirestoreAdminV1ImportDocumentsRequest {}
1381
1382/// Cloud Firestore indexes enable simple and complex queries against documents in a database.
1383///
1384/// # Activities
1385///
1386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1388///
1389/// * [databases collection groups indexes create projects](ProjectDatabaseCollectionGroupIndexCreateCall) (request)
1390/// * [databases collection groups indexes get projects](ProjectDatabaseCollectionGroupIndexGetCall) (response)
1391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1392#[serde_with::serde_as]
1393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1394pub struct GoogleFirestoreAdminV1Index {
1395    /// The API scope supported by this index.
1396    #[serde(rename = "apiScope")]
1397    pub api_scope: Option<String>,
1398    /// Immutable. The density configuration of the index.
1399    pub density: Option<String>,
1400    /// The fields supported by this index. For composite indexes, this requires a minimum of 2 and a maximum of 100 fields. The last field entry is always for the field path `__name__`. If, on creation, `__name__` was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the `__name__` will be ordered ASCENDING (unless explicitly specified). For single field indexes, this will always be exactly one entry with a field path equal to the field path of the associated field.
1401    pub fields: Option<Vec<GoogleFirestoreAdminV1IndexField>>,
1402    /// Optional. Whether the index is multikey. By default, the index is not multikey. For non-multikey indexes, none of the paths in the index definition reach or traverse an array, except via an explicit array index. For multikey indexes, at most one of the paths in the index definition reach or traverse an array, except via an explicit array index. Violations will result in errors. Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope.
1403    pub multikey: Option<bool>,
1404    /// Output only. A server defined name for this index. The form of this name for composite indexes will be: `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}` For single field indexes, this field will be empty.
1405    pub name: Option<String>,
1406    /// Indexes with a collection query scope specified allow queries against a collection that is the child of a specific document, specified at query time, and that has the same collection ID. Indexes with a collection group query scope specified allow queries against all collections descended from a specific document, specified at query time, and that have the same collection ID as this index.
1407    #[serde(rename = "queryScope")]
1408    pub query_scope: Option<String>,
1409    /// Optional. The number of shards for the index.
1410    #[serde(rename = "shardCount")]
1411    pub shard_count: Option<i32>,
1412    /// Output only. The serving state of the index.
1413    pub state: Option<String>,
1414    /// Optional. Whether it is an unique index. Unique index ensures all values for the indexed field(s) are unique across documents.
1415    pub unique: Option<bool>,
1416}
1417
1418impl common::RequestValue for GoogleFirestoreAdminV1Index {}
1419impl common::ResponseResult for GoogleFirestoreAdminV1Index {}
1420
1421/// The index configuration for this field.
1422///
1423/// This type is not used in any activity, and only used as *part* of another schema.
1424///
1425#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1426#[serde_with::serde_as]
1427#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1428pub struct GoogleFirestoreAdminV1IndexConfig {
1429    /// Output only. Specifies the resource name of the `Field` from which this field's index configuration is set (when `uses_ancestor_config` is true), or from which it *would* be set if this field had no index configuration (when `uses_ancestor_config` is false).
1430    #[serde(rename = "ancestorField")]
1431    pub ancestor_field: Option<String>,
1432    /// The indexes supported for this field.
1433    pub indexes: Option<Vec<GoogleFirestoreAdminV1Index>>,
1434    /// Output only When true, the `Field`'s index configuration is in the process of being reverted. Once complete, the index config will transition to the same state as the field specified by `ancestor_field`, at which point `uses_ancestor_config` will be `true` and `reverting` will be `false`.
1435    pub reverting: Option<bool>,
1436    /// Output only. When true, the `Field`'s index configuration is set from the configuration specified by the `ancestor_field`. When false, the `Field`'s index configuration is defined explicitly.
1437    #[serde(rename = "usesAncestorConfig")]
1438    pub uses_ancestor_config: Option<bool>,
1439}
1440
1441impl common::Part for GoogleFirestoreAdminV1IndexConfig {}
1442
1443/// A field in an index. The field_path describes which field is indexed, the value_mode describes how the field value is indexed.
1444///
1445/// This type is not used in any activity, and only used as *part* of another schema.
1446///
1447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1448#[serde_with::serde_as]
1449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1450pub struct GoogleFirestoreAdminV1IndexField {
1451    /// Indicates that this field supports operations on `array_value`s.
1452    #[serde(rename = "arrayConfig")]
1453    pub array_config: Option<String>,
1454    /// Can be __name__. For single field indexes, this must match the name of the field or may be omitted.
1455    #[serde(rename = "fieldPath")]
1456    pub field_path: Option<String>,
1457    /// Indicates that this field supports ordering by the specified order or comparing using =, !=, <, <=, >, >=.
1458    pub order: Option<String>,
1459    /// Indicates that this field supports nearest neighbor and distance operations on vector.
1460    #[serde(rename = "vectorConfig")]
1461    pub vector_config: Option<GoogleFirestoreAdminV1VectorConfig>,
1462}
1463
1464impl common::Part for GoogleFirestoreAdminV1IndexField {}
1465
1466/// The response for FirestoreAdmin.ListBackupSchedules.
1467///
1468/// # Activities
1469///
1470/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1471/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1472///
1473/// * [databases backup schedules list projects](ProjectDatabaseBackupScheduleListCall) (response)
1474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1475#[serde_with::serde_as]
1476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1477pub struct GoogleFirestoreAdminV1ListBackupSchedulesResponse {
1478    /// List of all backup schedules.
1479    #[serde(rename = "backupSchedules")]
1480    pub backup_schedules: Option<Vec<GoogleFirestoreAdminV1BackupSchedule>>,
1481}
1482
1483impl common::ResponseResult for GoogleFirestoreAdminV1ListBackupSchedulesResponse {}
1484
1485/// The response for FirestoreAdmin.ListBackups.
1486///
1487/// # Activities
1488///
1489/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1490/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1491///
1492/// * [locations backups list projects](ProjectLocationBackupListCall) (response)
1493#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1494#[serde_with::serde_as]
1495#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1496pub struct GoogleFirestoreAdminV1ListBackupsResponse {
1497    /// List of all backups for the project.
1498    pub backups: Option<Vec<GoogleFirestoreAdminV1Backup>>,
1499    /// List of locations that existing backups were not able to be fetched from. Instead of failing the entire requests when a single location is unreachable, this response returns a partial result set and list of locations unable to be reached here. The request can be retried against a single location to get a concrete error.
1500    pub unreachable: Option<Vec<String>>,
1501}
1502
1503impl common::ResponseResult for GoogleFirestoreAdminV1ListBackupsResponse {}
1504
1505/// The list of databases for a project.
1506///
1507/// # Activities
1508///
1509/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1510/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1511///
1512/// * [databases list projects](ProjectDatabaseListCall) (response)
1513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1514#[serde_with::serde_as]
1515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1516pub struct GoogleFirestoreAdminV1ListDatabasesResponse {
1517    /// The databases in the project.
1518    pub databases: Option<Vec<GoogleFirestoreAdminV1Database>>,
1519    /// In the event that data about individual databases cannot be listed they will be recorded here. An example entry might be: projects/some_project/locations/some_location This can happen if the Cloud Region that the Database resides in is currently unavailable. In this case we can't fetch all the details about the database. You may be able to get a more detailed error message (or possibly fetch the resource) by sending a 'Get' request for the resource or a 'List' request for the specific location.
1520    pub unreachable: Option<Vec<String>>,
1521}
1522
1523impl common::ResponseResult for GoogleFirestoreAdminV1ListDatabasesResponse {}
1524
1525/// The response for FirestoreAdmin.ListFields.
1526///
1527/// # Activities
1528///
1529/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1530/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1531///
1532/// * [databases collection groups fields list projects](ProjectDatabaseCollectionGroupFieldListCall) (response)
1533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1534#[serde_with::serde_as]
1535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1536pub struct GoogleFirestoreAdminV1ListFieldsResponse {
1537    /// The requested fields.
1538    pub fields: Option<Vec<GoogleFirestoreAdminV1Field>>,
1539    /// A page token that may be used to request another page of results. If blank, this is the last page.
1540    #[serde(rename = "nextPageToken")]
1541    pub next_page_token: Option<String>,
1542}
1543
1544impl common::ResponseResult for GoogleFirestoreAdminV1ListFieldsResponse {}
1545
1546/// The response for FirestoreAdmin.ListIndexes.
1547///
1548/// # Activities
1549///
1550/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1551/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1552///
1553/// * [databases collection groups indexes list projects](ProjectDatabaseCollectionGroupIndexListCall) (response)
1554#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1555#[serde_with::serde_as]
1556#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1557pub struct GoogleFirestoreAdminV1ListIndexesResponse {
1558    /// The requested indexes.
1559    pub indexes: Option<Vec<GoogleFirestoreAdminV1Index>>,
1560    /// A page token that may be used to request another page of results. If blank, this is the last page.
1561    #[serde(rename = "nextPageToken")]
1562    pub next_page_token: Option<String>,
1563}
1564
1565impl common::ResponseResult for GoogleFirestoreAdminV1ListIndexesResponse {}
1566
1567/// The response for FirestoreAdmin.ListUserCreds.
1568///
1569/// # Activities
1570///
1571/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1572/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1573///
1574/// * [databases user creds list projects](ProjectDatabaseUserCredListCall) (response)
1575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1576#[serde_with::serde_as]
1577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1578pub struct GoogleFirestoreAdminV1ListUserCredsResponse {
1579    /// The user creds for the database.
1580    #[serde(rename = "userCreds")]
1581    pub user_creds: Option<Vec<GoogleFirestoreAdminV1UserCreds>>,
1582}
1583
1584impl common::ResponseResult for GoogleFirestoreAdminV1ListUserCredsResponse {}
1585
1586/// A consistent snapshot of a database at a specific point in time. A PITR (Point-in-time recovery) snapshot with previous versions of a database's data is available for every minute up to the associated database's data retention period. If the PITR feature is enabled, the retention period is 7 days; otherwise, it is one hour.
1587///
1588/// This type is not used in any activity, and only used as *part* of another schema.
1589///
1590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1591#[serde_with::serde_as]
1592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1593pub struct GoogleFirestoreAdminV1PitrSnapshot {
1594    /// Required. The name of the database that this was a snapshot of. Format: `projects/{project}/databases/{database}`.
1595    pub database: Option<String>,
1596    /// Output only. Public UUID of the database the snapshot was associated with.
1597    #[serde(rename = "databaseUid")]
1598    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1599    pub database_uid: Option<Vec<u8>>,
1600    /// Required. Snapshot time of the database.
1601    #[serde(rename = "snapshotTime")]
1602    pub snapshot_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1603}
1604
1605impl common::Part for GoogleFirestoreAdminV1PitrSnapshot {}
1606
1607/// The request for FirestoreAdmin.ResetUserPassword.
1608///
1609/// # Activities
1610///
1611/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1612/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1613///
1614/// * [databases user creds reset password projects](ProjectDatabaseUserCredResetPasswordCall) (request)
1615#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1616#[serde_with::serde_as]
1617#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1618pub struct GoogleFirestoreAdminV1ResetUserPasswordRequest {
1619    _never_set: Option<bool>,
1620}
1621
1622impl common::RequestValue for GoogleFirestoreAdminV1ResetUserPasswordRequest {}
1623
1624/// Describes a Resource Identity principal.
1625///
1626/// This type is not used in any activity, and only used as *part* of another schema.
1627///
1628#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1629#[serde_with::serde_as]
1630#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1631pub struct GoogleFirestoreAdminV1ResourceIdentity {
1632    /// Output only. Principal identifier string. See: https://cloud.google.com/iam/docs/principal-identifiers
1633    pub principal: Option<String>,
1634}
1635
1636impl common::Part for GoogleFirestoreAdminV1ResourceIdentity {}
1637
1638/// The request message for FirestoreAdmin.RestoreDatabase.
1639///
1640/// # Activities
1641///
1642/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1643/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1644///
1645/// * [databases restore projects](ProjectDatabaseRestoreCall) (request)
1646#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1647#[serde_with::serde_as]
1648#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1649pub struct GoogleFirestoreAdminV1RestoreDatabaseRequest {
1650    /// Required. Backup to restore from. Must be from the same project as the parent. The restored database will be created in the same location as the source backup. Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
1651    pub backup: Option<String>,
1652    /// Required. The ID to use for the database, which will become the final component of the database's resource name. This database ID must not be associated with an existing database. This value should be 4-63 characters. Valid characters are /a-z-/ with first character a letter and the last a letter or a number. Must not be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. "(default)" database ID is also valid if the database is Standard edition.
1653    #[serde(rename = "databaseId")]
1654    pub database_id: Option<String>,
1655    /// Optional. Encryption configuration for the restored database. If this field is not specified, the restored database will use the same encryption configuration as the backup, namely use_source_encryption.
1656    #[serde(rename = "encryptionConfig")]
1657    pub encryption_config: Option<GoogleFirestoreAdminV1EncryptionConfig>,
1658    /// Optional. Immutable. Tags to be bound to the restored database. The tags should be provided in the format of `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
1659    pub tags: Option<HashMap<String, String>>,
1660}
1661
1662impl common::RequestValue for GoogleFirestoreAdminV1RestoreDatabaseRequest {}
1663
1664/// The configuration options for using the same encryption method as the source.
1665///
1666/// This type is not used in any activity, and only used as *part* of another schema.
1667///
1668#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1669#[serde_with::serde_as]
1670#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1671pub struct GoogleFirestoreAdminV1SourceEncryptionOptions {
1672    _never_set: Option<bool>,
1673}
1674
1675impl common::Part for GoogleFirestoreAdminV1SourceEncryptionOptions {}
1676
1677/// Information about the provenance of this database.
1678///
1679/// This type is not used in any activity, and only used as *part* of another schema.
1680///
1681#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1682#[serde_with::serde_as]
1683#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1684pub struct GoogleFirestoreAdminV1SourceInfo {
1685    /// If set, this database was restored from the specified backup (or a snapshot thereof).
1686    pub backup: Option<GoogleFirestoreAdminV1BackupSource>,
1687    /// The associated long-running operation. This field may not be set after the operation has completed. Format: `projects/{project}/databases/{database}/operations/{operation}`.
1688    pub operation: Option<String>,
1689}
1690
1691impl common::Part for GoogleFirestoreAdminV1SourceInfo {}
1692
1693/// Backup specific statistics.
1694///
1695/// This type is not used in any activity, and only used as *part* of another schema.
1696///
1697#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1698#[serde_with::serde_as]
1699#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1700pub struct GoogleFirestoreAdminV1Stats {
1701    /// Output only. The total number of documents contained in the backup.
1702    #[serde(rename = "documentCount")]
1703    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1704    pub document_count: Option<i64>,
1705    /// Output only. The total number of index entries contained in the backup.
1706    #[serde(rename = "indexCount")]
1707    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1708    pub index_count: Option<i64>,
1709    /// Output only. Summation of the size of all documents and index entries in the backup, measured in bytes.
1710    #[serde(rename = "sizeBytes")]
1711    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1712    pub size_bytes: Option<i64>,
1713}
1714
1715impl common::Part for GoogleFirestoreAdminV1Stats {}
1716
1717/// The TTL (time-to-live) configuration for documents that have this `Field` set. Storing a timestamp value into a TTL-enabled field will be treated as the document's absolute expiration time. Timestamp values in the past indicate that the document is eligible for immediate expiration. Using any other data type or leaving the field absent will disable expiration for the individual document.
1718///
1719/// This type is not used in any activity, and only used as *part* of another schema.
1720///
1721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1722#[serde_with::serde_as]
1723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1724pub struct GoogleFirestoreAdminV1TtlConfig {
1725    /// Output only. The state of the TTL configuration.
1726    pub state: Option<String>,
1727}
1728
1729impl common::Part for GoogleFirestoreAdminV1TtlConfig {}
1730
1731/// A Cloud Firestore User Creds.
1732///
1733/// # Activities
1734///
1735/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1736/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1737///
1738/// * [databases user creds create projects](ProjectDatabaseUserCredCreateCall) (request|response)
1739/// * [databases user creds disable projects](ProjectDatabaseUserCredDisableCall) (response)
1740/// * [databases user creds enable projects](ProjectDatabaseUserCredEnableCall) (response)
1741/// * [databases user creds get projects](ProjectDatabaseUserCredGetCall) (response)
1742/// * [databases user creds reset password projects](ProjectDatabaseUserCredResetPasswordCall) (response)
1743#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1744#[serde_with::serde_as]
1745#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1746pub struct GoogleFirestoreAdminV1UserCreds {
1747    /// Output only. The time the user creds were created.
1748    #[serde(rename = "createTime")]
1749    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1750    /// Identifier. The resource name of the UserCreds. Format: `projects/{project}/databases/{database}/userCreds/{user_creds}`
1751    pub name: Option<String>,
1752    /// Resource Identity descriptor.
1753    #[serde(rename = "resourceIdentity")]
1754    pub resource_identity: Option<GoogleFirestoreAdminV1ResourceIdentity>,
1755    /// Output only. The plaintext server-generated password for the user creds. Only populated in responses for CreateUserCreds and ResetUserPassword.
1756    #[serde(rename = "securePassword")]
1757    pub secure_password: Option<String>,
1758    /// Output only. Whether the user creds are enabled or disabled. Defaults to ENABLED on creation.
1759    pub state: Option<String>,
1760    /// Output only. The time the user creds were last updated.
1761    #[serde(rename = "updateTime")]
1762    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1763}
1764
1765impl common::RequestValue for GoogleFirestoreAdminV1UserCreds {}
1766impl common::ResponseResult for GoogleFirestoreAdminV1UserCreds {}
1767
1768/// The index configuration to support vector search operations
1769///
1770/// This type is not used in any activity, and only used as *part* of another schema.
1771///
1772#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1773#[serde_with::serde_as]
1774#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1775pub struct GoogleFirestoreAdminV1VectorConfig {
1776    /// Required. The vector dimension this configuration applies to. The resulting index will only include vectors of this dimension, and can be used for vector search with the same dimension.
1777    pub dimension: Option<i32>,
1778    /// Indicates the vector index is a flat index.
1779    pub flat: Option<GoogleFirestoreAdminV1FlatIndex>,
1780}
1781
1782impl common::Part for GoogleFirestoreAdminV1VectorConfig {}
1783
1784/// Represents a recurring schedule that runs on a specified day of the week. The time zone is UTC.
1785///
1786/// This type is not used in any activity, and only used as *part* of another schema.
1787///
1788#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1789#[serde_with::serde_as]
1790#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1791pub struct GoogleFirestoreAdminV1WeeklyRecurrence {
1792    /// The day of week to run. DAY_OF_WEEK_UNSPECIFIED is not allowed.
1793    pub day: Option<String>,
1794}
1795
1796impl common::Part for GoogleFirestoreAdminV1WeeklyRecurrence {}
1797
1798/// The request message for Operations.CancelOperation.
1799///
1800/// # Activities
1801///
1802/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1803/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1804///
1805/// * [databases operations cancel projects](ProjectDatabaseOperationCancelCall) (request)
1806#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1807#[serde_with::serde_as]
1808#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1809pub struct GoogleLongrunningCancelOperationRequest {
1810    _never_set: Option<bool>,
1811}
1812
1813impl common::RequestValue for GoogleLongrunningCancelOperationRequest {}
1814
1815/// The response message for Operations.ListOperations.
1816///
1817/// # Activities
1818///
1819/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1820/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1821///
1822/// * [databases operations list projects](ProjectDatabaseOperationListCall) (response)
1823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1824#[serde_with::serde_as]
1825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1826pub struct GoogleLongrunningListOperationsResponse {
1827    /// The standard List next-page token.
1828    #[serde(rename = "nextPageToken")]
1829    pub next_page_token: Option<String>,
1830    /// A list of operations that matches the specified filter in the request.
1831    pub operations: Option<Vec<GoogleLongrunningOperation>>,
1832    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
1833    pub unreachable: Option<Vec<String>>,
1834}
1835
1836impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
1837
1838/// This resource represents a long-running operation that is the result of a network API call.
1839///
1840/// # Activities
1841///
1842/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1843/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1844///
1845/// * [databases collection groups fields patch projects](ProjectDatabaseCollectionGroupFieldPatchCall) (response)
1846/// * [databases collection groups indexes create projects](ProjectDatabaseCollectionGroupIndexCreateCall) (response)
1847/// * [databases operations get projects](ProjectDatabaseOperationGetCall) (response)
1848/// * [databases bulk delete documents projects](ProjectDatabaseBulkDeleteDocumentCall) (response)
1849/// * [databases clone projects](ProjectDatabaseCloneCall) (response)
1850/// * [databases create projects](ProjectDatabaseCreateCall) (response)
1851/// * [databases delete projects](ProjectDatabaseDeleteCall) (response)
1852/// * [databases export documents projects](ProjectDatabaseExportDocumentCall) (response)
1853/// * [databases import documents projects](ProjectDatabaseImportDocumentCall) (response)
1854/// * [databases patch projects](ProjectDatabasePatchCall) (response)
1855/// * [databases restore projects](ProjectDatabaseRestoreCall) (response)
1856#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1857#[serde_with::serde_as]
1858#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1859pub struct GoogleLongrunningOperation {
1860    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
1861    pub done: Option<bool>,
1862    /// The error result of the operation in case of failure or cancellation.
1863    pub error: Option<Status>,
1864    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
1865    pub metadata: Option<HashMap<String, serde_json::Value>>,
1866    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
1867    pub name: Option<String>,
1868    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
1869    pub response: Option<HashMap<String, serde_json::Value>>,
1870}
1871
1872impl common::ResponseResult for GoogleLongrunningOperation {}
1873
1874/// An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
1875///
1876/// This type is not used in any activity, and only used as *part* of another schema.
1877///
1878#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1879#[serde_with::serde_as]
1880#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1881pub struct LatLng {
1882    /// The latitude in degrees. It must be in the range [-90.0, +90.0].
1883    pub latitude: Option<f64>,
1884    /// The longitude in degrees. It must be in the range [-180.0, +180.0].
1885    pub longitude: Option<f64>,
1886}
1887
1888impl common::Part for LatLng {}
1889
1890/// The request for Firestore.ListCollectionIds.
1891///
1892/// # Activities
1893///
1894/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1895/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1896///
1897/// * [databases documents list collection ids projects](ProjectDatabaseDocumentListCollectionIdCall) (request)
1898#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1899#[serde_with::serde_as]
1900#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1901pub struct ListCollectionIdsRequest {
1902    /// The maximum number of results to return.
1903    #[serde(rename = "pageSize")]
1904    pub page_size: Option<i32>,
1905    /// A page token. Must be a value from ListCollectionIdsResponse.
1906    #[serde(rename = "pageToken")]
1907    pub page_token: Option<String>,
1908    /// Reads documents as they were at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
1909    #[serde(rename = "readTime")]
1910    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1911}
1912
1913impl common::RequestValue for ListCollectionIdsRequest {}
1914
1915/// The response from Firestore.ListCollectionIds.
1916///
1917/// # Activities
1918///
1919/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1920/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1921///
1922/// * [databases documents list collection ids projects](ProjectDatabaseDocumentListCollectionIdCall) (response)
1923#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1924#[serde_with::serde_as]
1925#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1926pub struct ListCollectionIdsResponse {
1927    /// The collection ids.
1928    #[serde(rename = "collectionIds")]
1929    pub collection_ids: Option<Vec<String>>,
1930    /// A page token that may be used to continue the list.
1931    #[serde(rename = "nextPageToken")]
1932    pub next_page_token: Option<String>,
1933}
1934
1935impl common::ResponseResult for ListCollectionIdsResponse {}
1936
1937/// The response for Firestore.ListDocuments.
1938///
1939/// # Activities
1940///
1941/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1942/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1943///
1944/// * [databases documents list projects](ProjectDatabaseDocumentListCall) (response)
1945/// * [databases documents list documents projects](ProjectDatabaseDocumentListDocumentCall) (response)
1946#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1947#[serde_with::serde_as]
1948#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1949pub struct ListDocumentsResponse {
1950    /// The Documents found.
1951    pub documents: Option<Vec<Document>>,
1952    /// A token to retrieve the next page of documents. If this field is omitted, there are no subsequent pages.
1953    #[serde(rename = "nextPageToken")]
1954    pub next_page_token: Option<String>,
1955}
1956
1957impl common::ResponseResult for ListDocumentsResponse {}
1958
1959/// The response message for Locations.ListLocations.
1960///
1961/// # Activities
1962///
1963/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1964/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1965///
1966/// * [locations list projects](ProjectLocationListCall) (response)
1967#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1968#[serde_with::serde_as]
1969#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1970pub struct ListLocationsResponse {
1971    /// A list of locations that matches the specified filter in the request.
1972    pub locations: Option<Vec<Location>>,
1973    /// The standard List next-page token.
1974    #[serde(rename = "nextPageToken")]
1975    pub next_page_token: Option<String>,
1976}
1977
1978impl common::ResponseResult for ListLocationsResponse {}
1979
1980/// A request for Firestore.Listen
1981///
1982/// # Activities
1983///
1984/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1985/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1986///
1987/// * [databases documents listen projects](ProjectDatabaseDocumentListenCall) (request)
1988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1989#[serde_with::serde_as]
1990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1991pub struct ListenRequest {
1992    /// A target to add to this stream.
1993    #[serde(rename = "addTarget")]
1994    pub add_target: Option<Target>,
1995    /// Labels associated with this target change.
1996    pub labels: Option<HashMap<String, String>>,
1997    /// The ID of a target to remove from this stream.
1998    #[serde(rename = "removeTarget")]
1999    pub remove_target: Option<i32>,
2000}
2001
2002impl common::RequestValue for ListenRequest {}
2003
2004/// The response for Firestore.Listen.
2005///
2006/// # Activities
2007///
2008/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2009/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2010///
2011/// * [databases documents listen projects](ProjectDatabaseDocumentListenCall) (response)
2012#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2013#[serde_with::serde_as]
2014#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2015pub struct ListenResponse {
2016    /// A Document has changed.
2017    #[serde(rename = "documentChange")]
2018    pub document_change: Option<DocumentChange>,
2019    /// A Document has been deleted.
2020    #[serde(rename = "documentDelete")]
2021    pub document_delete: Option<DocumentDelete>,
2022    /// A Document has been removed from a target (because it is no longer relevant to that target).
2023    #[serde(rename = "documentRemove")]
2024    pub document_remove: Option<DocumentRemove>,
2025    /// A filter to apply to the set of documents previously returned for the given target. Returned when documents may have been removed from the given target, but the exact documents are unknown.
2026    pub filter: Option<ExistenceFilter>,
2027    /// Targets have changed.
2028    #[serde(rename = "targetChange")]
2029    pub target_change: Option<TargetChange>,
2030}
2031
2032impl common::ResponseResult for ListenResponse {}
2033
2034/// A resource that represents a Google Cloud location.
2035///
2036/// # Activities
2037///
2038/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2039/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2040///
2041/// * [locations get projects](ProjectLocationGetCall) (response)
2042#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2043#[serde_with::serde_as]
2044#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2045pub struct Location {
2046    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
2047    #[serde(rename = "displayName")]
2048    pub display_name: Option<String>,
2049    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
2050    pub labels: Option<HashMap<String, String>>,
2051    /// The canonical id for this location. For example: `"us-east1"`.
2052    #[serde(rename = "locationId")]
2053    pub location_id: Option<String>,
2054    /// Service-specific metadata. For example the available capacity at the given location.
2055    pub metadata: Option<HashMap<String, serde_json::Value>>,
2056    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
2057    pub name: Option<String>,
2058}
2059
2060impl common::ResponseResult for Location {}
2061
2062/// A map value.
2063///
2064/// This type is not used in any activity, and only used as *part* of another schema.
2065///
2066#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2067#[serde_with::serde_as]
2068#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2069pub struct MapValue {
2070    /// The map's fields. The map keys represent field names. Field names matching the regular expression `__.*__` are reserved. Reserved field names are forbidden except in certain documented contexts. The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be empty.
2071    pub fields: Option<HashMap<String, Value>>,
2072}
2073
2074impl common::Part for MapValue {}
2075
2076/// An order on a field.
2077///
2078/// This type is not used in any activity, and only used as *part* of another schema.
2079///
2080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2081#[serde_with::serde_as]
2082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2083pub struct Order {
2084    /// The direction to order by. Defaults to `ASCENDING`.
2085    pub direction: Option<String>,
2086    /// The field to order by.
2087    pub field: Option<FieldReference>,
2088}
2089
2090impl common::Part for Order {}
2091
2092/// The request for Firestore.PartitionQuery.
2093///
2094/// # Activities
2095///
2096/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2097/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2098///
2099/// * [databases documents partition query projects](ProjectDatabaseDocumentPartitionQueryCall) (request)
2100#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2101#[serde_with::serde_as]
2102#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2103pub struct PartitionQueryRequest {
2104    /// The maximum number of partitions to return in this call, subject to `partition_count`. For example, if `partition_count` = 10 and `page_size` = 8, the first call to PartitionQuery will return up to 8 partitions and a `next_page_token` if more results exist. A second call to PartitionQuery will return up to 2 partitions, to complete the total of 10 specified in `partition_count`.
2105    #[serde(rename = "pageSize")]
2106    pub page_size: Option<i32>,
2107    /// The `next_page_token` value returned from a previous call to PartitionQuery that may be used to get an additional set of results. There are no ordering guarantees between sets of results. Thus, using multiple sets of results will require merging the different result sets. For example, two subsequent calls using a page_token may return: * cursor B, cursor M, cursor Q * cursor A, cursor U, cursor W To obtain a complete result set ordered with respect to the results of the query supplied to PartitionQuery, the results sets should be merged: cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
2108    #[serde(rename = "pageToken")]
2109    pub page_token: Option<String>,
2110    /// The desired maximum number of partition points. The partitions may be returned across multiple pages of results. The number must be positive. The actual number of partitions returned may be fewer. For example, this may be set to one fewer than the number of parallel queries to be run, or in running a data pipeline job, one fewer than the number of workers or compute instances available.
2111    #[serde(rename = "partitionCount")]
2112    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2113    pub partition_count: Option<i64>,
2114    /// Reads documents as they were at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
2115    #[serde(rename = "readTime")]
2116    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2117    /// A structured query. Query must specify collection with all descendants and be ordered by name ascending. Other filters, order bys, limits, offsets, and start/end cursors are not supported.
2118    #[serde(rename = "structuredQuery")]
2119    pub structured_query: Option<StructuredQuery>,
2120}
2121
2122impl common::RequestValue for PartitionQueryRequest {}
2123
2124/// The response for Firestore.PartitionQuery.
2125///
2126/// # Activities
2127///
2128/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2129/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2130///
2131/// * [databases documents partition query projects](ProjectDatabaseDocumentPartitionQueryCall) (response)
2132#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2133#[serde_with::serde_as]
2134#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2135pub struct PartitionQueryResponse {
2136    /// A page token that may be used to request an additional set of results, up to the number specified by `partition_count` in the PartitionQuery request. If blank, there are no more results.
2137    #[serde(rename = "nextPageToken")]
2138    pub next_page_token: Option<String>,
2139    /// Partition results. Each partition is a split point that can be used by RunQuery as a starting or end point for the query results. The RunQuery requests must be made with the same query supplied to this PartitionQuery request. The partition cursors will be ordered according to same ordering as the results of the query supplied to PartitionQuery. For example, if a PartitionQuery request returns partition cursors A and B, running the following three queries will return the entire result set of the original query: * query, end_at A * query, start_at A, end_at B * query, start_at B An empty result may indicate that the query has too few results to be partitioned, or that the query is not yet supported for partitioning.
2140    pub partitions: Option<Vec<Cursor>>,
2141}
2142
2143impl common::ResponseResult for PartitionQueryResponse {}
2144
2145/// A Firestore query represented as an ordered list of operations / stages.
2146///
2147/// This type is not used in any activity, and only used as *part* of another schema.
2148///
2149#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2150#[serde_with::serde_as]
2151#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2152pub struct Pipeline {
2153    /// Required. Ordered list of stages to evaluate.
2154    pub stages: Option<Vec<Stage>>,
2155}
2156
2157impl common::Part for Pipeline {}
2158
2159/// Planning phase information for the query.
2160///
2161/// This type is not used in any activity, and only used as *part* of another schema.
2162///
2163#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2164#[serde_with::serde_as]
2165#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2166pub struct PlanSummary {
2167    /// The indexes selected for the query. For example: [ {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} ]
2168    #[serde(rename = "indexesUsed")]
2169    pub indexes_used: Option<Vec<HashMap<String, serde_json::Value>>>,
2170}
2171
2172impl common::Part for PlanSummary {}
2173
2174/// A precondition on a document, used for conditional operations.
2175///
2176/// This type is not used in any activity, and only used as *part* of another schema.
2177///
2178#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2179#[serde_with::serde_as]
2180#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2181pub struct Precondition {
2182    /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
2183    pub exists: Option<bool>,
2184    /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
2185    #[serde(rename = "updateTime")]
2186    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2187}
2188
2189impl common::Part for Precondition {}
2190
2191/// The projection of document's fields to return.
2192///
2193/// This type is not used in any activity, and only used as *part* of another schema.
2194///
2195#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2196#[serde_with::serde_as]
2197#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2198pub struct Projection {
2199    /// The fields to return. If empty, all fields are returned. To only return the name of the document, use `['__name__']`.
2200    pub fields: Option<Vec<FieldReference>>,
2201}
2202
2203impl common::Part for Projection {}
2204
2205/// A target specified by a query.
2206///
2207/// This type is not used in any activity, and only used as *part* of another schema.
2208///
2209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2210#[serde_with::serde_as]
2211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2212pub struct QueryTarget {
2213    /// The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
2214    pub parent: Option<String>,
2215    /// A structured query.
2216    #[serde(rename = "structuredQuery")]
2217    pub structured_query: Option<StructuredQuery>,
2218}
2219
2220impl common::Part for QueryTarget {}
2221
2222/// Options for a transaction that can only be used to read documents.
2223///
2224/// This type is not used in any activity, and only used as *part* of another schema.
2225///
2226#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2227#[serde_with::serde_as]
2228#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2229pub struct ReadOnly {
2230    /// Reads documents at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
2231    #[serde(rename = "readTime")]
2232    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2233}
2234
2235impl common::Part for ReadOnly {}
2236
2237/// Options for a transaction that can be used to read and write documents. Firestore does not allow 3rd party auth requests to create read-write. transactions.
2238///
2239/// This type is not used in any activity, and only used as *part* of another schema.
2240///
2241#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2242#[serde_with::serde_as]
2243#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2244pub struct ReadWrite {
2245    /// An optional transaction to retry.
2246    #[serde(rename = "retryTransaction")]
2247    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2248    pub retry_transaction: Option<Vec<u8>>,
2249}
2250
2251impl common::Part for ReadWrite {}
2252
2253/// The request for Firestore.Rollback.
2254///
2255/// # Activities
2256///
2257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2259///
2260/// * [databases documents rollback projects](ProjectDatabaseDocumentRollbackCall) (request)
2261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2262#[serde_with::serde_as]
2263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2264pub struct RollbackRequest {
2265    /// Required. The transaction to roll back.
2266    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2267    pub transaction: Option<Vec<u8>>,
2268}
2269
2270impl common::RequestValue for RollbackRequest {}
2271
2272/// The request for Firestore.RunAggregationQuery.
2273///
2274/// # Activities
2275///
2276/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2277/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2278///
2279/// * [databases documents run aggregation query projects](ProjectDatabaseDocumentRunAggregationQueryCall) (request)
2280#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2281#[serde_with::serde_as]
2282#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2283pub struct RunAggregationQueryRequest {
2284    /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
2285    #[serde(rename = "explainOptions")]
2286    pub explain_options: Option<ExplainOptions>,
2287    /// Starts a new transaction as part of the query, defaulting to read-only. The new transaction ID will be returned as the first response in the stream.
2288    #[serde(rename = "newTransaction")]
2289    pub new_transaction: Option<TransactionOptions>,
2290    /// Executes the query at the given timestamp. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
2291    #[serde(rename = "readTime")]
2292    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2293    /// An aggregation query.
2294    #[serde(rename = "structuredAggregationQuery")]
2295    pub structured_aggregation_query: Option<StructuredAggregationQuery>,
2296    /// Run the aggregation within an already active transaction. The value here is the opaque transaction ID to execute the query in.
2297    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2298    pub transaction: Option<Vec<u8>>,
2299}
2300
2301impl common::RequestValue for RunAggregationQueryRequest {}
2302
2303/// The response for Firestore.RunAggregationQuery.
2304///
2305/// # Activities
2306///
2307/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2308/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2309///
2310/// * [databases documents run aggregation query projects](ProjectDatabaseDocumentRunAggregationQueryCall) (response)
2311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2312#[serde_with::serde_as]
2313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2314pub struct RunAggregationQueryResponse {
2315    /// Query explain metrics. This is only present when the RunAggregationQueryRequest.explain_options is provided, and it is sent only once with the last response in the stream.
2316    #[serde(rename = "explainMetrics")]
2317    pub explain_metrics: Option<ExplainMetrics>,
2318    /// The time at which the aggregate result was computed. This is always monotonically increasing; in this case, the previous AggregationResult in the result stream are guaranteed not to have changed between their `read_time` and this one. If the query returns no results, a response with `read_time` and no `result` will be sent, and this represents the time at which the query was run.
2319    #[serde(rename = "readTime")]
2320    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2321    /// A single aggregation result. Not present when reporting partial progress.
2322    pub result: Option<AggregationResult>,
2323    /// The transaction that was started as part of this request. Only present on the first response when the request requested to start a new transaction.
2324    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2325    pub transaction: Option<Vec<u8>>,
2326}
2327
2328impl common::ResponseResult for RunAggregationQueryResponse {}
2329
2330/// The request for Firestore.RunQuery.
2331///
2332/// # Activities
2333///
2334/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2335/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2336///
2337/// * [databases documents run query projects](ProjectDatabaseDocumentRunQueryCall) (request)
2338#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2339#[serde_with::serde_as]
2340#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2341pub struct RunQueryRequest {
2342    /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
2343    #[serde(rename = "explainOptions")]
2344    pub explain_options: Option<ExplainOptions>,
2345    /// Starts a new transaction and reads the documents. Defaults to a read-only transaction. The new transaction ID will be returned as the first response in the stream.
2346    #[serde(rename = "newTransaction")]
2347    pub new_transaction: Option<TransactionOptions>,
2348    /// Reads documents as they were at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
2349    #[serde(rename = "readTime")]
2350    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2351    /// A structured query.
2352    #[serde(rename = "structuredQuery")]
2353    pub structured_query: Option<StructuredQuery>,
2354    /// Run the query within an already active transaction. The value here is the opaque transaction ID to execute the query in.
2355    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2356    pub transaction: Option<Vec<u8>>,
2357}
2358
2359impl common::RequestValue for RunQueryRequest {}
2360
2361/// The response for Firestore.RunQuery.
2362///
2363/// # Activities
2364///
2365/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2366/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2367///
2368/// * [databases documents run query projects](ProjectDatabaseDocumentRunQueryCall) (response)
2369#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2370#[serde_with::serde_as]
2371#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2372pub struct RunQueryResponse {
2373    /// A query result, not set when reporting partial progress.
2374    pub document: Option<Document>,
2375    /// If present, Firestore has completely finished the request and no more documents will be returned.
2376    pub done: Option<bool>,
2377    /// Query explain metrics. This is only present when the RunQueryRequest.explain_options is provided, and it is sent only once with the last response in the stream.
2378    #[serde(rename = "explainMetrics")]
2379    pub explain_metrics: Option<ExplainMetrics>,
2380    /// The time at which the document was read. This may be monotonically increasing; in this case, the previous documents in the result stream are guaranteed not to have changed between their `read_time` and this one. If the query returns no results, a response with `read_time` and no `document` will be sent, and this represents the time at which the query was run.
2381    #[serde(rename = "readTime")]
2382    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2383    /// The number of results that have been skipped due to an offset between the last response and the current response.
2384    #[serde(rename = "skippedResults")]
2385    pub skipped_results: Option<i32>,
2386    /// The transaction that was started as part of this request. Can only be set in the first response, and only if RunQueryRequest.new_transaction was set in the request. If set, no other fields will be set in this response.
2387    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2388    pub transaction: Option<Vec<u8>>,
2389}
2390
2391impl common::ResponseResult for RunQueryResponse {}
2392
2393/// A single operation within a pipeline. A stage is made up of a unique name, and a list of arguments. The exact number of arguments & types is dependent on the stage type. To give an example, the stage `filter(state = "MD")` would be encoded as: ``` name: "filter" args { function_value { name: "eq" args { field_reference_value: "state" } args { string_value: "MD" } } } ``` See public documentation for the full list.
2394///
2395/// This type is not used in any activity, and only used as *part* of another schema.
2396///
2397#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2398#[serde_with::serde_as]
2399#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2400pub struct Stage {
2401    /// Optional. Ordered list of arguments the given stage expects.
2402    pub args: Option<Vec<Value>>,
2403    /// Required. The name of the stage to evaluate. **Requires:** * must be in snake case (lower case with underscore separator).
2404    pub name: Option<String>,
2405    /// Optional. Optional named arguments that certain functions may support.
2406    pub options: Option<HashMap<String, Value>>,
2407}
2408
2409impl common::Part for Stage {}
2410
2411/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
2412///
2413/// This type is not used in any activity, and only used as *part* of another schema.
2414///
2415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2416#[serde_with::serde_as]
2417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2418pub struct Status {
2419    /// The status code, which should be an enum value of google.rpc.Code.
2420    pub code: Option<i32>,
2421    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2422    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2423    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
2424    pub message: Option<String>,
2425}
2426
2427impl common::Part for Status {}
2428
2429/// Firestore query for running an aggregation over a StructuredQuery.
2430///
2431/// This type is not used in any activity, and only used as *part* of another schema.
2432///
2433#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2434#[serde_with::serde_as]
2435#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2436pub struct StructuredAggregationQuery {
2437    /// Optional. Series of aggregations to apply over the results of the `structured_query`. Requires: * A minimum of one and maximum of five aggregations per query.
2438    pub aggregations: Option<Vec<Aggregation>>,
2439    /// Nested structured query.
2440    #[serde(rename = "structuredQuery")]
2441    pub structured_query: Option<StructuredQuery>,
2442}
2443
2444impl common::Part for StructuredAggregationQuery {}
2445
2446/// A Firestore query represented as an ordered list of operations / stages. This is considered the top-level function which plans and executes a query. It is logically equivalent to `query(stages, options)`, but prevents the client from having to build a function wrapper.
2447///
2448/// This type is not used in any activity, and only used as *part* of another schema.
2449///
2450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2451#[serde_with::serde_as]
2452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2453pub struct StructuredPipeline {
2454    /// Optional. Optional query-level arguments.
2455    pub options: Option<HashMap<String, Value>>,
2456    /// Required. The pipeline query to execute.
2457    pub pipeline: Option<Pipeline>,
2458}
2459
2460impl common::Part for StructuredPipeline {}
2461
2462/// A Firestore query. The query stages are executed in the following order: 1. from 2. where 3. select 4. order_by + start_at + end_at 5. offset 6. limit 7. find_nearest
2463///
2464/// This type is not used in any activity, and only used as *part* of another schema.
2465///
2466#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2467#[serde_with::serde_as]
2468#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2469pub struct StructuredQuery {
2470    /// A potential prefix of a position in the result set to end the query at. This is similar to `START_AT` but with it controlling the end position rather than the start position. Requires: * The number of values cannot be greater than the number of fields specified in the `ORDER BY` clause.
2471    #[serde(rename = "endAt")]
2472    pub end_at: Option<Cursor>,
2473    /// Optional. A potential nearest neighbors search. Applies after all other filters and ordering. Finds the closest vector embeddings to the given query vector.
2474    #[serde(rename = "findNearest")]
2475    pub find_nearest: Option<FindNearest>,
2476    /// The collections to query.
2477    pub from: Option<Vec<CollectionSelector>>,
2478    /// The maximum number of results to return. Applies after all other constraints. Requires: * The value must be greater than or equal to zero if specified.
2479    pub limit: Option<i32>,
2480    /// The number of documents to skip before returning the first result. This applies after the constraints specified by the `WHERE`, `START AT`, & `END AT` but before the `LIMIT` clause. Requires: * The value must be greater than or equal to zero if specified.
2481    pub offset: Option<i32>,
2482    /// The order to apply to the query results. Firestore allows callers to provide a full ordering, a partial ordering, or no ordering at all. In all cases, Firestore guarantees a stable ordering through the following rules: * The `order_by` is required to reference all fields used with an inequality filter. * All fields that are required to be in the `order_by` but are not already present are appended in lexicographical ordering of the field name. * If an order on `__name__` is not specified, it is appended by default. Fields are appended with the same sort direction as the last order specified, or 'ASCENDING' if no order was specified. For example: * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC` * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC` * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC` * `WHERE __name__ > ... AND a > 1` becomes `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
2483    #[serde(rename = "orderBy")]
2484    pub order_by: Option<Vec<Order>>,
2485    /// Optional sub-set of the fields to return. This acts as a DocumentMask over the documents returned from a query. When not set, assumes that the caller wants all fields returned.
2486    pub select: Option<Projection>,
2487    /// A potential prefix of a position in the result set to start the query at. The ordering of the result set is based on the `ORDER BY` clause of the original query. ``` SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC; ``` This query's results are ordered by `(b ASC, __name__ ASC)`. Cursors can reference either the full ordering or a prefix of the location, though it cannot reference more fields than what are in the provided `ORDER BY`. Continuing off the example above, attaching the following start cursors will have varying impact: - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND b > 2 AND __name__ > /k/123`. - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`. Unlike `OFFSET` which requires scanning over the first N results to skip, a start cursor allows the query to begin at a logical position. This position is not required to match an actual result, it will scan forward from this position to find the next document. Requires: * The number of values cannot be greater than the number of fields specified in the `ORDER BY` clause.
2488    #[serde(rename = "startAt")]
2489    pub start_at: Option<Cursor>,
2490    /// The filter to apply.
2491    #[serde(rename = "where")]
2492    pub where_: Option<Filter>,
2493}
2494
2495impl common::Part for StructuredQuery {}
2496
2497/// Sum of the values of the requested field. * Only numeric values will be aggregated. All non-numeric values including `NULL` are skipped. * If the aggregated values contain `NaN`, returns `NaN`. Infinity math follows IEEE-754 standards. * If the aggregated value set is empty, returns 0. * Returns a 64-bit integer if all aggregated numbers are integers and the sum result does not overflow. Otherwise, the result is returned as a double. Note that even if all the aggregated values are integers, the result is returned as a double if it cannot fit within a 64-bit signed integer. When this occurs, the returned value will lose precision. * When underflow occurs, floating-point aggregation is non-deterministic. This means that running the same query repeatedly without any changes to the underlying values could produce slightly different results each time. In those cases, values should be stored as integers over floating-point numbers.
2498///
2499/// This type is not used in any activity, and only used as *part* of another schema.
2500///
2501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2502#[serde_with::serde_as]
2503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2504pub struct Sum {
2505    /// The field to aggregate on.
2506    pub field: Option<FieldReference>,
2507}
2508
2509impl common::Part for Sum {}
2510
2511/// A specification of a set of documents to listen to.
2512///
2513/// This type is not used in any activity, and only used as *part* of another schema.
2514///
2515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2516#[serde_with::serde_as]
2517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2518pub struct Target {
2519    /// A target specified by a set of document names.
2520    pub documents: Option<DocumentsTarget>,
2521    /// The number of documents that last matched the query at the resume token or read time. This value is only relevant when a `resume_type` is provided. This value being present and greater than zero signals that the client wants `ExistenceFilter.unchanged_names` to be included in the response.
2522    #[serde(rename = "expectedCount")]
2523    pub expected_count: Option<i32>,
2524    /// If the target should be removed once it is current and consistent.
2525    pub once: Option<bool>,
2526    /// A target specified by a query.
2527    pub query: Option<QueryTarget>,
2528    /// Start listening after a specific `read_time`. The client must know the state of matching documents at this time.
2529    #[serde(rename = "readTime")]
2530    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2531    /// A resume token from a prior TargetChange for an identical target. Using a resume token with a different target is unsupported and may fail.
2532    #[serde(rename = "resumeToken")]
2533    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2534    pub resume_token: Option<Vec<u8>>,
2535    /// The target ID that identifies the target on the stream. Must be a positive number and non-zero. If `target_id` is 0 (or unspecified), the server will assign an ID for this target and return that in a `TargetChange::ADD` event. Once a target with `target_id=0` is added, all subsequent targets must also have `target_id=0`. If an `AddTarget` request with `target_id != 0` is sent to the server after a target with `target_id=0` is added, the server will immediately send a response with a `TargetChange::Remove` event. Note that if the client sends multiple `AddTarget` requests without an ID, the order of IDs returned in `TargetChange.target_ids` are undefined. Therefore, clients should provide a target ID instead of relying on the server to assign one. If `target_id` is non-zero, there must not be an existing active target on this stream with the same ID.
2536    #[serde(rename = "targetId")]
2537    pub target_id: Option<i32>,
2538}
2539
2540impl common::Part for Target {}
2541
2542/// Targets being watched have changed.
2543///
2544/// This type is not used in any activity, and only used as *part* of another schema.
2545///
2546#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2547#[serde_with::serde_as]
2548#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2549pub struct TargetChange {
2550    /// The error that resulted in this change, if applicable.
2551    pub cause: Option<Status>,
2552    /// The consistent `read_time` for the given `target_ids` (omitted when the target_ids are not at a consistent snapshot). The stream is guaranteed to send a `read_time` with `target_ids` empty whenever the entire stream reaches a new consistent snapshot. ADD, CURRENT, and RESET messages are guaranteed to (eventually) result in a new consistent snapshot (while NO_CHANGE and REMOVE messages are not). For a given stream, `read_time` is guaranteed to be monotonically increasing.
2553    #[serde(rename = "readTime")]
2554    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2555    /// A token that can be used to resume the stream for the given `target_ids`, or all targets if `target_ids` is empty. Not set on every target change.
2556    #[serde(rename = "resumeToken")]
2557    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2558    pub resume_token: Option<Vec<u8>>,
2559    /// The type of change that occurred.
2560    #[serde(rename = "targetChangeType")]
2561    pub target_change_type: Option<String>,
2562    /// The target IDs of targets that have changed. If empty, the change applies to all targets. The order of the target IDs is not defined.
2563    #[serde(rename = "targetIds")]
2564    pub target_ids: Option<Vec<i32>>,
2565}
2566
2567impl common::Part for TargetChange {}
2568
2569/// Options for creating a new transaction.
2570///
2571/// This type is not used in any activity, and only used as *part* of another schema.
2572///
2573#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2574#[serde_with::serde_as]
2575#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2576pub struct TransactionOptions {
2577    /// The transaction can only be used for read operations.
2578    #[serde(rename = "readOnly")]
2579    pub read_only: Option<ReadOnly>,
2580    /// The transaction can be used for both read and write operations.
2581    #[serde(rename = "readWrite")]
2582    pub read_write: Option<ReadWrite>,
2583}
2584
2585impl common::Part for TransactionOptions {}
2586
2587/// A filter with a single operand.
2588///
2589/// This type is not used in any activity, and only used as *part* of another schema.
2590///
2591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2592#[serde_with::serde_as]
2593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2594pub struct UnaryFilter {
2595    /// The field to which to apply the operator.
2596    pub field: Option<FieldReference>,
2597    /// The unary operator to apply.
2598    pub op: Option<String>,
2599}
2600
2601impl common::Part for UnaryFilter {}
2602
2603/// A message that can hold any of the supported value types.
2604///
2605/// This type is not used in any activity, and only used as *part* of another schema.
2606///
2607#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2608#[serde_with::serde_as]
2609#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2610pub struct Value {
2611    /// An array value. Cannot directly contain another array value, though can contain a map which contains another array.
2612    #[serde(rename = "arrayValue")]
2613    pub array_value: Option<ArrayValue>,
2614    /// A boolean value.
2615    #[serde(rename = "booleanValue")]
2616    pub boolean_value: Option<bool>,
2617    /// A bytes value. Must not exceed 1 MiB - 89 bytes. Only the first 1,500 bytes are considered by queries.
2618    #[serde(rename = "bytesValue")]
2619    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2620    pub bytes_value: Option<Vec<u8>>,
2621    /// A double value.
2622    #[serde(rename = "doubleValue")]
2623    pub double_value: Option<f64>,
2624    /// Value which references a field. This is considered relative (vs absolute) since it only refers to a field and not a field within a particular document. **Requires:** * Must follow field reference limitations. * Not allowed to be used when writing documents.
2625    #[serde(rename = "fieldReferenceValue")]
2626    pub field_reference_value: Option<String>,
2627    /// A value that represents an unevaluated expression. **Requires:** * Not allowed to be used when writing documents.
2628    #[serde(rename = "functionValue")]
2629    pub function_value: Option<Function>,
2630    /// A geo point value representing a point on the surface of Earth.
2631    #[serde(rename = "geoPointValue")]
2632    pub geo_point_value: Option<LatLng>,
2633    /// An integer value.
2634    #[serde(rename = "integerValue")]
2635    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2636    pub integer_value: Option<i64>,
2637    /// A map value.
2638    #[serde(rename = "mapValue")]
2639    pub map_value: Option<MapValue>,
2640    /// A null value.
2641    #[serde(rename = "nullValue")]
2642    pub null_value: Option<String>,
2643    /// A value that represents an unevaluated pipeline. **Requires:** * Not allowed to be used when writing documents.
2644    #[serde(rename = "pipelineValue")]
2645    pub pipeline_value: Option<Pipeline>,
2646    /// A reference to a document. For example: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
2647    #[serde(rename = "referenceValue")]
2648    pub reference_value: Option<String>,
2649    /// A string value. The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. Only the first 1,500 bytes of the UTF-8 representation are considered by queries.
2650    #[serde(rename = "stringValue")]
2651    pub string_value: Option<String>,
2652    /// A timestamp value. Precise only to microseconds. When stored, any additional precision is rounded down.
2653    #[serde(rename = "timestampValue")]
2654    pub timestamp_value: Option<chrono::DateTime<chrono::offset::Utc>>,
2655}
2656
2657impl common::Part for Value {}
2658
2659/// A write on a document.
2660///
2661/// This type is not used in any activity, and only used as *part* of another schema.
2662///
2663#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2664#[serde_with::serde_as]
2665#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2666pub struct Write {
2667    /// An optional precondition on the document. The write will fail if this is set and not met by the target document.
2668    #[serde(rename = "currentDocument")]
2669    pub current_document: Option<Precondition>,
2670    /// A document name to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
2671    pub delete: Option<String>,
2672    /// Applies a transformation to a document.
2673    pub transform: Option<DocumentTransform>,
2674    /// A document to write.
2675    pub update: Option<Document>,
2676    /// The fields to update in this write. This field can be set only when the operation is `update`. If the mask is not set for an `update` and the document exists, any existing data will be overwritten. If the mask is set and the document on the server has fields not covered by the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server. The field paths in this mask must not contain a reserved field name.
2677    #[serde(rename = "updateMask")]
2678    pub update_mask: Option<DocumentMask>,
2679    /// The transforms to perform after update. This field can be set only when the operation is `update`. If present, this write is equivalent to performing `update` and `transform` to the same document atomically and in order.
2680    #[serde(rename = "updateTransforms")]
2681    pub update_transforms: Option<Vec<FieldTransform>>,
2682}
2683
2684impl common::Part for Write {}
2685
2686/// The request for Firestore.Write. The first request creates a stream, or resumes an existing one from a token. When creating a new stream, the server replies with a response containing only an ID and a token, to use in the next request. When resuming a stream, the server first streams any responses later than the given token, then a response containing only an up-to-date token, to use in the next request.
2687///
2688/// # Activities
2689///
2690/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2691/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2692///
2693/// * [databases documents write projects](ProjectDatabaseDocumentWriteCall) (request)
2694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2695#[serde_with::serde_as]
2696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2697pub struct WriteRequest {
2698    /// Labels associated with this write request.
2699    pub labels: Option<HashMap<String, String>>,
2700    /// The ID of the write stream to resume. This may only be set in the first message. When left empty, a new write stream will be created.
2701    #[serde(rename = "streamId")]
2702    pub stream_id: Option<String>,
2703    /// A stream token that was previously sent by the server. The client should set this field to the token from the most recent WriteResponse it has received. This acknowledges that the client has received responses up to this token. After sending this token, earlier tokens may not be used anymore. The server may close the stream if there are too many unacknowledged responses. Leave this field unset when creating a new stream. To resume a stream at a specific point, set this field and the `stream_id` field. Leave this field unset when creating a new stream.
2704    #[serde(rename = "streamToken")]
2705    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2706    pub stream_token: Option<Vec<u8>>,
2707    /// The writes to apply. Always executed atomically and in order. This must be empty on the first request. This may be empty on the last request. This must not be empty on all other requests.
2708    pub writes: Option<Vec<Write>>,
2709}
2710
2711impl common::RequestValue for WriteRequest {}
2712
2713/// The response for Firestore.Write.
2714///
2715/// # Activities
2716///
2717/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2718/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2719///
2720/// * [databases documents write projects](ProjectDatabaseDocumentWriteCall) (response)
2721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2722#[serde_with::serde_as]
2723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2724pub struct WriteResponse {
2725    /// The time at which the commit occurred. Any read with an equal or greater `read_time` is guaranteed to see the effects of the write.
2726    #[serde(rename = "commitTime")]
2727    pub commit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2728    /// The ID of the stream. Only set on the first message, when a new stream was created.
2729    #[serde(rename = "streamId")]
2730    pub stream_id: Option<String>,
2731    /// A token that represents the position of this response in the stream. This can be used by a client to resume the stream at this point. This field is always set.
2732    #[serde(rename = "streamToken")]
2733    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2734    pub stream_token: Option<Vec<u8>>,
2735    /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
2736    #[serde(rename = "writeResults")]
2737    pub write_results: Option<Vec<WriteResult>>,
2738}
2739
2740impl common::ResponseResult for WriteResponse {}
2741
2742/// The result of applying a write.
2743///
2744/// This type is not used in any activity, and only used as *part* of another schema.
2745///
2746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2747#[serde_with::serde_as]
2748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2749pub struct WriteResult {
2750    /// The results of applying each DocumentTransform.FieldTransform, in the same order.
2751    #[serde(rename = "transformResults")]
2752    pub transform_results: Option<Vec<Value>>,
2753    /// The last update time of the document after applying the write. Not set after a `delete`. If the write did not actually change the document, this will be the previous update_time.
2754    #[serde(rename = "updateTime")]
2755    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2756}
2757
2758impl common::Part for WriteResult {}
2759
2760// ###################
2761// MethodBuilders ###
2762// #################
2763
2764/// A builder providing access to all methods supported on *project* resources.
2765/// It is not used directly, but through the [`Firestore`] hub.
2766///
2767/// # Example
2768///
2769/// Instantiate a resource builder
2770///
2771/// ```test_harness,no_run
2772/// extern crate hyper;
2773/// extern crate hyper_rustls;
2774/// extern crate google_firestore1 as firestore1;
2775///
2776/// # async fn dox() {
2777/// use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2778///
2779/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2780/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2781///     .with_native_roots()
2782///     .unwrap()
2783///     .https_only()
2784///     .enable_http2()
2785///     .build();
2786///
2787/// let executor = hyper_util::rt::TokioExecutor::new();
2788/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2789///     secret,
2790///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2791///     yup_oauth2::client::CustomHyperClientBuilder::from(
2792///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2793///     ),
2794/// ).build().await.unwrap();
2795///
2796/// let client = hyper_util::client::legacy::Client::builder(
2797///     hyper_util::rt::TokioExecutor::new()
2798/// )
2799/// .build(
2800///     hyper_rustls::HttpsConnectorBuilder::new()
2801///         .with_native_roots()
2802///         .unwrap()
2803///         .https_or_http()
2804///         .enable_http2()
2805///         .build()
2806/// );
2807/// let mut hub = Firestore::new(client, auth);
2808/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2809/// // like `databases_backup_schedules_create(...)`, `databases_backup_schedules_delete(...)`, `databases_backup_schedules_get(...)`, `databases_backup_schedules_list(...)`, `databases_backup_schedules_patch(...)`, `databases_bulk_delete_documents(...)`, `databases_clone(...)`, `databases_collection_groups_fields_get(...)`, `databases_collection_groups_fields_list(...)`, `databases_collection_groups_fields_patch(...)`, `databases_collection_groups_indexes_create(...)`, `databases_collection_groups_indexes_delete(...)`, `databases_collection_groups_indexes_get(...)`, `databases_collection_groups_indexes_list(...)`, `databases_create(...)`, `databases_delete(...)`, `databases_documents_batch_get(...)`, `databases_documents_batch_write(...)`, `databases_documents_begin_transaction(...)`, `databases_documents_commit(...)`, `databases_documents_create_document(...)`, `databases_documents_delete(...)`, `databases_documents_execute_pipeline(...)`, `databases_documents_get(...)`, `databases_documents_list(...)`, `databases_documents_list_collection_ids(...)`, `databases_documents_list_documents(...)`, `databases_documents_listen(...)`, `databases_documents_partition_query(...)`, `databases_documents_patch(...)`, `databases_documents_rollback(...)`, `databases_documents_run_aggregation_query(...)`, `databases_documents_run_query(...)`, `databases_documents_write(...)`, `databases_export_documents(...)`, `databases_get(...)`, `databases_import_documents(...)`, `databases_list(...)`, `databases_operations_cancel(...)`, `databases_operations_delete(...)`, `databases_operations_get(...)`, `databases_operations_list(...)`, `databases_patch(...)`, `databases_restore(...)`, `databases_user_creds_create(...)`, `databases_user_creds_delete(...)`, `databases_user_creds_disable(...)`, `databases_user_creds_enable(...)`, `databases_user_creds_get(...)`, `databases_user_creds_list(...)`, `databases_user_creds_reset_password(...)`, `locations_backups_delete(...)`, `locations_backups_get(...)`, `locations_backups_list(...)`, `locations_get(...)` and `locations_list(...)`
2810/// // to build up your call.
2811/// let rb = hub.projects();
2812/// # }
2813/// ```
2814pub struct ProjectMethods<'a, C>
2815where
2816    C: 'a,
2817{
2818    hub: &'a Firestore<C>,
2819}
2820
2821impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2822
2823impl<'a, C> ProjectMethods<'a, C> {
2824    /// Create a builder to help you perform the following task:
2825    ///
2826    /// Creates a backup schedule on a database. At most two backup schedules can be configured on a database, one daily backup schedule and one weekly backup schedule.
2827    ///
2828    /// # Arguments
2829    ///
2830    /// * `request` - No description provided.
2831    /// * `parent` - Required. The parent database. Format `projects/{project}/databases/{database}`
2832    pub fn databases_backup_schedules_create(
2833        &self,
2834        request: GoogleFirestoreAdminV1BackupSchedule,
2835        parent: &str,
2836    ) -> ProjectDatabaseBackupScheduleCreateCall<'a, C> {
2837        ProjectDatabaseBackupScheduleCreateCall {
2838            hub: self.hub,
2839            _request: request,
2840            _parent: parent.to_string(),
2841            _delegate: Default::default(),
2842            _additional_params: Default::default(),
2843            _scopes: Default::default(),
2844        }
2845    }
2846
2847    /// Create a builder to help you perform the following task:
2848    ///
2849    /// Deletes a backup schedule.
2850    ///
2851    /// # Arguments
2852    ///
2853    /// * `name` - Required. The name of the backup schedule. Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
2854    pub fn databases_backup_schedules_delete(
2855        &self,
2856        name: &str,
2857    ) -> ProjectDatabaseBackupScheduleDeleteCall<'a, C> {
2858        ProjectDatabaseBackupScheduleDeleteCall {
2859            hub: self.hub,
2860            _name: name.to_string(),
2861            _delegate: Default::default(),
2862            _additional_params: Default::default(),
2863            _scopes: Default::default(),
2864        }
2865    }
2866
2867    /// Create a builder to help you perform the following task:
2868    ///
2869    /// Gets information about a backup schedule.
2870    ///
2871    /// # Arguments
2872    ///
2873    /// * `name` - Required. The name of the backup schedule. Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
2874    pub fn databases_backup_schedules_get(
2875        &self,
2876        name: &str,
2877    ) -> ProjectDatabaseBackupScheduleGetCall<'a, C> {
2878        ProjectDatabaseBackupScheduleGetCall {
2879            hub: self.hub,
2880            _name: name.to_string(),
2881            _delegate: Default::default(),
2882            _additional_params: Default::default(),
2883            _scopes: Default::default(),
2884        }
2885    }
2886
2887    /// Create a builder to help you perform the following task:
2888    ///
2889    /// List backup schedules.
2890    ///
2891    /// # Arguments
2892    ///
2893    /// * `parent` - Required. The parent database. Format is `projects/{project}/databases/{database}`.
2894    pub fn databases_backup_schedules_list(
2895        &self,
2896        parent: &str,
2897    ) -> ProjectDatabaseBackupScheduleListCall<'a, C> {
2898        ProjectDatabaseBackupScheduleListCall {
2899            hub: self.hub,
2900            _parent: parent.to_string(),
2901            _delegate: Default::default(),
2902            _additional_params: Default::default(),
2903            _scopes: Default::default(),
2904        }
2905    }
2906
2907    /// Create a builder to help you perform the following task:
2908    ///
2909    /// Updates a backup schedule.
2910    ///
2911    /// # Arguments
2912    ///
2913    /// * `request` - No description provided.
2914    /// * `name` - Output only. The unique backup schedule identifier across all locations and databases for the given project. This will be auto-assigned. Format is `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
2915    pub fn databases_backup_schedules_patch(
2916        &self,
2917        request: GoogleFirestoreAdminV1BackupSchedule,
2918        name: &str,
2919    ) -> ProjectDatabaseBackupSchedulePatchCall<'a, C> {
2920        ProjectDatabaseBackupSchedulePatchCall {
2921            hub: self.hub,
2922            _request: request,
2923            _name: name.to_string(),
2924            _update_mask: Default::default(),
2925            _delegate: Default::default(),
2926            _additional_params: Default::default(),
2927            _scopes: Default::default(),
2928        }
2929    }
2930
2931    /// Create a builder to help you perform the following task:
2932    ///
2933    /// Gets the metadata and configuration for a Field.
2934    ///
2935    /// # Arguments
2936    ///
2937    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
2938    pub fn databases_collection_groups_fields_get(
2939        &self,
2940        name: &str,
2941    ) -> ProjectDatabaseCollectionGroupFieldGetCall<'a, C> {
2942        ProjectDatabaseCollectionGroupFieldGetCall {
2943            hub: self.hub,
2944            _name: name.to_string(),
2945            _delegate: Default::default(),
2946            _additional_params: Default::default(),
2947            _scopes: Default::default(),
2948        }
2949    }
2950
2951    /// Create a builder to help you perform the following task:
2952    ///
2953    /// Lists the field configuration and metadata for this database. Currently, FirestoreAdmin.ListFields only supports listing fields that have been explicitly overridden. To issue this query, call FirestoreAdmin.ListFields with the filter set to `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`.
2954    ///
2955    /// # Arguments
2956    ///
2957    /// * `parent` - Required. A parent name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
2958    pub fn databases_collection_groups_fields_list(
2959        &self,
2960        parent: &str,
2961    ) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C> {
2962        ProjectDatabaseCollectionGroupFieldListCall {
2963            hub: self.hub,
2964            _parent: parent.to_string(),
2965            _page_token: Default::default(),
2966            _page_size: Default::default(),
2967            _filter: Default::default(),
2968            _delegate: Default::default(),
2969            _additional_params: Default::default(),
2970            _scopes: Default::default(),
2971        }
2972    }
2973
2974    /// Create a builder to help you perform the following task:
2975    ///
2976    /// Updates a field configuration. Currently, field updates apply only to single field index configuration. However, calls to FirestoreAdmin.UpdateField should provide a field mask to avoid changing any configuration that the caller isn't aware of. The field mask should be specified as: `{ paths: "index_config" }`. This call returns a google.longrunning.Operation which may be used to track the status of the field update. The metadata for the operation will be the type FieldOperationMetadata. To configure the default field settings for the database, use the special `Field` with resource name: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
2977    ///
2978    /// # Arguments
2979    ///
2980    /// * `request` - No description provided.
2981    /// * `name` - Required. A field name of the form: `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` A field path can be a simple field name, e.g. `address` or a path to fields within `map_value` , e.g. `address.city`, or a special field path. The only valid special field is `*`, which represents any field. Field paths can be quoted using `` ` `` (backtick). The only character that must be escaped within a quoted field path is the backtick character itself, escaped using a backslash. Special characters in field paths that must be quoted include: `*`, `.`, `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters. Examples: `` `address.city` `` represents a field named `address.city`, not the map key `city` in the field `address`. `` `*` `` represents a field named `*`, not any field. A special `Field` contains the default indexing settings for all fields. This field's resource name is: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*` Indexes defined on this `Field` will be applied to all fields which do not have their own `Field` index configuration.
2982    pub fn databases_collection_groups_fields_patch(
2983        &self,
2984        request: GoogleFirestoreAdminV1Field,
2985        name: &str,
2986    ) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C> {
2987        ProjectDatabaseCollectionGroupFieldPatchCall {
2988            hub: self.hub,
2989            _request: request,
2990            _name: name.to_string(),
2991            _update_mask: Default::default(),
2992            _delegate: Default::default(),
2993            _additional_params: Default::default(),
2994            _scopes: Default::default(),
2995        }
2996    }
2997
2998    /// Create a builder to help you perform the following task:
2999    ///
3000    /// Creates a composite index. This returns a google.longrunning.Operation which may be used to track the status of the creation. The metadata for the operation will be the type IndexOperationMetadata.
3001    ///
3002    /// # Arguments
3003    ///
3004    /// * `request` - No description provided.
3005    /// * `parent` - Required. A parent name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
3006    pub fn databases_collection_groups_indexes_create(
3007        &self,
3008        request: GoogleFirestoreAdminV1Index,
3009        parent: &str,
3010    ) -> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C> {
3011        ProjectDatabaseCollectionGroupIndexCreateCall {
3012            hub: self.hub,
3013            _request: request,
3014            _parent: parent.to_string(),
3015            _delegate: Default::default(),
3016            _additional_params: Default::default(),
3017            _scopes: Default::default(),
3018        }
3019    }
3020
3021    /// Create a builder to help you perform the following task:
3022    ///
3023    /// Deletes a composite index.
3024    ///
3025    /// # Arguments
3026    ///
3027    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
3028    pub fn databases_collection_groups_indexes_delete(
3029        &self,
3030        name: &str,
3031    ) -> ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C> {
3032        ProjectDatabaseCollectionGroupIndexDeleteCall {
3033            hub: self.hub,
3034            _name: name.to_string(),
3035            _delegate: Default::default(),
3036            _additional_params: Default::default(),
3037            _scopes: Default::default(),
3038        }
3039    }
3040
3041    /// Create a builder to help you perform the following task:
3042    ///
3043    /// Gets a composite index.
3044    ///
3045    /// # Arguments
3046    ///
3047    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
3048    pub fn databases_collection_groups_indexes_get(
3049        &self,
3050        name: &str,
3051    ) -> ProjectDatabaseCollectionGroupIndexGetCall<'a, C> {
3052        ProjectDatabaseCollectionGroupIndexGetCall {
3053            hub: self.hub,
3054            _name: name.to_string(),
3055            _delegate: Default::default(),
3056            _additional_params: Default::default(),
3057            _scopes: Default::default(),
3058        }
3059    }
3060
3061    /// Create a builder to help you perform the following task:
3062    ///
3063    /// Lists composite indexes.
3064    ///
3065    /// # Arguments
3066    ///
3067    /// * `parent` - Required. A parent name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
3068    pub fn databases_collection_groups_indexes_list(
3069        &self,
3070        parent: &str,
3071    ) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C> {
3072        ProjectDatabaseCollectionGroupIndexListCall {
3073            hub: self.hub,
3074            _parent: parent.to_string(),
3075            _page_token: Default::default(),
3076            _page_size: Default::default(),
3077            _filter: Default::default(),
3078            _delegate: Default::default(),
3079            _additional_params: Default::default(),
3080            _scopes: Default::default(),
3081        }
3082    }
3083
3084    /// Create a builder to help you perform the following task:
3085    ///
3086    /// Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
3087    ///
3088    /// # Arguments
3089    ///
3090    /// * `request` - No description provided.
3091    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3092    pub fn databases_documents_batch_get(
3093        &self,
3094        request: BatchGetDocumentsRequest,
3095        database: &str,
3096    ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
3097        ProjectDatabaseDocumentBatchGetCall {
3098            hub: self.hub,
3099            _request: request,
3100            _database: database.to_string(),
3101            _delegate: Default::default(),
3102            _additional_params: Default::default(),
3103            _scopes: Default::default(),
3104        }
3105    }
3106
3107    /// Create a builder to help you perform the following task:
3108    ///
3109    /// Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write. If you require an atomically applied set of writes, use Commit instead.
3110    ///
3111    /// # Arguments
3112    ///
3113    /// * `request` - No description provided.
3114    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3115    pub fn databases_documents_batch_write(
3116        &self,
3117        request: BatchWriteRequest,
3118        database: &str,
3119    ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
3120        ProjectDatabaseDocumentBatchWriteCall {
3121            hub: self.hub,
3122            _request: request,
3123            _database: database.to_string(),
3124            _delegate: Default::default(),
3125            _additional_params: Default::default(),
3126            _scopes: Default::default(),
3127        }
3128    }
3129
3130    /// Create a builder to help you perform the following task:
3131    ///
3132    /// Starts a new transaction.
3133    ///
3134    /// # Arguments
3135    ///
3136    /// * `request` - No description provided.
3137    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3138    pub fn databases_documents_begin_transaction(
3139        &self,
3140        request: BeginTransactionRequest,
3141        database: &str,
3142    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3143        ProjectDatabaseDocumentBeginTransactionCall {
3144            hub: self.hub,
3145            _request: request,
3146            _database: database.to_string(),
3147            _delegate: Default::default(),
3148            _additional_params: Default::default(),
3149            _scopes: Default::default(),
3150        }
3151    }
3152
3153    /// Create a builder to help you perform the following task:
3154    ///
3155    /// Commits a transaction, while optionally updating documents.
3156    ///
3157    /// # Arguments
3158    ///
3159    /// * `request` - No description provided.
3160    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3161    pub fn databases_documents_commit(
3162        &self,
3163        request: CommitRequest,
3164        database: &str,
3165    ) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3166        ProjectDatabaseDocumentCommitCall {
3167            hub: self.hub,
3168            _request: request,
3169            _database: database.to_string(),
3170            _delegate: Default::default(),
3171            _additional_params: Default::default(),
3172            _scopes: Default::default(),
3173        }
3174    }
3175
3176    /// Create a builder to help you perform the following task:
3177    ///
3178    /// Creates a new document.
3179    ///
3180    /// # Arguments
3181    ///
3182    /// * `request` - No description provided.
3183    /// * `parent` - Required. The parent resource. For example: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
3184    /// * `collectionId` - Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
3185    pub fn databases_documents_create_document(
3186        &self,
3187        request: Document,
3188        parent: &str,
3189        collection_id: &str,
3190    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
3191        ProjectDatabaseDocumentCreateDocumentCall {
3192            hub: self.hub,
3193            _request: request,
3194            _parent: parent.to_string(),
3195            _collection_id: collection_id.to_string(),
3196            _mask_field_paths: Default::default(),
3197            _document_id: Default::default(),
3198            _delegate: Default::default(),
3199            _additional_params: Default::default(),
3200            _scopes: Default::default(),
3201        }
3202    }
3203
3204    /// Create a builder to help you perform the following task:
3205    ///
3206    /// Deletes a document.
3207    ///
3208    /// # Arguments
3209    ///
3210    /// * `name` - Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
3211    pub fn databases_documents_delete(
3212        &self,
3213        name: &str,
3214    ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
3215        ProjectDatabaseDocumentDeleteCall {
3216            hub: self.hub,
3217            _name: name.to_string(),
3218            _current_document_update_time: Default::default(),
3219            _current_document_exists: Default::default(),
3220            _delegate: Default::default(),
3221            _additional_params: Default::default(),
3222            _scopes: Default::default(),
3223        }
3224    }
3225
3226    /// Create a builder to help you perform the following task:
3227    ///
3228    /// Executes a pipeline query.
3229    ///
3230    /// # Arguments
3231    ///
3232    /// * `request` - No description provided.
3233    /// * `database` - Required. Database identifier, in the form `projects/{project}/databases/{database}`.
3234    pub fn databases_documents_execute_pipeline(
3235        &self,
3236        request: ExecutePipelineRequest,
3237        database: &str,
3238    ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
3239        ProjectDatabaseDocumentExecutePipelineCall {
3240            hub: self.hub,
3241            _request: request,
3242            _database: database.to_string(),
3243            _delegate: Default::default(),
3244            _additional_params: Default::default(),
3245            _scopes: Default::default(),
3246        }
3247    }
3248
3249    /// Create a builder to help you perform the following task:
3250    ///
3251    /// Gets a single document.
3252    ///
3253    /// # Arguments
3254    ///
3255    /// * `name` - Required. The resource name of the Document to get. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
3256    pub fn databases_documents_get(&self, name: &str) -> ProjectDatabaseDocumentGetCall<'a, C> {
3257        ProjectDatabaseDocumentGetCall {
3258            hub: self.hub,
3259            _name: name.to_string(),
3260            _transaction: Default::default(),
3261            _read_time: Default::default(),
3262            _mask_field_paths: Default::default(),
3263            _delegate: Default::default(),
3264            _additional_params: Default::default(),
3265            _scopes: Default::default(),
3266        }
3267    }
3268
3269    /// Create a builder to help you perform the following task:
3270    ///
3271    /// Lists documents.
3272    ///
3273    /// # Arguments
3274    ///
3275    /// * `parent` - Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
3276    /// * `collectionId` - Optional. The collection ID, relative to `parent`, to list. For example: `chatrooms` or `messages`. This is optional, and when not provided, Firestore will list documents from all collections under the provided `parent`.
3277    pub fn databases_documents_list(
3278        &self,
3279        parent: &str,
3280        collection_id: &str,
3281    ) -> ProjectDatabaseDocumentListCall<'a, C> {
3282        ProjectDatabaseDocumentListCall {
3283            hub: self.hub,
3284            _parent: parent.to_string(),
3285            _collection_id: collection_id.to_string(),
3286            _transaction: Default::default(),
3287            _show_missing: Default::default(),
3288            _read_time: Default::default(),
3289            _page_token: Default::default(),
3290            _page_size: Default::default(),
3291            _order_by: Default::default(),
3292            _mask_field_paths: Default::default(),
3293            _delegate: Default::default(),
3294            _additional_params: Default::default(),
3295            _scopes: Default::default(),
3296        }
3297    }
3298
3299    /// Create a builder to help you perform the following task:
3300    ///
3301    /// Lists all the collection IDs underneath a document.
3302    ///
3303    /// # Arguments
3304    ///
3305    /// * `request` - No description provided.
3306    /// * `parent` - Required. The parent document. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
3307    pub fn databases_documents_list_collection_ids(
3308        &self,
3309        request: ListCollectionIdsRequest,
3310        parent: &str,
3311    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
3312        ProjectDatabaseDocumentListCollectionIdCall {
3313            hub: self.hub,
3314            _request: request,
3315            _parent: parent.to_string(),
3316            _delegate: Default::default(),
3317            _additional_params: Default::default(),
3318            _scopes: Default::default(),
3319        }
3320    }
3321
3322    /// Create a builder to help you perform the following task:
3323    ///
3324    /// Lists documents.
3325    ///
3326    /// # Arguments
3327    ///
3328    /// * `parent` - Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
3329    /// * `collectionId` - Optional. The collection ID, relative to `parent`, to list. For example: `chatrooms` or `messages`. This is optional, and when not provided, Firestore will list documents from all collections under the provided `parent`.
3330    pub fn databases_documents_list_documents(
3331        &self,
3332        parent: &str,
3333        collection_id: &str,
3334    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
3335        ProjectDatabaseDocumentListDocumentCall {
3336            hub: self.hub,
3337            _parent: parent.to_string(),
3338            _collection_id: collection_id.to_string(),
3339            _transaction: Default::default(),
3340            _show_missing: Default::default(),
3341            _read_time: Default::default(),
3342            _page_token: Default::default(),
3343            _page_size: Default::default(),
3344            _order_by: Default::default(),
3345            _mask_field_paths: Default::default(),
3346            _delegate: Default::default(),
3347            _additional_params: Default::default(),
3348            _scopes: Default::default(),
3349        }
3350    }
3351
3352    /// Create a builder to help you perform the following task:
3353    ///
3354    /// Listens to changes. This method is only available via gRPC or WebChannel (not REST).
3355    ///
3356    /// # Arguments
3357    ///
3358    /// * `request` - No description provided.
3359    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3360    pub fn databases_documents_listen(
3361        &self,
3362        request: ListenRequest,
3363        database: &str,
3364    ) -> ProjectDatabaseDocumentListenCall<'a, C> {
3365        ProjectDatabaseDocumentListenCall {
3366            hub: self.hub,
3367            _request: request,
3368            _database: database.to_string(),
3369            _delegate: Default::default(),
3370            _additional_params: Default::default(),
3371            _scopes: Default::default(),
3372        }
3373    }
3374
3375    /// Create a builder to help you perform the following task:
3376    ///
3377    /// Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.
3378    ///
3379    /// # Arguments
3380    ///
3381    /// * `request` - No description provided.
3382    /// * `parent` - Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents`. Document resource names are not supported; only database resource names can be specified.
3383    pub fn databases_documents_partition_query(
3384        &self,
3385        request: PartitionQueryRequest,
3386        parent: &str,
3387    ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
3388        ProjectDatabaseDocumentPartitionQueryCall {
3389            hub: self.hub,
3390            _request: request,
3391            _parent: parent.to_string(),
3392            _delegate: Default::default(),
3393            _additional_params: Default::default(),
3394            _scopes: Default::default(),
3395        }
3396    }
3397
3398    /// Create a builder to help you perform the following task:
3399    ///
3400    /// Updates or inserts a document.
3401    ///
3402    /// # Arguments
3403    ///
3404    /// * `request` - No description provided.
3405    /// * `name` - The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
3406    pub fn databases_documents_patch(
3407        &self,
3408        request: Document,
3409        name: &str,
3410    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
3411        ProjectDatabaseDocumentPatchCall {
3412            hub: self.hub,
3413            _request: request,
3414            _name: name.to_string(),
3415            _update_mask_field_paths: Default::default(),
3416            _mask_field_paths: Default::default(),
3417            _current_document_update_time: Default::default(),
3418            _current_document_exists: Default::default(),
3419            _delegate: Default::default(),
3420            _additional_params: Default::default(),
3421            _scopes: Default::default(),
3422        }
3423    }
3424
3425    /// Create a builder to help you perform the following task:
3426    ///
3427    /// Rolls back a transaction.
3428    ///
3429    /// # Arguments
3430    ///
3431    /// * `request` - No description provided.
3432    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3433    pub fn databases_documents_rollback(
3434        &self,
3435        request: RollbackRequest,
3436        database: &str,
3437    ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
3438        ProjectDatabaseDocumentRollbackCall {
3439            hub: self.hub,
3440            _request: request,
3441            _database: database.to_string(),
3442            _delegate: Default::default(),
3443            _additional_params: Default::default(),
3444            _scopes: Default::default(),
3445        }
3446    }
3447
3448    /// Create a builder to help you perform the following task:
3449    ///
3450    /// Runs an aggregation query. Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of AggregationResult server-side. High-Level Example: ``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); ```
3451    ///
3452    /// # Arguments
3453    ///
3454    /// * `request` - No description provided.
3455    /// * `parent` - Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
3456    pub fn databases_documents_run_aggregation_query(
3457        &self,
3458        request: RunAggregationQueryRequest,
3459        parent: &str,
3460    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
3461        ProjectDatabaseDocumentRunAggregationQueryCall {
3462            hub: self.hub,
3463            _request: request,
3464            _parent: parent.to_string(),
3465            _delegate: Default::default(),
3466            _additional_params: Default::default(),
3467            _scopes: Default::default(),
3468        }
3469    }
3470
3471    /// Create a builder to help you perform the following task:
3472    ///
3473    /// Runs a query.
3474    ///
3475    /// # Arguments
3476    ///
3477    /// * `request` - No description provided.
3478    /// * `parent` - Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
3479    pub fn databases_documents_run_query(
3480        &self,
3481        request: RunQueryRequest,
3482        parent: &str,
3483    ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
3484        ProjectDatabaseDocumentRunQueryCall {
3485            hub: self.hub,
3486            _request: request,
3487            _parent: parent.to_string(),
3488            _delegate: Default::default(),
3489            _additional_params: Default::default(),
3490            _scopes: Default::default(),
3491        }
3492    }
3493
3494    /// Create a builder to help you perform the following task:
3495    ///
3496    /// Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).
3497    ///
3498    /// # Arguments
3499    ///
3500    /// * `request` - No description provided.
3501    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. This is only required in the first message.
3502    pub fn databases_documents_write(
3503        &self,
3504        request: WriteRequest,
3505        database: &str,
3506    ) -> ProjectDatabaseDocumentWriteCall<'a, C> {
3507        ProjectDatabaseDocumentWriteCall {
3508            hub: self.hub,
3509            _request: request,
3510            _database: database.to_string(),
3511            _delegate: Default::default(),
3512            _additional_params: Default::default(),
3513            _scopes: Default::default(),
3514        }
3515    }
3516
3517    /// Create a builder to help you perform the following task:
3518    ///
3519    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
3520    ///
3521    /// # Arguments
3522    ///
3523    /// * `request` - No description provided.
3524    /// * `name` - The name of the operation resource to be cancelled.
3525    pub fn databases_operations_cancel(
3526        &self,
3527        request: GoogleLongrunningCancelOperationRequest,
3528        name: &str,
3529    ) -> ProjectDatabaseOperationCancelCall<'a, C> {
3530        ProjectDatabaseOperationCancelCall {
3531            hub: self.hub,
3532            _request: request,
3533            _name: name.to_string(),
3534            _delegate: Default::default(),
3535            _additional_params: Default::default(),
3536            _scopes: Default::default(),
3537        }
3538    }
3539
3540    /// Create a builder to help you perform the following task:
3541    ///
3542    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
3543    ///
3544    /// # Arguments
3545    ///
3546    /// * `name` - The name of the operation resource to be deleted.
3547    pub fn databases_operations_delete(
3548        &self,
3549        name: &str,
3550    ) -> ProjectDatabaseOperationDeleteCall<'a, C> {
3551        ProjectDatabaseOperationDeleteCall {
3552            hub: self.hub,
3553            _name: name.to_string(),
3554            _delegate: Default::default(),
3555            _additional_params: Default::default(),
3556            _scopes: Default::default(),
3557        }
3558    }
3559
3560    /// Create a builder to help you perform the following task:
3561    ///
3562    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3563    ///
3564    /// # Arguments
3565    ///
3566    /// * `name` - The name of the operation resource.
3567    pub fn databases_operations_get(&self, name: &str) -> ProjectDatabaseOperationGetCall<'a, C> {
3568        ProjectDatabaseOperationGetCall {
3569            hub: self.hub,
3570            _name: name.to_string(),
3571            _delegate: Default::default(),
3572            _additional_params: Default::default(),
3573            _scopes: Default::default(),
3574        }
3575    }
3576
3577    /// Create a builder to help you perform the following task:
3578    ///
3579    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3580    ///
3581    /// # Arguments
3582    ///
3583    /// * `name` - The name of the operation's parent resource.
3584    pub fn databases_operations_list(&self, name: &str) -> ProjectDatabaseOperationListCall<'a, C> {
3585        ProjectDatabaseOperationListCall {
3586            hub: self.hub,
3587            _name: name.to_string(),
3588            _return_partial_success: Default::default(),
3589            _page_token: Default::default(),
3590            _page_size: Default::default(),
3591            _filter: Default::default(),
3592            _delegate: Default::default(),
3593            _additional_params: Default::default(),
3594            _scopes: Default::default(),
3595        }
3596    }
3597
3598    /// Create a builder to help you perform the following task:
3599    ///
3600    /// Create a user creds.
3601    ///
3602    /// # Arguments
3603    ///
3604    /// * `request` - No description provided.
3605    /// * `parent` - Required. A parent name of the form `projects/{project_id}/databases/{database_id}`
3606    pub fn databases_user_creds_create(
3607        &self,
3608        request: GoogleFirestoreAdminV1UserCreds,
3609        parent: &str,
3610    ) -> ProjectDatabaseUserCredCreateCall<'a, C> {
3611        ProjectDatabaseUserCredCreateCall {
3612            hub: self.hub,
3613            _request: request,
3614            _parent: parent.to_string(),
3615            _user_creds_id: Default::default(),
3616            _delegate: Default::default(),
3617            _additional_params: Default::default(),
3618            _scopes: Default::default(),
3619        }
3620    }
3621
3622    /// Create a builder to help you perform the following task:
3623    ///
3624    /// Deletes a user creds.
3625    ///
3626    /// # Arguments
3627    ///
3628    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
3629    pub fn databases_user_creds_delete(
3630        &self,
3631        name: &str,
3632    ) -> ProjectDatabaseUserCredDeleteCall<'a, C> {
3633        ProjectDatabaseUserCredDeleteCall {
3634            hub: self.hub,
3635            _name: name.to_string(),
3636            _delegate: Default::default(),
3637            _additional_params: Default::default(),
3638            _scopes: Default::default(),
3639        }
3640    }
3641
3642    /// Create a builder to help you perform the following task:
3643    ///
3644    /// Disables a user creds. No-op if the user creds are already disabled.
3645    ///
3646    /// # Arguments
3647    ///
3648    /// * `request` - No description provided.
3649    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
3650    pub fn databases_user_creds_disable(
3651        &self,
3652        request: GoogleFirestoreAdminV1DisableUserCredsRequest,
3653        name: &str,
3654    ) -> ProjectDatabaseUserCredDisableCall<'a, C> {
3655        ProjectDatabaseUserCredDisableCall {
3656            hub: self.hub,
3657            _request: request,
3658            _name: name.to_string(),
3659            _delegate: Default::default(),
3660            _additional_params: Default::default(),
3661            _scopes: Default::default(),
3662        }
3663    }
3664
3665    /// Create a builder to help you perform the following task:
3666    ///
3667    /// Enables a user creds. No-op if the user creds are already enabled.
3668    ///
3669    /// # Arguments
3670    ///
3671    /// * `request` - No description provided.
3672    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
3673    pub fn databases_user_creds_enable(
3674        &self,
3675        request: GoogleFirestoreAdminV1EnableUserCredsRequest,
3676        name: &str,
3677    ) -> ProjectDatabaseUserCredEnableCall<'a, C> {
3678        ProjectDatabaseUserCredEnableCall {
3679            hub: self.hub,
3680            _request: request,
3681            _name: name.to_string(),
3682            _delegate: Default::default(),
3683            _additional_params: Default::default(),
3684            _scopes: Default::default(),
3685        }
3686    }
3687
3688    /// Create a builder to help you perform the following task:
3689    ///
3690    /// Gets a user creds resource. Note that the returned resource does not contain the secret value itself.
3691    ///
3692    /// # Arguments
3693    ///
3694    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
3695    pub fn databases_user_creds_get(&self, name: &str) -> ProjectDatabaseUserCredGetCall<'a, C> {
3696        ProjectDatabaseUserCredGetCall {
3697            hub: self.hub,
3698            _name: name.to_string(),
3699            _delegate: Default::default(),
3700            _additional_params: Default::default(),
3701            _scopes: Default::default(),
3702        }
3703    }
3704
3705    /// Create a builder to help you perform the following task:
3706    ///
3707    /// List all user creds in the database. Note that the returned resource does not contain the secret value itself.
3708    ///
3709    /// # Arguments
3710    ///
3711    /// * `parent` - Required. A parent database name of the form `projects/{project_id}/databases/{database_id}`
3712    pub fn databases_user_creds_list(
3713        &self,
3714        parent: &str,
3715    ) -> ProjectDatabaseUserCredListCall<'a, C> {
3716        ProjectDatabaseUserCredListCall {
3717            hub: self.hub,
3718            _parent: parent.to_string(),
3719            _delegate: Default::default(),
3720            _additional_params: Default::default(),
3721            _scopes: Default::default(),
3722        }
3723    }
3724
3725    /// Create a builder to help you perform the following task:
3726    ///
3727    /// Resets the password of a user creds.
3728    ///
3729    /// # Arguments
3730    ///
3731    /// * `request` - No description provided.
3732    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
3733    pub fn databases_user_creds_reset_password(
3734        &self,
3735        request: GoogleFirestoreAdminV1ResetUserPasswordRequest,
3736        name: &str,
3737    ) -> ProjectDatabaseUserCredResetPasswordCall<'a, C> {
3738        ProjectDatabaseUserCredResetPasswordCall {
3739            hub: self.hub,
3740            _request: request,
3741            _name: name.to_string(),
3742            _delegate: Default::default(),
3743            _additional_params: Default::default(),
3744            _scopes: Default::default(),
3745        }
3746    }
3747
3748    /// Create a builder to help you perform the following task:
3749    ///
3750    /// Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated after the underlying system starts to process the request will not be deleted. The bulk delete occurs in the background and its progress can be monitored and managed via the Operation resource that is created. For more details on bulk delete behavior, refer to: https://cloud.google.com/firestore/docs/manage-data/bulk-delete
3751    ///
3752    /// # Arguments
3753    ///
3754    /// * `request` - No description provided.
3755    /// * `name` - Required. Database to operate. Should be of the form: `projects/{project_id}/databases/{database_id}`.
3756    pub fn databases_bulk_delete_documents(
3757        &self,
3758        request: GoogleFirestoreAdminV1BulkDeleteDocumentsRequest,
3759        name: &str,
3760    ) -> ProjectDatabaseBulkDeleteDocumentCall<'a, C> {
3761        ProjectDatabaseBulkDeleteDocumentCall {
3762            hub: self.hub,
3763            _request: request,
3764            _name: name.to_string(),
3765            _delegate: Default::default(),
3766            _additional_params: Default::default(),
3767            _scopes: Default::default(),
3768        }
3769    }
3770
3771    /// Create a builder to help you perform the following task:
3772    ///
3773    /// Creates a new database by cloning an existing one. The new database must be in the same cloud region or multi-region location as the existing database. This behaves similar to FirestoreAdmin.CreateDatabase except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing database. The long-running operation can be used to track the progress of the clone, with the Operation's metadata field type being the CloneDatabaseMetadata. The response type is the Database if the clone was successful. The new database is not readable or writeable until the LRO has completed.
3774    ///
3775    /// # Arguments
3776    ///
3777    /// * `request` - No description provided.
3778    /// * `parent` - Required. The project to clone the database in. Format is `projects/{project_id}`.
3779    pub fn databases_clone(
3780        &self,
3781        request: GoogleFirestoreAdminV1CloneDatabaseRequest,
3782        parent: &str,
3783    ) -> ProjectDatabaseCloneCall<'a, C> {
3784        ProjectDatabaseCloneCall {
3785            hub: self.hub,
3786            _request: request,
3787            _parent: parent.to_string(),
3788            _delegate: Default::default(),
3789            _additional_params: Default::default(),
3790            _scopes: Default::default(),
3791        }
3792    }
3793
3794    /// Create a builder to help you perform the following task:
3795    ///
3796    /// Create a database.
3797    ///
3798    /// # Arguments
3799    ///
3800    /// * `request` - No description provided.
3801    /// * `parent` - Required. A parent name of the form `projects/{project_id}`
3802    pub fn databases_create(
3803        &self,
3804        request: GoogleFirestoreAdminV1Database,
3805        parent: &str,
3806    ) -> ProjectDatabaseCreateCall<'a, C> {
3807        ProjectDatabaseCreateCall {
3808            hub: self.hub,
3809            _request: request,
3810            _parent: parent.to_string(),
3811            _database_id: Default::default(),
3812            _delegate: Default::default(),
3813            _additional_params: Default::default(),
3814            _scopes: Default::default(),
3815        }
3816    }
3817
3818    /// Create a builder to help you perform the following task:
3819    ///
3820    /// Deletes a database.
3821    ///
3822    /// # Arguments
3823    ///
3824    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}`
3825    pub fn databases_delete(&self, name: &str) -> ProjectDatabaseDeleteCall<'a, C> {
3826        ProjectDatabaseDeleteCall {
3827            hub: self.hub,
3828            _name: name.to_string(),
3829            _etag: Default::default(),
3830            _delegate: Default::default(),
3831            _additional_params: Default::default(),
3832            _scopes: Default::default(),
3833        }
3834    }
3835
3836    /// Create a builder to help you perform the following task:
3837    ///
3838    /// Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage. For more details on export behavior and output format, refer to: https://cloud.google.com/firestore/docs/manage-data/export-import
3839    ///
3840    /// # Arguments
3841    ///
3842    /// * `request` - No description provided.
3843    /// * `name` - Required. Database to export. Should be of the form: `projects/{project_id}/databases/{database_id}`.
3844    pub fn databases_export_documents(
3845        &self,
3846        request: GoogleFirestoreAdminV1ExportDocumentsRequest,
3847        name: &str,
3848    ) -> ProjectDatabaseExportDocumentCall<'a, C> {
3849        ProjectDatabaseExportDocumentCall {
3850            hub: self.hub,
3851            _request: request,
3852            _name: name.to_string(),
3853            _delegate: Default::default(),
3854            _additional_params: Default::default(),
3855            _scopes: Default::default(),
3856        }
3857    }
3858
3859    /// Create a builder to help you perform the following task:
3860    ///
3861    /// Gets information about a database.
3862    ///
3863    /// # Arguments
3864    ///
3865    /// * `name` - Required. A name of the form `projects/{project_id}/databases/{database_id}`
3866    pub fn databases_get(&self, name: &str) -> ProjectDatabaseGetCall<'a, C> {
3867        ProjectDatabaseGetCall {
3868            hub: self.hub,
3869            _name: name.to_string(),
3870            _delegate: Default::default(),
3871            _additional_params: Default::default(),
3872            _scopes: Default::default(),
3873        }
3874    }
3875
3876    /// Create a builder to help you perform the following task:
3877    ///
3878    /// Imports documents into Google Cloud Firestore. Existing documents with the same name are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Firestore.
3879    ///
3880    /// # Arguments
3881    ///
3882    /// * `request` - No description provided.
3883    /// * `name` - Required. Database to import into. Should be of the form: `projects/{project_id}/databases/{database_id}`.
3884    pub fn databases_import_documents(
3885        &self,
3886        request: GoogleFirestoreAdminV1ImportDocumentsRequest,
3887        name: &str,
3888    ) -> ProjectDatabaseImportDocumentCall<'a, C> {
3889        ProjectDatabaseImportDocumentCall {
3890            hub: self.hub,
3891            _request: request,
3892            _name: name.to_string(),
3893            _delegate: Default::default(),
3894            _additional_params: Default::default(),
3895            _scopes: Default::default(),
3896        }
3897    }
3898
3899    /// Create a builder to help you perform the following task:
3900    ///
3901    /// List all the databases in the project.
3902    ///
3903    /// # Arguments
3904    ///
3905    /// * `parent` - Required. A parent name of the form `projects/{project_id}`
3906    pub fn databases_list(&self, parent: &str) -> ProjectDatabaseListCall<'a, C> {
3907        ProjectDatabaseListCall {
3908            hub: self.hub,
3909            _parent: parent.to_string(),
3910            _show_deleted: Default::default(),
3911            _delegate: Default::default(),
3912            _additional_params: Default::default(),
3913            _scopes: Default::default(),
3914        }
3915    }
3916
3917    /// Create a builder to help you perform the following task:
3918    ///
3919    /// Updates a database.
3920    ///
3921    /// # Arguments
3922    ///
3923    /// * `request` - No description provided.
3924    /// * `name` - The resource name of the Database. Format: `projects/{project}/databases/{database}`
3925    pub fn databases_patch(
3926        &self,
3927        request: GoogleFirestoreAdminV1Database,
3928        name: &str,
3929    ) -> ProjectDatabasePatchCall<'a, C> {
3930        ProjectDatabasePatchCall {
3931            hub: self.hub,
3932            _request: request,
3933            _name: name.to_string(),
3934            _update_mask: Default::default(),
3935            _delegate: Default::default(),
3936            _additional_params: Default::default(),
3937            _scopes: Default::default(),
3938        }
3939    }
3940
3941    /// Create a builder to help you perform the following task:
3942    ///
3943    /// Creates a new database by restoring from an existing backup. The new database must be in the same cloud region or multi-region location as the existing backup. This behaves similar to FirestoreAdmin.CreateDatabase except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing backup. The long-running operation can be used to track the progress of the restore, with the Operation's metadata field type being the RestoreDatabaseMetadata. The response type is the Database if the restore was successful. The new database is not readable or writeable until the LRO has completed.
3944    ///
3945    /// # Arguments
3946    ///
3947    /// * `request` - No description provided.
3948    /// * `parent` - Required. The project to restore the database in. Format is `projects/{project_id}`.
3949    pub fn databases_restore(
3950        &self,
3951        request: GoogleFirestoreAdminV1RestoreDatabaseRequest,
3952        parent: &str,
3953    ) -> ProjectDatabaseRestoreCall<'a, C> {
3954        ProjectDatabaseRestoreCall {
3955            hub: self.hub,
3956            _request: request,
3957            _parent: parent.to_string(),
3958            _delegate: Default::default(),
3959            _additional_params: Default::default(),
3960            _scopes: Default::default(),
3961        }
3962    }
3963
3964    /// Create a builder to help you perform the following task:
3965    ///
3966    /// Deletes a backup.
3967    ///
3968    /// # Arguments
3969    ///
3970    /// * `name` - Required. Name of the backup to delete. format is `projects/{project}/locations/{location}/backups/{backup}`.
3971    pub fn locations_backups_delete(&self, name: &str) -> ProjectLocationBackupDeleteCall<'a, C> {
3972        ProjectLocationBackupDeleteCall {
3973            hub: self.hub,
3974            _name: name.to_string(),
3975            _delegate: Default::default(),
3976            _additional_params: Default::default(),
3977            _scopes: Default::default(),
3978        }
3979    }
3980
3981    /// Create a builder to help you perform the following task:
3982    ///
3983    /// Gets information about a backup.
3984    ///
3985    /// # Arguments
3986    ///
3987    /// * `name` - Required. Name of the backup to fetch. Format is `projects/{project}/locations/{location}/backups/{backup}`.
3988    pub fn locations_backups_get(&self, name: &str) -> ProjectLocationBackupGetCall<'a, C> {
3989        ProjectLocationBackupGetCall {
3990            hub: self.hub,
3991            _name: name.to_string(),
3992            _delegate: Default::default(),
3993            _additional_params: Default::default(),
3994            _scopes: Default::default(),
3995        }
3996    }
3997
3998    /// Create a builder to help you perform the following task:
3999    ///
4000    /// Lists all the backups.
4001    ///
4002    /// # Arguments
4003    ///
4004    /// * `parent` - Required. The location to list backups from. Format is `projects/{project}/locations/{location}`. Use `{location} = '-'` to list backups from all locations for the given project. This allows listing backups from a single location or from all locations.
4005    pub fn locations_backups_list(&self, parent: &str) -> ProjectLocationBackupListCall<'a, C> {
4006        ProjectLocationBackupListCall {
4007            hub: self.hub,
4008            _parent: parent.to_string(),
4009            _filter: Default::default(),
4010            _delegate: Default::default(),
4011            _additional_params: Default::default(),
4012            _scopes: Default::default(),
4013        }
4014    }
4015
4016    /// Create a builder to help you perform the following task:
4017    ///
4018    /// Gets information about a location.
4019    ///
4020    /// # Arguments
4021    ///
4022    /// * `name` - Resource name for the location.
4023    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
4024        ProjectLocationGetCall {
4025            hub: self.hub,
4026            _name: name.to_string(),
4027            _delegate: Default::default(),
4028            _additional_params: Default::default(),
4029            _scopes: Default::default(),
4030        }
4031    }
4032
4033    /// Create a builder to help you perform the following task:
4034    ///
4035    /// Lists information about the supported locations for this service.
4036    ///
4037    /// # Arguments
4038    ///
4039    /// * `name` - The resource that owns the locations collection, if applicable.
4040    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
4041        ProjectLocationListCall {
4042            hub: self.hub,
4043            _name: name.to_string(),
4044            _page_token: Default::default(),
4045            _page_size: Default::default(),
4046            _filter: Default::default(),
4047            _extra_location_types: Default::default(),
4048            _delegate: Default::default(),
4049            _additional_params: Default::default(),
4050            _scopes: Default::default(),
4051        }
4052    }
4053}
4054
4055// ###################
4056// CallBuilders   ###
4057// #################
4058
4059/// Creates a backup schedule on a database. At most two backup schedules can be configured on a database, one daily backup schedule and one weekly backup schedule.
4060///
4061/// A builder for the *databases.backupSchedules.create* method supported by a *project* resource.
4062/// It is not used directly, but through a [`ProjectMethods`] instance.
4063///
4064/// # Example
4065///
4066/// Instantiate a resource method builder
4067///
4068/// ```test_harness,no_run
4069/// # extern crate hyper;
4070/// # extern crate hyper_rustls;
4071/// # extern crate google_firestore1 as firestore1;
4072/// use firestore1::api::GoogleFirestoreAdminV1BackupSchedule;
4073/// # async fn dox() {
4074/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4075///
4076/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4077/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4078/// #     .with_native_roots()
4079/// #     .unwrap()
4080/// #     .https_only()
4081/// #     .enable_http2()
4082/// #     .build();
4083///
4084/// # let executor = hyper_util::rt::TokioExecutor::new();
4085/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4086/// #     secret,
4087/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4088/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4089/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4090/// #     ),
4091/// # ).build().await.unwrap();
4092///
4093/// # let client = hyper_util::client::legacy::Client::builder(
4094/// #     hyper_util::rt::TokioExecutor::new()
4095/// # )
4096/// # .build(
4097/// #     hyper_rustls::HttpsConnectorBuilder::new()
4098/// #         .with_native_roots()
4099/// #         .unwrap()
4100/// #         .https_or_http()
4101/// #         .enable_http2()
4102/// #         .build()
4103/// # );
4104/// # let mut hub = Firestore::new(client, auth);
4105/// // As the method needs a request, you would usually fill it with the desired information
4106/// // into the respective structure. Some of the parts shown here might not be applicable !
4107/// // Values shown here are possibly random and not representative !
4108/// let mut req = GoogleFirestoreAdminV1BackupSchedule::default();
4109///
4110/// // You can configure optional parameters by calling the respective setters at will, and
4111/// // execute the final call using `doit()`.
4112/// // Values shown here are possibly random and not representative !
4113/// let result = hub.projects().databases_backup_schedules_create(req, "parent")
4114///              .doit().await;
4115/// # }
4116/// ```
4117pub struct ProjectDatabaseBackupScheduleCreateCall<'a, C>
4118where
4119    C: 'a,
4120{
4121    hub: &'a Firestore<C>,
4122    _request: GoogleFirestoreAdminV1BackupSchedule,
4123    _parent: String,
4124    _delegate: Option<&'a mut dyn common::Delegate>,
4125    _additional_params: HashMap<String, String>,
4126    _scopes: BTreeSet<String>,
4127}
4128
4129impl<'a, C> common::CallBuilder for ProjectDatabaseBackupScheduleCreateCall<'a, C> {}
4130
4131impl<'a, C> ProjectDatabaseBackupScheduleCreateCall<'a, C>
4132where
4133    C: common::Connector,
4134{
4135    /// Perform the operation you have build so far.
4136    pub async fn doit(
4137        mut self,
4138    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1BackupSchedule)> {
4139        use std::borrow::Cow;
4140        use std::io::{Read, Seek};
4141
4142        use common::{url::Params, ToParts};
4143        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4144
4145        let mut dd = common::DefaultDelegate;
4146        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4147        dlg.begin(common::MethodInfo {
4148            id: "firestore.projects.databases.backupSchedules.create",
4149            http_method: hyper::Method::POST,
4150        });
4151
4152        for &field in ["alt", "parent"].iter() {
4153            if self._additional_params.contains_key(field) {
4154                dlg.finished(false);
4155                return Err(common::Error::FieldClash(field));
4156            }
4157        }
4158
4159        let mut params = Params::with_capacity(4 + self._additional_params.len());
4160        params.push("parent", self._parent);
4161
4162        params.extend(self._additional_params.iter());
4163
4164        params.push("alt", "json");
4165        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backupSchedules";
4166        if self._scopes.is_empty() {
4167            self._scopes
4168                .insert(Scope::CloudPlatform.as_ref().to_string());
4169        }
4170
4171        #[allow(clippy::single_element_loop)]
4172        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4173            url = params.uri_replacement(url, param_name, find_this, true);
4174        }
4175        {
4176            let to_remove = ["parent"];
4177            params.remove_params(&to_remove);
4178        }
4179
4180        let url = params.parse_with_url(&url);
4181
4182        let mut json_mime_type = mime::APPLICATION_JSON;
4183        let mut request_value_reader = {
4184            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4185            common::remove_json_null_values(&mut value);
4186            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4187            serde_json::to_writer(&mut dst, &value).unwrap();
4188            dst
4189        };
4190        let request_size = request_value_reader
4191            .seek(std::io::SeekFrom::End(0))
4192            .unwrap();
4193        request_value_reader
4194            .seek(std::io::SeekFrom::Start(0))
4195            .unwrap();
4196
4197        loop {
4198            let token = match self
4199                .hub
4200                .auth
4201                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4202                .await
4203            {
4204                Ok(token) => token,
4205                Err(e) => match dlg.token(e) {
4206                    Ok(token) => token,
4207                    Err(e) => {
4208                        dlg.finished(false);
4209                        return Err(common::Error::MissingToken(e));
4210                    }
4211                },
4212            };
4213            request_value_reader
4214                .seek(std::io::SeekFrom::Start(0))
4215                .unwrap();
4216            let mut req_result = {
4217                let client = &self.hub.client;
4218                dlg.pre_request();
4219                let mut req_builder = hyper::Request::builder()
4220                    .method(hyper::Method::POST)
4221                    .uri(url.as_str())
4222                    .header(USER_AGENT, self.hub._user_agent.clone());
4223
4224                if let Some(token) = token.as_ref() {
4225                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4226                }
4227
4228                let request = req_builder
4229                    .header(CONTENT_TYPE, json_mime_type.to_string())
4230                    .header(CONTENT_LENGTH, request_size as u64)
4231                    .body(common::to_body(
4232                        request_value_reader.get_ref().clone().into(),
4233                    ));
4234
4235                client.request(request.unwrap()).await
4236            };
4237
4238            match req_result {
4239                Err(err) => {
4240                    if let common::Retry::After(d) = dlg.http_error(&err) {
4241                        sleep(d).await;
4242                        continue;
4243                    }
4244                    dlg.finished(false);
4245                    return Err(common::Error::HttpError(err));
4246                }
4247                Ok(res) => {
4248                    let (mut parts, body) = res.into_parts();
4249                    let mut body = common::Body::new(body);
4250                    if !parts.status.is_success() {
4251                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4252                        let error = serde_json::from_str(&common::to_string(&bytes));
4253                        let response = common::to_response(parts, bytes.into());
4254
4255                        if let common::Retry::After(d) =
4256                            dlg.http_failure(&response, error.as_ref().ok())
4257                        {
4258                            sleep(d).await;
4259                            continue;
4260                        }
4261
4262                        dlg.finished(false);
4263
4264                        return Err(match error {
4265                            Ok(value) => common::Error::BadRequest(value),
4266                            _ => common::Error::Failure(response),
4267                        });
4268                    }
4269                    let response = {
4270                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4271                        let encoded = common::to_string(&bytes);
4272                        match serde_json::from_str(&encoded) {
4273                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4274                            Err(error) => {
4275                                dlg.response_json_decode_error(&encoded, &error);
4276                                return Err(common::Error::JsonDecodeError(
4277                                    encoded.to_string(),
4278                                    error,
4279                                ));
4280                            }
4281                        }
4282                    };
4283
4284                    dlg.finished(true);
4285                    return Ok(response);
4286                }
4287            }
4288        }
4289    }
4290
4291    ///
4292    /// Sets the *request* property to the given value.
4293    ///
4294    /// Even though the property as already been set when instantiating this call,
4295    /// we provide this method for API completeness.
4296    pub fn request(
4297        mut self,
4298        new_value: GoogleFirestoreAdminV1BackupSchedule,
4299    ) -> ProjectDatabaseBackupScheduleCreateCall<'a, C> {
4300        self._request = new_value;
4301        self
4302    }
4303    /// Required. The parent database. Format `projects/{project}/databases/{database}`
4304    ///
4305    /// Sets the *parent* path property to the given value.
4306    ///
4307    /// Even though the property as already been set when instantiating this call,
4308    /// we provide this method for API completeness.
4309    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseBackupScheduleCreateCall<'a, C> {
4310        self._parent = new_value.to_string();
4311        self
4312    }
4313    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4314    /// while executing the actual API request.
4315    ///
4316    /// ````text
4317    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4318    /// ````
4319    ///
4320    /// Sets the *delegate* property to the given value.
4321    pub fn delegate(
4322        mut self,
4323        new_value: &'a mut dyn common::Delegate,
4324    ) -> ProjectDatabaseBackupScheduleCreateCall<'a, C> {
4325        self._delegate = Some(new_value);
4326        self
4327    }
4328
4329    /// Set any additional parameter of the query string used in the request.
4330    /// It should be used to set parameters which are not yet available through their own
4331    /// setters.
4332    ///
4333    /// Please note that this method must not be used to set any of the known parameters
4334    /// which have their own setter method. If done anyway, the request will fail.
4335    ///
4336    /// # Additional Parameters
4337    ///
4338    /// * *$.xgafv* (query-string) - V1 error format.
4339    /// * *access_token* (query-string) - OAuth access token.
4340    /// * *alt* (query-string) - Data format for response.
4341    /// * *callback* (query-string) - JSONP
4342    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4343    /// * *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.
4344    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4345    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4346    /// * *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.
4347    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4348    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4349    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseBackupScheduleCreateCall<'a, C>
4350    where
4351        T: AsRef<str>,
4352    {
4353        self._additional_params
4354            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4355        self
4356    }
4357
4358    /// Identifies the authorization scope for the method you are building.
4359    ///
4360    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4361    /// [`Scope::CloudPlatform`].
4362    ///
4363    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4364    /// tokens for more than one scope.
4365    ///
4366    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4367    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4368    /// sufficient, a read-write scope will do as well.
4369    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseBackupScheduleCreateCall<'a, C>
4370    where
4371        St: AsRef<str>,
4372    {
4373        self._scopes.insert(String::from(scope.as_ref()));
4374        self
4375    }
4376    /// Identifies the authorization scope(s) for the method you are building.
4377    ///
4378    /// See [`Self::add_scope()`] for details.
4379    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseBackupScheduleCreateCall<'a, C>
4380    where
4381        I: IntoIterator<Item = St>,
4382        St: AsRef<str>,
4383    {
4384        self._scopes
4385            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4386        self
4387    }
4388
4389    /// Removes all scopes, and no default scope will be used either.
4390    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4391    /// for details).
4392    pub fn clear_scopes(mut self) -> ProjectDatabaseBackupScheduleCreateCall<'a, C> {
4393        self._scopes.clear();
4394        self
4395    }
4396}
4397
4398/// Deletes a backup schedule.
4399///
4400/// A builder for the *databases.backupSchedules.delete* method supported by a *project* resource.
4401/// It is not used directly, but through a [`ProjectMethods`] instance.
4402///
4403/// # Example
4404///
4405/// Instantiate a resource method builder
4406///
4407/// ```test_harness,no_run
4408/// # extern crate hyper;
4409/// # extern crate hyper_rustls;
4410/// # extern crate google_firestore1 as firestore1;
4411/// # async fn dox() {
4412/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4413///
4414/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4415/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4416/// #     .with_native_roots()
4417/// #     .unwrap()
4418/// #     .https_only()
4419/// #     .enable_http2()
4420/// #     .build();
4421///
4422/// # let executor = hyper_util::rt::TokioExecutor::new();
4423/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4424/// #     secret,
4425/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4426/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4427/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4428/// #     ),
4429/// # ).build().await.unwrap();
4430///
4431/// # let client = hyper_util::client::legacy::Client::builder(
4432/// #     hyper_util::rt::TokioExecutor::new()
4433/// # )
4434/// # .build(
4435/// #     hyper_rustls::HttpsConnectorBuilder::new()
4436/// #         .with_native_roots()
4437/// #         .unwrap()
4438/// #         .https_or_http()
4439/// #         .enable_http2()
4440/// #         .build()
4441/// # );
4442/// # let mut hub = Firestore::new(client, auth);
4443/// // You can configure optional parameters by calling the respective setters at will, and
4444/// // execute the final call using `doit()`.
4445/// // Values shown here are possibly random and not representative !
4446/// let result = hub.projects().databases_backup_schedules_delete("name")
4447///              .doit().await;
4448/// # }
4449/// ```
4450pub struct ProjectDatabaseBackupScheduleDeleteCall<'a, C>
4451where
4452    C: 'a,
4453{
4454    hub: &'a Firestore<C>,
4455    _name: String,
4456    _delegate: Option<&'a mut dyn common::Delegate>,
4457    _additional_params: HashMap<String, String>,
4458    _scopes: BTreeSet<String>,
4459}
4460
4461impl<'a, C> common::CallBuilder for ProjectDatabaseBackupScheduleDeleteCall<'a, C> {}
4462
4463impl<'a, C> ProjectDatabaseBackupScheduleDeleteCall<'a, C>
4464where
4465    C: common::Connector,
4466{
4467    /// Perform the operation you have build so far.
4468    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4469        use std::borrow::Cow;
4470        use std::io::{Read, Seek};
4471
4472        use common::{url::Params, ToParts};
4473        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4474
4475        let mut dd = common::DefaultDelegate;
4476        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4477        dlg.begin(common::MethodInfo {
4478            id: "firestore.projects.databases.backupSchedules.delete",
4479            http_method: hyper::Method::DELETE,
4480        });
4481
4482        for &field in ["alt", "name"].iter() {
4483            if self._additional_params.contains_key(field) {
4484                dlg.finished(false);
4485                return Err(common::Error::FieldClash(field));
4486            }
4487        }
4488
4489        let mut params = Params::with_capacity(3 + self._additional_params.len());
4490        params.push("name", self._name);
4491
4492        params.extend(self._additional_params.iter());
4493
4494        params.push("alt", "json");
4495        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4496        if self._scopes.is_empty() {
4497            self._scopes
4498                .insert(Scope::CloudPlatform.as_ref().to_string());
4499        }
4500
4501        #[allow(clippy::single_element_loop)]
4502        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4503            url = params.uri_replacement(url, param_name, find_this, true);
4504        }
4505        {
4506            let to_remove = ["name"];
4507            params.remove_params(&to_remove);
4508        }
4509
4510        let url = params.parse_with_url(&url);
4511
4512        loop {
4513            let token = match self
4514                .hub
4515                .auth
4516                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4517                .await
4518            {
4519                Ok(token) => token,
4520                Err(e) => match dlg.token(e) {
4521                    Ok(token) => token,
4522                    Err(e) => {
4523                        dlg.finished(false);
4524                        return Err(common::Error::MissingToken(e));
4525                    }
4526                },
4527            };
4528            let mut req_result = {
4529                let client = &self.hub.client;
4530                dlg.pre_request();
4531                let mut req_builder = hyper::Request::builder()
4532                    .method(hyper::Method::DELETE)
4533                    .uri(url.as_str())
4534                    .header(USER_AGENT, self.hub._user_agent.clone());
4535
4536                if let Some(token) = token.as_ref() {
4537                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4538                }
4539
4540                let request = req_builder
4541                    .header(CONTENT_LENGTH, 0_u64)
4542                    .body(common::to_body::<String>(None));
4543
4544                client.request(request.unwrap()).await
4545            };
4546
4547            match req_result {
4548                Err(err) => {
4549                    if let common::Retry::After(d) = dlg.http_error(&err) {
4550                        sleep(d).await;
4551                        continue;
4552                    }
4553                    dlg.finished(false);
4554                    return Err(common::Error::HttpError(err));
4555                }
4556                Ok(res) => {
4557                    let (mut parts, body) = res.into_parts();
4558                    let mut body = common::Body::new(body);
4559                    if !parts.status.is_success() {
4560                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4561                        let error = serde_json::from_str(&common::to_string(&bytes));
4562                        let response = common::to_response(parts, bytes.into());
4563
4564                        if let common::Retry::After(d) =
4565                            dlg.http_failure(&response, error.as_ref().ok())
4566                        {
4567                            sleep(d).await;
4568                            continue;
4569                        }
4570
4571                        dlg.finished(false);
4572
4573                        return Err(match error {
4574                            Ok(value) => common::Error::BadRequest(value),
4575                            _ => common::Error::Failure(response),
4576                        });
4577                    }
4578                    let response = {
4579                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4580                        let encoded = common::to_string(&bytes);
4581                        match serde_json::from_str(&encoded) {
4582                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4583                            Err(error) => {
4584                                dlg.response_json_decode_error(&encoded, &error);
4585                                return Err(common::Error::JsonDecodeError(
4586                                    encoded.to_string(),
4587                                    error,
4588                                ));
4589                            }
4590                        }
4591                    };
4592
4593                    dlg.finished(true);
4594                    return Ok(response);
4595                }
4596            }
4597        }
4598    }
4599
4600    /// Required. The name of the backup schedule. Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
4601    ///
4602    /// Sets the *name* path property to the given value.
4603    ///
4604    /// Even though the property as already been set when instantiating this call,
4605    /// we provide this method for API completeness.
4606    pub fn name(mut self, new_value: &str) -> ProjectDatabaseBackupScheduleDeleteCall<'a, C> {
4607        self._name = new_value.to_string();
4608        self
4609    }
4610    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4611    /// while executing the actual API request.
4612    ///
4613    /// ````text
4614    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4615    /// ````
4616    ///
4617    /// Sets the *delegate* property to the given value.
4618    pub fn delegate(
4619        mut self,
4620        new_value: &'a mut dyn common::Delegate,
4621    ) -> ProjectDatabaseBackupScheduleDeleteCall<'a, C> {
4622        self._delegate = Some(new_value);
4623        self
4624    }
4625
4626    /// Set any additional parameter of the query string used in the request.
4627    /// It should be used to set parameters which are not yet available through their own
4628    /// setters.
4629    ///
4630    /// Please note that this method must not be used to set any of the known parameters
4631    /// which have their own setter method. If done anyway, the request will fail.
4632    ///
4633    /// # Additional Parameters
4634    ///
4635    /// * *$.xgafv* (query-string) - V1 error format.
4636    /// * *access_token* (query-string) - OAuth access token.
4637    /// * *alt* (query-string) - Data format for response.
4638    /// * *callback* (query-string) - JSONP
4639    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4640    /// * *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.
4641    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4642    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4643    /// * *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.
4644    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4645    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4646    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseBackupScheduleDeleteCall<'a, C>
4647    where
4648        T: AsRef<str>,
4649    {
4650        self._additional_params
4651            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4652        self
4653    }
4654
4655    /// Identifies the authorization scope for the method you are building.
4656    ///
4657    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4658    /// [`Scope::CloudPlatform`].
4659    ///
4660    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4661    /// tokens for more than one scope.
4662    ///
4663    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4664    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4665    /// sufficient, a read-write scope will do as well.
4666    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseBackupScheduleDeleteCall<'a, C>
4667    where
4668        St: AsRef<str>,
4669    {
4670        self._scopes.insert(String::from(scope.as_ref()));
4671        self
4672    }
4673    /// Identifies the authorization scope(s) for the method you are building.
4674    ///
4675    /// See [`Self::add_scope()`] for details.
4676    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseBackupScheduleDeleteCall<'a, C>
4677    where
4678        I: IntoIterator<Item = St>,
4679        St: AsRef<str>,
4680    {
4681        self._scopes
4682            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4683        self
4684    }
4685
4686    /// Removes all scopes, and no default scope will be used either.
4687    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4688    /// for details).
4689    pub fn clear_scopes(mut self) -> ProjectDatabaseBackupScheduleDeleteCall<'a, C> {
4690        self._scopes.clear();
4691        self
4692    }
4693}
4694
4695/// Gets information about a backup schedule.
4696///
4697/// A builder for the *databases.backupSchedules.get* method supported by a *project* resource.
4698/// It is not used directly, but through a [`ProjectMethods`] instance.
4699///
4700/// # Example
4701///
4702/// Instantiate a resource method builder
4703///
4704/// ```test_harness,no_run
4705/// # extern crate hyper;
4706/// # extern crate hyper_rustls;
4707/// # extern crate google_firestore1 as firestore1;
4708/// # async fn dox() {
4709/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4710///
4711/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4712/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4713/// #     .with_native_roots()
4714/// #     .unwrap()
4715/// #     .https_only()
4716/// #     .enable_http2()
4717/// #     .build();
4718///
4719/// # let executor = hyper_util::rt::TokioExecutor::new();
4720/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4721/// #     secret,
4722/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4723/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4724/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4725/// #     ),
4726/// # ).build().await.unwrap();
4727///
4728/// # let client = hyper_util::client::legacy::Client::builder(
4729/// #     hyper_util::rt::TokioExecutor::new()
4730/// # )
4731/// # .build(
4732/// #     hyper_rustls::HttpsConnectorBuilder::new()
4733/// #         .with_native_roots()
4734/// #         .unwrap()
4735/// #         .https_or_http()
4736/// #         .enable_http2()
4737/// #         .build()
4738/// # );
4739/// # let mut hub = Firestore::new(client, auth);
4740/// // You can configure optional parameters by calling the respective setters at will, and
4741/// // execute the final call using `doit()`.
4742/// // Values shown here are possibly random and not representative !
4743/// let result = hub.projects().databases_backup_schedules_get("name")
4744///              .doit().await;
4745/// # }
4746/// ```
4747pub struct ProjectDatabaseBackupScheduleGetCall<'a, C>
4748where
4749    C: 'a,
4750{
4751    hub: &'a Firestore<C>,
4752    _name: String,
4753    _delegate: Option<&'a mut dyn common::Delegate>,
4754    _additional_params: HashMap<String, String>,
4755    _scopes: BTreeSet<String>,
4756}
4757
4758impl<'a, C> common::CallBuilder for ProjectDatabaseBackupScheduleGetCall<'a, C> {}
4759
4760impl<'a, C> ProjectDatabaseBackupScheduleGetCall<'a, C>
4761where
4762    C: common::Connector,
4763{
4764    /// Perform the operation you have build so far.
4765    pub async fn doit(
4766        mut self,
4767    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1BackupSchedule)> {
4768        use std::borrow::Cow;
4769        use std::io::{Read, Seek};
4770
4771        use common::{url::Params, ToParts};
4772        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4773
4774        let mut dd = common::DefaultDelegate;
4775        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4776        dlg.begin(common::MethodInfo {
4777            id: "firestore.projects.databases.backupSchedules.get",
4778            http_method: hyper::Method::GET,
4779        });
4780
4781        for &field in ["alt", "name"].iter() {
4782            if self._additional_params.contains_key(field) {
4783                dlg.finished(false);
4784                return Err(common::Error::FieldClash(field));
4785            }
4786        }
4787
4788        let mut params = Params::with_capacity(3 + self._additional_params.len());
4789        params.push("name", self._name);
4790
4791        params.extend(self._additional_params.iter());
4792
4793        params.push("alt", "json");
4794        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4795        if self._scopes.is_empty() {
4796            self._scopes
4797                .insert(Scope::CloudPlatform.as_ref().to_string());
4798        }
4799
4800        #[allow(clippy::single_element_loop)]
4801        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4802            url = params.uri_replacement(url, param_name, find_this, true);
4803        }
4804        {
4805            let to_remove = ["name"];
4806            params.remove_params(&to_remove);
4807        }
4808
4809        let url = params.parse_with_url(&url);
4810
4811        loop {
4812            let token = match self
4813                .hub
4814                .auth
4815                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4816                .await
4817            {
4818                Ok(token) => token,
4819                Err(e) => match dlg.token(e) {
4820                    Ok(token) => token,
4821                    Err(e) => {
4822                        dlg.finished(false);
4823                        return Err(common::Error::MissingToken(e));
4824                    }
4825                },
4826            };
4827            let mut req_result = {
4828                let client = &self.hub.client;
4829                dlg.pre_request();
4830                let mut req_builder = hyper::Request::builder()
4831                    .method(hyper::Method::GET)
4832                    .uri(url.as_str())
4833                    .header(USER_AGENT, self.hub._user_agent.clone());
4834
4835                if let Some(token) = token.as_ref() {
4836                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4837                }
4838
4839                let request = req_builder
4840                    .header(CONTENT_LENGTH, 0_u64)
4841                    .body(common::to_body::<String>(None));
4842
4843                client.request(request.unwrap()).await
4844            };
4845
4846            match req_result {
4847                Err(err) => {
4848                    if let common::Retry::After(d) = dlg.http_error(&err) {
4849                        sleep(d).await;
4850                        continue;
4851                    }
4852                    dlg.finished(false);
4853                    return Err(common::Error::HttpError(err));
4854                }
4855                Ok(res) => {
4856                    let (mut parts, body) = res.into_parts();
4857                    let mut body = common::Body::new(body);
4858                    if !parts.status.is_success() {
4859                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4860                        let error = serde_json::from_str(&common::to_string(&bytes));
4861                        let response = common::to_response(parts, bytes.into());
4862
4863                        if let common::Retry::After(d) =
4864                            dlg.http_failure(&response, error.as_ref().ok())
4865                        {
4866                            sleep(d).await;
4867                            continue;
4868                        }
4869
4870                        dlg.finished(false);
4871
4872                        return Err(match error {
4873                            Ok(value) => common::Error::BadRequest(value),
4874                            _ => common::Error::Failure(response),
4875                        });
4876                    }
4877                    let response = {
4878                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4879                        let encoded = common::to_string(&bytes);
4880                        match serde_json::from_str(&encoded) {
4881                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4882                            Err(error) => {
4883                                dlg.response_json_decode_error(&encoded, &error);
4884                                return Err(common::Error::JsonDecodeError(
4885                                    encoded.to_string(),
4886                                    error,
4887                                ));
4888                            }
4889                        }
4890                    };
4891
4892                    dlg.finished(true);
4893                    return Ok(response);
4894                }
4895            }
4896        }
4897    }
4898
4899    /// Required. The name of the backup schedule. Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
4900    ///
4901    /// Sets the *name* path property to the given value.
4902    ///
4903    /// Even though the property as already been set when instantiating this call,
4904    /// we provide this method for API completeness.
4905    pub fn name(mut self, new_value: &str) -> ProjectDatabaseBackupScheduleGetCall<'a, C> {
4906        self._name = new_value.to_string();
4907        self
4908    }
4909    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4910    /// while executing the actual API request.
4911    ///
4912    /// ````text
4913    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4914    /// ````
4915    ///
4916    /// Sets the *delegate* property to the given value.
4917    pub fn delegate(
4918        mut self,
4919        new_value: &'a mut dyn common::Delegate,
4920    ) -> ProjectDatabaseBackupScheduleGetCall<'a, C> {
4921        self._delegate = Some(new_value);
4922        self
4923    }
4924
4925    /// Set any additional parameter of the query string used in the request.
4926    /// It should be used to set parameters which are not yet available through their own
4927    /// setters.
4928    ///
4929    /// Please note that this method must not be used to set any of the known parameters
4930    /// which have their own setter method. If done anyway, the request will fail.
4931    ///
4932    /// # Additional Parameters
4933    ///
4934    /// * *$.xgafv* (query-string) - V1 error format.
4935    /// * *access_token* (query-string) - OAuth access token.
4936    /// * *alt* (query-string) - Data format for response.
4937    /// * *callback* (query-string) - JSONP
4938    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4939    /// * *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.
4940    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4941    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4942    /// * *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.
4943    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4944    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4945    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseBackupScheduleGetCall<'a, C>
4946    where
4947        T: AsRef<str>,
4948    {
4949        self._additional_params
4950            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4951        self
4952    }
4953
4954    /// Identifies the authorization scope for the method you are building.
4955    ///
4956    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4957    /// [`Scope::CloudPlatform`].
4958    ///
4959    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4960    /// tokens for more than one scope.
4961    ///
4962    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4963    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4964    /// sufficient, a read-write scope will do as well.
4965    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseBackupScheduleGetCall<'a, C>
4966    where
4967        St: AsRef<str>,
4968    {
4969        self._scopes.insert(String::from(scope.as_ref()));
4970        self
4971    }
4972    /// Identifies the authorization scope(s) for the method you are building.
4973    ///
4974    /// See [`Self::add_scope()`] for details.
4975    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseBackupScheduleGetCall<'a, C>
4976    where
4977        I: IntoIterator<Item = St>,
4978        St: AsRef<str>,
4979    {
4980        self._scopes
4981            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4982        self
4983    }
4984
4985    /// Removes all scopes, and no default scope will be used either.
4986    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4987    /// for details).
4988    pub fn clear_scopes(mut self) -> ProjectDatabaseBackupScheduleGetCall<'a, C> {
4989        self._scopes.clear();
4990        self
4991    }
4992}
4993
4994/// List backup schedules.
4995///
4996/// A builder for the *databases.backupSchedules.list* method supported by a *project* resource.
4997/// It is not used directly, but through a [`ProjectMethods`] instance.
4998///
4999/// # Example
5000///
5001/// Instantiate a resource method builder
5002///
5003/// ```test_harness,no_run
5004/// # extern crate hyper;
5005/// # extern crate hyper_rustls;
5006/// # extern crate google_firestore1 as firestore1;
5007/// # async fn dox() {
5008/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5009///
5010/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5011/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5012/// #     .with_native_roots()
5013/// #     .unwrap()
5014/// #     .https_only()
5015/// #     .enable_http2()
5016/// #     .build();
5017///
5018/// # let executor = hyper_util::rt::TokioExecutor::new();
5019/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5020/// #     secret,
5021/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5022/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5023/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5024/// #     ),
5025/// # ).build().await.unwrap();
5026///
5027/// # let client = hyper_util::client::legacy::Client::builder(
5028/// #     hyper_util::rt::TokioExecutor::new()
5029/// # )
5030/// # .build(
5031/// #     hyper_rustls::HttpsConnectorBuilder::new()
5032/// #         .with_native_roots()
5033/// #         .unwrap()
5034/// #         .https_or_http()
5035/// #         .enable_http2()
5036/// #         .build()
5037/// # );
5038/// # let mut hub = Firestore::new(client, auth);
5039/// // You can configure optional parameters by calling the respective setters at will, and
5040/// // execute the final call using `doit()`.
5041/// // Values shown here are possibly random and not representative !
5042/// let result = hub.projects().databases_backup_schedules_list("parent")
5043///              .doit().await;
5044/// # }
5045/// ```
5046pub struct ProjectDatabaseBackupScheduleListCall<'a, C>
5047where
5048    C: 'a,
5049{
5050    hub: &'a Firestore<C>,
5051    _parent: String,
5052    _delegate: Option<&'a mut dyn common::Delegate>,
5053    _additional_params: HashMap<String, String>,
5054    _scopes: BTreeSet<String>,
5055}
5056
5057impl<'a, C> common::CallBuilder for ProjectDatabaseBackupScheduleListCall<'a, C> {}
5058
5059impl<'a, C> ProjectDatabaseBackupScheduleListCall<'a, C>
5060where
5061    C: common::Connector,
5062{
5063    /// Perform the operation you have build so far.
5064    pub async fn doit(
5065        mut self,
5066    ) -> common::Result<(
5067        common::Response,
5068        GoogleFirestoreAdminV1ListBackupSchedulesResponse,
5069    )> {
5070        use std::borrow::Cow;
5071        use std::io::{Read, Seek};
5072
5073        use common::{url::Params, ToParts};
5074        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5075
5076        let mut dd = common::DefaultDelegate;
5077        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5078        dlg.begin(common::MethodInfo {
5079            id: "firestore.projects.databases.backupSchedules.list",
5080            http_method: hyper::Method::GET,
5081        });
5082
5083        for &field in ["alt", "parent"].iter() {
5084            if self._additional_params.contains_key(field) {
5085                dlg.finished(false);
5086                return Err(common::Error::FieldClash(field));
5087            }
5088        }
5089
5090        let mut params = Params::with_capacity(3 + self._additional_params.len());
5091        params.push("parent", self._parent);
5092
5093        params.extend(self._additional_params.iter());
5094
5095        params.push("alt", "json");
5096        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backupSchedules";
5097        if self._scopes.is_empty() {
5098            self._scopes
5099                .insert(Scope::CloudPlatform.as_ref().to_string());
5100        }
5101
5102        #[allow(clippy::single_element_loop)]
5103        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5104            url = params.uri_replacement(url, param_name, find_this, true);
5105        }
5106        {
5107            let to_remove = ["parent"];
5108            params.remove_params(&to_remove);
5109        }
5110
5111        let url = params.parse_with_url(&url);
5112
5113        loop {
5114            let token = match self
5115                .hub
5116                .auth
5117                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5118                .await
5119            {
5120                Ok(token) => token,
5121                Err(e) => match dlg.token(e) {
5122                    Ok(token) => token,
5123                    Err(e) => {
5124                        dlg.finished(false);
5125                        return Err(common::Error::MissingToken(e));
5126                    }
5127                },
5128            };
5129            let mut req_result = {
5130                let client = &self.hub.client;
5131                dlg.pre_request();
5132                let mut req_builder = hyper::Request::builder()
5133                    .method(hyper::Method::GET)
5134                    .uri(url.as_str())
5135                    .header(USER_AGENT, self.hub._user_agent.clone());
5136
5137                if let Some(token) = token.as_ref() {
5138                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5139                }
5140
5141                let request = req_builder
5142                    .header(CONTENT_LENGTH, 0_u64)
5143                    .body(common::to_body::<String>(None));
5144
5145                client.request(request.unwrap()).await
5146            };
5147
5148            match req_result {
5149                Err(err) => {
5150                    if let common::Retry::After(d) = dlg.http_error(&err) {
5151                        sleep(d).await;
5152                        continue;
5153                    }
5154                    dlg.finished(false);
5155                    return Err(common::Error::HttpError(err));
5156                }
5157                Ok(res) => {
5158                    let (mut parts, body) = res.into_parts();
5159                    let mut body = common::Body::new(body);
5160                    if !parts.status.is_success() {
5161                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5162                        let error = serde_json::from_str(&common::to_string(&bytes));
5163                        let response = common::to_response(parts, bytes.into());
5164
5165                        if let common::Retry::After(d) =
5166                            dlg.http_failure(&response, error.as_ref().ok())
5167                        {
5168                            sleep(d).await;
5169                            continue;
5170                        }
5171
5172                        dlg.finished(false);
5173
5174                        return Err(match error {
5175                            Ok(value) => common::Error::BadRequest(value),
5176                            _ => common::Error::Failure(response),
5177                        });
5178                    }
5179                    let response = {
5180                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5181                        let encoded = common::to_string(&bytes);
5182                        match serde_json::from_str(&encoded) {
5183                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5184                            Err(error) => {
5185                                dlg.response_json_decode_error(&encoded, &error);
5186                                return Err(common::Error::JsonDecodeError(
5187                                    encoded.to_string(),
5188                                    error,
5189                                ));
5190                            }
5191                        }
5192                    };
5193
5194                    dlg.finished(true);
5195                    return Ok(response);
5196                }
5197            }
5198        }
5199    }
5200
5201    /// Required. The parent database. Format is `projects/{project}/databases/{database}`.
5202    ///
5203    /// Sets the *parent* path property to the given value.
5204    ///
5205    /// Even though the property as already been set when instantiating this call,
5206    /// we provide this method for API completeness.
5207    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseBackupScheduleListCall<'a, C> {
5208        self._parent = new_value.to_string();
5209        self
5210    }
5211    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5212    /// while executing the actual API request.
5213    ///
5214    /// ````text
5215    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5216    /// ````
5217    ///
5218    /// Sets the *delegate* property to the given value.
5219    pub fn delegate(
5220        mut self,
5221        new_value: &'a mut dyn common::Delegate,
5222    ) -> ProjectDatabaseBackupScheduleListCall<'a, C> {
5223        self._delegate = Some(new_value);
5224        self
5225    }
5226
5227    /// Set any additional parameter of the query string used in the request.
5228    /// It should be used to set parameters which are not yet available through their own
5229    /// setters.
5230    ///
5231    /// Please note that this method must not be used to set any of the known parameters
5232    /// which have their own setter method. If done anyway, the request will fail.
5233    ///
5234    /// # Additional Parameters
5235    ///
5236    /// * *$.xgafv* (query-string) - V1 error format.
5237    /// * *access_token* (query-string) - OAuth access token.
5238    /// * *alt* (query-string) - Data format for response.
5239    /// * *callback* (query-string) - JSONP
5240    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5241    /// * *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.
5242    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5243    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5244    /// * *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.
5245    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5246    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5247    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseBackupScheduleListCall<'a, C>
5248    where
5249        T: AsRef<str>,
5250    {
5251        self._additional_params
5252            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5253        self
5254    }
5255
5256    /// Identifies the authorization scope for the method you are building.
5257    ///
5258    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5259    /// [`Scope::CloudPlatform`].
5260    ///
5261    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5262    /// tokens for more than one scope.
5263    ///
5264    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5265    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5266    /// sufficient, a read-write scope will do as well.
5267    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseBackupScheduleListCall<'a, C>
5268    where
5269        St: AsRef<str>,
5270    {
5271        self._scopes.insert(String::from(scope.as_ref()));
5272        self
5273    }
5274    /// Identifies the authorization scope(s) for the method you are building.
5275    ///
5276    /// See [`Self::add_scope()`] for details.
5277    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseBackupScheduleListCall<'a, C>
5278    where
5279        I: IntoIterator<Item = St>,
5280        St: AsRef<str>,
5281    {
5282        self._scopes
5283            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5284        self
5285    }
5286
5287    /// Removes all scopes, and no default scope will be used either.
5288    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5289    /// for details).
5290    pub fn clear_scopes(mut self) -> ProjectDatabaseBackupScheduleListCall<'a, C> {
5291        self._scopes.clear();
5292        self
5293    }
5294}
5295
5296/// Updates a backup schedule.
5297///
5298/// A builder for the *databases.backupSchedules.patch* method supported by a *project* resource.
5299/// It is not used directly, but through a [`ProjectMethods`] instance.
5300///
5301/// # Example
5302///
5303/// Instantiate a resource method builder
5304///
5305/// ```test_harness,no_run
5306/// # extern crate hyper;
5307/// # extern crate hyper_rustls;
5308/// # extern crate google_firestore1 as firestore1;
5309/// use firestore1::api::GoogleFirestoreAdminV1BackupSchedule;
5310/// # async fn dox() {
5311/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5312///
5313/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5314/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5315/// #     .with_native_roots()
5316/// #     .unwrap()
5317/// #     .https_only()
5318/// #     .enable_http2()
5319/// #     .build();
5320///
5321/// # let executor = hyper_util::rt::TokioExecutor::new();
5322/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5323/// #     secret,
5324/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5325/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5326/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5327/// #     ),
5328/// # ).build().await.unwrap();
5329///
5330/// # let client = hyper_util::client::legacy::Client::builder(
5331/// #     hyper_util::rt::TokioExecutor::new()
5332/// # )
5333/// # .build(
5334/// #     hyper_rustls::HttpsConnectorBuilder::new()
5335/// #         .with_native_roots()
5336/// #         .unwrap()
5337/// #         .https_or_http()
5338/// #         .enable_http2()
5339/// #         .build()
5340/// # );
5341/// # let mut hub = Firestore::new(client, auth);
5342/// // As the method needs a request, you would usually fill it with the desired information
5343/// // into the respective structure. Some of the parts shown here might not be applicable !
5344/// // Values shown here are possibly random and not representative !
5345/// let mut req = GoogleFirestoreAdminV1BackupSchedule::default();
5346///
5347/// // You can configure optional parameters by calling the respective setters at will, and
5348/// // execute the final call using `doit()`.
5349/// // Values shown here are possibly random and not representative !
5350/// let result = hub.projects().databases_backup_schedules_patch(req, "name")
5351///              .update_mask(FieldMask::new::<&str>(&[]))
5352///              .doit().await;
5353/// # }
5354/// ```
5355pub struct ProjectDatabaseBackupSchedulePatchCall<'a, C>
5356where
5357    C: 'a,
5358{
5359    hub: &'a Firestore<C>,
5360    _request: GoogleFirestoreAdminV1BackupSchedule,
5361    _name: String,
5362    _update_mask: Option<common::FieldMask>,
5363    _delegate: Option<&'a mut dyn common::Delegate>,
5364    _additional_params: HashMap<String, String>,
5365    _scopes: BTreeSet<String>,
5366}
5367
5368impl<'a, C> common::CallBuilder for ProjectDatabaseBackupSchedulePatchCall<'a, C> {}
5369
5370impl<'a, C> ProjectDatabaseBackupSchedulePatchCall<'a, C>
5371where
5372    C: common::Connector,
5373{
5374    /// Perform the operation you have build so far.
5375    pub async fn doit(
5376        mut self,
5377    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1BackupSchedule)> {
5378        use std::borrow::Cow;
5379        use std::io::{Read, Seek};
5380
5381        use common::{url::Params, ToParts};
5382        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5383
5384        let mut dd = common::DefaultDelegate;
5385        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5386        dlg.begin(common::MethodInfo {
5387            id: "firestore.projects.databases.backupSchedules.patch",
5388            http_method: hyper::Method::PATCH,
5389        });
5390
5391        for &field in ["alt", "name", "updateMask"].iter() {
5392            if self._additional_params.contains_key(field) {
5393                dlg.finished(false);
5394                return Err(common::Error::FieldClash(field));
5395            }
5396        }
5397
5398        let mut params = Params::with_capacity(5 + self._additional_params.len());
5399        params.push("name", self._name);
5400        if let Some(value) = self._update_mask.as_ref() {
5401            params.push("updateMask", value.to_string());
5402        }
5403
5404        params.extend(self._additional_params.iter());
5405
5406        params.push("alt", "json");
5407        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5408        if self._scopes.is_empty() {
5409            self._scopes
5410                .insert(Scope::CloudPlatform.as_ref().to_string());
5411        }
5412
5413        #[allow(clippy::single_element_loop)]
5414        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5415            url = params.uri_replacement(url, param_name, find_this, true);
5416        }
5417        {
5418            let to_remove = ["name"];
5419            params.remove_params(&to_remove);
5420        }
5421
5422        let url = params.parse_with_url(&url);
5423
5424        let mut json_mime_type = mime::APPLICATION_JSON;
5425        let mut request_value_reader = {
5426            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5427            common::remove_json_null_values(&mut value);
5428            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5429            serde_json::to_writer(&mut dst, &value).unwrap();
5430            dst
5431        };
5432        let request_size = request_value_reader
5433            .seek(std::io::SeekFrom::End(0))
5434            .unwrap();
5435        request_value_reader
5436            .seek(std::io::SeekFrom::Start(0))
5437            .unwrap();
5438
5439        loop {
5440            let token = match self
5441                .hub
5442                .auth
5443                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5444                .await
5445            {
5446                Ok(token) => token,
5447                Err(e) => match dlg.token(e) {
5448                    Ok(token) => token,
5449                    Err(e) => {
5450                        dlg.finished(false);
5451                        return Err(common::Error::MissingToken(e));
5452                    }
5453                },
5454            };
5455            request_value_reader
5456                .seek(std::io::SeekFrom::Start(0))
5457                .unwrap();
5458            let mut req_result = {
5459                let client = &self.hub.client;
5460                dlg.pre_request();
5461                let mut req_builder = hyper::Request::builder()
5462                    .method(hyper::Method::PATCH)
5463                    .uri(url.as_str())
5464                    .header(USER_AGENT, self.hub._user_agent.clone());
5465
5466                if let Some(token) = token.as_ref() {
5467                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5468                }
5469
5470                let request = req_builder
5471                    .header(CONTENT_TYPE, json_mime_type.to_string())
5472                    .header(CONTENT_LENGTH, request_size as u64)
5473                    .body(common::to_body(
5474                        request_value_reader.get_ref().clone().into(),
5475                    ));
5476
5477                client.request(request.unwrap()).await
5478            };
5479
5480            match req_result {
5481                Err(err) => {
5482                    if let common::Retry::After(d) = dlg.http_error(&err) {
5483                        sleep(d).await;
5484                        continue;
5485                    }
5486                    dlg.finished(false);
5487                    return Err(common::Error::HttpError(err));
5488                }
5489                Ok(res) => {
5490                    let (mut parts, body) = res.into_parts();
5491                    let mut body = common::Body::new(body);
5492                    if !parts.status.is_success() {
5493                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5494                        let error = serde_json::from_str(&common::to_string(&bytes));
5495                        let response = common::to_response(parts, bytes.into());
5496
5497                        if let common::Retry::After(d) =
5498                            dlg.http_failure(&response, error.as_ref().ok())
5499                        {
5500                            sleep(d).await;
5501                            continue;
5502                        }
5503
5504                        dlg.finished(false);
5505
5506                        return Err(match error {
5507                            Ok(value) => common::Error::BadRequest(value),
5508                            _ => common::Error::Failure(response),
5509                        });
5510                    }
5511                    let response = {
5512                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5513                        let encoded = common::to_string(&bytes);
5514                        match serde_json::from_str(&encoded) {
5515                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5516                            Err(error) => {
5517                                dlg.response_json_decode_error(&encoded, &error);
5518                                return Err(common::Error::JsonDecodeError(
5519                                    encoded.to_string(),
5520                                    error,
5521                                ));
5522                            }
5523                        }
5524                    };
5525
5526                    dlg.finished(true);
5527                    return Ok(response);
5528                }
5529            }
5530        }
5531    }
5532
5533    ///
5534    /// Sets the *request* property to the given value.
5535    ///
5536    /// Even though the property as already been set when instantiating this call,
5537    /// we provide this method for API completeness.
5538    pub fn request(
5539        mut self,
5540        new_value: GoogleFirestoreAdminV1BackupSchedule,
5541    ) -> ProjectDatabaseBackupSchedulePatchCall<'a, C> {
5542        self._request = new_value;
5543        self
5544    }
5545    /// Output only. The unique backup schedule identifier across all locations and databases for the given project. This will be auto-assigned. Format is `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
5546    ///
5547    /// Sets the *name* path property to the given value.
5548    ///
5549    /// Even though the property as already been set when instantiating this call,
5550    /// we provide this method for API completeness.
5551    pub fn name(mut self, new_value: &str) -> ProjectDatabaseBackupSchedulePatchCall<'a, C> {
5552        self._name = new_value.to_string();
5553        self
5554    }
5555    /// The list of fields to be updated.
5556    ///
5557    /// Sets the *update mask* query property to the given value.
5558    pub fn update_mask(
5559        mut self,
5560        new_value: common::FieldMask,
5561    ) -> ProjectDatabaseBackupSchedulePatchCall<'a, C> {
5562        self._update_mask = Some(new_value);
5563        self
5564    }
5565    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5566    /// while executing the actual API request.
5567    ///
5568    /// ````text
5569    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5570    /// ````
5571    ///
5572    /// Sets the *delegate* property to the given value.
5573    pub fn delegate(
5574        mut self,
5575        new_value: &'a mut dyn common::Delegate,
5576    ) -> ProjectDatabaseBackupSchedulePatchCall<'a, C> {
5577        self._delegate = Some(new_value);
5578        self
5579    }
5580
5581    /// Set any additional parameter of the query string used in the request.
5582    /// It should be used to set parameters which are not yet available through their own
5583    /// setters.
5584    ///
5585    /// Please note that this method must not be used to set any of the known parameters
5586    /// which have their own setter method. If done anyway, the request will fail.
5587    ///
5588    /// # Additional Parameters
5589    ///
5590    /// * *$.xgafv* (query-string) - V1 error format.
5591    /// * *access_token* (query-string) - OAuth access token.
5592    /// * *alt* (query-string) - Data format for response.
5593    /// * *callback* (query-string) - JSONP
5594    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5595    /// * *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.
5596    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5597    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5598    /// * *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.
5599    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5600    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5601    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseBackupSchedulePatchCall<'a, C>
5602    where
5603        T: AsRef<str>,
5604    {
5605        self._additional_params
5606            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5607        self
5608    }
5609
5610    /// Identifies the authorization scope for the method you are building.
5611    ///
5612    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5613    /// [`Scope::CloudPlatform`].
5614    ///
5615    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5616    /// tokens for more than one scope.
5617    ///
5618    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5619    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5620    /// sufficient, a read-write scope will do as well.
5621    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseBackupSchedulePatchCall<'a, C>
5622    where
5623        St: AsRef<str>,
5624    {
5625        self._scopes.insert(String::from(scope.as_ref()));
5626        self
5627    }
5628    /// Identifies the authorization scope(s) for the method you are building.
5629    ///
5630    /// See [`Self::add_scope()`] for details.
5631    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseBackupSchedulePatchCall<'a, C>
5632    where
5633        I: IntoIterator<Item = St>,
5634        St: AsRef<str>,
5635    {
5636        self._scopes
5637            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5638        self
5639    }
5640
5641    /// Removes all scopes, and no default scope will be used either.
5642    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5643    /// for details).
5644    pub fn clear_scopes(mut self) -> ProjectDatabaseBackupSchedulePatchCall<'a, C> {
5645        self._scopes.clear();
5646        self
5647    }
5648}
5649
5650/// Gets the metadata and configuration for a Field.
5651///
5652/// A builder for the *databases.collectionGroups.fields.get* method supported by a *project* resource.
5653/// It is not used directly, but through a [`ProjectMethods`] instance.
5654///
5655/// # Example
5656///
5657/// Instantiate a resource method builder
5658///
5659/// ```test_harness,no_run
5660/// # extern crate hyper;
5661/// # extern crate hyper_rustls;
5662/// # extern crate google_firestore1 as firestore1;
5663/// # async fn dox() {
5664/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5665///
5666/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5667/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5668/// #     .with_native_roots()
5669/// #     .unwrap()
5670/// #     .https_only()
5671/// #     .enable_http2()
5672/// #     .build();
5673///
5674/// # let executor = hyper_util::rt::TokioExecutor::new();
5675/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5676/// #     secret,
5677/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5678/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5679/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5680/// #     ),
5681/// # ).build().await.unwrap();
5682///
5683/// # let client = hyper_util::client::legacy::Client::builder(
5684/// #     hyper_util::rt::TokioExecutor::new()
5685/// # )
5686/// # .build(
5687/// #     hyper_rustls::HttpsConnectorBuilder::new()
5688/// #         .with_native_roots()
5689/// #         .unwrap()
5690/// #         .https_or_http()
5691/// #         .enable_http2()
5692/// #         .build()
5693/// # );
5694/// # let mut hub = Firestore::new(client, auth);
5695/// // You can configure optional parameters by calling the respective setters at will, and
5696/// // execute the final call using `doit()`.
5697/// // Values shown here are possibly random and not representative !
5698/// let result = hub.projects().databases_collection_groups_fields_get("name")
5699///              .doit().await;
5700/// # }
5701/// ```
5702pub struct ProjectDatabaseCollectionGroupFieldGetCall<'a, C>
5703where
5704    C: 'a,
5705{
5706    hub: &'a Firestore<C>,
5707    _name: String,
5708    _delegate: Option<&'a mut dyn common::Delegate>,
5709    _additional_params: HashMap<String, String>,
5710    _scopes: BTreeSet<String>,
5711}
5712
5713impl<'a, C> common::CallBuilder for ProjectDatabaseCollectionGroupFieldGetCall<'a, C> {}
5714
5715impl<'a, C> ProjectDatabaseCollectionGroupFieldGetCall<'a, C>
5716where
5717    C: common::Connector,
5718{
5719    /// Perform the operation you have build so far.
5720    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleFirestoreAdminV1Field)> {
5721        use std::borrow::Cow;
5722        use std::io::{Read, Seek};
5723
5724        use common::{url::Params, ToParts};
5725        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5726
5727        let mut dd = common::DefaultDelegate;
5728        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5729        dlg.begin(common::MethodInfo {
5730            id: "firestore.projects.databases.collectionGroups.fields.get",
5731            http_method: hyper::Method::GET,
5732        });
5733
5734        for &field in ["alt", "name"].iter() {
5735            if self._additional_params.contains_key(field) {
5736                dlg.finished(false);
5737                return Err(common::Error::FieldClash(field));
5738            }
5739        }
5740
5741        let mut params = Params::with_capacity(3 + self._additional_params.len());
5742        params.push("name", self._name);
5743
5744        params.extend(self._additional_params.iter());
5745
5746        params.push("alt", "json");
5747        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5748        if self._scopes.is_empty() {
5749            self._scopes
5750                .insert(Scope::CloudPlatform.as_ref().to_string());
5751        }
5752
5753        #[allow(clippy::single_element_loop)]
5754        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5755            url = params.uri_replacement(url, param_name, find_this, true);
5756        }
5757        {
5758            let to_remove = ["name"];
5759            params.remove_params(&to_remove);
5760        }
5761
5762        let url = params.parse_with_url(&url);
5763
5764        loop {
5765            let token = match self
5766                .hub
5767                .auth
5768                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5769                .await
5770            {
5771                Ok(token) => token,
5772                Err(e) => match dlg.token(e) {
5773                    Ok(token) => token,
5774                    Err(e) => {
5775                        dlg.finished(false);
5776                        return Err(common::Error::MissingToken(e));
5777                    }
5778                },
5779            };
5780            let mut req_result = {
5781                let client = &self.hub.client;
5782                dlg.pre_request();
5783                let mut req_builder = hyper::Request::builder()
5784                    .method(hyper::Method::GET)
5785                    .uri(url.as_str())
5786                    .header(USER_AGENT, self.hub._user_agent.clone());
5787
5788                if let Some(token) = token.as_ref() {
5789                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5790                }
5791
5792                let request = req_builder
5793                    .header(CONTENT_LENGTH, 0_u64)
5794                    .body(common::to_body::<String>(None));
5795
5796                client.request(request.unwrap()).await
5797            };
5798
5799            match req_result {
5800                Err(err) => {
5801                    if let common::Retry::After(d) = dlg.http_error(&err) {
5802                        sleep(d).await;
5803                        continue;
5804                    }
5805                    dlg.finished(false);
5806                    return Err(common::Error::HttpError(err));
5807                }
5808                Ok(res) => {
5809                    let (mut parts, body) = res.into_parts();
5810                    let mut body = common::Body::new(body);
5811                    if !parts.status.is_success() {
5812                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5813                        let error = serde_json::from_str(&common::to_string(&bytes));
5814                        let response = common::to_response(parts, bytes.into());
5815
5816                        if let common::Retry::After(d) =
5817                            dlg.http_failure(&response, error.as_ref().ok())
5818                        {
5819                            sleep(d).await;
5820                            continue;
5821                        }
5822
5823                        dlg.finished(false);
5824
5825                        return Err(match error {
5826                            Ok(value) => common::Error::BadRequest(value),
5827                            _ => common::Error::Failure(response),
5828                        });
5829                    }
5830                    let response = {
5831                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5832                        let encoded = common::to_string(&bytes);
5833                        match serde_json::from_str(&encoded) {
5834                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5835                            Err(error) => {
5836                                dlg.response_json_decode_error(&encoded, &error);
5837                                return Err(common::Error::JsonDecodeError(
5838                                    encoded.to_string(),
5839                                    error,
5840                                ));
5841                            }
5842                        }
5843                    };
5844
5845                    dlg.finished(true);
5846                    return Ok(response);
5847                }
5848            }
5849        }
5850    }
5851
5852    /// Required. A name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
5853    ///
5854    /// Sets the *name* path property to the given value.
5855    ///
5856    /// Even though the property as already been set when instantiating this call,
5857    /// we provide this method for API completeness.
5858    pub fn name(mut self, new_value: &str) -> ProjectDatabaseCollectionGroupFieldGetCall<'a, C> {
5859        self._name = new_value.to_string();
5860        self
5861    }
5862    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5863    /// while executing the actual API request.
5864    ///
5865    /// ````text
5866    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5867    /// ````
5868    ///
5869    /// Sets the *delegate* property to the given value.
5870    pub fn delegate(
5871        mut self,
5872        new_value: &'a mut dyn common::Delegate,
5873    ) -> ProjectDatabaseCollectionGroupFieldGetCall<'a, C> {
5874        self._delegate = Some(new_value);
5875        self
5876    }
5877
5878    /// Set any additional parameter of the query string used in the request.
5879    /// It should be used to set parameters which are not yet available through their own
5880    /// setters.
5881    ///
5882    /// Please note that this method must not be used to set any of the known parameters
5883    /// which have their own setter method. If done anyway, the request will fail.
5884    ///
5885    /// # Additional Parameters
5886    ///
5887    /// * *$.xgafv* (query-string) - V1 error format.
5888    /// * *access_token* (query-string) - OAuth access token.
5889    /// * *alt* (query-string) - Data format for response.
5890    /// * *callback* (query-string) - JSONP
5891    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5892    /// * *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.
5893    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5894    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5895    /// * *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.
5896    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5897    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5898    pub fn param<T>(
5899        mut self,
5900        name: T,
5901        value: T,
5902    ) -> ProjectDatabaseCollectionGroupFieldGetCall<'a, C>
5903    where
5904        T: AsRef<str>,
5905    {
5906        self._additional_params
5907            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5908        self
5909    }
5910
5911    /// Identifies the authorization scope for the method you are building.
5912    ///
5913    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5914    /// [`Scope::CloudPlatform`].
5915    ///
5916    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5917    /// tokens for more than one scope.
5918    ///
5919    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5920    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5921    /// sufficient, a read-write scope will do as well.
5922    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseCollectionGroupFieldGetCall<'a, C>
5923    where
5924        St: AsRef<str>,
5925    {
5926        self._scopes.insert(String::from(scope.as_ref()));
5927        self
5928    }
5929    /// Identifies the authorization scope(s) for the method you are building.
5930    ///
5931    /// See [`Self::add_scope()`] for details.
5932    pub fn add_scopes<I, St>(
5933        mut self,
5934        scopes: I,
5935    ) -> ProjectDatabaseCollectionGroupFieldGetCall<'a, C>
5936    where
5937        I: IntoIterator<Item = St>,
5938        St: AsRef<str>,
5939    {
5940        self._scopes
5941            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5942        self
5943    }
5944
5945    /// Removes all scopes, and no default scope will be used either.
5946    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5947    /// for details).
5948    pub fn clear_scopes(mut self) -> ProjectDatabaseCollectionGroupFieldGetCall<'a, C> {
5949        self._scopes.clear();
5950        self
5951    }
5952}
5953
5954/// Lists the field configuration and metadata for this database. Currently, FirestoreAdmin.ListFields only supports listing fields that have been explicitly overridden. To issue this query, call FirestoreAdmin.ListFields with the filter set to `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`.
5955///
5956/// A builder for the *databases.collectionGroups.fields.list* method supported by a *project* resource.
5957/// It is not used directly, but through a [`ProjectMethods`] instance.
5958///
5959/// # Example
5960///
5961/// Instantiate a resource method builder
5962///
5963/// ```test_harness,no_run
5964/// # extern crate hyper;
5965/// # extern crate hyper_rustls;
5966/// # extern crate google_firestore1 as firestore1;
5967/// # async fn dox() {
5968/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5969///
5970/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5971/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5972/// #     .with_native_roots()
5973/// #     .unwrap()
5974/// #     .https_only()
5975/// #     .enable_http2()
5976/// #     .build();
5977///
5978/// # let executor = hyper_util::rt::TokioExecutor::new();
5979/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5980/// #     secret,
5981/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5982/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5983/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5984/// #     ),
5985/// # ).build().await.unwrap();
5986///
5987/// # let client = hyper_util::client::legacy::Client::builder(
5988/// #     hyper_util::rt::TokioExecutor::new()
5989/// # )
5990/// # .build(
5991/// #     hyper_rustls::HttpsConnectorBuilder::new()
5992/// #         .with_native_roots()
5993/// #         .unwrap()
5994/// #         .https_or_http()
5995/// #         .enable_http2()
5996/// #         .build()
5997/// # );
5998/// # let mut hub = Firestore::new(client, auth);
5999/// // You can configure optional parameters by calling the respective setters at will, and
6000/// // execute the final call using `doit()`.
6001/// // Values shown here are possibly random and not representative !
6002/// let result = hub.projects().databases_collection_groups_fields_list("parent")
6003///              .page_token("amet.")
6004///              .page_size(-20)
6005///              .filter("ipsum")
6006///              .doit().await;
6007/// # }
6008/// ```
6009pub struct ProjectDatabaseCollectionGroupFieldListCall<'a, C>
6010where
6011    C: 'a,
6012{
6013    hub: &'a Firestore<C>,
6014    _parent: String,
6015    _page_token: Option<String>,
6016    _page_size: Option<i32>,
6017    _filter: Option<String>,
6018    _delegate: Option<&'a mut dyn common::Delegate>,
6019    _additional_params: HashMap<String, String>,
6020    _scopes: BTreeSet<String>,
6021}
6022
6023impl<'a, C> common::CallBuilder for ProjectDatabaseCollectionGroupFieldListCall<'a, C> {}
6024
6025impl<'a, C> ProjectDatabaseCollectionGroupFieldListCall<'a, C>
6026where
6027    C: common::Connector,
6028{
6029    /// Perform the operation you have build so far.
6030    pub async fn doit(
6031        mut self,
6032    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1ListFieldsResponse)> {
6033        use std::borrow::Cow;
6034        use std::io::{Read, Seek};
6035
6036        use common::{url::Params, ToParts};
6037        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6038
6039        let mut dd = common::DefaultDelegate;
6040        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6041        dlg.begin(common::MethodInfo {
6042            id: "firestore.projects.databases.collectionGroups.fields.list",
6043            http_method: hyper::Method::GET,
6044        });
6045
6046        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
6047            if self._additional_params.contains_key(field) {
6048                dlg.finished(false);
6049                return Err(common::Error::FieldClash(field));
6050            }
6051        }
6052
6053        let mut params = Params::with_capacity(6 + self._additional_params.len());
6054        params.push("parent", self._parent);
6055        if let Some(value) = self._page_token.as_ref() {
6056            params.push("pageToken", value);
6057        }
6058        if let Some(value) = self._page_size.as_ref() {
6059            params.push("pageSize", value.to_string());
6060        }
6061        if let Some(value) = self._filter.as_ref() {
6062            params.push("filter", value);
6063        }
6064
6065        params.extend(self._additional_params.iter());
6066
6067        params.push("alt", "json");
6068        let mut url = self.hub._base_url.clone() + "v1/{+parent}/fields";
6069        if self._scopes.is_empty() {
6070            self._scopes
6071                .insert(Scope::CloudPlatform.as_ref().to_string());
6072        }
6073
6074        #[allow(clippy::single_element_loop)]
6075        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6076            url = params.uri_replacement(url, param_name, find_this, true);
6077        }
6078        {
6079            let to_remove = ["parent"];
6080            params.remove_params(&to_remove);
6081        }
6082
6083        let url = params.parse_with_url(&url);
6084
6085        loop {
6086            let token = match self
6087                .hub
6088                .auth
6089                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6090                .await
6091            {
6092                Ok(token) => token,
6093                Err(e) => match dlg.token(e) {
6094                    Ok(token) => token,
6095                    Err(e) => {
6096                        dlg.finished(false);
6097                        return Err(common::Error::MissingToken(e));
6098                    }
6099                },
6100            };
6101            let mut req_result = {
6102                let client = &self.hub.client;
6103                dlg.pre_request();
6104                let mut req_builder = hyper::Request::builder()
6105                    .method(hyper::Method::GET)
6106                    .uri(url.as_str())
6107                    .header(USER_AGENT, self.hub._user_agent.clone());
6108
6109                if let Some(token) = token.as_ref() {
6110                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6111                }
6112
6113                let request = req_builder
6114                    .header(CONTENT_LENGTH, 0_u64)
6115                    .body(common::to_body::<String>(None));
6116
6117                client.request(request.unwrap()).await
6118            };
6119
6120            match req_result {
6121                Err(err) => {
6122                    if let common::Retry::After(d) = dlg.http_error(&err) {
6123                        sleep(d).await;
6124                        continue;
6125                    }
6126                    dlg.finished(false);
6127                    return Err(common::Error::HttpError(err));
6128                }
6129                Ok(res) => {
6130                    let (mut parts, body) = res.into_parts();
6131                    let mut body = common::Body::new(body);
6132                    if !parts.status.is_success() {
6133                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6134                        let error = serde_json::from_str(&common::to_string(&bytes));
6135                        let response = common::to_response(parts, bytes.into());
6136
6137                        if let common::Retry::After(d) =
6138                            dlg.http_failure(&response, error.as_ref().ok())
6139                        {
6140                            sleep(d).await;
6141                            continue;
6142                        }
6143
6144                        dlg.finished(false);
6145
6146                        return Err(match error {
6147                            Ok(value) => common::Error::BadRequest(value),
6148                            _ => common::Error::Failure(response),
6149                        });
6150                    }
6151                    let response = {
6152                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6153                        let encoded = common::to_string(&bytes);
6154                        match serde_json::from_str(&encoded) {
6155                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6156                            Err(error) => {
6157                                dlg.response_json_decode_error(&encoded, &error);
6158                                return Err(common::Error::JsonDecodeError(
6159                                    encoded.to_string(),
6160                                    error,
6161                                ));
6162                            }
6163                        }
6164                    };
6165
6166                    dlg.finished(true);
6167                    return Ok(response);
6168                }
6169            }
6170        }
6171    }
6172
6173    /// Required. A parent name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
6174    ///
6175    /// Sets the *parent* path property to the given value.
6176    ///
6177    /// Even though the property as already been set when instantiating this call,
6178    /// we provide this method for API completeness.
6179    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C> {
6180        self._parent = new_value.to_string();
6181        self
6182    }
6183    /// A page token, returned from a previous call to FirestoreAdmin.ListFields, that may be used to get the next page of results.
6184    ///
6185    /// Sets the *page token* query property to the given value.
6186    pub fn page_token(
6187        mut self,
6188        new_value: &str,
6189    ) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C> {
6190        self._page_token = Some(new_value.to_string());
6191        self
6192    }
6193    /// The number of results to return.
6194    ///
6195    /// Sets the *page size* query property to the given value.
6196    pub fn page_size(
6197        mut self,
6198        new_value: i32,
6199    ) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C> {
6200        self._page_size = Some(new_value);
6201        self
6202    }
6203    /// The filter to apply to list results. Currently, FirestoreAdmin.ListFields only supports listing fields that have been explicitly overridden. To issue this query, call FirestoreAdmin.ListFields with a filter that includes `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`.
6204    ///
6205    /// Sets the *filter* query property to the given value.
6206    pub fn filter(mut self, new_value: &str) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C> {
6207        self._filter = Some(new_value.to_string());
6208        self
6209    }
6210    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6211    /// while executing the actual API request.
6212    ///
6213    /// ````text
6214    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6215    /// ````
6216    ///
6217    /// Sets the *delegate* property to the given value.
6218    pub fn delegate(
6219        mut self,
6220        new_value: &'a mut dyn common::Delegate,
6221    ) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C> {
6222        self._delegate = Some(new_value);
6223        self
6224    }
6225
6226    /// Set any additional parameter of the query string used in the request.
6227    /// It should be used to set parameters which are not yet available through their own
6228    /// setters.
6229    ///
6230    /// Please note that this method must not be used to set any of the known parameters
6231    /// which have their own setter method. If done anyway, the request will fail.
6232    ///
6233    /// # Additional Parameters
6234    ///
6235    /// * *$.xgafv* (query-string) - V1 error format.
6236    /// * *access_token* (query-string) - OAuth access token.
6237    /// * *alt* (query-string) - Data format for response.
6238    /// * *callback* (query-string) - JSONP
6239    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6240    /// * *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.
6241    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6242    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6243    /// * *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.
6244    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6245    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6246    pub fn param<T>(
6247        mut self,
6248        name: T,
6249        value: T,
6250    ) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C>
6251    where
6252        T: AsRef<str>,
6253    {
6254        self._additional_params
6255            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6256        self
6257    }
6258
6259    /// Identifies the authorization scope for the method you are building.
6260    ///
6261    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6262    /// [`Scope::CloudPlatform`].
6263    ///
6264    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6265    /// tokens for more than one scope.
6266    ///
6267    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6268    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6269    /// sufficient, a read-write scope will do as well.
6270    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C>
6271    where
6272        St: AsRef<str>,
6273    {
6274        self._scopes.insert(String::from(scope.as_ref()));
6275        self
6276    }
6277    /// Identifies the authorization scope(s) for the method you are building.
6278    ///
6279    /// See [`Self::add_scope()`] for details.
6280    pub fn add_scopes<I, St>(
6281        mut self,
6282        scopes: I,
6283    ) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C>
6284    where
6285        I: IntoIterator<Item = St>,
6286        St: AsRef<str>,
6287    {
6288        self._scopes
6289            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6290        self
6291    }
6292
6293    /// Removes all scopes, and no default scope will be used either.
6294    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6295    /// for details).
6296    pub fn clear_scopes(mut self) -> ProjectDatabaseCollectionGroupFieldListCall<'a, C> {
6297        self._scopes.clear();
6298        self
6299    }
6300}
6301
6302/// Updates a field configuration. Currently, field updates apply only to single field index configuration. However, calls to FirestoreAdmin.UpdateField should provide a field mask to avoid changing any configuration that the caller isn't aware of. The field mask should be specified as: `{ paths: "index_config" }`. This call returns a google.longrunning.Operation which may be used to track the status of the field update. The metadata for the operation will be the type FieldOperationMetadata. To configure the default field settings for the database, use the special `Field` with resource name: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
6303///
6304/// A builder for the *databases.collectionGroups.fields.patch* method supported by a *project* resource.
6305/// It is not used directly, but through a [`ProjectMethods`] instance.
6306///
6307/// # Example
6308///
6309/// Instantiate a resource method builder
6310///
6311/// ```test_harness,no_run
6312/// # extern crate hyper;
6313/// # extern crate hyper_rustls;
6314/// # extern crate google_firestore1 as firestore1;
6315/// use firestore1::api::GoogleFirestoreAdminV1Field;
6316/// # async fn dox() {
6317/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6318///
6319/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6320/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6321/// #     .with_native_roots()
6322/// #     .unwrap()
6323/// #     .https_only()
6324/// #     .enable_http2()
6325/// #     .build();
6326///
6327/// # let executor = hyper_util::rt::TokioExecutor::new();
6328/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6329/// #     secret,
6330/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6331/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6332/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6333/// #     ),
6334/// # ).build().await.unwrap();
6335///
6336/// # let client = hyper_util::client::legacy::Client::builder(
6337/// #     hyper_util::rt::TokioExecutor::new()
6338/// # )
6339/// # .build(
6340/// #     hyper_rustls::HttpsConnectorBuilder::new()
6341/// #         .with_native_roots()
6342/// #         .unwrap()
6343/// #         .https_or_http()
6344/// #         .enable_http2()
6345/// #         .build()
6346/// # );
6347/// # let mut hub = Firestore::new(client, auth);
6348/// // As the method needs a request, you would usually fill it with the desired information
6349/// // into the respective structure. Some of the parts shown here might not be applicable !
6350/// // Values shown here are possibly random and not representative !
6351/// let mut req = GoogleFirestoreAdminV1Field::default();
6352///
6353/// // You can configure optional parameters by calling the respective setters at will, and
6354/// // execute the final call using `doit()`.
6355/// // Values shown here are possibly random and not representative !
6356/// let result = hub.projects().databases_collection_groups_fields_patch(req, "name")
6357///              .update_mask(FieldMask::new::<&str>(&[]))
6358///              .doit().await;
6359/// # }
6360/// ```
6361pub struct ProjectDatabaseCollectionGroupFieldPatchCall<'a, C>
6362where
6363    C: 'a,
6364{
6365    hub: &'a Firestore<C>,
6366    _request: GoogleFirestoreAdminV1Field,
6367    _name: String,
6368    _update_mask: Option<common::FieldMask>,
6369    _delegate: Option<&'a mut dyn common::Delegate>,
6370    _additional_params: HashMap<String, String>,
6371    _scopes: BTreeSet<String>,
6372}
6373
6374impl<'a, C> common::CallBuilder for ProjectDatabaseCollectionGroupFieldPatchCall<'a, C> {}
6375
6376impl<'a, C> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C>
6377where
6378    C: common::Connector,
6379{
6380    /// Perform the operation you have build so far.
6381    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6382        use std::borrow::Cow;
6383        use std::io::{Read, Seek};
6384
6385        use common::{url::Params, ToParts};
6386        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6387
6388        let mut dd = common::DefaultDelegate;
6389        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6390        dlg.begin(common::MethodInfo {
6391            id: "firestore.projects.databases.collectionGroups.fields.patch",
6392            http_method: hyper::Method::PATCH,
6393        });
6394
6395        for &field in ["alt", "name", "updateMask"].iter() {
6396            if self._additional_params.contains_key(field) {
6397                dlg.finished(false);
6398                return Err(common::Error::FieldClash(field));
6399            }
6400        }
6401
6402        let mut params = Params::with_capacity(5 + self._additional_params.len());
6403        params.push("name", self._name);
6404        if let Some(value) = self._update_mask.as_ref() {
6405            params.push("updateMask", value.to_string());
6406        }
6407
6408        params.extend(self._additional_params.iter());
6409
6410        params.push("alt", "json");
6411        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6412        if self._scopes.is_empty() {
6413            self._scopes
6414                .insert(Scope::CloudPlatform.as_ref().to_string());
6415        }
6416
6417        #[allow(clippy::single_element_loop)]
6418        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6419            url = params.uri_replacement(url, param_name, find_this, true);
6420        }
6421        {
6422            let to_remove = ["name"];
6423            params.remove_params(&to_remove);
6424        }
6425
6426        let url = params.parse_with_url(&url);
6427
6428        let mut json_mime_type = mime::APPLICATION_JSON;
6429        let mut request_value_reader = {
6430            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6431            common::remove_json_null_values(&mut value);
6432            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6433            serde_json::to_writer(&mut dst, &value).unwrap();
6434            dst
6435        };
6436        let request_size = request_value_reader
6437            .seek(std::io::SeekFrom::End(0))
6438            .unwrap();
6439        request_value_reader
6440            .seek(std::io::SeekFrom::Start(0))
6441            .unwrap();
6442
6443        loop {
6444            let token = match self
6445                .hub
6446                .auth
6447                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6448                .await
6449            {
6450                Ok(token) => token,
6451                Err(e) => match dlg.token(e) {
6452                    Ok(token) => token,
6453                    Err(e) => {
6454                        dlg.finished(false);
6455                        return Err(common::Error::MissingToken(e));
6456                    }
6457                },
6458            };
6459            request_value_reader
6460                .seek(std::io::SeekFrom::Start(0))
6461                .unwrap();
6462            let mut req_result = {
6463                let client = &self.hub.client;
6464                dlg.pre_request();
6465                let mut req_builder = hyper::Request::builder()
6466                    .method(hyper::Method::PATCH)
6467                    .uri(url.as_str())
6468                    .header(USER_AGENT, self.hub._user_agent.clone());
6469
6470                if let Some(token) = token.as_ref() {
6471                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6472                }
6473
6474                let request = req_builder
6475                    .header(CONTENT_TYPE, json_mime_type.to_string())
6476                    .header(CONTENT_LENGTH, request_size as u64)
6477                    .body(common::to_body(
6478                        request_value_reader.get_ref().clone().into(),
6479                    ));
6480
6481                client.request(request.unwrap()).await
6482            };
6483
6484            match req_result {
6485                Err(err) => {
6486                    if let common::Retry::After(d) = dlg.http_error(&err) {
6487                        sleep(d).await;
6488                        continue;
6489                    }
6490                    dlg.finished(false);
6491                    return Err(common::Error::HttpError(err));
6492                }
6493                Ok(res) => {
6494                    let (mut parts, body) = res.into_parts();
6495                    let mut body = common::Body::new(body);
6496                    if !parts.status.is_success() {
6497                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6498                        let error = serde_json::from_str(&common::to_string(&bytes));
6499                        let response = common::to_response(parts, bytes.into());
6500
6501                        if let common::Retry::After(d) =
6502                            dlg.http_failure(&response, error.as_ref().ok())
6503                        {
6504                            sleep(d).await;
6505                            continue;
6506                        }
6507
6508                        dlg.finished(false);
6509
6510                        return Err(match error {
6511                            Ok(value) => common::Error::BadRequest(value),
6512                            _ => common::Error::Failure(response),
6513                        });
6514                    }
6515                    let response = {
6516                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6517                        let encoded = common::to_string(&bytes);
6518                        match serde_json::from_str(&encoded) {
6519                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6520                            Err(error) => {
6521                                dlg.response_json_decode_error(&encoded, &error);
6522                                return Err(common::Error::JsonDecodeError(
6523                                    encoded.to_string(),
6524                                    error,
6525                                ));
6526                            }
6527                        }
6528                    };
6529
6530                    dlg.finished(true);
6531                    return Ok(response);
6532                }
6533            }
6534        }
6535    }
6536
6537    ///
6538    /// Sets the *request* property to the given value.
6539    ///
6540    /// Even though the property as already been set when instantiating this call,
6541    /// we provide this method for API completeness.
6542    pub fn request(
6543        mut self,
6544        new_value: GoogleFirestoreAdminV1Field,
6545    ) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C> {
6546        self._request = new_value;
6547        self
6548    }
6549    /// Required. A field name of the form: `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` A field path can be a simple field name, e.g. `address` or a path to fields within `map_value` , e.g. `address.city`, or a special field path. The only valid special field is `*`, which represents any field. Field paths can be quoted using `` ` `` (backtick). The only character that must be escaped within a quoted field path is the backtick character itself, escaped using a backslash. Special characters in field paths that must be quoted include: `*`, `.`, `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters. Examples: `` `address.city` `` represents a field named `address.city`, not the map key `city` in the field `address`. `` `*` `` represents a field named `*`, not any field. A special `Field` contains the default indexing settings for all fields. This field's resource name is: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*` Indexes defined on this `Field` will be applied to all fields which do not have their own `Field` index configuration.
6550    ///
6551    /// Sets the *name* path property to the given value.
6552    ///
6553    /// Even though the property as already been set when instantiating this call,
6554    /// we provide this method for API completeness.
6555    pub fn name(mut self, new_value: &str) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C> {
6556        self._name = new_value.to_string();
6557        self
6558    }
6559    /// A mask, relative to the field. If specified, only configuration specified by this field_mask will be updated in the field.
6560    ///
6561    /// Sets the *update mask* query property to the given value.
6562    pub fn update_mask(
6563        mut self,
6564        new_value: common::FieldMask,
6565    ) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C> {
6566        self._update_mask = Some(new_value);
6567        self
6568    }
6569    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6570    /// while executing the actual API request.
6571    ///
6572    /// ````text
6573    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6574    /// ````
6575    ///
6576    /// Sets the *delegate* property to the given value.
6577    pub fn delegate(
6578        mut self,
6579        new_value: &'a mut dyn common::Delegate,
6580    ) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C> {
6581        self._delegate = Some(new_value);
6582        self
6583    }
6584
6585    /// Set any additional parameter of the query string used in the request.
6586    /// It should be used to set parameters which are not yet available through their own
6587    /// setters.
6588    ///
6589    /// Please note that this method must not be used to set any of the known parameters
6590    /// which have their own setter method. If done anyway, the request will fail.
6591    ///
6592    /// # Additional Parameters
6593    ///
6594    /// * *$.xgafv* (query-string) - V1 error format.
6595    /// * *access_token* (query-string) - OAuth access token.
6596    /// * *alt* (query-string) - Data format for response.
6597    /// * *callback* (query-string) - JSONP
6598    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6599    /// * *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.
6600    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6601    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6602    /// * *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.
6603    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6604    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6605    pub fn param<T>(
6606        mut self,
6607        name: T,
6608        value: T,
6609    ) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C>
6610    where
6611        T: AsRef<str>,
6612    {
6613        self._additional_params
6614            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6615        self
6616    }
6617
6618    /// Identifies the authorization scope for the method you are building.
6619    ///
6620    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6621    /// [`Scope::CloudPlatform`].
6622    ///
6623    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6624    /// tokens for more than one scope.
6625    ///
6626    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6627    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6628    /// sufficient, a read-write scope will do as well.
6629    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C>
6630    where
6631        St: AsRef<str>,
6632    {
6633        self._scopes.insert(String::from(scope.as_ref()));
6634        self
6635    }
6636    /// Identifies the authorization scope(s) for the method you are building.
6637    ///
6638    /// See [`Self::add_scope()`] for details.
6639    pub fn add_scopes<I, St>(
6640        mut self,
6641        scopes: I,
6642    ) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C>
6643    where
6644        I: IntoIterator<Item = St>,
6645        St: AsRef<str>,
6646    {
6647        self._scopes
6648            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6649        self
6650    }
6651
6652    /// Removes all scopes, and no default scope will be used either.
6653    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6654    /// for details).
6655    pub fn clear_scopes(mut self) -> ProjectDatabaseCollectionGroupFieldPatchCall<'a, C> {
6656        self._scopes.clear();
6657        self
6658    }
6659}
6660
6661/// Creates a composite index. This returns a google.longrunning.Operation which may be used to track the status of the creation. The metadata for the operation will be the type IndexOperationMetadata.
6662///
6663/// A builder for the *databases.collectionGroups.indexes.create* method supported by a *project* resource.
6664/// It is not used directly, but through a [`ProjectMethods`] instance.
6665///
6666/// # Example
6667///
6668/// Instantiate a resource method builder
6669///
6670/// ```test_harness,no_run
6671/// # extern crate hyper;
6672/// # extern crate hyper_rustls;
6673/// # extern crate google_firestore1 as firestore1;
6674/// use firestore1::api::GoogleFirestoreAdminV1Index;
6675/// # async fn dox() {
6676/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6677///
6678/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6679/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6680/// #     .with_native_roots()
6681/// #     .unwrap()
6682/// #     .https_only()
6683/// #     .enable_http2()
6684/// #     .build();
6685///
6686/// # let executor = hyper_util::rt::TokioExecutor::new();
6687/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6688/// #     secret,
6689/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6690/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6691/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6692/// #     ),
6693/// # ).build().await.unwrap();
6694///
6695/// # let client = hyper_util::client::legacy::Client::builder(
6696/// #     hyper_util::rt::TokioExecutor::new()
6697/// # )
6698/// # .build(
6699/// #     hyper_rustls::HttpsConnectorBuilder::new()
6700/// #         .with_native_roots()
6701/// #         .unwrap()
6702/// #         .https_or_http()
6703/// #         .enable_http2()
6704/// #         .build()
6705/// # );
6706/// # let mut hub = Firestore::new(client, auth);
6707/// // As the method needs a request, you would usually fill it with the desired information
6708/// // into the respective structure. Some of the parts shown here might not be applicable !
6709/// // Values shown here are possibly random and not representative !
6710/// let mut req = GoogleFirestoreAdminV1Index::default();
6711///
6712/// // You can configure optional parameters by calling the respective setters at will, and
6713/// // execute the final call using `doit()`.
6714/// // Values shown here are possibly random and not representative !
6715/// let result = hub.projects().databases_collection_groups_indexes_create(req, "parent")
6716///              .doit().await;
6717/// # }
6718/// ```
6719pub struct ProjectDatabaseCollectionGroupIndexCreateCall<'a, C>
6720where
6721    C: 'a,
6722{
6723    hub: &'a Firestore<C>,
6724    _request: GoogleFirestoreAdminV1Index,
6725    _parent: String,
6726    _delegate: Option<&'a mut dyn common::Delegate>,
6727    _additional_params: HashMap<String, String>,
6728    _scopes: BTreeSet<String>,
6729}
6730
6731impl<'a, C> common::CallBuilder for ProjectDatabaseCollectionGroupIndexCreateCall<'a, C> {}
6732
6733impl<'a, C> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C>
6734where
6735    C: common::Connector,
6736{
6737    /// Perform the operation you have build so far.
6738    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6739        use std::borrow::Cow;
6740        use std::io::{Read, Seek};
6741
6742        use common::{url::Params, ToParts};
6743        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6744
6745        let mut dd = common::DefaultDelegate;
6746        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6747        dlg.begin(common::MethodInfo {
6748            id: "firestore.projects.databases.collectionGroups.indexes.create",
6749            http_method: hyper::Method::POST,
6750        });
6751
6752        for &field in ["alt", "parent"].iter() {
6753            if self._additional_params.contains_key(field) {
6754                dlg.finished(false);
6755                return Err(common::Error::FieldClash(field));
6756            }
6757        }
6758
6759        let mut params = Params::with_capacity(4 + self._additional_params.len());
6760        params.push("parent", self._parent);
6761
6762        params.extend(self._additional_params.iter());
6763
6764        params.push("alt", "json");
6765        let mut url = self.hub._base_url.clone() + "v1/{+parent}/indexes";
6766        if self._scopes.is_empty() {
6767            self._scopes
6768                .insert(Scope::CloudPlatform.as_ref().to_string());
6769        }
6770
6771        #[allow(clippy::single_element_loop)]
6772        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6773            url = params.uri_replacement(url, param_name, find_this, true);
6774        }
6775        {
6776            let to_remove = ["parent"];
6777            params.remove_params(&to_remove);
6778        }
6779
6780        let url = params.parse_with_url(&url);
6781
6782        let mut json_mime_type = mime::APPLICATION_JSON;
6783        let mut request_value_reader = {
6784            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6785            common::remove_json_null_values(&mut value);
6786            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6787            serde_json::to_writer(&mut dst, &value).unwrap();
6788            dst
6789        };
6790        let request_size = request_value_reader
6791            .seek(std::io::SeekFrom::End(0))
6792            .unwrap();
6793        request_value_reader
6794            .seek(std::io::SeekFrom::Start(0))
6795            .unwrap();
6796
6797        loop {
6798            let token = match self
6799                .hub
6800                .auth
6801                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6802                .await
6803            {
6804                Ok(token) => token,
6805                Err(e) => match dlg.token(e) {
6806                    Ok(token) => token,
6807                    Err(e) => {
6808                        dlg.finished(false);
6809                        return Err(common::Error::MissingToken(e));
6810                    }
6811                },
6812            };
6813            request_value_reader
6814                .seek(std::io::SeekFrom::Start(0))
6815                .unwrap();
6816            let mut req_result = {
6817                let client = &self.hub.client;
6818                dlg.pre_request();
6819                let mut req_builder = hyper::Request::builder()
6820                    .method(hyper::Method::POST)
6821                    .uri(url.as_str())
6822                    .header(USER_AGENT, self.hub._user_agent.clone());
6823
6824                if let Some(token) = token.as_ref() {
6825                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6826                }
6827
6828                let request = req_builder
6829                    .header(CONTENT_TYPE, json_mime_type.to_string())
6830                    .header(CONTENT_LENGTH, request_size as u64)
6831                    .body(common::to_body(
6832                        request_value_reader.get_ref().clone().into(),
6833                    ));
6834
6835                client.request(request.unwrap()).await
6836            };
6837
6838            match req_result {
6839                Err(err) => {
6840                    if let common::Retry::After(d) = dlg.http_error(&err) {
6841                        sleep(d).await;
6842                        continue;
6843                    }
6844                    dlg.finished(false);
6845                    return Err(common::Error::HttpError(err));
6846                }
6847                Ok(res) => {
6848                    let (mut parts, body) = res.into_parts();
6849                    let mut body = common::Body::new(body);
6850                    if !parts.status.is_success() {
6851                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6852                        let error = serde_json::from_str(&common::to_string(&bytes));
6853                        let response = common::to_response(parts, bytes.into());
6854
6855                        if let common::Retry::After(d) =
6856                            dlg.http_failure(&response, error.as_ref().ok())
6857                        {
6858                            sleep(d).await;
6859                            continue;
6860                        }
6861
6862                        dlg.finished(false);
6863
6864                        return Err(match error {
6865                            Ok(value) => common::Error::BadRequest(value),
6866                            _ => common::Error::Failure(response),
6867                        });
6868                    }
6869                    let response = {
6870                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6871                        let encoded = common::to_string(&bytes);
6872                        match serde_json::from_str(&encoded) {
6873                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6874                            Err(error) => {
6875                                dlg.response_json_decode_error(&encoded, &error);
6876                                return Err(common::Error::JsonDecodeError(
6877                                    encoded.to_string(),
6878                                    error,
6879                                ));
6880                            }
6881                        }
6882                    };
6883
6884                    dlg.finished(true);
6885                    return Ok(response);
6886                }
6887            }
6888        }
6889    }
6890
6891    ///
6892    /// Sets the *request* property to the given value.
6893    ///
6894    /// Even though the property as already been set when instantiating this call,
6895    /// we provide this method for API completeness.
6896    pub fn request(
6897        mut self,
6898        new_value: GoogleFirestoreAdminV1Index,
6899    ) -> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C> {
6900        self._request = new_value;
6901        self
6902    }
6903    /// Required. A parent name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
6904    ///
6905    /// Sets the *parent* path property to the given value.
6906    ///
6907    /// Even though the property as already been set when instantiating this call,
6908    /// we provide this method for API completeness.
6909    pub fn parent(
6910        mut self,
6911        new_value: &str,
6912    ) -> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C> {
6913        self._parent = new_value.to_string();
6914        self
6915    }
6916    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6917    /// while executing the actual API request.
6918    ///
6919    /// ````text
6920    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6921    /// ````
6922    ///
6923    /// Sets the *delegate* property to the given value.
6924    pub fn delegate(
6925        mut self,
6926        new_value: &'a mut dyn common::Delegate,
6927    ) -> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C> {
6928        self._delegate = Some(new_value);
6929        self
6930    }
6931
6932    /// Set any additional parameter of the query string used in the request.
6933    /// It should be used to set parameters which are not yet available through their own
6934    /// setters.
6935    ///
6936    /// Please note that this method must not be used to set any of the known parameters
6937    /// which have their own setter method. If done anyway, the request will fail.
6938    ///
6939    /// # Additional Parameters
6940    ///
6941    /// * *$.xgafv* (query-string) - V1 error format.
6942    /// * *access_token* (query-string) - OAuth access token.
6943    /// * *alt* (query-string) - Data format for response.
6944    /// * *callback* (query-string) - JSONP
6945    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6946    /// * *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.
6947    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6948    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6949    /// * *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.
6950    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6951    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6952    pub fn param<T>(
6953        mut self,
6954        name: T,
6955        value: T,
6956    ) -> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C>
6957    where
6958        T: AsRef<str>,
6959    {
6960        self._additional_params
6961            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6962        self
6963    }
6964
6965    /// Identifies the authorization scope for the method you are building.
6966    ///
6967    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6968    /// [`Scope::CloudPlatform`].
6969    ///
6970    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6971    /// tokens for more than one scope.
6972    ///
6973    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6974    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6975    /// sufficient, a read-write scope will do as well.
6976    pub fn add_scope<St>(
6977        mut self,
6978        scope: St,
6979    ) -> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C>
6980    where
6981        St: AsRef<str>,
6982    {
6983        self._scopes.insert(String::from(scope.as_ref()));
6984        self
6985    }
6986    /// Identifies the authorization scope(s) for the method you are building.
6987    ///
6988    /// See [`Self::add_scope()`] for details.
6989    pub fn add_scopes<I, St>(
6990        mut self,
6991        scopes: I,
6992    ) -> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C>
6993    where
6994        I: IntoIterator<Item = St>,
6995        St: AsRef<str>,
6996    {
6997        self._scopes
6998            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6999        self
7000    }
7001
7002    /// Removes all scopes, and no default scope will be used either.
7003    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7004    /// for details).
7005    pub fn clear_scopes(mut self) -> ProjectDatabaseCollectionGroupIndexCreateCall<'a, C> {
7006        self._scopes.clear();
7007        self
7008    }
7009}
7010
7011/// Deletes a composite index.
7012///
7013/// A builder for the *databases.collectionGroups.indexes.delete* method supported by a *project* resource.
7014/// It is not used directly, but through a [`ProjectMethods`] instance.
7015///
7016/// # Example
7017///
7018/// Instantiate a resource method builder
7019///
7020/// ```test_harness,no_run
7021/// # extern crate hyper;
7022/// # extern crate hyper_rustls;
7023/// # extern crate google_firestore1 as firestore1;
7024/// # async fn dox() {
7025/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7026///
7027/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7028/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7029/// #     .with_native_roots()
7030/// #     .unwrap()
7031/// #     .https_only()
7032/// #     .enable_http2()
7033/// #     .build();
7034///
7035/// # let executor = hyper_util::rt::TokioExecutor::new();
7036/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7037/// #     secret,
7038/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7039/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7040/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7041/// #     ),
7042/// # ).build().await.unwrap();
7043///
7044/// # let client = hyper_util::client::legacy::Client::builder(
7045/// #     hyper_util::rt::TokioExecutor::new()
7046/// # )
7047/// # .build(
7048/// #     hyper_rustls::HttpsConnectorBuilder::new()
7049/// #         .with_native_roots()
7050/// #         .unwrap()
7051/// #         .https_or_http()
7052/// #         .enable_http2()
7053/// #         .build()
7054/// # );
7055/// # let mut hub = Firestore::new(client, auth);
7056/// // You can configure optional parameters by calling the respective setters at will, and
7057/// // execute the final call using `doit()`.
7058/// // Values shown here are possibly random and not representative !
7059/// let result = hub.projects().databases_collection_groups_indexes_delete("name")
7060///              .doit().await;
7061/// # }
7062/// ```
7063pub struct ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C>
7064where
7065    C: 'a,
7066{
7067    hub: &'a Firestore<C>,
7068    _name: String,
7069    _delegate: Option<&'a mut dyn common::Delegate>,
7070    _additional_params: HashMap<String, String>,
7071    _scopes: BTreeSet<String>,
7072}
7073
7074impl<'a, C> common::CallBuilder for ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C> {}
7075
7076impl<'a, C> ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C>
7077where
7078    C: common::Connector,
7079{
7080    /// Perform the operation you have build so far.
7081    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7082        use std::borrow::Cow;
7083        use std::io::{Read, Seek};
7084
7085        use common::{url::Params, ToParts};
7086        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7087
7088        let mut dd = common::DefaultDelegate;
7089        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7090        dlg.begin(common::MethodInfo {
7091            id: "firestore.projects.databases.collectionGroups.indexes.delete",
7092            http_method: hyper::Method::DELETE,
7093        });
7094
7095        for &field in ["alt", "name"].iter() {
7096            if self._additional_params.contains_key(field) {
7097                dlg.finished(false);
7098                return Err(common::Error::FieldClash(field));
7099            }
7100        }
7101
7102        let mut params = Params::with_capacity(3 + self._additional_params.len());
7103        params.push("name", self._name);
7104
7105        params.extend(self._additional_params.iter());
7106
7107        params.push("alt", "json");
7108        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7109        if self._scopes.is_empty() {
7110            self._scopes
7111                .insert(Scope::CloudPlatform.as_ref().to_string());
7112        }
7113
7114        #[allow(clippy::single_element_loop)]
7115        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7116            url = params.uri_replacement(url, param_name, find_this, true);
7117        }
7118        {
7119            let to_remove = ["name"];
7120            params.remove_params(&to_remove);
7121        }
7122
7123        let url = params.parse_with_url(&url);
7124
7125        loop {
7126            let token = match self
7127                .hub
7128                .auth
7129                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7130                .await
7131            {
7132                Ok(token) => token,
7133                Err(e) => match dlg.token(e) {
7134                    Ok(token) => token,
7135                    Err(e) => {
7136                        dlg.finished(false);
7137                        return Err(common::Error::MissingToken(e));
7138                    }
7139                },
7140            };
7141            let mut req_result = {
7142                let client = &self.hub.client;
7143                dlg.pre_request();
7144                let mut req_builder = hyper::Request::builder()
7145                    .method(hyper::Method::DELETE)
7146                    .uri(url.as_str())
7147                    .header(USER_AGENT, self.hub._user_agent.clone());
7148
7149                if let Some(token) = token.as_ref() {
7150                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7151                }
7152
7153                let request = req_builder
7154                    .header(CONTENT_LENGTH, 0_u64)
7155                    .body(common::to_body::<String>(None));
7156
7157                client.request(request.unwrap()).await
7158            };
7159
7160            match req_result {
7161                Err(err) => {
7162                    if let common::Retry::After(d) = dlg.http_error(&err) {
7163                        sleep(d).await;
7164                        continue;
7165                    }
7166                    dlg.finished(false);
7167                    return Err(common::Error::HttpError(err));
7168                }
7169                Ok(res) => {
7170                    let (mut parts, body) = res.into_parts();
7171                    let mut body = common::Body::new(body);
7172                    if !parts.status.is_success() {
7173                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7174                        let error = serde_json::from_str(&common::to_string(&bytes));
7175                        let response = common::to_response(parts, bytes.into());
7176
7177                        if let common::Retry::After(d) =
7178                            dlg.http_failure(&response, error.as_ref().ok())
7179                        {
7180                            sleep(d).await;
7181                            continue;
7182                        }
7183
7184                        dlg.finished(false);
7185
7186                        return Err(match error {
7187                            Ok(value) => common::Error::BadRequest(value),
7188                            _ => common::Error::Failure(response),
7189                        });
7190                    }
7191                    let response = {
7192                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7193                        let encoded = common::to_string(&bytes);
7194                        match serde_json::from_str(&encoded) {
7195                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7196                            Err(error) => {
7197                                dlg.response_json_decode_error(&encoded, &error);
7198                                return Err(common::Error::JsonDecodeError(
7199                                    encoded.to_string(),
7200                                    error,
7201                                ));
7202                            }
7203                        }
7204                    };
7205
7206                    dlg.finished(true);
7207                    return Ok(response);
7208                }
7209            }
7210        }
7211    }
7212
7213    /// Required. A name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
7214    ///
7215    /// Sets the *name* path property to the given value.
7216    ///
7217    /// Even though the property as already been set when instantiating this call,
7218    /// we provide this method for API completeness.
7219    pub fn name(mut self, new_value: &str) -> ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C> {
7220        self._name = new_value.to_string();
7221        self
7222    }
7223    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7224    /// while executing the actual API request.
7225    ///
7226    /// ````text
7227    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7228    /// ````
7229    ///
7230    /// Sets the *delegate* property to the given value.
7231    pub fn delegate(
7232        mut self,
7233        new_value: &'a mut dyn common::Delegate,
7234    ) -> ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C> {
7235        self._delegate = Some(new_value);
7236        self
7237    }
7238
7239    /// Set any additional parameter of the query string used in the request.
7240    /// It should be used to set parameters which are not yet available through their own
7241    /// setters.
7242    ///
7243    /// Please note that this method must not be used to set any of the known parameters
7244    /// which have their own setter method. If done anyway, the request will fail.
7245    ///
7246    /// # Additional Parameters
7247    ///
7248    /// * *$.xgafv* (query-string) - V1 error format.
7249    /// * *access_token* (query-string) - OAuth access token.
7250    /// * *alt* (query-string) - Data format for response.
7251    /// * *callback* (query-string) - JSONP
7252    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7253    /// * *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.
7254    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7255    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7256    /// * *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.
7257    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7258    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7259    pub fn param<T>(
7260        mut self,
7261        name: T,
7262        value: T,
7263    ) -> ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C>
7264    where
7265        T: AsRef<str>,
7266    {
7267        self._additional_params
7268            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7269        self
7270    }
7271
7272    /// Identifies the authorization scope for the method you are building.
7273    ///
7274    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7275    /// [`Scope::CloudPlatform`].
7276    ///
7277    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7278    /// tokens for more than one scope.
7279    ///
7280    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7281    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7282    /// sufficient, a read-write scope will do as well.
7283    pub fn add_scope<St>(
7284        mut self,
7285        scope: St,
7286    ) -> ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C>
7287    where
7288        St: AsRef<str>,
7289    {
7290        self._scopes.insert(String::from(scope.as_ref()));
7291        self
7292    }
7293    /// Identifies the authorization scope(s) for the method you are building.
7294    ///
7295    /// See [`Self::add_scope()`] for details.
7296    pub fn add_scopes<I, St>(
7297        mut self,
7298        scopes: I,
7299    ) -> ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C>
7300    where
7301        I: IntoIterator<Item = St>,
7302        St: AsRef<str>,
7303    {
7304        self._scopes
7305            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7306        self
7307    }
7308
7309    /// Removes all scopes, and no default scope will be used either.
7310    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7311    /// for details).
7312    pub fn clear_scopes(mut self) -> ProjectDatabaseCollectionGroupIndexDeleteCall<'a, C> {
7313        self._scopes.clear();
7314        self
7315    }
7316}
7317
7318/// Gets a composite index.
7319///
7320/// A builder for the *databases.collectionGroups.indexes.get* method supported by a *project* resource.
7321/// It is not used directly, but through a [`ProjectMethods`] instance.
7322///
7323/// # Example
7324///
7325/// Instantiate a resource method builder
7326///
7327/// ```test_harness,no_run
7328/// # extern crate hyper;
7329/// # extern crate hyper_rustls;
7330/// # extern crate google_firestore1 as firestore1;
7331/// # async fn dox() {
7332/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7333///
7334/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7335/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7336/// #     .with_native_roots()
7337/// #     .unwrap()
7338/// #     .https_only()
7339/// #     .enable_http2()
7340/// #     .build();
7341///
7342/// # let executor = hyper_util::rt::TokioExecutor::new();
7343/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7344/// #     secret,
7345/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7346/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7347/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7348/// #     ),
7349/// # ).build().await.unwrap();
7350///
7351/// # let client = hyper_util::client::legacy::Client::builder(
7352/// #     hyper_util::rt::TokioExecutor::new()
7353/// # )
7354/// # .build(
7355/// #     hyper_rustls::HttpsConnectorBuilder::new()
7356/// #         .with_native_roots()
7357/// #         .unwrap()
7358/// #         .https_or_http()
7359/// #         .enable_http2()
7360/// #         .build()
7361/// # );
7362/// # let mut hub = Firestore::new(client, auth);
7363/// // You can configure optional parameters by calling the respective setters at will, and
7364/// // execute the final call using `doit()`.
7365/// // Values shown here are possibly random and not representative !
7366/// let result = hub.projects().databases_collection_groups_indexes_get("name")
7367///              .doit().await;
7368/// # }
7369/// ```
7370pub struct ProjectDatabaseCollectionGroupIndexGetCall<'a, C>
7371where
7372    C: 'a,
7373{
7374    hub: &'a Firestore<C>,
7375    _name: String,
7376    _delegate: Option<&'a mut dyn common::Delegate>,
7377    _additional_params: HashMap<String, String>,
7378    _scopes: BTreeSet<String>,
7379}
7380
7381impl<'a, C> common::CallBuilder for ProjectDatabaseCollectionGroupIndexGetCall<'a, C> {}
7382
7383impl<'a, C> ProjectDatabaseCollectionGroupIndexGetCall<'a, C>
7384where
7385    C: common::Connector,
7386{
7387    /// Perform the operation you have build so far.
7388    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleFirestoreAdminV1Index)> {
7389        use std::borrow::Cow;
7390        use std::io::{Read, Seek};
7391
7392        use common::{url::Params, ToParts};
7393        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7394
7395        let mut dd = common::DefaultDelegate;
7396        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7397        dlg.begin(common::MethodInfo {
7398            id: "firestore.projects.databases.collectionGroups.indexes.get",
7399            http_method: hyper::Method::GET,
7400        });
7401
7402        for &field in ["alt", "name"].iter() {
7403            if self._additional_params.contains_key(field) {
7404                dlg.finished(false);
7405                return Err(common::Error::FieldClash(field));
7406            }
7407        }
7408
7409        let mut params = Params::with_capacity(3 + self._additional_params.len());
7410        params.push("name", self._name);
7411
7412        params.extend(self._additional_params.iter());
7413
7414        params.push("alt", "json");
7415        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7416        if self._scopes.is_empty() {
7417            self._scopes
7418                .insert(Scope::CloudPlatform.as_ref().to_string());
7419        }
7420
7421        #[allow(clippy::single_element_loop)]
7422        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7423            url = params.uri_replacement(url, param_name, find_this, true);
7424        }
7425        {
7426            let to_remove = ["name"];
7427            params.remove_params(&to_remove);
7428        }
7429
7430        let url = params.parse_with_url(&url);
7431
7432        loop {
7433            let token = match self
7434                .hub
7435                .auth
7436                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7437                .await
7438            {
7439                Ok(token) => token,
7440                Err(e) => match dlg.token(e) {
7441                    Ok(token) => token,
7442                    Err(e) => {
7443                        dlg.finished(false);
7444                        return Err(common::Error::MissingToken(e));
7445                    }
7446                },
7447            };
7448            let mut req_result = {
7449                let client = &self.hub.client;
7450                dlg.pre_request();
7451                let mut req_builder = hyper::Request::builder()
7452                    .method(hyper::Method::GET)
7453                    .uri(url.as_str())
7454                    .header(USER_AGENT, self.hub._user_agent.clone());
7455
7456                if let Some(token) = token.as_ref() {
7457                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7458                }
7459
7460                let request = req_builder
7461                    .header(CONTENT_LENGTH, 0_u64)
7462                    .body(common::to_body::<String>(None));
7463
7464                client.request(request.unwrap()).await
7465            };
7466
7467            match req_result {
7468                Err(err) => {
7469                    if let common::Retry::After(d) = dlg.http_error(&err) {
7470                        sleep(d).await;
7471                        continue;
7472                    }
7473                    dlg.finished(false);
7474                    return Err(common::Error::HttpError(err));
7475                }
7476                Ok(res) => {
7477                    let (mut parts, body) = res.into_parts();
7478                    let mut body = common::Body::new(body);
7479                    if !parts.status.is_success() {
7480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7481                        let error = serde_json::from_str(&common::to_string(&bytes));
7482                        let response = common::to_response(parts, bytes.into());
7483
7484                        if let common::Retry::After(d) =
7485                            dlg.http_failure(&response, error.as_ref().ok())
7486                        {
7487                            sleep(d).await;
7488                            continue;
7489                        }
7490
7491                        dlg.finished(false);
7492
7493                        return Err(match error {
7494                            Ok(value) => common::Error::BadRequest(value),
7495                            _ => common::Error::Failure(response),
7496                        });
7497                    }
7498                    let response = {
7499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7500                        let encoded = common::to_string(&bytes);
7501                        match serde_json::from_str(&encoded) {
7502                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7503                            Err(error) => {
7504                                dlg.response_json_decode_error(&encoded, &error);
7505                                return Err(common::Error::JsonDecodeError(
7506                                    encoded.to_string(),
7507                                    error,
7508                                ));
7509                            }
7510                        }
7511                    };
7512
7513                    dlg.finished(true);
7514                    return Ok(response);
7515                }
7516            }
7517        }
7518    }
7519
7520    /// Required. A name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
7521    ///
7522    /// Sets the *name* path property to the given value.
7523    ///
7524    /// Even though the property as already been set when instantiating this call,
7525    /// we provide this method for API completeness.
7526    pub fn name(mut self, new_value: &str) -> ProjectDatabaseCollectionGroupIndexGetCall<'a, C> {
7527        self._name = new_value.to_string();
7528        self
7529    }
7530    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7531    /// while executing the actual API request.
7532    ///
7533    /// ````text
7534    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7535    /// ````
7536    ///
7537    /// Sets the *delegate* property to the given value.
7538    pub fn delegate(
7539        mut self,
7540        new_value: &'a mut dyn common::Delegate,
7541    ) -> ProjectDatabaseCollectionGroupIndexGetCall<'a, C> {
7542        self._delegate = Some(new_value);
7543        self
7544    }
7545
7546    /// Set any additional parameter of the query string used in the request.
7547    /// It should be used to set parameters which are not yet available through their own
7548    /// setters.
7549    ///
7550    /// Please note that this method must not be used to set any of the known parameters
7551    /// which have their own setter method. If done anyway, the request will fail.
7552    ///
7553    /// # Additional Parameters
7554    ///
7555    /// * *$.xgafv* (query-string) - V1 error format.
7556    /// * *access_token* (query-string) - OAuth access token.
7557    /// * *alt* (query-string) - Data format for response.
7558    /// * *callback* (query-string) - JSONP
7559    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7560    /// * *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.
7561    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7562    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7563    /// * *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.
7564    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7565    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7566    pub fn param<T>(
7567        mut self,
7568        name: T,
7569        value: T,
7570    ) -> ProjectDatabaseCollectionGroupIndexGetCall<'a, C>
7571    where
7572        T: AsRef<str>,
7573    {
7574        self._additional_params
7575            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7576        self
7577    }
7578
7579    /// Identifies the authorization scope for the method you are building.
7580    ///
7581    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7582    /// [`Scope::CloudPlatform`].
7583    ///
7584    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7585    /// tokens for more than one scope.
7586    ///
7587    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7588    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7589    /// sufficient, a read-write scope will do as well.
7590    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseCollectionGroupIndexGetCall<'a, C>
7591    where
7592        St: AsRef<str>,
7593    {
7594        self._scopes.insert(String::from(scope.as_ref()));
7595        self
7596    }
7597    /// Identifies the authorization scope(s) for the method you are building.
7598    ///
7599    /// See [`Self::add_scope()`] for details.
7600    pub fn add_scopes<I, St>(
7601        mut self,
7602        scopes: I,
7603    ) -> ProjectDatabaseCollectionGroupIndexGetCall<'a, C>
7604    where
7605        I: IntoIterator<Item = St>,
7606        St: AsRef<str>,
7607    {
7608        self._scopes
7609            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7610        self
7611    }
7612
7613    /// Removes all scopes, and no default scope will be used either.
7614    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7615    /// for details).
7616    pub fn clear_scopes(mut self) -> ProjectDatabaseCollectionGroupIndexGetCall<'a, C> {
7617        self._scopes.clear();
7618        self
7619    }
7620}
7621
7622/// Lists composite indexes.
7623///
7624/// A builder for the *databases.collectionGroups.indexes.list* method supported by a *project* resource.
7625/// It is not used directly, but through a [`ProjectMethods`] instance.
7626///
7627/// # Example
7628///
7629/// Instantiate a resource method builder
7630///
7631/// ```test_harness,no_run
7632/// # extern crate hyper;
7633/// # extern crate hyper_rustls;
7634/// # extern crate google_firestore1 as firestore1;
7635/// # async fn dox() {
7636/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7637///
7638/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7639/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7640/// #     .with_native_roots()
7641/// #     .unwrap()
7642/// #     .https_only()
7643/// #     .enable_http2()
7644/// #     .build();
7645///
7646/// # let executor = hyper_util::rt::TokioExecutor::new();
7647/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7648/// #     secret,
7649/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7650/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7651/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7652/// #     ),
7653/// # ).build().await.unwrap();
7654///
7655/// # let client = hyper_util::client::legacy::Client::builder(
7656/// #     hyper_util::rt::TokioExecutor::new()
7657/// # )
7658/// # .build(
7659/// #     hyper_rustls::HttpsConnectorBuilder::new()
7660/// #         .with_native_roots()
7661/// #         .unwrap()
7662/// #         .https_or_http()
7663/// #         .enable_http2()
7664/// #         .build()
7665/// # );
7666/// # let mut hub = Firestore::new(client, auth);
7667/// // You can configure optional parameters by calling the respective setters at will, and
7668/// // execute the final call using `doit()`.
7669/// // Values shown here are possibly random and not representative !
7670/// let result = hub.projects().databases_collection_groups_indexes_list("parent")
7671///              .page_token("ea")
7672///              .page_size(-55)
7673///              .filter("invidunt")
7674///              .doit().await;
7675/// # }
7676/// ```
7677pub struct ProjectDatabaseCollectionGroupIndexListCall<'a, C>
7678where
7679    C: 'a,
7680{
7681    hub: &'a Firestore<C>,
7682    _parent: String,
7683    _page_token: Option<String>,
7684    _page_size: Option<i32>,
7685    _filter: Option<String>,
7686    _delegate: Option<&'a mut dyn common::Delegate>,
7687    _additional_params: HashMap<String, String>,
7688    _scopes: BTreeSet<String>,
7689}
7690
7691impl<'a, C> common::CallBuilder for ProjectDatabaseCollectionGroupIndexListCall<'a, C> {}
7692
7693impl<'a, C> ProjectDatabaseCollectionGroupIndexListCall<'a, C>
7694where
7695    C: common::Connector,
7696{
7697    /// Perform the operation you have build so far.
7698    pub async fn doit(
7699        mut self,
7700    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1ListIndexesResponse)> {
7701        use std::borrow::Cow;
7702        use std::io::{Read, Seek};
7703
7704        use common::{url::Params, ToParts};
7705        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7706
7707        let mut dd = common::DefaultDelegate;
7708        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7709        dlg.begin(common::MethodInfo {
7710            id: "firestore.projects.databases.collectionGroups.indexes.list",
7711            http_method: hyper::Method::GET,
7712        });
7713
7714        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
7715            if self._additional_params.contains_key(field) {
7716                dlg.finished(false);
7717                return Err(common::Error::FieldClash(field));
7718            }
7719        }
7720
7721        let mut params = Params::with_capacity(6 + self._additional_params.len());
7722        params.push("parent", self._parent);
7723        if let Some(value) = self._page_token.as_ref() {
7724            params.push("pageToken", value);
7725        }
7726        if let Some(value) = self._page_size.as_ref() {
7727            params.push("pageSize", value.to_string());
7728        }
7729        if let Some(value) = self._filter.as_ref() {
7730            params.push("filter", value);
7731        }
7732
7733        params.extend(self._additional_params.iter());
7734
7735        params.push("alt", "json");
7736        let mut url = self.hub._base_url.clone() + "v1/{+parent}/indexes";
7737        if self._scopes.is_empty() {
7738            self._scopes
7739                .insert(Scope::CloudPlatform.as_ref().to_string());
7740        }
7741
7742        #[allow(clippy::single_element_loop)]
7743        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7744            url = params.uri_replacement(url, param_name, find_this, true);
7745        }
7746        {
7747            let to_remove = ["parent"];
7748            params.remove_params(&to_remove);
7749        }
7750
7751        let url = params.parse_with_url(&url);
7752
7753        loop {
7754            let token = match self
7755                .hub
7756                .auth
7757                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7758                .await
7759            {
7760                Ok(token) => token,
7761                Err(e) => match dlg.token(e) {
7762                    Ok(token) => token,
7763                    Err(e) => {
7764                        dlg.finished(false);
7765                        return Err(common::Error::MissingToken(e));
7766                    }
7767                },
7768            };
7769            let mut req_result = {
7770                let client = &self.hub.client;
7771                dlg.pre_request();
7772                let mut req_builder = hyper::Request::builder()
7773                    .method(hyper::Method::GET)
7774                    .uri(url.as_str())
7775                    .header(USER_AGENT, self.hub._user_agent.clone());
7776
7777                if let Some(token) = token.as_ref() {
7778                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7779                }
7780
7781                let request = req_builder
7782                    .header(CONTENT_LENGTH, 0_u64)
7783                    .body(common::to_body::<String>(None));
7784
7785                client.request(request.unwrap()).await
7786            };
7787
7788            match req_result {
7789                Err(err) => {
7790                    if let common::Retry::After(d) = dlg.http_error(&err) {
7791                        sleep(d).await;
7792                        continue;
7793                    }
7794                    dlg.finished(false);
7795                    return Err(common::Error::HttpError(err));
7796                }
7797                Ok(res) => {
7798                    let (mut parts, body) = res.into_parts();
7799                    let mut body = common::Body::new(body);
7800                    if !parts.status.is_success() {
7801                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7802                        let error = serde_json::from_str(&common::to_string(&bytes));
7803                        let response = common::to_response(parts, bytes.into());
7804
7805                        if let common::Retry::After(d) =
7806                            dlg.http_failure(&response, error.as_ref().ok())
7807                        {
7808                            sleep(d).await;
7809                            continue;
7810                        }
7811
7812                        dlg.finished(false);
7813
7814                        return Err(match error {
7815                            Ok(value) => common::Error::BadRequest(value),
7816                            _ => common::Error::Failure(response),
7817                        });
7818                    }
7819                    let response = {
7820                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7821                        let encoded = common::to_string(&bytes);
7822                        match serde_json::from_str(&encoded) {
7823                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7824                            Err(error) => {
7825                                dlg.response_json_decode_error(&encoded, &error);
7826                                return Err(common::Error::JsonDecodeError(
7827                                    encoded.to_string(),
7828                                    error,
7829                                ));
7830                            }
7831                        }
7832                    };
7833
7834                    dlg.finished(true);
7835                    return Ok(response);
7836                }
7837            }
7838        }
7839    }
7840
7841    /// Required. A parent name of the form `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
7842    ///
7843    /// Sets the *parent* path property to the given value.
7844    ///
7845    /// Even though the property as already been set when instantiating this call,
7846    /// we provide this method for API completeness.
7847    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C> {
7848        self._parent = new_value.to_string();
7849        self
7850    }
7851    /// A page token, returned from a previous call to FirestoreAdmin.ListIndexes, that may be used to get the next page of results.
7852    ///
7853    /// Sets the *page token* query property to the given value.
7854    pub fn page_token(
7855        mut self,
7856        new_value: &str,
7857    ) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C> {
7858        self._page_token = Some(new_value.to_string());
7859        self
7860    }
7861    /// The number of results to return.
7862    ///
7863    /// Sets the *page size* query property to the given value.
7864    pub fn page_size(
7865        mut self,
7866        new_value: i32,
7867    ) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C> {
7868        self._page_size = Some(new_value);
7869        self
7870    }
7871    /// The filter to apply to list results.
7872    ///
7873    /// Sets the *filter* query property to the given value.
7874    pub fn filter(mut self, new_value: &str) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C> {
7875        self._filter = Some(new_value.to_string());
7876        self
7877    }
7878    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7879    /// while executing the actual API request.
7880    ///
7881    /// ````text
7882    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7883    /// ````
7884    ///
7885    /// Sets the *delegate* property to the given value.
7886    pub fn delegate(
7887        mut self,
7888        new_value: &'a mut dyn common::Delegate,
7889    ) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C> {
7890        self._delegate = Some(new_value);
7891        self
7892    }
7893
7894    /// Set any additional parameter of the query string used in the request.
7895    /// It should be used to set parameters which are not yet available through their own
7896    /// setters.
7897    ///
7898    /// Please note that this method must not be used to set any of the known parameters
7899    /// which have their own setter method. If done anyway, the request will fail.
7900    ///
7901    /// # Additional Parameters
7902    ///
7903    /// * *$.xgafv* (query-string) - V1 error format.
7904    /// * *access_token* (query-string) - OAuth access token.
7905    /// * *alt* (query-string) - Data format for response.
7906    /// * *callback* (query-string) - JSONP
7907    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7908    /// * *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.
7909    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7910    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7911    /// * *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.
7912    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7913    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7914    pub fn param<T>(
7915        mut self,
7916        name: T,
7917        value: T,
7918    ) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C>
7919    where
7920        T: AsRef<str>,
7921    {
7922        self._additional_params
7923            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7924        self
7925    }
7926
7927    /// Identifies the authorization scope for the method you are building.
7928    ///
7929    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7930    /// [`Scope::CloudPlatform`].
7931    ///
7932    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7933    /// tokens for more than one scope.
7934    ///
7935    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7936    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7937    /// sufficient, a read-write scope will do as well.
7938    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C>
7939    where
7940        St: AsRef<str>,
7941    {
7942        self._scopes.insert(String::from(scope.as_ref()));
7943        self
7944    }
7945    /// Identifies the authorization scope(s) for the method you are building.
7946    ///
7947    /// See [`Self::add_scope()`] for details.
7948    pub fn add_scopes<I, St>(
7949        mut self,
7950        scopes: I,
7951    ) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C>
7952    where
7953        I: IntoIterator<Item = St>,
7954        St: AsRef<str>,
7955    {
7956        self._scopes
7957            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7958        self
7959    }
7960
7961    /// Removes all scopes, and no default scope will be used either.
7962    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7963    /// for details).
7964    pub fn clear_scopes(mut self) -> ProjectDatabaseCollectionGroupIndexListCall<'a, C> {
7965        self._scopes.clear();
7966        self
7967    }
7968}
7969
7970/// Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
7971///
7972/// A builder for the *databases.documents.batchGet* method supported by a *project* resource.
7973/// It is not used directly, but through a [`ProjectMethods`] instance.
7974///
7975/// # Example
7976///
7977/// Instantiate a resource method builder
7978///
7979/// ```test_harness,no_run
7980/// # extern crate hyper;
7981/// # extern crate hyper_rustls;
7982/// # extern crate google_firestore1 as firestore1;
7983/// use firestore1::api::BatchGetDocumentsRequest;
7984/// # async fn dox() {
7985/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7986///
7987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7988/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7989/// #     .with_native_roots()
7990/// #     .unwrap()
7991/// #     .https_only()
7992/// #     .enable_http2()
7993/// #     .build();
7994///
7995/// # let executor = hyper_util::rt::TokioExecutor::new();
7996/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7997/// #     secret,
7998/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7999/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8000/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8001/// #     ),
8002/// # ).build().await.unwrap();
8003///
8004/// # let client = hyper_util::client::legacy::Client::builder(
8005/// #     hyper_util::rt::TokioExecutor::new()
8006/// # )
8007/// # .build(
8008/// #     hyper_rustls::HttpsConnectorBuilder::new()
8009/// #         .with_native_roots()
8010/// #         .unwrap()
8011/// #         .https_or_http()
8012/// #         .enable_http2()
8013/// #         .build()
8014/// # );
8015/// # let mut hub = Firestore::new(client, auth);
8016/// // As the method needs a request, you would usually fill it with the desired information
8017/// // into the respective structure. Some of the parts shown here might not be applicable !
8018/// // Values shown here are possibly random and not representative !
8019/// let mut req = BatchGetDocumentsRequest::default();
8020///
8021/// // You can configure optional parameters by calling the respective setters at will, and
8022/// // execute the final call using `doit()`.
8023/// // Values shown here are possibly random and not representative !
8024/// let result = hub.projects().databases_documents_batch_get(req, "database")
8025///              .doit().await;
8026/// # }
8027/// ```
8028pub struct ProjectDatabaseDocumentBatchGetCall<'a, C>
8029where
8030    C: 'a,
8031{
8032    hub: &'a Firestore<C>,
8033    _request: BatchGetDocumentsRequest,
8034    _database: String,
8035    _delegate: Option<&'a mut dyn common::Delegate>,
8036    _additional_params: HashMap<String, String>,
8037    _scopes: BTreeSet<String>,
8038}
8039
8040impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBatchGetCall<'a, C> {}
8041
8042impl<'a, C> ProjectDatabaseDocumentBatchGetCall<'a, C>
8043where
8044    C: common::Connector,
8045{
8046    /// Perform the operation you have build so far.
8047    pub async fn doit(mut self) -> common::Result<(common::Response, BatchGetDocumentsResponse)> {
8048        use std::borrow::Cow;
8049        use std::io::{Read, Seek};
8050
8051        use common::{url::Params, ToParts};
8052        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8053
8054        let mut dd = common::DefaultDelegate;
8055        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8056        dlg.begin(common::MethodInfo {
8057            id: "firestore.projects.databases.documents.batchGet",
8058            http_method: hyper::Method::POST,
8059        });
8060
8061        for &field in ["alt", "database"].iter() {
8062            if self._additional_params.contains_key(field) {
8063                dlg.finished(false);
8064                return Err(common::Error::FieldClash(field));
8065            }
8066        }
8067
8068        let mut params = Params::with_capacity(4 + self._additional_params.len());
8069        params.push("database", self._database);
8070
8071        params.extend(self._additional_params.iter());
8072
8073        params.push("alt", "json");
8074        let mut url = self.hub._base_url.clone() + "v1/{+database}/documents:batchGet";
8075        if self._scopes.is_empty() {
8076            self._scopes
8077                .insert(Scope::CloudPlatform.as_ref().to_string());
8078        }
8079
8080        #[allow(clippy::single_element_loop)]
8081        for &(find_this, param_name) in [("{+database}", "database")].iter() {
8082            url = params.uri_replacement(url, param_name, find_this, true);
8083        }
8084        {
8085            let to_remove = ["database"];
8086            params.remove_params(&to_remove);
8087        }
8088
8089        let url = params.parse_with_url(&url);
8090
8091        let mut json_mime_type = mime::APPLICATION_JSON;
8092        let mut request_value_reader = {
8093            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8094            common::remove_json_null_values(&mut value);
8095            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8096            serde_json::to_writer(&mut dst, &value).unwrap();
8097            dst
8098        };
8099        let request_size = request_value_reader
8100            .seek(std::io::SeekFrom::End(0))
8101            .unwrap();
8102        request_value_reader
8103            .seek(std::io::SeekFrom::Start(0))
8104            .unwrap();
8105
8106        loop {
8107            let token = match self
8108                .hub
8109                .auth
8110                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8111                .await
8112            {
8113                Ok(token) => token,
8114                Err(e) => match dlg.token(e) {
8115                    Ok(token) => token,
8116                    Err(e) => {
8117                        dlg.finished(false);
8118                        return Err(common::Error::MissingToken(e));
8119                    }
8120                },
8121            };
8122            request_value_reader
8123                .seek(std::io::SeekFrom::Start(0))
8124                .unwrap();
8125            let mut req_result = {
8126                let client = &self.hub.client;
8127                dlg.pre_request();
8128                let mut req_builder = hyper::Request::builder()
8129                    .method(hyper::Method::POST)
8130                    .uri(url.as_str())
8131                    .header(USER_AGENT, self.hub._user_agent.clone());
8132
8133                if let Some(token) = token.as_ref() {
8134                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8135                }
8136
8137                let request = req_builder
8138                    .header(CONTENT_TYPE, json_mime_type.to_string())
8139                    .header(CONTENT_LENGTH, request_size as u64)
8140                    .body(common::to_body(
8141                        request_value_reader.get_ref().clone().into(),
8142                    ));
8143
8144                client.request(request.unwrap()).await
8145            };
8146
8147            match req_result {
8148                Err(err) => {
8149                    if let common::Retry::After(d) = dlg.http_error(&err) {
8150                        sleep(d).await;
8151                        continue;
8152                    }
8153                    dlg.finished(false);
8154                    return Err(common::Error::HttpError(err));
8155                }
8156                Ok(res) => {
8157                    let (mut parts, body) = res.into_parts();
8158                    let mut body = common::Body::new(body);
8159                    if !parts.status.is_success() {
8160                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8161                        let error = serde_json::from_str(&common::to_string(&bytes));
8162                        let response = common::to_response(parts, bytes.into());
8163
8164                        if let common::Retry::After(d) =
8165                            dlg.http_failure(&response, error.as_ref().ok())
8166                        {
8167                            sleep(d).await;
8168                            continue;
8169                        }
8170
8171                        dlg.finished(false);
8172
8173                        return Err(match error {
8174                            Ok(value) => common::Error::BadRequest(value),
8175                            _ => common::Error::Failure(response),
8176                        });
8177                    }
8178                    let response = {
8179                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8180                        let encoded = common::to_string(&bytes);
8181                        match serde_json::from_str(&encoded) {
8182                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8183                            Err(error) => {
8184                                dlg.response_json_decode_error(&encoded, &error);
8185                                return Err(common::Error::JsonDecodeError(
8186                                    encoded.to_string(),
8187                                    error,
8188                                ));
8189                            }
8190                        }
8191                    };
8192
8193                    dlg.finished(true);
8194                    return Ok(response);
8195                }
8196            }
8197        }
8198    }
8199
8200    ///
8201    /// Sets the *request* property to the given value.
8202    ///
8203    /// Even though the property as already been set when instantiating this call,
8204    /// we provide this method for API completeness.
8205    pub fn request(
8206        mut self,
8207        new_value: BatchGetDocumentsRequest,
8208    ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
8209        self._request = new_value;
8210        self
8211    }
8212    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
8213    ///
8214    /// Sets the *database* path property to the given value.
8215    ///
8216    /// Even though the property as already been set when instantiating this call,
8217    /// we provide this method for API completeness.
8218    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
8219        self._database = new_value.to_string();
8220        self
8221    }
8222    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8223    /// while executing the actual API request.
8224    ///
8225    /// ````text
8226    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8227    /// ````
8228    ///
8229    /// Sets the *delegate* property to the given value.
8230    pub fn delegate(
8231        mut self,
8232        new_value: &'a mut dyn common::Delegate,
8233    ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
8234        self._delegate = Some(new_value);
8235        self
8236    }
8237
8238    /// Set any additional parameter of the query string used in the request.
8239    /// It should be used to set parameters which are not yet available through their own
8240    /// setters.
8241    ///
8242    /// Please note that this method must not be used to set any of the known parameters
8243    /// which have their own setter method. If done anyway, the request will fail.
8244    ///
8245    /// # Additional Parameters
8246    ///
8247    /// * *$.xgafv* (query-string) - V1 error format.
8248    /// * *access_token* (query-string) - OAuth access token.
8249    /// * *alt* (query-string) - Data format for response.
8250    /// * *callback* (query-string) - JSONP
8251    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8252    /// * *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.
8253    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8254    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8255    /// * *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.
8256    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8257    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8258    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
8259    where
8260        T: AsRef<str>,
8261    {
8262        self._additional_params
8263            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8264        self
8265    }
8266
8267    /// Identifies the authorization scope for the method you are building.
8268    ///
8269    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8270    /// [`Scope::CloudPlatform`].
8271    ///
8272    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8273    /// tokens for more than one scope.
8274    ///
8275    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8276    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8277    /// sufficient, a read-write scope will do as well.
8278    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
8279    where
8280        St: AsRef<str>,
8281    {
8282        self._scopes.insert(String::from(scope.as_ref()));
8283        self
8284    }
8285    /// Identifies the authorization scope(s) for the method you are building.
8286    ///
8287    /// See [`Self::add_scope()`] for details.
8288    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
8289    where
8290        I: IntoIterator<Item = St>,
8291        St: AsRef<str>,
8292    {
8293        self._scopes
8294            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8295        self
8296    }
8297
8298    /// Removes all scopes, and no default scope will be used either.
8299    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8300    /// for details).
8301    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
8302        self._scopes.clear();
8303        self
8304    }
8305}
8306
8307/// Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write. If you require an atomically applied set of writes, use Commit instead.
8308///
8309/// A builder for the *databases.documents.batchWrite* method supported by a *project* resource.
8310/// It is not used directly, but through a [`ProjectMethods`] instance.
8311///
8312/// # Example
8313///
8314/// Instantiate a resource method builder
8315///
8316/// ```test_harness,no_run
8317/// # extern crate hyper;
8318/// # extern crate hyper_rustls;
8319/// # extern crate google_firestore1 as firestore1;
8320/// use firestore1::api::BatchWriteRequest;
8321/// # async fn dox() {
8322/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8323///
8324/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8325/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8326/// #     .with_native_roots()
8327/// #     .unwrap()
8328/// #     .https_only()
8329/// #     .enable_http2()
8330/// #     .build();
8331///
8332/// # let executor = hyper_util::rt::TokioExecutor::new();
8333/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8334/// #     secret,
8335/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8336/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8337/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8338/// #     ),
8339/// # ).build().await.unwrap();
8340///
8341/// # let client = hyper_util::client::legacy::Client::builder(
8342/// #     hyper_util::rt::TokioExecutor::new()
8343/// # )
8344/// # .build(
8345/// #     hyper_rustls::HttpsConnectorBuilder::new()
8346/// #         .with_native_roots()
8347/// #         .unwrap()
8348/// #         .https_or_http()
8349/// #         .enable_http2()
8350/// #         .build()
8351/// # );
8352/// # let mut hub = Firestore::new(client, auth);
8353/// // As the method needs a request, you would usually fill it with the desired information
8354/// // into the respective structure. Some of the parts shown here might not be applicable !
8355/// // Values shown here are possibly random and not representative !
8356/// let mut req = BatchWriteRequest::default();
8357///
8358/// // You can configure optional parameters by calling the respective setters at will, and
8359/// // execute the final call using `doit()`.
8360/// // Values shown here are possibly random and not representative !
8361/// let result = hub.projects().databases_documents_batch_write(req, "database")
8362///              .doit().await;
8363/// # }
8364/// ```
8365pub struct ProjectDatabaseDocumentBatchWriteCall<'a, C>
8366where
8367    C: 'a,
8368{
8369    hub: &'a Firestore<C>,
8370    _request: BatchWriteRequest,
8371    _database: String,
8372    _delegate: Option<&'a mut dyn common::Delegate>,
8373    _additional_params: HashMap<String, String>,
8374    _scopes: BTreeSet<String>,
8375}
8376
8377impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBatchWriteCall<'a, C> {}
8378
8379impl<'a, C> ProjectDatabaseDocumentBatchWriteCall<'a, C>
8380where
8381    C: common::Connector,
8382{
8383    /// Perform the operation you have build so far.
8384    pub async fn doit(mut self) -> common::Result<(common::Response, BatchWriteResponse)> {
8385        use std::borrow::Cow;
8386        use std::io::{Read, Seek};
8387
8388        use common::{url::Params, ToParts};
8389        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8390
8391        let mut dd = common::DefaultDelegate;
8392        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8393        dlg.begin(common::MethodInfo {
8394            id: "firestore.projects.databases.documents.batchWrite",
8395            http_method: hyper::Method::POST,
8396        });
8397
8398        for &field in ["alt", "database"].iter() {
8399            if self._additional_params.contains_key(field) {
8400                dlg.finished(false);
8401                return Err(common::Error::FieldClash(field));
8402            }
8403        }
8404
8405        let mut params = Params::with_capacity(4 + self._additional_params.len());
8406        params.push("database", self._database);
8407
8408        params.extend(self._additional_params.iter());
8409
8410        params.push("alt", "json");
8411        let mut url = self.hub._base_url.clone() + "v1/{+database}/documents:batchWrite";
8412        if self._scopes.is_empty() {
8413            self._scopes
8414                .insert(Scope::CloudPlatform.as_ref().to_string());
8415        }
8416
8417        #[allow(clippy::single_element_loop)]
8418        for &(find_this, param_name) in [("{+database}", "database")].iter() {
8419            url = params.uri_replacement(url, param_name, find_this, true);
8420        }
8421        {
8422            let to_remove = ["database"];
8423            params.remove_params(&to_remove);
8424        }
8425
8426        let url = params.parse_with_url(&url);
8427
8428        let mut json_mime_type = mime::APPLICATION_JSON;
8429        let mut request_value_reader = {
8430            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8431            common::remove_json_null_values(&mut value);
8432            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8433            serde_json::to_writer(&mut dst, &value).unwrap();
8434            dst
8435        };
8436        let request_size = request_value_reader
8437            .seek(std::io::SeekFrom::End(0))
8438            .unwrap();
8439        request_value_reader
8440            .seek(std::io::SeekFrom::Start(0))
8441            .unwrap();
8442
8443        loop {
8444            let token = match self
8445                .hub
8446                .auth
8447                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8448                .await
8449            {
8450                Ok(token) => token,
8451                Err(e) => match dlg.token(e) {
8452                    Ok(token) => token,
8453                    Err(e) => {
8454                        dlg.finished(false);
8455                        return Err(common::Error::MissingToken(e));
8456                    }
8457                },
8458            };
8459            request_value_reader
8460                .seek(std::io::SeekFrom::Start(0))
8461                .unwrap();
8462            let mut req_result = {
8463                let client = &self.hub.client;
8464                dlg.pre_request();
8465                let mut req_builder = hyper::Request::builder()
8466                    .method(hyper::Method::POST)
8467                    .uri(url.as_str())
8468                    .header(USER_AGENT, self.hub._user_agent.clone());
8469
8470                if let Some(token) = token.as_ref() {
8471                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8472                }
8473
8474                let request = req_builder
8475                    .header(CONTENT_TYPE, json_mime_type.to_string())
8476                    .header(CONTENT_LENGTH, request_size as u64)
8477                    .body(common::to_body(
8478                        request_value_reader.get_ref().clone().into(),
8479                    ));
8480
8481                client.request(request.unwrap()).await
8482            };
8483
8484            match req_result {
8485                Err(err) => {
8486                    if let common::Retry::After(d) = dlg.http_error(&err) {
8487                        sleep(d).await;
8488                        continue;
8489                    }
8490                    dlg.finished(false);
8491                    return Err(common::Error::HttpError(err));
8492                }
8493                Ok(res) => {
8494                    let (mut parts, body) = res.into_parts();
8495                    let mut body = common::Body::new(body);
8496                    if !parts.status.is_success() {
8497                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8498                        let error = serde_json::from_str(&common::to_string(&bytes));
8499                        let response = common::to_response(parts, bytes.into());
8500
8501                        if let common::Retry::After(d) =
8502                            dlg.http_failure(&response, error.as_ref().ok())
8503                        {
8504                            sleep(d).await;
8505                            continue;
8506                        }
8507
8508                        dlg.finished(false);
8509
8510                        return Err(match error {
8511                            Ok(value) => common::Error::BadRequest(value),
8512                            _ => common::Error::Failure(response),
8513                        });
8514                    }
8515                    let response = {
8516                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8517                        let encoded = common::to_string(&bytes);
8518                        match serde_json::from_str(&encoded) {
8519                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8520                            Err(error) => {
8521                                dlg.response_json_decode_error(&encoded, &error);
8522                                return Err(common::Error::JsonDecodeError(
8523                                    encoded.to_string(),
8524                                    error,
8525                                ));
8526                            }
8527                        }
8528                    };
8529
8530                    dlg.finished(true);
8531                    return Ok(response);
8532                }
8533            }
8534        }
8535    }
8536
8537    ///
8538    /// Sets the *request* property to the given value.
8539    ///
8540    /// Even though the property as already been set when instantiating this call,
8541    /// we provide this method for API completeness.
8542    pub fn request(
8543        mut self,
8544        new_value: BatchWriteRequest,
8545    ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
8546        self._request = new_value;
8547        self
8548    }
8549    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
8550    ///
8551    /// Sets the *database* path property to the given value.
8552    ///
8553    /// Even though the property as already been set when instantiating this call,
8554    /// we provide this method for API completeness.
8555    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
8556        self._database = new_value.to_string();
8557        self
8558    }
8559    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8560    /// while executing the actual API request.
8561    ///
8562    /// ````text
8563    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8564    /// ````
8565    ///
8566    /// Sets the *delegate* property to the given value.
8567    pub fn delegate(
8568        mut self,
8569        new_value: &'a mut dyn common::Delegate,
8570    ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
8571        self._delegate = Some(new_value);
8572        self
8573    }
8574
8575    /// Set any additional parameter of the query string used in the request.
8576    /// It should be used to set parameters which are not yet available through their own
8577    /// setters.
8578    ///
8579    /// Please note that this method must not be used to set any of the known parameters
8580    /// which have their own setter method. If done anyway, the request will fail.
8581    ///
8582    /// # Additional Parameters
8583    ///
8584    /// * *$.xgafv* (query-string) - V1 error format.
8585    /// * *access_token* (query-string) - OAuth access token.
8586    /// * *alt* (query-string) - Data format for response.
8587    /// * *callback* (query-string) - JSONP
8588    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8589    /// * *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.
8590    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8591    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8592    /// * *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.
8593    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8594    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8595    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
8596    where
8597        T: AsRef<str>,
8598    {
8599        self._additional_params
8600            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8601        self
8602    }
8603
8604    /// Identifies the authorization scope for the method you are building.
8605    ///
8606    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8607    /// [`Scope::CloudPlatform`].
8608    ///
8609    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8610    /// tokens for more than one scope.
8611    ///
8612    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8613    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8614    /// sufficient, a read-write scope will do as well.
8615    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
8616    where
8617        St: AsRef<str>,
8618    {
8619        self._scopes.insert(String::from(scope.as_ref()));
8620        self
8621    }
8622    /// Identifies the authorization scope(s) for the method you are building.
8623    ///
8624    /// See [`Self::add_scope()`] for details.
8625    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
8626    where
8627        I: IntoIterator<Item = St>,
8628        St: AsRef<str>,
8629    {
8630        self._scopes
8631            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8632        self
8633    }
8634
8635    /// Removes all scopes, and no default scope will be used either.
8636    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8637    /// for details).
8638    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
8639        self._scopes.clear();
8640        self
8641    }
8642}
8643
8644/// Starts a new transaction.
8645///
8646/// A builder for the *databases.documents.beginTransaction* method supported by a *project* resource.
8647/// It is not used directly, but through a [`ProjectMethods`] instance.
8648///
8649/// # Example
8650///
8651/// Instantiate a resource method builder
8652///
8653/// ```test_harness,no_run
8654/// # extern crate hyper;
8655/// # extern crate hyper_rustls;
8656/// # extern crate google_firestore1 as firestore1;
8657/// use firestore1::api::BeginTransactionRequest;
8658/// # async fn dox() {
8659/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8660///
8661/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8662/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8663/// #     .with_native_roots()
8664/// #     .unwrap()
8665/// #     .https_only()
8666/// #     .enable_http2()
8667/// #     .build();
8668///
8669/// # let executor = hyper_util::rt::TokioExecutor::new();
8670/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8671/// #     secret,
8672/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8673/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8674/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8675/// #     ),
8676/// # ).build().await.unwrap();
8677///
8678/// # let client = hyper_util::client::legacy::Client::builder(
8679/// #     hyper_util::rt::TokioExecutor::new()
8680/// # )
8681/// # .build(
8682/// #     hyper_rustls::HttpsConnectorBuilder::new()
8683/// #         .with_native_roots()
8684/// #         .unwrap()
8685/// #         .https_or_http()
8686/// #         .enable_http2()
8687/// #         .build()
8688/// # );
8689/// # let mut hub = Firestore::new(client, auth);
8690/// // As the method needs a request, you would usually fill it with the desired information
8691/// // into the respective structure. Some of the parts shown here might not be applicable !
8692/// // Values shown here are possibly random and not representative !
8693/// let mut req = BeginTransactionRequest::default();
8694///
8695/// // You can configure optional parameters by calling the respective setters at will, and
8696/// // execute the final call using `doit()`.
8697/// // Values shown here are possibly random and not representative !
8698/// let result = hub.projects().databases_documents_begin_transaction(req, "database")
8699///              .doit().await;
8700/// # }
8701/// ```
8702pub struct ProjectDatabaseDocumentBeginTransactionCall<'a, C>
8703where
8704    C: 'a,
8705{
8706    hub: &'a Firestore<C>,
8707    _request: BeginTransactionRequest,
8708    _database: String,
8709    _delegate: Option<&'a mut dyn common::Delegate>,
8710    _additional_params: HashMap<String, String>,
8711    _scopes: BTreeSet<String>,
8712}
8713
8714impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBeginTransactionCall<'a, C> {}
8715
8716impl<'a, C> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
8717where
8718    C: common::Connector,
8719{
8720    /// Perform the operation you have build so far.
8721    pub async fn doit(mut self) -> common::Result<(common::Response, BeginTransactionResponse)> {
8722        use std::borrow::Cow;
8723        use std::io::{Read, Seek};
8724
8725        use common::{url::Params, ToParts};
8726        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8727
8728        let mut dd = common::DefaultDelegate;
8729        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8730        dlg.begin(common::MethodInfo {
8731            id: "firestore.projects.databases.documents.beginTransaction",
8732            http_method: hyper::Method::POST,
8733        });
8734
8735        for &field in ["alt", "database"].iter() {
8736            if self._additional_params.contains_key(field) {
8737                dlg.finished(false);
8738                return Err(common::Error::FieldClash(field));
8739            }
8740        }
8741
8742        let mut params = Params::with_capacity(4 + self._additional_params.len());
8743        params.push("database", self._database);
8744
8745        params.extend(self._additional_params.iter());
8746
8747        params.push("alt", "json");
8748        let mut url = self.hub._base_url.clone() + "v1/{+database}/documents:beginTransaction";
8749        if self._scopes.is_empty() {
8750            self._scopes
8751                .insert(Scope::CloudPlatform.as_ref().to_string());
8752        }
8753
8754        #[allow(clippy::single_element_loop)]
8755        for &(find_this, param_name) in [("{+database}", "database")].iter() {
8756            url = params.uri_replacement(url, param_name, find_this, true);
8757        }
8758        {
8759            let to_remove = ["database"];
8760            params.remove_params(&to_remove);
8761        }
8762
8763        let url = params.parse_with_url(&url);
8764
8765        let mut json_mime_type = mime::APPLICATION_JSON;
8766        let mut request_value_reader = {
8767            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8768            common::remove_json_null_values(&mut value);
8769            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8770            serde_json::to_writer(&mut dst, &value).unwrap();
8771            dst
8772        };
8773        let request_size = request_value_reader
8774            .seek(std::io::SeekFrom::End(0))
8775            .unwrap();
8776        request_value_reader
8777            .seek(std::io::SeekFrom::Start(0))
8778            .unwrap();
8779
8780        loop {
8781            let token = match self
8782                .hub
8783                .auth
8784                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8785                .await
8786            {
8787                Ok(token) => token,
8788                Err(e) => match dlg.token(e) {
8789                    Ok(token) => token,
8790                    Err(e) => {
8791                        dlg.finished(false);
8792                        return Err(common::Error::MissingToken(e));
8793                    }
8794                },
8795            };
8796            request_value_reader
8797                .seek(std::io::SeekFrom::Start(0))
8798                .unwrap();
8799            let mut req_result = {
8800                let client = &self.hub.client;
8801                dlg.pre_request();
8802                let mut req_builder = hyper::Request::builder()
8803                    .method(hyper::Method::POST)
8804                    .uri(url.as_str())
8805                    .header(USER_AGENT, self.hub._user_agent.clone());
8806
8807                if let Some(token) = token.as_ref() {
8808                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8809                }
8810
8811                let request = req_builder
8812                    .header(CONTENT_TYPE, json_mime_type.to_string())
8813                    .header(CONTENT_LENGTH, request_size as u64)
8814                    .body(common::to_body(
8815                        request_value_reader.get_ref().clone().into(),
8816                    ));
8817
8818                client.request(request.unwrap()).await
8819            };
8820
8821            match req_result {
8822                Err(err) => {
8823                    if let common::Retry::After(d) = dlg.http_error(&err) {
8824                        sleep(d).await;
8825                        continue;
8826                    }
8827                    dlg.finished(false);
8828                    return Err(common::Error::HttpError(err));
8829                }
8830                Ok(res) => {
8831                    let (mut parts, body) = res.into_parts();
8832                    let mut body = common::Body::new(body);
8833                    if !parts.status.is_success() {
8834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8835                        let error = serde_json::from_str(&common::to_string(&bytes));
8836                        let response = common::to_response(parts, bytes.into());
8837
8838                        if let common::Retry::After(d) =
8839                            dlg.http_failure(&response, error.as_ref().ok())
8840                        {
8841                            sleep(d).await;
8842                            continue;
8843                        }
8844
8845                        dlg.finished(false);
8846
8847                        return Err(match error {
8848                            Ok(value) => common::Error::BadRequest(value),
8849                            _ => common::Error::Failure(response),
8850                        });
8851                    }
8852                    let response = {
8853                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8854                        let encoded = common::to_string(&bytes);
8855                        match serde_json::from_str(&encoded) {
8856                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8857                            Err(error) => {
8858                                dlg.response_json_decode_error(&encoded, &error);
8859                                return Err(common::Error::JsonDecodeError(
8860                                    encoded.to_string(),
8861                                    error,
8862                                ));
8863                            }
8864                        }
8865                    };
8866
8867                    dlg.finished(true);
8868                    return Ok(response);
8869                }
8870            }
8871        }
8872    }
8873
8874    ///
8875    /// Sets the *request* property to the given value.
8876    ///
8877    /// Even though the property as already been set when instantiating this call,
8878    /// we provide this method for API completeness.
8879    pub fn request(
8880        mut self,
8881        new_value: BeginTransactionRequest,
8882    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
8883        self._request = new_value;
8884        self
8885    }
8886    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
8887    ///
8888    /// Sets the *database* path property to the given value.
8889    ///
8890    /// Even though the property as already been set when instantiating this call,
8891    /// we provide this method for API completeness.
8892    pub fn database(
8893        mut self,
8894        new_value: &str,
8895    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
8896        self._database = new_value.to_string();
8897        self
8898    }
8899    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8900    /// while executing the actual API request.
8901    ///
8902    /// ````text
8903    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8904    /// ````
8905    ///
8906    /// Sets the *delegate* property to the given value.
8907    pub fn delegate(
8908        mut self,
8909        new_value: &'a mut dyn common::Delegate,
8910    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
8911        self._delegate = Some(new_value);
8912        self
8913    }
8914
8915    /// Set any additional parameter of the query string used in the request.
8916    /// It should be used to set parameters which are not yet available through their own
8917    /// setters.
8918    ///
8919    /// Please note that this method must not be used to set any of the known parameters
8920    /// which have their own setter method. If done anyway, the request will fail.
8921    ///
8922    /// # Additional Parameters
8923    ///
8924    /// * *$.xgafv* (query-string) - V1 error format.
8925    /// * *access_token* (query-string) - OAuth access token.
8926    /// * *alt* (query-string) - Data format for response.
8927    /// * *callback* (query-string) - JSONP
8928    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8929    /// * *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.
8930    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8931    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8932    /// * *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.
8933    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8934    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8935    pub fn param<T>(
8936        mut self,
8937        name: T,
8938        value: T,
8939    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
8940    where
8941        T: AsRef<str>,
8942    {
8943        self._additional_params
8944            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8945        self
8946    }
8947
8948    /// Identifies the authorization scope for the method you are building.
8949    ///
8950    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8951    /// [`Scope::CloudPlatform`].
8952    ///
8953    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8954    /// tokens for more than one scope.
8955    ///
8956    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8957    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8958    /// sufficient, a read-write scope will do as well.
8959    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
8960    where
8961        St: AsRef<str>,
8962    {
8963        self._scopes.insert(String::from(scope.as_ref()));
8964        self
8965    }
8966    /// Identifies the authorization scope(s) for the method you are building.
8967    ///
8968    /// See [`Self::add_scope()`] for details.
8969    pub fn add_scopes<I, St>(
8970        mut self,
8971        scopes: I,
8972    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
8973    where
8974        I: IntoIterator<Item = St>,
8975        St: AsRef<str>,
8976    {
8977        self._scopes
8978            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8979        self
8980    }
8981
8982    /// Removes all scopes, and no default scope will be used either.
8983    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8984    /// for details).
8985    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
8986        self._scopes.clear();
8987        self
8988    }
8989}
8990
8991/// Commits a transaction, while optionally updating documents.
8992///
8993/// A builder for the *databases.documents.commit* method supported by a *project* resource.
8994/// It is not used directly, but through a [`ProjectMethods`] instance.
8995///
8996/// # Example
8997///
8998/// Instantiate a resource method builder
8999///
9000/// ```test_harness,no_run
9001/// # extern crate hyper;
9002/// # extern crate hyper_rustls;
9003/// # extern crate google_firestore1 as firestore1;
9004/// use firestore1::api::CommitRequest;
9005/// # async fn dox() {
9006/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9007///
9008/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9009/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9010/// #     .with_native_roots()
9011/// #     .unwrap()
9012/// #     .https_only()
9013/// #     .enable_http2()
9014/// #     .build();
9015///
9016/// # let executor = hyper_util::rt::TokioExecutor::new();
9017/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9018/// #     secret,
9019/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9020/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9021/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9022/// #     ),
9023/// # ).build().await.unwrap();
9024///
9025/// # let client = hyper_util::client::legacy::Client::builder(
9026/// #     hyper_util::rt::TokioExecutor::new()
9027/// # )
9028/// # .build(
9029/// #     hyper_rustls::HttpsConnectorBuilder::new()
9030/// #         .with_native_roots()
9031/// #         .unwrap()
9032/// #         .https_or_http()
9033/// #         .enable_http2()
9034/// #         .build()
9035/// # );
9036/// # let mut hub = Firestore::new(client, auth);
9037/// // As the method needs a request, you would usually fill it with the desired information
9038/// // into the respective structure. Some of the parts shown here might not be applicable !
9039/// // Values shown here are possibly random and not representative !
9040/// let mut req = CommitRequest::default();
9041///
9042/// // You can configure optional parameters by calling the respective setters at will, and
9043/// // execute the final call using `doit()`.
9044/// // Values shown here are possibly random and not representative !
9045/// let result = hub.projects().databases_documents_commit(req, "database")
9046///              .doit().await;
9047/// # }
9048/// ```
9049pub struct ProjectDatabaseDocumentCommitCall<'a, C>
9050where
9051    C: 'a,
9052{
9053    hub: &'a Firestore<C>,
9054    _request: CommitRequest,
9055    _database: String,
9056    _delegate: Option<&'a mut dyn common::Delegate>,
9057    _additional_params: HashMap<String, String>,
9058    _scopes: BTreeSet<String>,
9059}
9060
9061impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentCommitCall<'a, C> {}
9062
9063impl<'a, C> ProjectDatabaseDocumentCommitCall<'a, C>
9064where
9065    C: common::Connector,
9066{
9067    /// Perform the operation you have build so far.
9068    pub async fn doit(mut self) -> common::Result<(common::Response, CommitResponse)> {
9069        use std::borrow::Cow;
9070        use std::io::{Read, Seek};
9071
9072        use common::{url::Params, ToParts};
9073        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9074
9075        let mut dd = common::DefaultDelegate;
9076        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9077        dlg.begin(common::MethodInfo {
9078            id: "firestore.projects.databases.documents.commit",
9079            http_method: hyper::Method::POST,
9080        });
9081
9082        for &field in ["alt", "database"].iter() {
9083            if self._additional_params.contains_key(field) {
9084                dlg.finished(false);
9085                return Err(common::Error::FieldClash(field));
9086            }
9087        }
9088
9089        let mut params = Params::with_capacity(4 + self._additional_params.len());
9090        params.push("database", self._database);
9091
9092        params.extend(self._additional_params.iter());
9093
9094        params.push("alt", "json");
9095        let mut url = self.hub._base_url.clone() + "v1/{+database}/documents:commit";
9096        if self._scopes.is_empty() {
9097            self._scopes
9098                .insert(Scope::CloudPlatform.as_ref().to_string());
9099        }
9100
9101        #[allow(clippy::single_element_loop)]
9102        for &(find_this, param_name) in [("{+database}", "database")].iter() {
9103            url = params.uri_replacement(url, param_name, find_this, true);
9104        }
9105        {
9106            let to_remove = ["database"];
9107            params.remove_params(&to_remove);
9108        }
9109
9110        let url = params.parse_with_url(&url);
9111
9112        let mut json_mime_type = mime::APPLICATION_JSON;
9113        let mut request_value_reader = {
9114            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9115            common::remove_json_null_values(&mut value);
9116            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9117            serde_json::to_writer(&mut dst, &value).unwrap();
9118            dst
9119        };
9120        let request_size = request_value_reader
9121            .seek(std::io::SeekFrom::End(0))
9122            .unwrap();
9123        request_value_reader
9124            .seek(std::io::SeekFrom::Start(0))
9125            .unwrap();
9126
9127        loop {
9128            let token = match self
9129                .hub
9130                .auth
9131                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9132                .await
9133            {
9134                Ok(token) => token,
9135                Err(e) => match dlg.token(e) {
9136                    Ok(token) => token,
9137                    Err(e) => {
9138                        dlg.finished(false);
9139                        return Err(common::Error::MissingToken(e));
9140                    }
9141                },
9142            };
9143            request_value_reader
9144                .seek(std::io::SeekFrom::Start(0))
9145                .unwrap();
9146            let mut req_result = {
9147                let client = &self.hub.client;
9148                dlg.pre_request();
9149                let mut req_builder = hyper::Request::builder()
9150                    .method(hyper::Method::POST)
9151                    .uri(url.as_str())
9152                    .header(USER_AGENT, self.hub._user_agent.clone());
9153
9154                if let Some(token) = token.as_ref() {
9155                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9156                }
9157
9158                let request = req_builder
9159                    .header(CONTENT_TYPE, json_mime_type.to_string())
9160                    .header(CONTENT_LENGTH, request_size as u64)
9161                    .body(common::to_body(
9162                        request_value_reader.get_ref().clone().into(),
9163                    ));
9164
9165                client.request(request.unwrap()).await
9166            };
9167
9168            match req_result {
9169                Err(err) => {
9170                    if let common::Retry::After(d) = dlg.http_error(&err) {
9171                        sleep(d).await;
9172                        continue;
9173                    }
9174                    dlg.finished(false);
9175                    return Err(common::Error::HttpError(err));
9176                }
9177                Ok(res) => {
9178                    let (mut parts, body) = res.into_parts();
9179                    let mut body = common::Body::new(body);
9180                    if !parts.status.is_success() {
9181                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9182                        let error = serde_json::from_str(&common::to_string(&bytes));
9183                        let response = common::to_response(parts, bytes.into());
9184
9185                        if let common::Retry::After(d) =
9186                            dlg.http_failure(&response, error.as_ref().ok())
9187                        {
9188                            sleep(d).await;
9189                            continue;
9190                        }
9191
9192                        dlg.finished(false);
9193
9194                        return Err(match error {
9195                            Ok(value) => common::Error::BadRequest(value),
9196                            _ => common::Error::Failure(response),
9197                        });
9198                    }
9199                    let response = {
9200                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9201                        let encoded = common::to_string(&bytes);
9202                        match serde_json::from_str(&encoded) {
9203                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9204                            Err(error) => {
9205                                dlg.response_json_decode_error(&encoded, &error);
9206                                return Err(common::Error::JsonDecodeError(
9207                                    encoded.to_string(),
9208                                    error,
9209                                ));
9210                            }
9211                        }
9212                    };
9213
9214                    dlg.finished(true);
9215                    return Ok(response);
9216                }
9217            }
9218        }
9219    }
9220
9221    ///
9222    /// Sets the *request* property to the given value.
9223    ///
9224    /// Even though the property as already been set when instantiating this call,
9225    /// we provide this method for API completeness.
9226    pub fn request(mut self, new_value: CommitRequest) -> ProjectDatabaseDocumentCommitCall<'a, C> {
9227        self._request = new_value;
9228        self
9229    }
9230    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
9231    ///
9232    /// Sets the *database* path property to the given value.
9233    ///
9234    /// Even though the property as already been set when instantiating this call,
9235    /// we provide this method for API completeness.
9236    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentCommitCall<'a, C> {
9237        self._database = new_value.to_string();
9238        self
9239    }
9240    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9241    /// while executing the actual API request.
9242    ///
9243    /// ````text
9244    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9245    /// ````
9246    ///
9247    /// Sets the *delegate* property to the given value.
9248    pub fn delegate(
9249        mut self,
9250        new_value: &'a mut dyn common::Delegate,
9251    ) -> ProjectDatabaseDocumentCommitCall<'a, C> {
9252        self._delegate = Some(new_value);
9253        self
9254    }
9255
9256    /// Set any additional parameter of the query string used in the request.
9257    /// It should be used to set parameters which are not yet available through their own
9258    /// setters.
9259    ///
9260    /// Please note that this method must not be used to set any of the known parameters
9261    /// which have their own setter method. If done anyway, the request will fail.
9262    ///
9263    /// # Additional Parameters
9264    ///
9265    /// * *$.xgafv* (query-string) - V1 error format.
9266    /// * *access_token* (query-string) - OAuth access token.
9267    /// * *alt* (query-string) - Data format for response.
9268    /// * *callback* (query-string) - JSONP
9269    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9270    /// * *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.
9271    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9272    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9273    /// * *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.
9274    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9275    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9276    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentCommitCall<'a, C>
9277    where
9278        T: AsRef<str>,
9279    {
9280        self._additional_params
9281            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9282        self
9283    }
9284
9285    /// Identifies the authorization scope for the method you are building.
9286    ///
9287    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9288    /// [`Scope::CloudPlatform`].
9289    ///
9290    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9291    /// tokens for more than one scope.
9292    ///
9293    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9294    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9295    /// sufficient, a read-write scope will do as well.
9296    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentCommitCall<'a, C>
9297    where
9298        St: AsRef<str>,
9299    {
9300        self._scopes.insert(String::from(scope.as_ref()));
9301        self
9302    }
9303    /// Identifies the authorization scope(s) for the method you are building.
9304    ///
9305    /// See [`Self::add_scope()`] for details.
9306    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentCommitCall<'a, C>
9307    where
9308        I: IntoIterator<Item = St>,
9309        St: AsRef<str>,
9310    {
9311        self._scopes
9312            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9313        self
9314    }
9315
9316    /// Removes all scopes, and no default scope will be used either.
9317    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9318    /// for details).
9319    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentCommitCall<'a, C> {
9320        self._scopes.clear();
9321        self
9322    }
9323}
9324
9325/// Creates a new document.
9326///
9327/// A builder for the *databases.documents.createDocument* method supported by a *project* resource.
9328/// It is not used directly, but through a [`ProjectMethods`] instance.
9329///
9330/// # Example
9331///
9332/// Instantiate a resource method builder
9333///
9334/// ```test_harness,no_run
9335/// # extern crate hyper;
9336/// # extern crate hyper_rustls;
9337/// # extern crate google_firestore1 as firestore1;
9338/// use firestore1::api::Document;
9339/// # async fn dox() {
9340/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9341///
9342/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9343/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9344/// #     .with_native_roots()
9345/// #     .unwrap()
9346/// #     .https_only()
9347/// #     .enable_http2()
9348/// #     .build();
9349///
9350/// # let executor = hyper_util::rt::TokioExecutor::new();
9351/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9352/// #     secret,
9353/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9354/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9355/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9356/// #     ),
9357/// # ).build().await.unwrap();
9358///
9359/// # let client = hyper_util::client::legacy::Client::builder(
9360/// #     hyper_util::rt::TokioExecutor::new()
9361/// # )
9362/// # .build(
9363/// #     hyper_rustls::HttpsConnectorBuilder::new()
9364/// #         .with_native_roots()
9365/// #         .unwrap()
9366/// #         .https_or_http()
9367/// #         .enable_http2()
9368/// #         .build()
9369/// # );
9370/// # let mut hub = Firestore::new(client, auth);
9371/// // As the method needs a request, you would usually fill it with the desired information
9372/// // into the respective structure. Some of the parts shown here might not be applicable !
9373/// // Values shown here are possibly random and not representative !
9374/// let mut req = Document::default();
9375///
9376/// // You can configure optional parameters by calling the respective setters at will, and
9377/// // execute the final call using `doit()`.
9378/// // Values shown here are possibly random and not representative !
9379/// let result = hub.projects().databases_documents_create_document(req, "parent", "collectionId")
9380///              .add_mask_field_paths("rebum.")
9381///              .document_id("est")
9382///              .doit().await;
9383/// # }
9384/// ```
9385pub struct ProjectDatabaseDocumentCreateDocumentCall<'a, C>
9386where
9387    C: 'a,
9388{
9389    hub: &'a Firestore<C>,
9390    _request: Document,
9391    _parent: String,
9392    _collection_id: String,
9393    _mask_field_paths: Vec<String>,
9394    _document_id: Option<String>,
9395    _delegate: Option<&'a mut dyn common::Delegate>,
9396    _additional_params: HashMap<String, String>,
9397    _scopes: BTreeSet<String>,
9398}
9399
9400impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentCreateDocumentCall<'a, C> {}
9401
9402impl<'a, C> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
9403where
9404    C: common::Connector,
9405{
9406    /// Perform the operation you have build so far.
9407    pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
9408        use std::borrow::Cow;
9409        use std::io::{Read, Seek};
9410
9411        use common::{url::Params, ToParts};
9412        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9413
9414        let mut dd = common::DefaultDelegate;
9415        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9416        dlg.begin(common::MethodInfo {
9417            id: "firestore.projects.databases.documents.createDocument",
9418            http_method: hyper::Method::POST,
9419        });
9420
9421        for &field in [
9422            "alt",
9423            "parent",
9424            "collectionId",
9425            "mask.fieldPaths",
9426            "documentId",
9427        ]
9428        .iter()
9429        {
9430            if self._additional_params.contains_key(field) {
9431                dlg.finished(false);
9432                return Err(common::Error::FieldClash(field));
9433            }
9434        }
9435
9436        let mut params = Params::with_capacity(7 + self._additional_params.len());
9437        params.push("parent", self._parent);
9438        params.push("collectionId", self._collection_id);
9439        if !self._mask_field_paths.is_empty() {
9440            for f in self._mask_field_paths.iter() {
9441                params.push("mask.fieldPaths", f);
9442            }
9443        }
9444        if let Some(value) = self._document_id.as_ref() {
9445            params.push("documentId", value);
9446        }
9447
9448        params.extend(self._additional_params.iter());
9449
9450        params.push("alt", "json");
9451        let mut url = self.hub._base_url.clone() + "v1/{+parent}/{collectionId}";
9452        if self._scopes.is_empty() {
9453            self._scopes
9454                .insert(Scope::CloudPlatform.as_ref().to_string());
9455        }
9456
9457        #[allow(clippy::single_element_loop)]
9458        for &(find_this, param_name) in
9459            [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
9460        {
9461            url = params.uri_replacement(url, param_name, find_this, true);
9462        }
9463        {
9464            let to_remove = ["collectionId", "parent"];
9465            params.remove_params(&to_remove);
9466        }
9467
9468        let url = params.parse_with_url(&url);
9469
9470        let mut json_mime_type = mime::APPLICATION_JSON;
9471        let mut request_value_reader = {
9472            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9473            common::remove_json_null_values(&mut value);
9474            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9475            serde_json::to_writer(&mut dst, &value).unwrap();
9476            dst
9477        };
9478        let request_size = request_value_reader
9479            .seek(std::io::SeekFrom::End(0))
9480            .unwrap();
9481        request_value_reader
9482            .seek(std::io::SeekFrom::Start(0))
9483            .unwrap();
9484
9485        loop {
9486            let token = match self
9487                .hub
9488                .auth
9489                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9490                .await
9491            {
9492                Ok(token) => token,
9493                Err(e) => match dlg.token(e) {
9494                    Ok(token) => token,
9495                    Err(e) => {
9496                        dlg.finished(false);
9497                        return Err(common::Error::MissingToken(e));
9498                    }
9499                },
9500            };
9501            request_value_reader
9502                .seek(std::io::SeekFrom::Start(0))
9503                .unwrap();
9504            let mut req_result = {
9505                let client = &self.hub.client;
9506                dlg.pre_request();
9507                let mut req_builder = hyper::Request::builder()
9508                    .method(hyper::Method::POST)
9509                    .uri(url.as_str())
9510                    .header(USER_AGENT, self.hub._user_agent.clone());
9511
9512                if let Some(token) = token.as_ref() {
9513                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9514                }
9515
9516                let request = req_builder
9517                    .header(CONTENT_TYPE, json_mime_type.to_string())
9518                    .header(CONTENT_LENGTH, request_size as u64)
9519                    .body(common::to_body(
9520                        request_value_reader.get_ref().clone().into(),
9521                    ));
9522
9523                client.request(request.unwrap()).await
9524            };
9525
9526            match req_result {
9527                Err(err) => {
9528                    if let common::Retry::After(d) = dlg.http_error(&err) {
9529                        sleep(d).await;
9530                        continue;
9531                    }
9532                    dlg.finished(false);
9533                    return Err(common::Error::HttpError(err));
9534                }
9535                Ok(res) => {
9536                    let (mut parts, body) = res.into_parts();
9537                    let mut body = common::Body::new(body);
9538                    if !parts.status.is_success() {
9539                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9540                        let error = serde_json::from_str(&common::to_string(&bytes));
9541                        let response = common::to_response(parts, bytes.into());
9542
9543                        if let common::Retry::After(d) =
9544                            dlg.http_failure(&response, error.as_ref().ok())
9545                        {
9546                            sleep(d).await;
9547                            continue;
9548                        }
9549
9550                        dlg.finished(false);
9551
9552                        return Err(match error {
9553                            Ok(value) => common::Error::BadRequest(value),
9554                            _ => common::Error::Failure(response),
9555                        });
9556                    }
9557                    let response = {
9558                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9559                        let encoded = common::to_string(&bytes);
9560                        match serde_json::from_str(&encoded) {
9561                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9562                            Err(error) => {
9563                                dlg.response_json_decode_error(&encoded, &error);
9564                                return Err(common::Error::JsonDecodeError(
9565                                    encoded.to_string(),
9566                                    error,
9567                                ));
9568                            }
9569                        }
9570                    };
9571
9572                    dlg.finished(true);
9573                    return Ok(response);
9574                }
9575            }
9576        }
9577    }
9578
9579    ///
9580    /// Sets the *request* property to the given value.
9581    ///
9582    /// Even though the property as already been set when instantiating this call,
9583    /// we provide this method for API completeness.
9584    pub fn request(
9585        mut self,
9586        new_value: Document,
9587    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
9588        self._request = new_value;
9589        self
9590    }
9591    /// Required. The parent resource. For example: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
9592    ///
9593    /// Sets the *parent* path property to the given value.
9594    ///
9595    /// Even though the property as already been set when instantiating this call,
9596    /// we provide this method for API completeness.
9597    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
9598        self._parent = new_value.to_string();
9599        self
9600    }
9601    /// Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
9602    ///
9603    /// Sets the *collection id* path property to the given value.
9604    ///
9605    /// Even though the property as already been set when instantiating this call,
9606    /// we provide this method for API completeness.
9607    pub fn collection_id(
9608        mut self,
9609        new_value: &str,
9610    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
9611        self._collection_id = new_value.to_string();
9612        self
9613    }
9614    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
9615    ///
9616    /// Append the given value to the *mask.field paths* query property.
9617    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9618    pub fn add_mask_field_paths(
9619        mut self,
9620        new_value: &str,
9621    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
9622        self._mask_field_paths.push(new_value.to_string());
9623        self
9624    }
9625    /// The client-assigned document ID to use for this document. Optional. If not specified, an ID will be assigned by the service.
9626    ///
9627    /// Sets the *document id* query property to the given value.
9628    pub fn document_id(
9629        mut self,
9630        new_value: &str,
9631    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
9632        self._document_id = Some(new_value.to_string());
9633        self
9634    }
9635    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9636    /// while executing the actual API request.
9637    ///
9638    /// ````text
9639    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9640    /// ````
9641    ///
9642    /// Sets the *delegate* property to the given value.
9643    pub fn delegate(
9644        mut self,
9645        new_value: &'a mut dyn common::Delegate,
9646    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
9647        self._delegate = Some(new_value);
9648        self
9649    }
9650
9651    /// Set any additional parameter of the query string used in the request.
9652    /// It should be used to set parameters which are not yet available through their own
9653    /// setters.
9654    ///
9655    /// Please note that this method must not be used to set any of the known parameters
9656    /// which have their own setter method. If done anyway, the request will fail.
9657    ///
9658    /// # Additional Parameters
9659    ///
9660    /// * *$.xgafv* (query-string) - V1 error format.
9661    /// * *access_token* (query-string) - OAuth access token.
9662    /// * *alt* (query-string) - Data format for response.
9663    /// * *callback* (query-string) - JSONP
9664    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9665    /// * *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.
9666    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9667    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9668    /// * *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.
9669    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9670    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9671    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
9672    where
9673        T: AsRef<str>,
9674    {
9675        self._additional_params
9676            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9677        self
9678    }
9679
9680    /// Identifies the authorization scope for the method you are building.
9681    ///
9682    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9683    /// [`Scope::CloudPlatform`].
9684    ///
9685    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9686    /// tokens for more than one scope.
9687    ///
9688    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9689    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9690    /// sufficient, a read-write scope will do as well.
9691    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
9692    where
9693        St: AsRef<str>,
9694    {
9695        self._scopes.insert(String::from(scope.as_ref()));
9696        self
9697    }
9698    /// Identifies the authorization scope(s) for the method you are building.
9699    ///
9700    /// See [`Self::add_scope()`] for details.
9701    pub fn add_scopes<I, St>(
9702        mut self,
9703        scopes: I,
9704    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
9705    where
9706        I: IntoIterator<Item = St>,
9707        St: AsRef<str>,
9708    {
9709        self._scopes
9710            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9711        self
9712    }
9713
9714    /// Removes all scopes, and no default scope will be used either.
9715    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9716    /// for details).
9717    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
9718        self._scopes.clear();
9719        self
9720    }
9721}
9722
9723/// Deletes a document.
9724///
9725/// A builder for the *databases.documents.delete* method supported by a *project* resource.
9726/// It is not used directly, but through a [`ProjectMethods`] instance.
9727///
9728/// # Example
9729///
9730/// Instantiate a resource method builder
9731///
9732/// ```test_harness,no_run
9733/// # extern crate hyper;
9734/// # extern crate hyper_rustls;
9735/// # extern crate google_firestore1 as firestore1;
9736/// # async fn dox() {
9737/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9738///
9739/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9740/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9741/// #     .with_native_roots()
9742/// #     .unwrap()
9743/// #     .https_only()
9744/// #     .enable_http2()
9745/// #     .build();
9746///
9747/// # let executor = hyper_util::rt::TokioExecutor::new();
9748/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9749/// #     secret,
9750/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9751/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9752/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9753/// #     ),
9754/// # ).build().await.unwrap();
9755///
9756/// # let client = hyper_util::client::legacy::Client::builder(
9757/// #     hyper_util::rt::TokioExecutor::new()
9758/// # )
9759/// # .build(
9760/// #     hyper_rustls::HttpsConnectorBuilder::new()
9761/// #         .with_native_roots()
9762/// #         .unwrap()
9763/// #         .https_or_http()
9764/// #         .enable_http2()
9765/// #         .build()
9766/// # );
9767/// # let mut hub = Firestore::new(client, auth);
9768/// // You can configure optional parameters by calling the respective setters at will, and
9769/// // execute the final call using `doit()`.
9770/// // Values shown here are possibly random and not representative !
9771/// let result = hub.projects().databases_documents_delete("name")
9772///              .current_document_update_time(chrono::Utc::now())
9773///              .current_document_exists(true)
9774///              .doit().await;
9775/// # }
9776/// ```
9777pub struct ProjectDatabaseDocumentDeleteCall<'a, C>
9778where
9779    C: 'a,
9780{
9781    hub: &'a Firestore<C>,
9782    _name: String,
9783    _current_document_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
9784    _current_document_exists: Option<bool>,
9785    _delegate: Option<&'a mut dyn common::Delegate>,
9786    _additional_params: HashMap<String, String>,
9787    _scopes: BTreeSet<String>,
9788}
9789
9790impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentDeleteCall<'a, C> {}
9791
9792impl<'a, C> ProjectDatabaseDocumentDeleteCall<'a, C>
9793where
9794    C: common::Connector,
9795{
9796    /// Perform the operation you have build so far.
9797    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9798        use std::borrow::Cow;
9799        use std::io::{Read, Seek};
9800
9801        use common::{url::Params, ToParts};
9802        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9803
9804        let mut dd = common::DefaultDelegate;
9805        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9806        dlg.begin(common::MethodInfo {
9807            id: "firestore.projects.databases.documents.delete",
9808            http_method: hyper::Method::DELETE,
9809        });
9810
9811        for &field in [
9812            "alt",
9813            "name",
9814            "currentDocument.updateTime",
9815            "currentDocument.exists",
9816        ]
9817        .iter()
9818        {
9819            if self._additional_params.contains_key(field) {
9820                dlg.finished(false);
9821                return Err(common::Error::FieldClash(field));
9822            }
9823        }
9824
9825        let mut params = Params::with_capacity(5 + self._additional_params.len());
9826        params.push("name", self._name);
9827        if let Some(value) = self._current_document_update_time.as_ref() {
9828            params.push(
9829                "currentDocument.updateTime",
9830                common::serde::datetime_to_string(&value),
9831            );
9832        }
9833        if let Some(value) = self._current_document_exists.as_ref() {
9834            params.push("currentDocument.exists", value.to_string());
9835        }
9836
9837        params.extend(self._additional_params.iter());
9838
9839        params.push("alt", "json");
9840        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9841        if self._scopes.is_empty() {
9842            self._scopes
9843                .insert(Scope::CloudPlatform.as_ref().to_string());
9844        }
9845
9846        #[allow(clippy::single_element_loop)]
9847        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9848            url = params.uri_replacement(url, param_name, find_this, true);
9849        }
9850        {
9851            let to_remove = ["name"];
9852            params.remove_params(&to_remove);
9853        }
9854
9855        let url = params.parse_with_url(&url);
9856
9857        loop {
9858            let token = match self
9859                .hub
9860                .auth
9861                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9862                .await
9863            {
9864                Ok(token) => token,
9865                Err(e) => match dlg.token(e) {
9866                    Ok(token) => token,
9867                    Err(e) => {
9868                        dlg.finished(false);
9869                        return Err(common::Error::MissingToken(e));
9870                    }
9871                },
9872            };
9873            let mut req_result = {
9874                let client = &self.hub.client;
9875                dlg.pre_request();
9876                let mut req_builder = hyper::Request::builder()
9877                    .method(hyper::Method::DELETE)
9878                    .uri(url.as_str())
9879                    .header(USER_AGENT, self.hub._user_agent.clone());
9880
9881                if let Some(token) = token.as_ref() {
9882                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9883                }
9884
9885                let request = req_builder
9886                    .header(CONTENT_LENGTH, 0_u64)
9887                    .body(common::to_body::<String>(None));
9888
9889                client.request(request.unwrap()).await
9890            };
9891
9892            match req_result {
9893                Err(err) => {
9894                    if let common::Retry::After(d) = dlg.http_error(&err) {
9895                        sleep(d).await;
9896                        continue;
9897                    }
9898                    dlg.finished(false);
9899                    return Err(common::Error::HttpError(err));
9900                }
9901                Ok(res) => {
9902                    let (mut parts, body) = res.into_parts();
9903                    let mut body = common::Body::new(body);
9904                    if !parts.status.is_success() {
9905                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9906                        let error = serde_json::from_str(&common::to_string(&bytes));
9907                        let response = common::to_response(parts, bytes.into());
9908
9909                        if let common::Retry::After(d) =
9910                            dlg.http_failure(&response, error.as_ref().ok())
9911                        {
9912                            sleep(d).await;
9913                            continue;
9914                        }
9915
9916                        dlg.finished(false);
9917
9918                        return Err(match error {
9919                            Ok(value) => common::Error::BadRequest(value),
9920                            _ => common::Error::Failure(response),
9921                        });
9922                    }
9923                    let response = {
9924                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9925                        let encoded = common::to_string(&bytes);
9926                        match serde_json::from_str(&encoded) {
9927                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9928                            Err(error) => {
9929                                dlg.response_json_decode_error(&encoded, &error);
9930                                return Err(common::Error::JsonDecodeError(
9931                                    encoded.to_string(),
9932                                    error,
9933                                ));
9934                            }
9935                        }
9936                    };
9937
9938                    dlg.finished(true);
9939                    return Ok(response);
9940                }
9941            }
9942        }
9943    }
9944
9945    /// Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
9946    ///
9947    /// Sets the *name* path property to the given value.
9948    ///
9949    /// Even though the property as already been set when instantiating this call,
9950    /// we provide this method for API completeness.
9951    pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
9952        self._name = new_value.to_string();
9953        self
9954    }
9955    /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
9956    ///
9957    /// Sets the *current document.update time* query property to the given value.
9958    pub fn current_document_update_time(
9959        mut self,
9960        new_value: chrono::DateTime<chrono::offset::Utc>,
9961    ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
9962        self._current_document_update_time = Some(new_value);
9963        self
9964    }
9965    /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
9966    ///
9967    /// Sets the *current document.exists* query property to the given value.
9968    pub fn current_document_exists(
9969        mut self,
9970        new_value: bool,
9971    ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
9972        self._current_document_exists = Some(new_value);
9973        self
9974    }
9975    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9976    /// while executing the actual API request.
9977    ///
9978    /// ````text
9979    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9980    /// ````
9981    ///
9982    /// Sets the *delegate* property to the given value.
9983    pub fn delegate(
9984        mut self,
9985        new_value: &'a mut dyn common::Delegate,
9986    ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
9987        self._delegate = Some(new_value);
9988        self
9989    }
9990
9991    /// Set any additional parameter of the query string used in the request.
9992    /// It should be used to set parameters which are not yet available through their own
9993    /// setters.
9994    ///
9995    /// Please note that this method must not be used to set any of the known parameters
9996    /// which have their own setter method. If done anyway, the request will fail.
9997    ///
9998    /// # Additional Parameters
9999    ///
10000    /// * *$.xgafv* (query-string) - V1 error format.
10001    /// * *access_token* (query-string) - OAuth access token.
10002    /// * *alt* (query-string) - Data format for response.
10003    /// * *callback* (query-string) - JSONP
10004    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10005    /// * *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.
10006    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10007    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10008    /// * *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.
10009    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10010    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10011    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentDeleteCall<'a, C>
10012    where
10013        T: AsRef<str>,
10014    {
10015        self._additional_params
10016            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10017        self
10018    }
10019
10020    /// Identifies the authorization scope for the method you are building.
10021    ///
10022    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10023    /// [`Scope::CloudPlatform`].
10024    ///
10025    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10026    /// tokens for more than one scope.
10027    ///
10028    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10029    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10030    /// sufficient, a read-write scope will do as well.
10031    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentDeleteCall<'a, C>
10032    where
10033        St: AsRef<str>,
10034    {
10035        self._scopes.insert(String::from(scope.as_ref()));
10036        self
10037    }
10038    /// Identifies the authorization scope(s) for the method you are building.
10039    ///
10040    /// See [`Self::add_scope()`] for details.
10041    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentDeleteCall<'a, C>
10042    where
10043        I: IntoIterator<Item = St>,
10044        St: AsRef<str>,
10045    {
10046        self._scopes
10047            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10048        self
10049    }
10050
10051    /// Removes all scopes, and no default scope will be used either.
10052    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10053    /// for details).
10054    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
10055        self._scopes.clear();
10056        self
10057    }
10058}
10059
10060/// Executes a pipeline query.
10061///
10062/// A builder for the *databases.documents.executePipeline* method supported by a *project* resource.
10063/// It is not used directly, but through a [`ProjectMethods`] instance.
10064///
10065/// # Example
10066///
10067/// Instantiate a resource method builder
10068///
10069/// ```test_harness,no_run
10070/// # extern crate hyper;
10071/// # extern crate hyper_rustls;
10072/// # extern crate google_firestore1 as firestore1;
10073/// use firestore1::api::ExecutePipelineRequest;
10074/// # async fn dox() {
10075/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10076///
10077/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10078/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10079/// #     .with_native_roots()
10080/// #     .unwrap()
10081/// #     .https_only()
10082/// #     .enable_http2()
10083/// #     .build();
10084///
10085/// # let executor = hyper_util::rt::TokioExecutor::new();
10086/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10087/// #     secret,
10088/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10089/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10090/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10091/// #     ),
10092/// # ).build().await.unwrap();
10093///
10094/// # let client = hyper_util::client::legacy::Client::builder(
10095/// #     hyper_util::rt::TokioExecutor::new()
10096/// # )
10097/// # .build(
10098/// #     hyper_rustls::HttpsConnectorBuilder::new()
10099/// #         .with_native_roots()
10100/// #         .unwrap()
10101/// #         .https_or_http()
10102/// #         .enable_http2()
10103/// #         .build()
10104/// # );
10105/// # let mut hub = Firestore::new(client, auth);
10106/// // As the method needs a request, you would usually fill it with the desired information
10107/// // into the respective structure. Some of the parts shown here might not be applicable !
10108/// // Values shown here are possibly random and not representative !
10109/// let mut req = ExecutePipelineRequest::default();
10110///
10111/// // You can configure optional parameters by calling the respective setters at will, and
10112/// // execute the final call using `doit()`.
10113/// // Values shown here are possibly random and not representative !
10114/// let result = hub.projects().databases_documents_execute_pipeline(req, "database")
10115///              .doit().await;
10116/// # }
10117/// ```
10118pub struct ProjectDatabaseDocumentExecutePipelineCall<'a, C>
10119where
10120    C: 'a,
10121{
10122    hub: &'a Firestore<C>,
10123    _request: ExecutePipelineRequest,
10124    _database: String,
10125    _delegate: Option<&'a mut dyn common::Delegate>,
10126    _additional_params: HashMap<String, String>,
10127    _scopes: BTreeSet<String>,
10128}
10129
10130impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentExecutePipelineCall<'a, C> {}
10131
10132impl<'a, C> ProjectDatabaseDocumentExecutePipelineCall<'a, C>
10133where
10134    C: common::Connector,
10135{
10136    /// Perform the operation you have build so far.
10137    pub async fn doit(mut self) -> common::Result<(common::Response, ExecutePipelineResponse)> {
10138        use std::borrow::Cow;
10139        use std::io::{Read, Seek};
10140
10141        use common::{url::Params, ToParts};
10142        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10143
10144        let mut dd = common::DefaultDelegate;
10145        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10146        dlg.begin(common::MethodInfo {
10147            id: "firestore.projects.databases.documents.executePipeline",
10148            http_method: hyper::Method::POST,
10149        });
10150
10151        for &field in ["alt", "database"].iter() {
10152            if self._additional_params.contains_key(field) {
10153                dlg.finished(false);
10154                return Err(common::Error::FieldClash(field));
10155            }
10156        }
10157
10158        let mut params = Params::with_capacity(4 + self._additional_params.len());
10159        params.push("database", self._database);
10160
10161        params.extend(self._additional_params.iter());
10162
10163        params.push("alt", "json");
10164        let mut url = self.hub._base_url.clone() + "v1/{+database}/documents:executePipeline";
10165        if self._scopes.is_empty() {
10166            self._scopes
10167                .insert(Scope::CloudPlatform.as_ref().to_string());
10168        }
10169
10170        #[allow(clippy::single_element_loop)]
10171        for &(find_this, param_name) in [("{+database}", "database")].iter() {
10172            url = params.uri_replacement(url, param_name, find_this, true);
10173        }
10174        {
10175            let to_remove = ["database"];
10176            params.remove_params(&to_remove);
10177        }
10178
10179        let url = params.parse_with_url(&url);
10180
10181        let mut json_mime_type = mime::APPLICATION_JSON;
10182        let mut request_value_reader = {
10183            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10184            common::remove_json_null_values(&mut value);
10185            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10186            serde_json::to_writer(&mut dst, &value).unwrap();
10187            dst
10188        };
10189        let request_size = request_value_reader
10190            .seek(std::io::SeekFrom::End(0))
10191            .unwrap();
10192        request_value_reader
10193            .seek(std::io::SeekFrom::Start(0))
10194            .unwrap();
10195
10196        loop {
10197            let token = match self
10198                .hub
10199                .auth
10200                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10201                .await
10202            {
10203                Ok(token) => token,
10204                Err(e) => match dlg.token(e) {
10205                    Ok(token) => token,
10206                    Err(e) => {
10207                        dlg.finished(false);
10208                        return Err(common::Error::MissingToken(e));
10209                    }
10210                },
10211            };
10212            request_value_reader
10213                .seek(std::io::SeekFrom::Start(0))
10214                .unwrap();
10215            let mut req_result = {
10216                let client = &self.hub.client;
10217                dlg.pre_request();
10218                let mut req_builder = hyper::Request::builder()
10219                    .method(hyper::Method::POST)
10220                    .uri(url.as_str())
10221                    .header(USER_AGENT, self.hub._user_agent.clone());
10222
10223                if let Some(token) = token.as_ref() {
10224                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10225                }
10226
10227                let request = req_builder
10228                    .header(CONTENT_TYPE, json_mime_type.to_string())
10229                    .header(CONTENT_LENGTH, request_size as u64)
10230                    .body(common::to_body(
10231                        request_value_reader.get_ref().clone().into(),
10232                    ));
10233
10234                client.request(request.unwrap()).await
10235            };
10236
10237            match req_result {
10238                Err(err) => {
10239                    if let common::Retry::After(d) = dlg.http_error(&err) {
10240                        sleep(d).await;
10241                        continue;
10242                    }
10243                    dlg.finished(false);
10244                    return Err(common::Error::HttpError(err));
10245                }
10246                Ok(res) => {
10247                    let (mut parts, body) = res.into_parts();
10248                    let mut body = common::Body::new(body);
10249                    if !parts.status.is_success() {
10250                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10251                        let error = serde_json::from_str(&common::to_string(&bytes));
10252                        let response = common::to_response(parts, bytes.into());
10253
10254                        if let common::Retry::After(d) =
10255                            dlg.http_failure(&response, error.as_ref().ok())
10256                        {
10257                            sleep(d).await;
10258                            continue;
10259                        }
10260
10261                        dlg.finished(false);
10262
10263                        return Err(match error {
10264                            Ok(value) => common::Error::BadRequest(value),
10265                            _ => common::Error::Failure(response),
10266                        });
10267                    }
10268                    let response = {
10269                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10270                        let encoded = common::to_string(&bytes);
10271                        match serde_json::from_str(&encoded) {
10272                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10273                            Err(error) => {
10274                                dlg.response_json_decode_error(&encoded, &error);
10275                                return Err(common::Error::JsonDecodeError(
10276                                    encoded.to_string(),
10277                                    error,
10278                                ));
10279                            }
10280                        }
10281                    };
10282
10283                    dlg.finished(true);
10284                    return Ok(response);
10285                }
10286            }
10287        }
10288    }
10289
10290    ///
10291    /// Sets the *request* property to the given value.
10292    ///
10293    /// Even though the property as already been set when instantiating this call,
10294    /// we provide this method for API completeness.
10295    pub fn request(
10296        mut self,
10297        new_value: ExecutePipelineRequest,
10298    ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
10299        self._request = new_value;
10300        self
10301    }
10302    /// Required. Database identifier, in the form `projects/{project}/databases/{database}`.
10303    ///
10304    /// Sets the *database* path property to the given value.
10305    ///
10306    /// Even though the property as already been set when instantiating this call,
10307    /// we provide this method for API completeness.
10308    pub fn database(
10309        mut self,
10310        new_value: &str,
10311    ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
10312        self._database = new_value.to_string();
10313        self
10314    }
10315    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10316    /// while executing the actual API request.
10317    ///
10318    /// ````text
10319    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10320    /// ````
10321    ///
10322    /// Sets the *delegate* property to the given value.
10323    pub fn delegate(
10324        mut self,
10325        new_value: &'a mut dyn common::Delegate,
10326    ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
10327        self._delegate = Some(new_value);
10328        self
10329    }
10330
10331    /// Set any additional parameter of the query string used in the request.
10332    /// It should be used to set parameters which are not yet available through their own
10333    /// setters.
10334    ///
10335    /// Please note that this method must not be used to set any of the known parameters
10336    /// which have their own setter method. If done anyway, the request will fail.
10337    ///
10338    /// # Additional Parameters
10339    ///
10340    /// * *$.xgafv* (query-string) - V1 error format.
10341    /// * *access_token* (query-string) - OAuth access token.
10342    /// * *alt* (query-string) - Data format for response.
10343    /// * *callback* (query-string) - JSONP
10344    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10345    /// * *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.
10346    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10347    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10348    /// * *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.
10349    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10350    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10351    pub fn param<T>(
10352        mut self,
10353        name: T,
10354        value: T,
10355    ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C>
10356    where
10357        T: AsRef<str>,
10358    {
10359        self._additional_params
10360            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10361        self
10362    }
10363
10364    /// Identifies the authorization scope for the method you are building.
10365    ///
10366    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10367    /// [`Scope::CloudPlatform`].
10368    ///
10369    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10370    /// tokens for more than one scope.
10371    ///
10372    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10373    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10374    /// sufficient, a read-write scope will do as well.
10375    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C>
10376    where
10377        St: AsRef<str>,
10378    {
10379        self._scopes.insert(String::from(scope.as_ref()));
10380        self
10381    }
10382    /// Identifies the authorization scope(s) for the method you are building.
10383    ///
10384    /// See [`Self::add_scope()`] for details.
10385    pub fn add_scopes<I, St>(
10386        mut self,
10387        scopes: I,
10388    ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C>
10389    where
10390        I: IntoIterator<Item = St>,
10391        St: AsRef<str>,
10392    {
10393        self._scopes
10394            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10395        self
10396    }
10397
10398    /// Removes all scopes, and no default scope will be used either.
10399    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10400    /// for details).
10401    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
10402        self._scopes.clear();
10403        self
10404    }
10405}
10406
10407/// Gets a single document.
10408///
10409/// A builder for the *databases.documents.get* method supported by a *project* resource.
10410/// It is not used directly, but through a [`ProjectMethods`] instance.
10411///
10412/// # Example
10413///
10414/// Instantiate a resource method builder
10415///
10416/// ```test_harness,no_run
10417/// # extern crate hyper;
10418/// # extern crate hyper_rustls;
10419/// # extern crate google_firestore1 as firestore1;
10420/// # async fn dox() {
10421/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10422///
10423/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10424/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10425/// #     .with_native_roots()
10426/// #     .unwrap()
10427/// #     .https_only()
10428/// #     .enable_http2()
10429/// #     .build();
10430///
10431/// # let executor = hyper_util::rt::TokioExecutor::new();
10432/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10433/// #     secret,
10434/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10435/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10436/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10437/// #     ),
10438/// # ).build().await.unwrap();
10439///
10440/// # let client = hyper_util::client::legacy::Client::builder(
10441/// #     hyper_util::rt::TokioExecutor::new()
10442/// # )
10443/// # .build(
10444/// #     hyper_rustls::HttpsConnectorBuilder::new()
10445/// #         .with_native_roots()
10446/// #         .unwrap()
10447/// #         .https_or_http()
10448/// #         .enable_http2()
10449/// #         .build()
10450/// # );
10451/// # let mut hub = Firestore::new(client, auth);
10452/// // You can configure optional parameters by calling the respective setters at will, and
10453/// // execute the final call using `doit()`.
10454/// // Values shown here are possibly random and not representative !
10455/// let result = hub.projects().databases_documents_get("name")
10456///              .transaction(vec![0, 1, 2, 3])
10457///              .read_time(chrono::Utc::now())
10458///              .add_mask_field_paths("ea")
10459///              .doit().await;
10460/// # }
10461/// ```
10462pub struct ProjectDatabaseDocumentGetCall<'a, C>
10463where
10464    C: 'a,
10465{
10466    hub: &'a Firestore<C>,
10467    _name: String,
10468    _transaction: Option<Vec<u8>>,
10469    _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
10470    _mask_field_paths: Vec<String>,
10471    _delegate: Option<&'a mut dyn common::Delegate>,
10472    _additional_params: HashMap<String, String>,
10473    _scopes: BTreeSet<String>,
10474}
10475
10476impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentGetCall<'a, C> {}
10477
10478impl<'a, C> ProjectDatabaseDocumentGetCall<'a, C>
10479where
10480    C: common::Connector,
10481{
10482    /// Perform the operation you have build so far.
10483    pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
10484        use std::borrow::Cow;
10485        use std::io::{Read, Seek};
10486
10487        use common::{url::Params, ToParts};
10488        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10489
10490        let mut dd = common::DefaultDelegate;
10491        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10492        dlg.begin(common::MethodInfo {
10493            id: "firestore.projects.databases.documents.get",
10494            http_method: hyper::Method::GET,
10495        });
10496
10497        for &field in ["alt", "name", "transaction", "readTime", "mask.fieldPaths"].iter() {
10498            if self._additional_params.contains_key(field) {
10499                dlg.finished(false);
10500                return Err(common::Error::FieldClash(field));
10501            }
10502        }
10503
10504        let mut params = Params::with_capacity(6 + self._additional_params.len());
10505        params.push("name", self._name);
10506        if let Some(value) = self._transaction.as_ref() {
10507            params.push(
10508                "transaction",
10509                common::serde::standard_base64::to_string(&value),
10510            );
10511        }
10512        if let Some(value) = self._read_time.as_ref() {
10513            params.push("readTime", common::serde::datetime_to_string(&value));
10514        }
10515        if !self._mask_field_paths.is_empty() {
10516            for f in self._mask_field_paths.iter() {
10517                params.push("mask.fieldPaths", f);
10518            }
10519        }
10520
10521        params.extend(self._additional_params.iter());
10522
10523        params.push("alt", "json");
10524        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10525        if self._scopes.is_empty() {
10526            self._scopes
10527                .insert(Scope::CloudPlatform.as_ref().to_string());
10528        }
10529
10530        #[allow(clippy::single_element_loop)]
10531        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10532            url = params.uri_replacement(url, param_name, find_this, true);
10533        }
10534        {
10535            let to_remove = ["name"];
10536            params.remove_params(&to_remove);
10537        }
10538
10539        let url = params.parse_with_url(&url);
10540
10541        loop {
10542            let token = match self
10543                .hub
10544                .auth
10545                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10546                .await
10547            {
10548                Ok(token) => token,
10549                Err(e) => match dlg.token(e) {
10550                    Ok(token) => token,
10551                    Err(e) => {
10552                        dlg.finished(false);
10553                        return Err(common::Error::MissingToken(e));
10554                    }
10555                },
10556            };
10557            let mut req_result = {
10558                let client = &self.hub.client;
10559                dlg.pre_request();
10560                let mut req_builder = hyper::Request::builder()
10561                    .method(hyper::Method::GET)
10562                    .uri(url.as_str())
10563                    .header(USER_AGENT, self.hub._user_agent.clone());
10564
10565                if let Some(token) = token.as_ref() {
10566                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10567                }
10568
10569                let request = req_builder
10570                    .header(CONTENT_LENGTH, 0_u64)
10571                    .body(common::to_body::<String>(None));
10572
10573                client.request(request.unwrap()).await
10574            };
10575
10576            match req_result {
10577                Err(err) => {
10578                    if let common::Retry::After(d) = dlg.http_error(&err) {
10579                        sleep(d).await;
10580                        continue;
10581                    }
10582                    dlg.finished(false);
10583                    return Err(common::Error::HttpError(err));
10584                }
10585                Ok(res) => {
10586                    let (mut parts, body) = res.into_parts();
10587                    let mut body = common::Body::new(body);
10588                    if !parts.status.is_success() {
10589                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10590                        let error = serde_json::from_str(&common::to_string(&bytes));
10591                        let response = common::to_response(parts, bytes.into());
10592
10593                        if let common::Retry::After(d) =
10594                            dlg.http_failure(&response, error.as_ref().ok())
10595                        {
10596                            sleep(d).await;
10597                            continue;
10598                        }
10599
10600                        dlg.finished(false);
10601
10602                        return Err(match error {
10603                            Ok(value) => common::Error::BadRequest(value),
10604                            _ => common::Error::Failure(response),
10605                        });
10606                    }
10607                    let response = {
10608                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10609                        let encoded = common::to_string(&bytes);
10610                        match serde_json::from_str(&encoded) {
10611                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10612                            Err(error) => {
10613                                dlg.response_json_decode_error(&encoded, &error);
10614                                return Err(common::Error::JsonDecodeError(
10615                                    encoded.to_string(),
10616                                    error,
10617                                ));
10618                            }
10619                        }
10620                    };
10621
10622                    dlg.finished(true);
10623                    return Ok(response);
10624                }
10625            }
10626        }
10627    }
10628
10629    /// Required. The resource name of the Document to get. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
10630    ///
10631    /// Sets the *name* path property to the given value.
10632    ///
10633    /// Even though the property as already been set when instantiating this call,
10634    /// we provide this method for API completeness.
10635    pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentGetCall<'a, C> {
10636        self._name = new_value.to_string();
10637        self
10638    }
10639    /// Reads the document in a transaction.
10640    ///
10641    /// Sets the *transaction* query property to the given value.
10642    pub fn transaction(mut self, new_value: Vec<u8>) -> ProjectDatabaseDocumentGetCall<'a, C> {
10643        self._transaction = Some(new_value);
10644        self
10645    }
10646    /// Reads the version of the document at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
10647    ///
10648    /// Sets the *read time* query property to the given value.
10649    pub fn read_time(
10650        mut self,
10651        new_value: chrono::DateTime<chrono::offset::Utc>,
10652    ) -> ProjectDatabaseDocumentGetCall<'a, C> {
10653        self._read_time = Some(new_value);
10654        self
10655    }
10656    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
10657    ///
10658    /// Append the given value to the *mask.field paths* query property.
10659    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10660    pub fn add_mask_field_paths(
10661        mut self,
10662        new_value: &str,
10663    ) -> ProjectDatabaseDocumentGetCall<'a, C> {
10664        self._mask_field_paths.push(new_value.to_string());
10665        self
10666    }
10667    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10668    /// while executing the actual API request.
10669    ///
10670    /// ````text
10671    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10672    /// ````
10673    ///
10674    /// Sets the *delegate* property to the given value.
10675    pub fn delegate(
10676        mut self,
10677        new_value: &'a mut dyn common::Delegate,
10678    ) -> ProjectDatabaseDocumentGetCall<'a, C> {
10679        self._delegate = Some(new_value);
10680        self
10681    }
10682
10683    /// Set any additional parameter of the query string used in the request.
10684    /// It should be used to set parameters which are not yet available through their own
10685    /// setters.
10686    ///
10687    /// Please note that this method must not be used to set any of the known parameters
10688    /// which have their own setter method. If done anyway, the request will fail.
10689    ///
10690    /// # Additional Parameters
10691    ///
10692    /// * *$.xgafv* (query-string) - V1 error format.
10693    /// * *access_token* (query-string) - OAuth access token.
10694    /// * *alt* (query-string) - Data format for response.
10695    /// * *callback* (query-string) - JSONP
10696    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10697    /// * *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.
10698    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10699    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10700    /// * *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.
10701    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10702    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10703    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentGetCall<'a, C>
10704    where
10705        T: AsRef<str>,
10706    {
10707        self._additional_params
10708            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10709        self
10710    }
10711
10712    /// Identifies the authorization scope for the method you are building.
10713    ///
10714    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10715    /// [`Scope::CloudPlatform`].
10716    ///
10717    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10718    /// tokens for more than one scope.
10719    ///
10720    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10721    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10722    /// sufficient, a read-write scope will do as well.
10723    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentGetCall<'a, C>
10724    where
10725        St: AsRef<str>,
10726    {
10727        self._scopes.insert(String::from(scope.as_ref()));
10728        self
10729    }
10730    /// Identifies the authorization scope(s) for the method you are building.
10731    ///
10732    /// See [`Self::add_scope()`] for details.
10733    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentGetCall<'a, C>
10734    where
10735        I: IntoIterator<Item = St>,
10736        St: AsRef<str>,
10737    {
10738        self._scopes
10739            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10740        self
10741    }
10742
10743    /// Removes all scopes, and no default scope will be used either.
10744    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10745    /// for details).
10746    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentGetCall<'a, C> {
10747        self._scopes.clear();
10748        self
10749    }
10750}
10751
10752/// Lists documents.
10753///
10754/// A builder for the *databases.documents.list* method supported by a *project* resource.
10755/// It is not used directly, but through a [`ProjectMethods`] instance.
10756///
10757/// # Example
10758///
10759/// Instantiate a resource method builder
10760///
10761/// ```test_harness,no_run
10762/// # extern crate hyper;
10763/// # extern crate hyper_rustls;
10764/// # extern crate google_firestore1 as firestore1;
10765/// # async fn dox() {
10766/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10767///
10768/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10769/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10770/// #     .with_native_roots()
10771/// #     .unwrap()
10772/// #     .https_only()
10773/// #     .enable_http2()
10774/// #     .build();
10775///
10776/// # let executor = hyper_util::rt::TokioExecutor::new();
10777/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10778/// #     secret,
10779/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10780/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10781/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10782/// #     ),
10783/// # ).build().await.unwrap();
10784///
10785/// # let client = hyper_util::client::legacy::Client::builder(
10786/// #     hyper_util::rt::TokioExecutor::new()
10787/// # )
10788/// # .build(
10789/// #     hyper_rustls::HttpsConnectorBuilder::new()
10790/// #         .with_native_roots()
10791/// #         .unwrap()
10792/// #         .https_or_http()
10793/// #         .enable_http2()
10794/// #         .build()
10795/// # );
10796/// # let mut hub = Firestore::new(client, auth);
10797/// // You can configure optional parameters by calling the respective setters at will, and
10798/// // execute the final call using `doit()`.
10799/// // Values shown here are possibly random and not representative !
10800/// let result = hub.projects().databases_documents_list("parent", "collectionId")
10801///              .transaction(vec![0, 1, 2, 3])
10802///              .show_missing(false)
10803///              .read_time(chrono::Utc::now())
10804///              .page_token("sed")
10805///              .page_size(-70)
10806///              .order_by("sed")
10807///              .add_mask_field_paths("no")
10808///              .doit().await;
10809/// # }
10810/// ```
10811pub struct ProjectDatabaseDocumentListCall<'a, C>
10812where
10813    C: 'a,
10814{
10815    hub: &'a Firestore<C>,
10816    _parent: String,
10817    _collection_id: String,
10818    _transaction: Option<Vec<u8>>,
10819    _show_missing: Option<bool>,
10820    _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
10821    _page_token: Option<String>,
10822    _page_size: Option<i32>,
10823    _order_by: Option<String>,
10824    _mask_field_paths: Vec<String>,
10825    _delegate: Option<&'a mut dyn common::Delegate>,
10826    _additional_params: HashMap<String, String>,
10827    _scopes: BTreeSet<String>,
10828}
10829
10830impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListCall<'a, C> {}
10831
10832impl<'a, C> ProjectDatabaseDocumentListCall<'a, C>
10833where
10834    C: common::Connector,
10835{
10836    /// Perform the operation you have build so far.
10837    pub async fn doit(mut self) -> common::Result<(common::Response, ListDocumentsResponse)> {
10838        use std::borrow::Cow;
10839        use std::io::{Read, Seek};
10840
10841        use common::{url::Params, ToParts};
10842        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10843
10844        let mut dd = common::DefaultDelegate;
10845        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10846        dlg.begin(common::MethodInfo {
10847            id: "firestore.projects.databases.documents.list",
10848            http_method: hyper::Method::GET,
10849        });
10850
10851        for &field in [
10852            "alt",
10853            "parent",
10854            "collectionId",
10855            "transaction",
10856            "showMissing",
10857            "readTime",
10858            "pageToken",
10859            "pageSize",
10860            "orderBy",
10861            "mask.fieldPaths",
10862        ]
10863        .iter()
10864        {
10865            if self._additional_params.contains_key(field) {
10866                dlg.finished(false);
10867                return Err(common::Error::FieldClash(field));
10868            }
10869        }
10870
10871        let mut params = Params::with_capacity(11 + self._additional_params.len());
10872        params.push("parent", self._parent);
10873        params.push("collectionId", self._collection_id);
10874        if let Some(value) = self._transaction.as_ref() {
10875            params.push(
10876                "transaction",
10877                common::serde::standard_base64::to_string(&value),
10878            );
10879        }
10880        if let Some(value) = self._show_missing.as_ref() {
10881            params.push("showMissing", value.to_string());
10882        }
10883        if let Some(value) = self._read_time.as_ref() {
10884            params.push("readTime", common::serde::datetime_to_string(&value));
10885        }
10886        if let Some(value) = self._page_token.as_ref() {
10887            params.push("pageToken", value);
10888        }
10889        if let Some(value) = self._page_size.as_ref() {
10890            params.push("pageSize", value.to_string());
10891        }
10892        if let Some(value) = self._order_by.as_ref() {
10893            params.push("orderBy", value);
10894        }
10895        if !self._mask_field_paths.is_empty() {
10896            for f in self._mask_field_paths.iter() {
10897                params.push("mask.fieldPaths", f);
10898            }
10899        }
10900
10901        params.extend(self._additional_params.iter());
10902
10903        params.push("alt", "json");
10904        let mut url = self.hub._base_url.clone() + "v1/{+parent}/{collectionId}";
10905        if self._scopes.is_empty() {
10906            self._scopes
10907                .insert(Scope::CloudPlatform.as_ref().to_string());
10908        }
10909
10910        #[allow(clippy::single_element_loop)]
10911        for &(find_this, param_name) in
10912            [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
10913        {
10914            url = params.uri_replacement(url, param_name, find_this, true);
10915        }
10916        {
10917            let to_remove = ["collectionId", "parent"];
10918            params.remove_params(&to_remove);
10919        }
10920
10921        let url = params.parse_with_url(&url);
10922
10923        loop {
10924            let token = match self
10925                .hub
10926                .auth
10927                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10928                .await
10929            {
10930                Ok(token) => token,
10931                Err(e) => match dlg.token(e) {
10932                    Ok(token) => token,
10933                    Err(e) => {
10934                        dlg.finished(false);
10935                        return Err(common::Error::MissingToken(e));
10936                    }
10937                },
10938            };
10939            let mut req_result = {
10940                let client = &self.hub.client;
10941                dlg.pre_request();
10942                let mut req_builder = hyper::Request::builder()
10943                    .method(hyper::Method::GET)
10944                    .uri(url.as_str())
10945                    .header(USER_AGENT, self.hub._user_agent.clone());
10946
10947                if let Some(token) = token.as_ref() {
10948                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10949                }
10950
10951                let request = req_builder
10952                    .header(CONTENT_LENGTH, 0_u64)
10953                    .body(common::to_body::<String>(None));
10954
10955                client.request(request.unwrap()).await
10956            };
10957
10958            match req_result {
10959                Err(err) => {
10960                    if let common::Retry::After(d) = dlg.http_error(&err) {
10961                        sleep(d).await;
10962                        continue;
10963                    }
10964                    dlg.finished(false);
10965                    return Err(common::Error::HttpError(err));
10966                }
10967                Ok(res) => {
10968                    let (mut parts, body) = res.into_parts();
10969                    let mut body = common::Body::new(body);
10970                    if !parts.status.is_success() {
10971                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10972                        let error = serde_json::from_str(&common::to_string(&bytes));
10973                        let response = common::to_response(parts, bytes.into());
10974
10975                        if let common::Retry::After(d) =
10976                            dlg.http_failure(&response, error.as_ref().ok())
10977                        {
10978                            sleep(d).await;
10979                            continue;
10980                        }
10981
10982                        dlg.finished(false);
10983
10984                        return Err(match error {
10985                            Ok(value) => common::Error::BadRequest(value),
10986                            _ => common::Error::Failure(response),
10987                        });
10988                    }
10989                    let response = {
10990                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10991                        let encoded = common::to_string(&bytes);
10992                        match serde_json::from_str(&encoded) {
10993                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10994                            Err(error) => {
10995                                dlg.response_json_decode_error(&encoded, &error);
10996                                return Err(common::Error::JsonDecodeError(
10997                                    encoded.to_string(),
10998                                    error,
10999                                ));
11000                            }
11001                        }
11002                    };
11003
11004                    dlg.finished(true);
11005                    return Ok(response);
11006                }
11007            }
11008        }
11009    }
11010
11011    /// Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
11012    ///
11013    /// Sets the *parent* path property to the given value.
11014    ///
11015    /// Even though the property as already been set when instantiating this call,
11016    /// we provide this method for API completeness.
11017    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
11018        self._parent = new_value.to_string();
11019        self
11020    }
11021    /// Optional. The collection ID, relative to `parent`, to list. For example: `chatrooms` or `messages`. This is optional, and when not provided, Firestore will list documents from all collections under the provided `parent`.
11022    ///
11023    /// Sets the *collection id* path property to the given value.
11024    ///
11025    /// Even though the property as already been set when instantiating this call,
11026    /// we provide this method for API completeness.
11027    pub fn collection_id(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
11028        self._collection_id = new_value.to_string();
11029        self
11030    }
11031    /// Perform the read as part of an already active transaction.
11032    ///
11033    /// Sets the *transaction* query property to the given value.
11034    pub fn transaction(mut self, new_value: Vec<u8>) -> ProjectDatabaseDocumentListCall<'a, C> {
11035        self._transaction = Some(new_value);
11036        self
11037    }
11038    /// If the list should show missing documents. A document is missing if it does not exist, but there are sub-documents nested underneath it. When true, such missing documents will be returned with a key but will not have fields, `create_time`, or `update_time` set. Requests with `show_missing` may not specify `where` or `order_by`.
11039    ///
11040    /// Sets the *show missing* query property to the given value.
11041    pub fn show_missing(mut self, new_value: bool) -> ProjectDatabaseDocumentListCall<'a, C> {
11042        self._show_missing = Some(new_value);
11043        self
11044    }
11045    /// Perform the read at the provided time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
11046    ///
11047    /// Sets the *read time* query property to the given value.
11048    pub fn read_time(
11049        mut self,
11050        new_value: chrono::DateTime<chrono::offset::Utc>,
11051    ) -> ProjectDatabaseDocumentListCall<'a, C> {
11052        self._read_time = Some(new_value);
11053        self
11054    }
11055    /// Optional. A page token, received from a previous `ListDocuments` response. Provide this to retrieve the subsequent page. When paginating, all other parameters (with the exception of `page_size`) must match the values set in the request that generated the page token.
11056    ///
11057    /// Sets the *page token* query property to the given value.
11058    pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
11059        self._page_token = Some(new_value.to_string());
11060        self
11061    }
11062    /// Optional. The maximum number of documents to return in a single response. Firestore may return fewer than this value.
11063    ///
11064    /// Sets the *page size* query property to the given value.
11065    pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseDocumentListCall<'a, C> {
11066        self._page_size = Some(new_value);
11067        self
11068    }
11069    /// Optional. The optional ordering of the documents to return. For example: `priority desc, __name__ desc`. This mirrors the `ORDER BY` used in Firestore queries but in a string representation. When absent, documents are ordered based on `__name__ ASC`.
11070    ///
11071    /// Sets the *order by* query property to the given value.
11072    pub fn order_by(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
11073        self._order_by = Some(new_value.to_string());
11074        self
11075    }
11076    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
11077    ///
11078    /// Append the given value to the *mask.field paths* query property.
11079    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11080    pub fn add_mask_field_paths(
11081        mut self,
11082        new_value: &str,
11083    ) -> ProjectDatabaseDocumentListCall<'a, C> {
11084        self._mask_field_paths.push(new_value.to_string());
11085        self
11086    }
11087    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11088    /// while executing the actual API request.
11089    ///
11090    /// ````text
11091    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11092    /// ````
11093    ///
11094    /// Sets the *delegate* property to the given value.
11095    pub fn delegate(
11096        mut self,
11097        new_value: &'a mut dyn common::Delegate,
11098    ) -> ProjectDatabaseDocumentListCall<'a, C> {
11099        self._delegate = Some(new_value);
11100        self
11101    }
11102
11103    /// Set any additional parameter of the query string used in the request.
11104    /// It should be used to set parameters which are not yet available through their own
11105    /// setters.
11106    ///
11107    /// Please note that this method must not be used to set any of the known parameters
11108    /// which have their own setter method. If done anyway, the request will fail.
11109    ///
11110    /// # Additional Parameters
11111    ///
11112    /// * *$.xgafv* (query-string) - V1 error format.
11113    /// * *access_token* (query-string) - OAuth access token.
11114    /// * *alt* (query-string) - Data format for response.
11115    /// * *callback* (query-string) - JSONP
11116    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11117    /// * *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.
11118    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11119    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11120    /// * *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.
11121    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11122    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11123    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListCall<'a, C>
11124    where
11125        T: AsRef<str>,
11126    {
11127        self._additional_params
11128            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11129        self
11130    }
11131
11132    /// Identifies the authorization scope for the method you are building.
11133    ///
11134    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11135    /// [`Scope::CloudPlatform`].
11136    ///
11137    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11138    /// tokens for more than one scope.
11139    ///
11140    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11141    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11142    /// sufficient, a read-write scope will do as well.
11143    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListCall<'a, C>
11144    where
11145        St: AsRef<str>,
11146    {
11147        self._scopes.insert(String::from(scope.as_ref()));
11148        self
11149    }
11150    /// Identifies the authorization scope(s) for the method you are building.
11151    ///
11152    /// See [`Self::add_scope()`] for details.
11153    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListCall<'a, C>
11154    where
11155        I: IntoIterator<Item = St>,
11156        St: AsRef<str>,
11157    {
11158        self._scopes
11159            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11160        self
11161    }
11162
11163    /// Removes all scopes, and no default scope will be used either.
11164    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11165    /// for details).
11166    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListCall<'a, C> {
11167        self._scopes.clear();
11168        self
11169    }
11170}
11171
11172/// Lists all the collection IDs underneath a document.
11173///
11174/// A builder for the *databases.documents.listCollectionIds* method supported by a *project* resource.
11175/// It is not used directly, but through a [`ProjectMethods`] instance.
11176///
11177/// # Example
11178///
11179/// Instantiate a resource method builder
11180///
11181/// ```test_harness,no_run
11182/// # extern crate hyper;
11183/// # extern crate hyper_rustls;
11184/// # extern crate google_firestore1 as firestore1;
11185/// use firestore1::api::ListCollectionIdsRequest;
11186/// # async fn dox() {
11187/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11188///
11189/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11190/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11191/// #     .with_native_roots()
11192/// #     .unwrap()
11193/// #     .https_only()
11194/// #     .enable_http2()
11195/// #     .build();
11196///
11197/// # let executor = hyper_util::rt::TokioExecutor::new();
11198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11199/// #     secret,
11200/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11201/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11202/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11203/// #     ),
11204/// # ).build().await.unwrap();
11205///
11206/// # let client = hyper_util::client::legacy::Client::builder(
11207/// #     hyper_util::rt::TokioExecutor::new()
11208/// # )
11209/// # .build(
11210/// #     hyper_rustls::HttpsConnectorBuilder::new()
11211/// #         .with_native_roots()
11212/// #         .unwrap()
11213/// #         .https_or_http()
11214/// #         .enable_http2()
11215/// #         .build()
11216/// # );
11217/// # let mut hub = Firestore::new(client, auth);
11218/// // As the method needs a request, you would usually fill it with the desired information
11219/// // into the respective structure. Some of the parts shown here might not be applicable !
11220/// // Values shown here are possibly random and not representative !
11221/// let mut req = ListCollectionIdsRequest::default();
11222///
11223/// // You can configure optional parameters by calling the respective setters at will, and
11224/// // execute the final call using `doit()`.
11225/// // Values shown here are possibly random and not representative !
11226/// let result = hub.projects().databases_documents_list_collection_ids(req, "parent")
11227///              .doit().await;
11228/// # }
11229/// ```
11230pub struct ProjectDatabaseDocumentListCollectionIdCall<'a, C>
11231where
11232    C: 'a,
11233{
11234    hub: &'a Firestore<C>,
11235    _request: ListCollectionIdsRequest,
11236    _parent: String,
11237    _delegate: Option<&'a mut dyn common::Delegate>,
11238    _additional_params: HashMap<String, String>,
11239    _scopes: BTreeSet<String>,
11240}
11241
11242impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListCollectionIdCall<'a, C> {}
11243
11244impl<'a, C> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
11245where
11246    C: common::Connector,
11247{
11248    /// Perform the operation you have build so far.
11249    pub async fn doit(mut self) -> common::Result<(common::Response, ListCollectionIdsResponse)> {
11250        use std::borrow::Cow;
11251        use std::io::{Read, Seek};
11252
11253        use common::{url::Params, ToParts};
11254        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11255
11256        let mut dd = common::DefaultDelegate;
11257        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11258        dlg.begin(common::MethodInfo {
11259            id: "firestore.projects.databases.documents.listCollectionIds",
11260            http_method: hyper::Method::POST,
11261        });
11262
11263        for &field in ["alt", "parent"].iter() {
11264            if self._additional_params.contains_key(field) {
11265                dlg.finished(false);
11266                return Err(common::Error::FieldClash(field));
11267            }
11268        }
11269
11270        let mut params = Params::with_capacity(4 + self._additional_params.len());
11271        params.push("parent", self._parent);
11272
11273        params.extend(self._additional_params.iter());
11274
11275        params.push("alt", "json");
11276        let mut url = self.hub._base_url.clone() + "v1/{+parent}:listCollectionIds";
11277        if self._scopes.is_empty() {
11278            self._scopes
11279                .insert(Scope::CloudPlatform.as_ref().to_string());
11280        }
11281
11282        #[allow(clippy::single_element_loop)]
11283        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11284            url = params.uri_replacement(url, param_name, find_this, true);
11285        }
11286        {
11287            let to_remove = ["parent"];
11288            params.remove_params(&to_remove);
11289        }
11290
11291        let url = params.parse_with_url(&url);
11292
11293        let mut json_mime_type = mime::APPLICATION_JSON;
11294        let mut request_value_reader = {
11295            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11296            common::remove_json_null_values(&mut value);
11297            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11298            serde_json::to_writer(&mut dst, &value).unwrap();
11299            dst
11300        };
11301        let request_size = request_value_reader
11302            .seek(std::io::SeekFrom::End(0))
11303            .unwrap();
11304        request_value_reader
11305            .seek(std::io::SeekFrom::Start(0))
11306            .unwrap();
11307
11308        loop {
11309            let token = match self
11310                .hub
11311                .auth
11312                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11313                .await
11314            {
11315                Ok(token) => token,
11316                Err(e) => match dlg.token(e) {
11317                    Ok(token) => token,
11318                    Err(e) => {
11319                        dlg.finished(false);
11320                        return Err(common::Error::MissingToken(e));
11321                    }
11322                },
11323            };
11324            request_value_reader
11325                .seek(std::io::SeekFrom::Start(0))
11326                .unwrap();
11327            let mut req_result = {
11328                let client = &self.hub.client;
11329                dlg.pre_request();
11330                let mut req_builder = hyper::Request::builder()
11331                    .method(hyper::Method::POST)
11332                    .uri(url.as_str())
11333                    .header(USER_AGENT, self.hub._user_agent.clone());
11334
11335                if let Some(token) = token.as_ref() {
11336                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11337                }
11338
11339                let request = req_builder
11340                    .header(CONTENT_TYPE, json_mime_type.to_string())
11341                    .header(CONTENT_LENGTH, request_size as u64)
11342                    .body(common::to_body(
11343                        request_value_reader.get_ref().clone().into(),
11344                    ));
11345
11346                client.request(request.unwrap()).await
11347            };
11348
11349            match req_result {
11350                Err(err) => {
11351                    if let common::Retry::After(d) = dlg.http_error(&err) {
11352                        sleep(d).await;
11353                        continue;
11354                    }
11355                    dlg.finished(false);
11356                    return Err(common::Error::HttpError(err));
11357                }
11358                Ok(res) => {
11359                    let (mut parts, body) = res.into_parts();
11360                    let mut body = common::Body::new(body);
11361                    if !parts.status.is_success() {
11362                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11363                        let error = serde_json::from_str(&common::to_string(&bytes));
11364                        let response = common::to_response(parts, bytes.into());
11365
11366                        if let common::Retry::After(d) =
11367                            dlg.http_failure(&response, error.as_ref().ok())
11368                        {
11369                            sleep(d).await;
11370                            continue;
11371                        }
11372
11373                        dlg.finished(false);
11374
11375                        return Err(match error {
11376                            Ok(value) => common::Error::BadRequest(value),
11377                            _ => common::Error::Failure(response),
11378                        });
11379                    }
11380                    let response = {
11381                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11382                        let encoded = common::to_string(&bytes);
11383                        match serde_json::from_str(&encoded) {
11384                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11385                            Err(error) => {
11386                                dlg.response_json_decode_error(&encoded, &error);
11387                                return Err(common::Error::JsonDecodeError(
11388                                    encoded.to_string(),
11389                                    error,
11390                                ));
11391                            }
11392                        }
11393                    };
11394
11395                    dlg.finished(true);
11396                    return Ok(response);
11397                }
11398            }
11399        }
11400    }
11401
11402    ///
11403    /// Sets the *request* property to the given value.
11404    ///
11405    /// Even though the property as already been set when instantiating this call,
11406    /// we provide this method for API completeness.
11407    pub fn request(
11408        mut self,
11409        new_value: ListCollectionIdsRequest,
11410    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
11411        self._request = new_value;
11412        self
11413    }
11414    /// Required. The parent document. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
11415    ///
11416    /// Sets the *parent* path property to the given value.
11417    ///
11418    /// Even though the property as already been set when instantiating this call,
11419    /// we provide this method for API completeness.
11420    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
11421        self._parent = new_value.to_string();
11422        self
11423    }
11424    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11425    /// while executing the actual API request.
11426    ///
11427    /// ````text
11428    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11429    /// ````
11430    ///
11431    /// Sets the *delegate* property to the given value.
11432    pub fn delegate(
11433        mut self,
11434        new_value: &'a mut dyn common::Delegate,
11435    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
11436        self._delegate = Some(new_value);
11437        self
11438    }
11439
11440    /// Set any additional parameter of the query string used in the request.
11441    /// It should be used to set parameters which are not yet available through their own
11442    /// setters.
11443    ///
11444    /// Please note that this method must not be used to set any of the known parameters
11445    /// which have their own setter method. If done anyway, the request will fail.
11446    ///
11447    /// # Additional Parameters
11448    ///
11449    /// * *$.xgafv* (query-string) - V1 error format.
11450    /// * *access_token* (query-string) - OAuth access token.
11451    /// * *alt* (query-string) - Data format for response.
11452    /// * *callback* (query-string) - JSONP
11453    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11454    /// * *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.
11455    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11456    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11457    /// * *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.
11458    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11459    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11460    pub fn param<T>(
11461        mut self,
11462        name: T,
11463        value: T,
11464    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
11465    where
11466        T: AsRef<str>,
11467    {
11468        self._additional_params
11469            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11470        self
11471    }
11472
11473    /// Identifies the authorization scope for the method you are building.
11474    ///
11475    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11476    /// [`Scope::CloudPlatform`].
11477    ///
11478    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11479    /// tokens for more than one scope.
11480    ///
11481    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11482    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11483    /// sufficient, a read-write scope will do as well.
11484    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
11485    where
11486        St: AsRef<str>,
11487    {
11488        self._scopes.insert(String::from(scope.as_ref()));
11489        self
11490    }
11491    /// Identifies the authorization scope(s) for the method you are building.
11492    ///
11493    /// See [`Self::add_scope()`] for details.
11494    pub fn add_scopes<I, St>(
11495        mut self,
11496        scopes: I,
11497    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
11498    where
11499        I: IntoIterator<Item = St>,
11500        St: AsRef<str>,
11501    {
11502        self._scopes
11503            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11504        self
11505    }
11506
11507    /// Removes all scopes, and no default scope will be used either.
11508    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11509    /// for details).
11510    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
11511        self._scopes.clear();
11512        self
11513    }
11514}
11515
11516/// Lists documents.
11517///
11518/// A builder for the *databases.documents.listDocuments* method supported by a *project* resource.
11519/// It is not used directly, but through a [`ProjectMethods`] instance.
11520///
11521/// # Example
11522///
11523/// Instantiate a resource method builder
11524///
11525/// ```test_harness,no_run
11526/// # extern crate hyper;
11527/// # extern crate hyper_rustls;
11528/// # extern crate google_firestore1 as firestore1;
11529/// # async fn dox() {
11530/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11531///
11532/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11533/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11534/// #     .with_native_roots()
11535/// #     .unwrap()
11536/// #     .https_only()
11537/// #     .enable_http2()
11538/// #     .build();
11539///
11540/// # let executor = hyper_util::rt::TokioExecutor::new();
11541/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11542/// #     secret,
11543/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11544/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11545/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11546/// #     ),
11547/// # ).build().await.unwrap();
11548///
11549/// # let client = hyper_util::client::legacy::Client::builder(
11550/// #     hyper_util::rt::TokioExecutor::new()
11551/// # )
11552/// # .build(
11553/// #     hyper_rustls::HttpsConnectorBuilder::new()
11554/// #         .with_native_roots()
11555/// #         .unwrap()
11556/// #         .https_or_http()
11557/// #         .enable_http2()
11558/// #         .build()
11559/// # );
11560/// # let mut hub = Firestore::new(client, auth);
11561/// // You can configure optional parameters by calling the respective setters at will, and
11562/// // execute the final call using `doit()`.
11563/// // Values shown here are possibly random and not representative !
11564/// let result = hub.projects().databases_documents_list_documents("parent", "collectionId")
11565///              .transaction(vec![0, 1, 2, 3])
11566///              .show_missing(true)
11567///              .read_time(chrono::Utc::now())
11568///              .page_token("et")
11569///              .page_size(-68)
11570///              .order_by("vero")
11571///              .add_mask_field_paths("erat")
11572///              .doit().await;
11573/// # }
11574/// ```
11575pub struct ProjectDatabaseDocumentListDocumentCall<'a, C>
11576where
11577    C: 'a,
11578{
11579    hub: &'a Firestore<C>,
11580    _parent: String,
11581    _collection_id: String,
11582    _transaction: Option<Vec<u8>>,
11583    _show_missing: Option<bool>,
11584    _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
11585    _page_token: Option<String>,
11586    _page_size: Option<i32>,
11587    _order_by: Option<String>,
11588    _mask_field_paths: Vec<String>,
11589    _delegate: Option<&'a mut dyn common::Delegate>,
11590    _additional_params: HashMap<String, String>,
11591    _scopes: BTreeSet<String>,
11592}
11593
11594impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListDocumentCall<'a, C> {}
11595
11596impl<'a, C> ProjectDatabaseDocumentListDocumentCall<'a, C>
11597where
11598    C: common::Connector,
11599{
11600    /// Perform the operation you have build so far.
11601    pub async fn doit(mut self) -> common::Result<(common::Response, ListDocumentsResponse)> {
11602        use std::borrow::Cow;
11603        use std::io::{Read, Seek};
11604
11605        use common::{url::Params, ToParts};
11606        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11607
11608        let mut dd = common::DefaultDelegate;
11609        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11610        dlg.begin(common::MethodInfo {
11611            id: "firestore.projects.databases.documents.listDocuments",
11612            http_method: hyper::Method::GET,
11613        });
11614
11615        for &field in [
11616            "alt",
11617            "parent",
11618            "collectionId",
11619            "transaction",
11620            "showMissing",
11621            "readTime",
11622            "pageToken",
11623            "pageSize",
11624            "orderBy",
11625            "mask.fieldPaths",
11626        ]
11627        .iter()
11628        {
11629            if self._additional_params.contains_key(field) {
11630                dlg.finished(false);
11631                return Err(common::Error::FieldClash(field));
11632            }
11633        }
11634
11635        let mut params = Params::with_capacity(11 + self._additional_params.len());
11636        params.push("parent", self._parent);
11637        params.push("collectionId", self._collection_id);
11638        if let Some(value) = self._transaction.as_ref() {
11639            params.push(
11640                "transaction",
11641                common::serde::standard_base64::to_string(&value),
11642            );
11643        }
11644        if let Some(value) = self._show_missing.as_ref() {
11645            params.push("showMissing", value.to_string());
11646        }
11647        if let Some(value) = self._read_time.as_ref() {
11648            params.push("readTime", common::serde::datetime_to_string(&value));
11649        }
11650        if let Some(value) = self._page_token.as_ref() {
11651            params.push("pageToken", value);
11652        }
11653        if let Some(value) = self._page_size.as_ref() {
11654            params.push("pageSize", value.to_string());
11655        }
11656        if let Some(value) = self._order_by.as_ref() {
11657            params.push("orderBy", value);
11658        }
11659        if !self._mask_field_paths.is_empty() {
11660            for f in self._mask_field_paths.iter() {
11661                params.push("mask.fieldPaths", f);
11662            }
11663        }
11664
11665        params.extend(self._additional_params.iter());
11666
11667        params.push("alt", "json");
11668        let mut url = self.hub._base_url.clone() + "v1/{+parent}/{collectionId}";
11669        if self._scopes.is_empty() {
11670            self._scopes
11671                .insert(Scope::CloudPlatform.as_ref().to_string());
11672        }
11673
11674        #[allow(clippy::single_element_loop)]
11675        for &(find_this, param_name) in
11676            [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
11677        {
11678            url = params.uri_replacement(url, param_name, find_this, true);
11679        }
11680        {
11681            let to_remove = ["collectionId", "parent"];
11682            params.remove_params(&to_remove);
11683        }
11684
11685        let url = params.parse_with_url(&url);
11686
11687        loop {
11688            let token = match self
11689                .hub
11690                .auth
11691                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11692                .await
11693            {
11694                Ok(token) => token,
11695                Err(e) => match dlg.token(e) {
11696                    Ok(token) => token,
11697                    Err(e) => {
11698                        dlg.finished(false);
11699                        return Err(common::Error::MissingToken(e));
11700                    }
11701                },
11702            };
11703            let mut req_result = {
11704                let client = &self.hub.client;
11705                dlg.pre_request();
11706                let mut req_builder = hyper::Request::builder()
11707                    .method(hyper::Method::GET)
11708                    .uri(url.as_str())
11709                    .header(USER_AGENT, self.hub._user_agent.clone());
11710
11711                if let Some(token) = token.as_ref() {
11712                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11713                }
11714
11715                let request = req_builder
11716                    .header(CONTENT_LENGTH, 0_u64)
11717                    .body(common::to_body::<String>(None));
11718
11719                client.request(request.unwrap()).await
11720            };
11721
11722            match req_result {
11723                Err(err) => {
11724                    if let common::Retry::After(d) = dlg.http_error(&err) {
11725                        sleep(d).await;
11726                        continue;
11727                    }
11728                    dlg.finished(false);
11729                    return Err(common::Error::HttpError(err));
11730                }
11731                Ok(res) => {
11732                    let (mut parts, body) = res.into_parts();
11733                    let mut body = common::Body::new(body);
11734                    if !parts.status.is_success() {
11735                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11736                        let error = serde_json::from_str(&common::to_string(&bytes));
11737                        let response = common::to_response(parts, bytes.into());
11738
11739                        if let common::Retry::After(d) =
11740                            dlg.http_failure(&response, error.as_ref().ok())
11741                        {
11742                            sleep(d).await;
11743                            continue;
11744                        }
11745
11746                        dlg.finished(false);
11747
11748                        return Err(match error {
11749                            Ok(value) => common::Error::BadRequest(value),
11750                            _ => common::Error::Failure(response),
11751                        });
11752                    }
11753                    let response = {
11754                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11755                        let encoded = common::to_string(&bytes);
11756                        match serde_json::from_str(&encoded) {
11757                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11758                            Err(error) => {
11759                                dlg.response_json_decode_error(&encoded, &error);
11760                                return Err(common::Error::JsonDecodeError(
11761                                    encoded.to_string(),
11762                                    error,
11763                                ));
11764                            }
11765                        }
11766                    };
11767
11768                    dlg.finished(true);
11769                    return Ok(response);
11770                }
11771            }
11772        }
11773    }
11774
11775    /// Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
11776    ///
11777    /// Sets the *parent* path property to the given value.
11778    ///
11779    /// Even though the property as already been set when instantiating this call,
11780    /// we provide this method for API completeness.
11781    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11782        self._parent = new_value.to_string();
11783        self
11784    }
11785    /// Optional. The collection ID, relative to `parent`, to list. For example: `chatrooms` or `messages`. This is optional, and when not provided, Firestore will list documents from all collections under the provided `parent`.
11786    ///
11787    /// Sets the *collection id* path property to the given value.
11788    ///
11789    /// Even though the property as already been set when instantiating this call,
11790    /// we provide this method for API completeness.
11791    pub fn collection_id(
11792        mut self,
11793        new_value: &str,
11794    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11795        self._collection_id = new_value.to_string();
11796        self
11797    }
11798    /// Perform the read as part of an already active transaction.
11799    ///
11800    /// Sets the *transaction* query property to the given value.
11801    pub fn transaction(
11802        mut self,
11803        new_value: Vec<u8>,
11804    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11805        self._transaction = Some(new_value);
11806        self
11807    }
11808    /// If the list should show missing documents. A document is missing if it does not exist, but there are sub-documents nested underneath it. When true, such missing documents will be returned with a key but will not have fields, `create_time`, or `update_time` set. Requests with `show_missing` may not specify `where` or `order_by`.
11809    ///
11810    /// Sets the *show missing* query property to the given value.
11811    pub fn show_missing(
11812        mut self,
11813        new_value: bool,
11814    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11815        self._show_missing = Some(new_value);
11816        self
11817    }
11818    /// Perform the read at the provided time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
11819    ///
11820    /// Sets the *read time* query property to the given value.
11821    pub fn read_time(
11822        mut self,
11823        new_value: chrono::DateTime<chrono::offset::Utc>,
11824    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11825        self._read_time = Some(new_value);
11826        self
11827    }
11828    /// Optional. A page token, received from a previous `ListDocuments` response. Provide this to retrieve the subsequent page. When paginating, all other parameters (with the exception of `page_size`) must match the values set in the request that generated the page token.
11829    ///
11830    /// Sets the *page token* query property to the given value.
11831    pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11832        self._page_token = Some(new_value.to_string());
11833        self
11834    }
11835    /// Optional. The maximum number of documents to return in a single response. Firestore may return fewer than this value.
11836    ///
11837    /// Sets the *page size* query property to the given value.
11838    pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11839        self._page_size = Some(new_value);
11840        self
11841    }
11842    /// Optional. The optional ordering of the documents to return. For example: `priority desc, __name__ desc`. This mirrors the `ORDER BY` used in Firestore queries but in a string representation. When absent, documents are ordered based on `__name__ ASC`.
11843    ///
11844    /// Sets the *order by* query property to the given value.
11845    pub fn order_by(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11846        self._order_by = Some(new_value.to_string());
11847        self
11848    }
11849    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
11850    ///
11851    /// Append the given value to the *mask.field paths* query property.
11852    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11853    pub fn add_mask_field_paths(
11854        mut self,
11855        new_value: &str,
11856    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11857        self._mask_field_paths.push(new_value.to_string());
11858        self
11859    }
11860    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11861    /// while executing the actual API request.
11862    ///
11863    /// ````text
11864    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11865    /// ````
11866    ///
11867    /// Sets the *delegate* property to the given value.
11868    pub fn delegate(
11869        mut self,
11870        new_value: &'a mut dyn common::Delegate,
11871    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11872        self._delegate = Some(new_value);
11873        self
11874    }
11875
11876    /// Set any additional parameter of the query string used in the request.
11877    /// It should be used to set parameters which are not yet available through their own
11878    /// setters.
11879    ///
11880    /// Please note that this method must not be used to set any of the known parameters
11881    /// which have their own setter method. If done anyway, the request will fail.
11882    ///
11883    /// # Additional Parameters
11884    ///
11885    /// * *$.xgafv* (query-string) - V1 error format.
11886    /// * *access_token* (query-string) - OAuth access token.
11887    /// * *alt* (query-string) - Data format for response.
11888    /// * *callback* (query-string) - JSONP
11889    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11890    /// * *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.
11891    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11892    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11893    /// * *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.
11894    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11895    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11896    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListDocumentCall<'a, C>
11897    where
11898        T: AsRef<str>,
11899    {
11900        self._additional_params
11901            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11902        self
11903    }
11904
11905    /// Identifies the authorization scope for the method you are building.
11906    ///
11907    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11908    /// [`Scope::CloudPlatform`].
11909    ///
11910    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11911    /// tokens for more than one scope.
11912    ///
11913    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11914    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11915    /// sufficient, a read-write scope will do as well.
11916    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListDocumentCall<'a, C>
11917    where
11918        St: AsRef<str>,
11919    {
11920        self._scopes.insert(String::from(scope.as_ref()));
11921        self
11922    }
11923    /// Identifies the authorization scope(s) for the method you are building.
11924    ///
11925    /// See [`Self::add_scope()`] for details.
11926    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListDocumentCall<'a, C>
11927    where
11928        I: IntoIterator<Item = St>,
11929        St: AsRef<str>,
11930    {
11931        self._scopes
11932            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11933        self
11934    }
11935
11936    /// Removes all scopes, and no default scope will be used either.
11937    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11938    /// for details).
11939    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
11940        self._scopes.clear();
11941        self
11942    }
11943}
11944
11945/// Listens to changes. This method is only available via gRPC or WebChannel (not REST).
11946///
11947/// A builder for the *databases.documents.listen* method supported by a *project* resource.
11948/// It is not used directly, but through a [`ProjectMethods`] instance.
11949///
11950/// # Example
11951///
11952/// Instantiate a resource method builder
11953///
11954/// ```test_harness,no_run
11955/// # extern crate hyper;
11956/// # extern crate hyper_rustls;
11957/// # extern crate google_firestore1 as firestore1;
11958/// use firestore1::api::ListenRequest;
11959/// # async fn dox() {
11960/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11961///
11962/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11963/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11964/// #     .with_native_roots()
11965/// #     .unwrap()
11966/// #     .https_only()
11967/// #     .enable_http2()
11968/// #     .build();
11969///
11970/// # let executor = hyper_util::rt::TokioExecutor::new();
11971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11972/// #     secret,
11973/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11974/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11975/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11976/// #     ),
11977/// # ).build().await.unwrap();
11978///
11979/// # let client = hyper_util::client::legacy::Client::builder(
11980/// #     hyper_util::rt::TokioExecutor::new()
11981/// # )
11982/// # .build(
11983/// #     hyper_rustls::HttpsConnectorBuilder::new()
11984/// #         .with_native_roots()
11985/// #         .unwrap()
11986/// #         .https_or_http()
11987/// #         .enable_http2()
11988/// #         .build()
11989/// # );
11990/// # let mut hub = Firestore::new(client, auth);
11991/// // As the method needs a request, you would usually fill it with the desired information
11992/// // into the respective structure. Some of the parts shown here might not be applicable !
11993/// // Values shown here are possibly random and not representative !
11994/// let mut req = ListenRequest::default();
11995///
11996/// // You can configure optional parameters by calling the respective setters at will, and
11997/// // execute the final call using `doit()`.
11998/// // Values shown here are possibly random and not representative !
11999/// let result = hub.projects().databases_documents_listen(req, "database")
12000///              .doit().await;
12001/// # }
12002/// ```
12003pub struct ProjectDatabaseDocumentListenCall<'a, C>
12004where
12005    C: 'a,
12006{
12007    hub: &'a Firestore<C>,
12008    _request: ListenRequest,
12009    _database: String,
12010    _delegate: Option<&'a mut dyn common::Delegate>,
12011    _additional_params: HashMap<String, String>,
12012    _scopes: BTreeSet<String>,
12013}
12014
12015impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListenCall<'a, C> {}
12016
12017impl<'a, C> ProjectDatabaseDocumentListenCall<'a, C>
12018where
12019    C: common::Connector,
12020{
12021    /// Perform the operation you have build so far.
12022    pub async fn doit(mut self) -> common::Result<(common::Response, ListenResponse)> {
12023        use std::borrow::Cow;
12024        use std::io::{Read, Seek};
12025
12026        use common::{url::Params, ToParts};
12027        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12028
12029        let mut dd = common::DefaultDelegate;
12030        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12031        dlg.begin(common::MethodInfo {
12032            id: "firestore.projects.databases.documents.listen",
12033            http_method: hyper::Method::POST,
12034        });
12035
12036        for &field in ["alt", "database"].iter() {
12037            if self._additional_params.contains_key(field) {
12038                dlg.finished(false);
12039                return Err(common::Error::FieldClash(field));
12040            }
12041        }
12042
12043        let mut params = Params::with_capacity(4 + self._additional_params.len());
12044        params.push("database", self._database);
12045
12046        params.extend(self._additional_params.iter());
12047
12048        params.push("alt", "json");
12049        let mut url = self.hub._base_url.clone() + "v1/{+database}/documents:listen";
12050        if self._scopes.is_empty() {
12051            self._scopes
12052                .insert(Scope::CloudPlatform.as_ref().to_string());
12053        }
12054
12055        #[allow(clippy::single_element_loop)]
12056        for &(find_this, param_name) in [("{+database}", "database")].iter() {
12057            url = params.uri_replacement(url, param_name, find_this, true);
12058        }
12059        {
12060            let to_remove = ["database"];
12061            params.remove_params(&to_remove);
12062        }
12063
12064        let url = params.parse_with_url(&url);
12065
12066        let mut json_mime_type = mime::APPLICATION_JSON;
12067        let mut request_value_reader = {
12068            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12069            common::remove_json_null_values(&mut value);
12070            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12071            serde_json::to_writer(&mut dst, &value).unwrap();
12072            dst
12073        };
12074        let request_size = request_value_reader
12075            .seek(std::io::SeekFrom::End(0))
12076            .unwrap();
12077        request_value_reader
12078            .seek(std::io::SeekFrom::Start(0))
12079            .unwrap();
12080
12081        loop {
12082            let token = match self
12083                .hub
12084                .auth
12085                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12086                .await
12087            {
12088                Ok(token) => token,
12089                Err(e) => match dlg.token(e) {
12090                    Ok(token) => token,
12091                    Err(e) => {
12092                        dlg.finished(false);
12093                        return Err(common::Error::MissingToken(e));
12094                    }
12095                },
12096            };
12097            request_value_reader
12098                .seek(std::io::SeekFrom::Start(0))
12099                .unwrap();
12100            let mut req_result = {
12101                let client = &self.hub.client;
12102                dlg.pre_request();
12103                let mut req_builder = hyper::Request::builder()
12104                    .method(hyper::Method::POST)
12105                    .uri(url.as_str())
12106                    .header(USER_AGENT, self.hub._user_agent.clone());
12107
12108                if let Some(token) = token.as_ref() {
12109                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12110                }
12111
12112                let request = req_builder
12113                    .header(CONTENT_TYPE, json_mime_type.to_string())
12114                    .header(CONTENT_LENGTH, request_size as u64)
12115                    .body(common::to_body(
12116                        request_value_reader.get_ref().clone().into(),
12117                    ));
12118
12119                client.request(request.unwrap()).await
12120            };
12121
12122            match req_result {
12123                Err(err) => {
12124                    if let common::Retry::After(d) = dlg.http_error(&err) {
12125                        sleep(d).await;
12126                        continue;
12127                    }
12128                    dlg.finished(false);
12129                    return Err(common::Error::HttpError(err));
12130                }
12131                Ok(res) => {
12132                    let (mut parts, body) = res.into_parts();
12133                    let mut body = common::Body::new(body);
12134                    if !parts.status.is_success() {
12135                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12136                        let error = serde_json::from_str(&common::to_string(&bytes));
12137                        let response = common::to_response(parts, bytes.into());
12138
12139                        if let common::Retry::After(d) =
12140                            dlg.http_failure(&response, error.as_ref().ok())
12141                        {
12142                            sleep(d).await;
12143                            continue;
12144                        }
12145
12146                        dlg.finished(false);
12147
12148                        return Err(match error {
12149                            Ok(value) => common::Error::BadRequest(value),
12150                            _ => common::Error::Failure(response),
12151                        });
12152                    }
12153                    let response = {
12154                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12155                        let encoded = common::to_string(&bytes);
12156                        match serde_json::from_str(&encoded) {
12157                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12158                            Err(error) => {
12159                                dlg.response_json_decode_error(&encoded, &error);
12160                                return Err(common::Error::JsonDecodeError(
12161                                    encoded.to_string(),
12162                                    error,
12163                                ));
12164                            }
12165                        }
12166                    };
12167
12168                    dlg.finished(true);
12169                    return Ok(response);
12170                }
12171            }
12172        }
12173    }
12174
12175    ///
12176    /// Sets the *request* property to the given value.
12177    ///
12178    /// Even though the property as already been set when instantiating this call,
12179    /// we provide this method for API completeness.
12180    pub fn request(mut self, new_value: ListenRequest) -> ProjectDatabaseDocumentListenCall<'a, C> {
12181        self._request = new_value;
12182        self
12183    }
12184    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
12185    ///
12186    /// Sets the *database* path property to the given value.
12187    ///
12188    /// Even though the property as already been set when instantiating this call,
12189    /// we provide this method for API completeness.
12190    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentListenCall<'a, C> {
12191        self._database = new_value.to_string();
12192        self
12193    }
12194    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12195    /// while executing the actual API request.
12196    ///
12197    /// ````text
12198    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12199    /// ````
12200    ///
12201    /// Sets the *delegate* property to the given value.
12202    pub fn delegate(
12203        mut self,
12204        new_value: &'a mut dyn common::Delegate,
12205    ) -> ProjectDatabaseDocumentListenCall<'a, C> {
12206        self._delegate = Some(new_value);
12207        self
12208    }
12209
12210    /// Set any additional parameter of the query string used in the request.
12211    /// It should be used to set parameters which are not yet available through their own
12212    /// setters.
12213    ///
12214    /// Please note that this method must not be used to set any of the known parameters
12215    /// which have their own setter method. If done anyway, the request will fail.
12216    ///
12217    /// # Additional Parameters
12218    ///
12219    /// * *$.xgafv* (query-string) - V1 error format.
12220    /// * *access_token* (query-string) - OAuth access token.
12221    /// * *alt* (query-string) - Data format for response.
12222    /// * *callback* (query-string) - JSONP
12223    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12224    /// * *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.
12225    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12226    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12227    /// * *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.
12228    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12229    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12230    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListenCall<'a, C>
12231    where
12232        T: AsRef<str>,
12233    {
12234        self._additional_params
12235            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12236        self
12237    }
12238
12239    /// Identifies the authorization scope for the method you are building.
12240    ///
12241    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12242    /// [`Scope::CloudPlatform`].
12243    ///
12244    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12245    /// tokens for more than one scope.
12246    ///
12247    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12248    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12249    /// sufficient, a read-write scope will do as well.
12250    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListenCall<'a, C>
12251    where
12252        St: AsRef<str>,
12253    {
12254        self._scopes.insert(String::from(scope.as_ref()));
12255        self
12256    }
12257    /// Identifies the authorization scope(s) for the method you are building.
12258    ///
12259    /// See [`Self::add_scope()`] for details.
12260    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListenCall<'a, C>
12261    where
12262        I: IntoIterator<Item = St>,
12263        St: AsRef<str>,
12264    {
12265        self._scopes
12266            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12267        self
12268    }
12269
12270    /// Removes all scopes, and no default scope will be used either.
12271    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12272    /// for details).
12273    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListenCall<'a, C> {
12274        self._scopes.clear();
12275        self
12276    }
12277}
12278
12279/// Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.
12280///
12281/// A builder for the *databases.documents.partitionQuery* method supported by a *project* resource.
12282/// It is not used directly, but through a [`ProjectMethods`] instance.
12283///
12284/// # Example
12285///
12286/// Instantiate a resource method builder
12287///
12288/// ```test_harness,no_run
12289/// # extern crate hyper;
12290/// # extern crate hyper_rustls;
12291/// # extern crate google_firestore1 as firestore1;
12292/// use firestore1::api::PartitionQueryRequest;
12293/// # async fn dox() {
12294/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12295///
12296/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12297/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12298/// #     .with_native_roots()
12299/// #     .unwrap()
12300/// #     .https_only()
12301/// #     .enable_http2()
12302/// #     .build();
12303///
12304/// # let executor = hyper_util::rt::TokioExecutor::new();
12305/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12306/// #     secret,
12307/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12308/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12309/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12310/// #     ),
12311/// # ).build().await.unwrap();
12312///
12313/// # let client = hyper_util::client::legacy::Client::builder(
12314/// #     hyper_util::rt::TokioExecutor::new()
12315/// # )
12316/// # .build(
12317/// #     hyper_rustls::HttpsConnectorBuilder::new()
12318/// #         .with_native_roots()
12319/// #         .unwrap()
12320/// #         .https_or_http()
12321/// #         .enable_http2()
12322/// #         .build()
12323/// # );
12324/// # let mut hub = Firestore::new(client, auth);
12325/// // As the method needs a request, you would usually fill it with the desired information
12326/// // into the respective structure. Some of the parts shown here might not be applicable !
12327/// // Values shown here are possibly random and not representative !
12328/// let mut req = PartitionQueryRequest::default();
12329///
12330/// // You can configure optional parameters by calling the respective setters at will, and
12331/// // execute the final call using `doit()`.
12332/// // Values shown here are possibly random and not representative !
12333/// let result = hub.projects().databases_documents_partition_query(req, "parent")
12334///              .doit().await;
12335/// # }
12336/// ```
12337pub struct ProjectDatabaseDocumentPartitionQueryCall<'a, C>
12338where
12339    C: 'a,
12340{
12341    hub: &'a Firestore<C>,
12342    _request: PartitionQueryRequest,
12343    _parent: String,
12344    _delegate: Option<&'a mut dyn common::Delegate>,
12345    _additional_params: HashMap<String, String>,
12346    _scopes: BTreeSet<String>,
12347}
12348
12349impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentPartitionQueryCall<'a, C> {}
12350
12351impl<'a, C> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
12352where
12353    C: common::Connector,
12354{
12355    /// Perform the operation you have build so far.
12356    pub async fn doit(mut self) -> common::Result<(common::Response, PartitionQueryResponse)> {
12357        use std::borrow::Cow;
12358        use std::io::{Read, Seek};
12359
12360        use common::{url::Params, ToParts};
12361        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12362
12363        let mut dd = common::DefaultDelegate;
12364        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12365        dlg.begin(common::MethodInfo {
12366            id: "firestore.projects.databases.documents.partitionQuery",
12367            http_method: hyper::Method::POST,
12368        });
12369
12370        for &field in ["alt", "parent"].iter() {
12371            if self._additional_params.contains_key(field) {
12372                dlg.finished(false);
12373                return Err(common::Error::FieldClash(field));
12374            }
12375        }
12376
12377        let mut params = Params::with_capacity(4 + self._additional_params.len());
12378        params.push("parent", self._parent);
12379
12380        params.extend(self._additional_params.iter());
12381
12382        params.push("alt", "json");
12383        let mut url = self.hub._base_url.clone() + "v1/{+parent}:partitionQuery";
12384        if self._scopes.is_empty() {
12385            self._scopes
12386                .insert(Scope::CloudPlatform.as_ref().to_string());
12387        }
12388
12389        #[allow(clippy::single_element_loop)]
12390        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12391            url = params.uri_replacement(url, param_name, find_this, true);
12392        }
12393        {
12394            let to_remove = ["parent"];
12395            params.remove_params(&to_remove);
12396        }
12397
12398        let url = params.parse_with_url(&url);
12399
12400        let mut json_mime_type = mime::APPLICATION_JSON;
12401        let mut request_value_reader = {
12402            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12403            common::remove_json_null_values(&mut value);
12404            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12405            serde_json::to_writer(&mut dst, &value).unwrap();
12406            dst
12407        };
12408        let request_size = request_value_reader
12409            .seek(std::io::SeekFrom::End(0))
12410            .unwrap();
12411        request_value_reader
12412            .seek(std::io::SeekFrom::Start(0))
12413            .unwrap();
12414
12415        loop {
12416            let token = match self
12417                .hub
12418                .auth
12419                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12420                .await
12421            {
12422                Ok(token) => token,
12423                Err(e) => match dlg.token(e) {
12424                    Ok(token) => token,
12425                    Err(e) => {
12426                        dlg.finished(false);
12427                        return Err(common::Error::MissingToken(e));
12428                    }
12429                },
12430            };
12431            request_value_reader
12432                .seek(std::io::SeekFrom::Start(0))
12433                .unwrap();
12434            let mut req_result = {
12435                let client = &self.hub.client;
12436                dlg.pre_request();
12437                let mut req_builder = hyper::Request::builder()
12438                    .method(hyper::Method::POST)
12439                    .uri(url.as_str())
12440                    .header(USER_AGENT, self.hub._user_agent.clone());
12441
12442                if let Some(token) = token.as_ref() {
12443                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12444                }
12445
12446                let request = req_builder
12447                    .header(CONTENT_TYPE, json_mime_type.to_string())
12448                    .header(CONTENT_LENGTH, request_size as u64)
12449                    .body(common::to_body(
12450                        request_value_reader.get_ref().clone().into(),
12451                    ));
12452
12453                client.request(request.unwrap()).await
12454            };
12455
12456            match req_result {
12457                Err(err) => {
12458                    if let common::Retry::After(d) = dlg.http_error(&err) {
12459                        sleep(d).await;
12460                        continue;
12461                    }
12462                    dlg.finished(false);
12463                    return Err(common::Error::HttpError(err));
12464                }
12465                Ok(res) => {
12466                    let (mut parts, body) = res.into_parts();
12467                    let mut body = common::Body::new(body);
12468                    if !parts.status.is_success() {
12469                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12470                        let error = serde_json::from_str(&common::to_string(&bytes));
12471                        let response = common::to_response(parts, bytes.into());
12472
12473                        if let common::Retry::After(d) =
12474                            dlg.http_failure(&response, error.as_ref().ok())
12475                        {
12476                            sleep(d).await;
12477                            continue;
12478                        }
12479
12480                        dlg.finished(false);
12481
12482                        return Err(match error {
12483                            Ok(value) => common::Error::BadRequest(value),
12484                            _ => common::Error::Failure(response),
12485                        });
12486                    }
12487                    let response = {
12488                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12489                        let encoded = common::to_string(&bytes);
12490                        match serde_json::from_str(&encoded) {
12491                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12492                            Err(error) => {
12493                                dlg.response_json_decode_error(&encoded, &error);
12494                                return Err(common::Error::JsonDecodeError(
12495                                    encoded.to_string(),
12496                                    error,
12497                                ));
12498                            }
12499                        }
12500                    };
12501
12502                    dlg.finished(true);
12503                    return Ok(response);
12504                }
12505            }
12506        }
12507    }
12508
12509    ///
12510    /// Sets the *request* property to the given value.
12511    ///
12512    /// Even though the property as already been set when instantiating this call,
12513    /// we provide this method for API completeness.
12514    pub fn request(
12515        mut self,
12516        new_value: PartitionQueryRequest,
12517    ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
12518        self._request = new_value;
12519        self
12520    }
12521    /// Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents`. Document resource names are not supported; only database resource names can be specified.
12522    ///
12523    /// Sets the *parent* path property to the given value.
12524    ///
12525    /// Even though the property as already been set when instantiating this call,
12526    /// we provide this method for API completeness.
12527    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
12528        self._parent = new_value.to_string();
12529        self
12530    }
12531    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12532    /// while executing the actual API request.
12533    ///
12534    /// ````text
12535    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12536    /// ````
12537    ///
12538    /// Sets the *delegate* property to the given value.
12539    pub fn delegate(
12540        mut self,
12541        new_value: &'a mut dyn common::Delegate,
12542    ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
12543        self._delegate = Some(new_value);
12544        self
12545    }
12546
12547    /// Set any additional parameter of the query string used in the request.
12548    /// It should be used to set parameters which are not yet available through their own
12549    /// setters.
12550    ///
12551    /// Please note that this method must not be used to set any of the known parameters
12552    /// which have their own setter method. If done anyway, the request will fail.
12553    ///
12554    /// # Additional Parameters
12555    ///
12556    /// * *$.xgafv* (query-string) - V1 error format.
12557    /// * *access_token* (query-string) - OAuth access token.
12558    /// * *alt* (query-string) - Data format for response.
12559    /// * *callback* (query-string) - JSONP
12560    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12561    /// * *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.
12562    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12563    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12564    /// * *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.
12565    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12566    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12567    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
12568    where
12569        T: AsRef<str>,
12570    {
12571        self._additional_params
12572            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12573        self
12574    }
12575
12576    /// Identifies the authorization scope for the method you are building.
12577    ///
12578    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12579    /// [`Scope::CloudPlatform`].
12580    ///
12581    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12582    /// tokens for more than one scope.
12583    ///
12584    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12585    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12586    /// sufficient, a read-write scope will do as well.
12587    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
12588    where
12589        St: AsRef<str>,
12590    {
12591        self._scopes.insert(String::from(scope.as_ref()));
12592        self
12593    }
12594    /// Identifies the authorization scope(s) for the method you are building.
12595    ///
12596    /// See [`Self::add_scope()`] for details.
12597    pub fn add_scopes<I, St>(
12598        mut self,
12599        scopes: I,
12600    ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
12601    where
12602        I: IntoIterator<Item = St>,
12603        St: AsRef<str>,
12604    {
12605        self._scopes
12606            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12607        self
12608    }
12609
12610    /// Removes all scopes, and no default scope will be used either.
12611    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12612    /// for details).
12613    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
12614        self._scopes.clear();
12615        self
12616    }
12617}
12618
12619/// Updates or inserts a document.
12620///
12621/// A builder for the *databases.documents.patch* method supported by a *project* resource.
12622/// It is not used directly, but through a [`ProjectMethods`] instance.
12623///
12624/// # Example
12625///
12626/// Instantiate a resource method builder
12627///
12628/// ```test_harness,no_run
12629/// # extern crate hyper;
12630/// # extern crate hyper_rustls;
12631/// # extern crate google_firestore1 as firestore1;
12632/// use firestore1::api::Document;
12633/// # async fn dox() {
12634/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12635///
12636/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12637/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12638/// #     .with_native_roots()
12639/// #     .unwrap()
12640/// #     .https_only()
12641/// #     .enable_http2()
12642/// #     .build();
12643///
12644/// # let executor = hyper_util::rt::TokioExecutor::new();
12645/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12646/// #     secret,
12647/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12648/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12649/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12650/// #     ),
12651/// # ).build().await.unwrap();
12652///
12653/// # let client = hyper_util::client::legacy::Client::builder(
12654/// #     hyper_util::rt::TokioExecutor::new()
12655/// # )
12656/// # .build(
12657/// #     hyper_rustls::HttpsConnectorBuilder::new()
12658/// #         .with_native_roots()
12659/// #         .unwrap()
12660/// #         .https_or_http()
12661/// #         .enable_http2()
12662/// #         .build()
12663/// # );
12664/// # let mut hub = Firestore::new(client, auth);
12665/// // As the method needs a request, you would usually fill it with the desired information
12666/// // into the respective structure. Some of the parts shown here might not be applicable !
12667/// // Values shown here are possibly random and not representative !
12668/// let mut req = Document::default();
12669///
12670/// // You can configure optional parameters by calling the respective setters at will, and
12671/// // execute the final call using `doit()`.
12672/// // Values shown here are possibly random and not representative !
12673/// let result = hub.projects().databases_documents_patch(req, "name")
12674///              .add_update_mask_field_paths("et")
12675///              .add_mask_field_paths("voluptua.")
12676///              .current_document_update_time(chrono::Utc::now())
12677///              .current_document_exists(false)
12678///              .doit().await;
12679/// # }
12680/// ```
12681pub struct ProjectDatabaseDocumentPatchCall<'a, C>
12682where
12683    C: 'a,
12684{
12685    hub: &'a Firestore<C>,
12686    _request: Document,
12687    _name: String,
12688    _update_mask_field_paths: Vec<String>,
12689    _mask_field_paths: Vec<String>,
12690    _current_document_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
12691    _current_document_exists: Option<bool>,
12692    _delegate: Option<&'a mut dyn common::Delegate>,
12693    _additional_params: HashMap<String, String>,
12694    _scopes: BTreeSet<String>,
12695}
12696
12697impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentPatchCall<'a, C> {}
12698
12699impl<'a, C> ProjectDatabaseDocumentPatchCall<'a, C>
12700where
12701    C: common::Connector,
12702{
12703    /// Perform the operation you have build so far.
12704    pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
12705        use std::borrow::Cow;
12706        use std::io::{Read, Seek};
12707
12708        use common::{url::Params, ToParts};
12709        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12710
12711        let mut dd = common::DefaultDelegate;
12712        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12713        dlg.begin(common::MethodInfo {
12714            id: "firestore.projects.databases.documents.patch",
12715            http_method: hyper::Method::PATCH,
12716        });
12717
12718        for &field in [
12719            "alt",
12720            "name",
12721            "updateMask.fieldPaths",
12722            "mask.fieldPaths",
12723            "currentDocument.updateTime",
12724            "currentDocument.exists",
12725        ]
12726        .iter()
12727        {
12728            if self._additional_params.contains_key(field) {
12729                dlg.finished(false);
12730                return Err(common::Error::FieldClash(field));
12731            }
12732        }
12733
12734        let mut params = Params::with_capacity(8 + self._additional_params.len());
12735        params.push("name", self._name);
12736        if !self._update_mask_field_paths.is_empty() {
12737            for f in self._update_mask_field_paths.iter() {
12738                params.push("updateMask.fieldPaths", f);
12739            }
12740        }
12741        if !self._mask_field_paths.is_empty() {
12742            for f in self._mask_field_paths.iter() {
12743                params.push("mask.fieldPaths", f);
12744            }
12745        }
12746        if let Some(value) = self._current_document_update_time.as_ref() {
12747            params.push(
12748                "currentDocument.updateTime",
12749                common::serde::datetime_to_string(&value),
12750            );
12751        }
12752        if let Some(value) = self._current_document_exists.as_ref() {
12753            params.push("currentDocument.exists", value.to_string());
12754        }
12755
12756        params.extend(self._additional_params.iter());
12757
12758        params.push("alt", "json");
12759        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12760        if self._scopes.is_empty() {
12761            self._scopes
12762                .insert(Scope::CloudPlatform.as_ref().to_string());
12763        }
12764
12765        #[allow(clippy::single_element_loop)]
12766        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12767            url = params.uri_replacement(url, param_name, find_this, true);
12768        }
12769        {
12770            let to_remove = ["name"];
12771            params.remove_params(&to_remove);
12772        }
12773
12774        let url = params.parse_with_url(&url);
12775
12776        let mut json_mime_type = mime::APPLICATION_JSON;
12777        let mut request_value_reader = {
12778            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12779            common::remove_json_null_values(&mut value);
12780            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12781            serde_json::to_writer(&mut dst, &value).unwrap();
12782            dst
12783        };
12784        let request_size = request_value_reader
12785            .seek(std::io::SeekFrom::End(0))
12786            .unwrap();
12787        request_value_reader
12788            .seek(std::io::SeekFrom::Start(0))
12789            .unwrap();
12790
12791        loop {
12792            let token = match self
12793                .hub
12794                .auth
12795                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12796                .await
12797            {
12798                Ok(token) => token,
12799                Err(e) => match dlg.token(e) {
12800                    Ok(token) => token,
12801                    Err(e) => {
12802                        dlg.finished(false);
12803                        return Err(common::Error::MissingToken(e));
12804                    }
12805                },
12806            };
12807            request_value_reader
12808                .seek(std::io::SeekFrom::Start(0))
12809                .unwrap();
12810            let mut req_result = {
12811                let client = &self.hub.client;
12812                dlg.pre_request();
12813                let mut req_builder = hyper::Request::builder()
12814                    .method(hyper::Method::PATCH)
12815                    .uri(url.as_str())
12816                    .header(USER_AGENT, self.hub._user_agent.clone());
12817
12818                if let Some(token) = token.as_ref() {
12819                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12820                }
12821
12822                let request = req_builder
12823                    .header(CONTENT_TYPE, json_mime_type.to_string())
12824                    .header(CONTENT_LENGTH, request_size as u64)
12825                    .body(common::to_body(
12826                        request_value_reader.get_ref().clone().into(),
12827                    ));
12828
12829                client.request(request.unwrap()).await
12830            };
12831
12832            match req_result {
12833                Err(err) => {
12834                    if let common::Retry::After(d) = dlg.http_error(&err) {
12835                        sleep(d).await;
12836                        continue;
12837                    }
12838                    dlg.finished(false);
12839                    return Err(common::Error::HttpError(err));
12840                }
12841                Ok(res) => {
12842                    let (mut parts, body) = res.into_parts();
12843                    let mut body = common::Body::new(body);
12844                    if !parts.status.is_success() {
12845                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12846                        let error = serde_json::from_str(&common::to_string(&bytes));
12847                        let response = common::to_response(parts, bytes.into());
12848
12849                        if let common::Retry::After(d) =
12850                            dlg.http_failure(&response, error.as_ref().ok())
12851                        {
12852                            sleep(d).await;
12853                            continue;
12854                        }
12855
12856                        dlg.finished(false);
12857
12858                        return Err(match error {
12859                            Ok(value) => common::Error::BadRequest(value),
12860                            _ => common::Error::Failure(response),
12861                        });
12862                    }
12863                    let response = {
12864                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12865                        let encoded = common::to_string(&bytes);
12866                        match serde_json::from_str(&encoded) {
12867                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12868                            Err(error) => {
12869                                dlg.response_json_decode_error(&encoded, &error);
12870                                return Err(common::Error::JsonDecodeError(
12871                                    encoded.to_string(),
12872                                    error,
12873                                ));
12874                            }
12875                        }
12876                    };
12877
12878                    dlg.finished(true);
12879                    return Ok(response);
12880                }
12881            }
12882        }
12883    }
12884
12885    ///
12886    /// Sets the *request* property to the given value.
12887    ///
12888    /// Even though the property as already been set when instantiating this call,
12889    /// we provide this method for API completeness.
12890    pub fn request(mut self, new_value: Document) -> ProjectDatabaseDocumentPatchCall<'a, C> {
12891        self._request = new_value;
12892        self
12893    }
12894    /// The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
12895    ///
12896    /// Sets the *name* path property to the given value.
12897    ///
12898    /// Even though the property as already been set when instantiating this call,
12899    /// we provide this method for API completeness.
12900    pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentPatchCall<'a, C> {
12901        self._name = new_value.to_string();
12902        self
12903    }
12904    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
12905    ///
12906    /// Append the given value to the *update mask.field paths* query property.
12907    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
12908    pub fn add_update_mask_field_paths(
12909        mut self,
12910        new_value: &str,
12911    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
12912        self._update_mask_field_paths.push(new_value.to_string());
12913        self
12914    }
12915    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
12916    ///
12917    /// Append the given value to the *mask.field paths* query property.
12918    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
12919    pub fn add_mask_field_paths(
12920        mut self,
12921        new_value: &str,
12922    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
12923        self._mask_field_paths.push(new_value.to_string());
12924        self
12925    }
12926    /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
12927    ///
12928    /// Sets the *current document.update time* query property to the given value.
12929    pub fn current_document_update_time(
12930        mut self,
12931        new_value: chrono::DateTime<chrono::offset::Utc>,
12932    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
12933        self._current_document_update_time = Some(new_value);
12934        self
12935    }
12936    /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
12937    ///
12938    /// Sets the *current document.exists* query property to the given value.
12939    pub fn current_document_exists(
12940        mut self,
12941        new_value: bool,
12942    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
12943        self._current_document_exists = Some(new_value);
12944        self
12945    }
12946    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12947    /// while executing the actual API request.
12948    ///
12949    /// ````text
12950    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12951    /// ````
12952    ///
12953    /// Sets the *delegate* property to the given value.
12954    pub fn delegate(
12955        mut self,
12956        new_value: &'a mut dyn common::Delegate,
12957    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
12958        self._delegate = Some(new_value);
12959        self
12960    }
12961
12962    /// Set any additional parameter of the query string used in the request.
12963    /// It should be used to set parameters which are not yet available through their own
12964    /// setters.
12965    ///
12966    /// Please note that this method must not be used to set any of the known parameters
12967    /// which have their own setter method. If done anyway, the request will fail.
12968    ///
12969    /// # Additional Parameters
12970    ///
12971    /// * *$.xgafv* (query-string) - V1 error format.
12972    /// * *access_token* (query-string) - OAuth access token.
12973    /// * *alt* (query-string) - Data format for response.
12974    /// * *callback* (query-string) - JSONP
12975    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12976    /// * *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.
12977    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12978    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12979    /// * *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.
12980    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12981    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12982    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentPatchCall<'a, C>
12983    where
12984        T: AsRef<str>,
12985    {
12986        self._additional_params
12987            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12988        self
12989    }
12990
12991    /// Identifies the authorization scope for the method you are building.
12992    ///
12993    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12994    /// [`Scope::CloudPlatform`].
12995    ///
12996    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12997    /// tokens for more than one scope.
12998    ///
12999    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13000    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13001    /// sufficient, a read-write scope will do as well.
13002    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentPatchCall<'a, C>
13003    where
13004        St: AsRef<str>,
13005    {
13006        self._scopes.insert(String::from(scope.as_ref()));
13007        self
13008    }
13009    /// Identifies the authorization scope(s) for the method you are building.
13010    ///
13011    /// See [`Self::add_scope()`] for details.
13012    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentPatchCall<'a, C>
13013    where
13014        I: IntoIterator<Item = St>,
13015        St: AsRef<str>,
13016    {
13017        self._scopes
13018            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13019        self
13020    }
13021
13022    /// Removes all scopes, and no default scope will be used either.
13023    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13024    /// for details).
13025    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentPatchCall<'a, C> {
13026        self._scopes.clear();
13027        self
13028    }
13029}
13030
13031/// Rolls back a transaction.
13032///
13033/// A builder for the *databases.documents.rollback* method supported by a *project* resource.
13034/// It is not used directly, but through a [`ProjectMethods`] instance.
13035///
13036/// # Example
13037///
13038/// Instantiate a resource method builder
13039///
13040/// ```test_harness,no_run
13041/// # extern crate hyper;
13042/// # extern crate hyper_rustls;
13043/// # extern crate google_firestore1 as firestore1;
13044/// use firestore1::api::RollbackRequest;
13045/// # async fn dox() {
13046/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13047///
13048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13049/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13050/// #     .with_native_roots()
13051/// #     .unwrap()
13052/// #     .https_only()
13053/// #     .enable_http2()
13054/// #     .build();
13055///
13056/// # let executor = hyper_util::rt::TokioExecutor::new();
13057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13058/// #     secret,
13059/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13060/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13061/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13062/// #     ),
13063/// # ).build().await.unwrap();
13064///
13065/// # let client = hyper_util::client::legacy::Client::builder(
13066/// #     hyper_util::rt::TokioExecutor::new()
13067/// # )
13068/// # .build(
13069/// #     hyper_rustls::HttpsConnectorBuilder::new()
13070/// #         .with_native_roots()
13071/// #         .unwrap()
13072/// #         .https_or_http()
13073/// #         .enable_http2()
13074/// #         .build()
13075/// # );
13076/// # let mut hub = Firestore::new(client, auth);
13077/// // As the method needs a request, you would usually fill it with the desired information
13078/// // into the respective structure. Some of the parts shown here might not be applicable !
13079/// // Values shown here are possibly random and not representative !
13080/// let mut req = RollbackRequest::default();
13081///
13082/// // You can configure optional parameters by calling the respective setters at will, and
13083/// // execute the final call using `doit()`.
13084/// // Values shown here are possibly random and not representative !
13085/// let result = hub.projects().databases_documents_rollback(req, "database")
13086///              .doit().await;
13087/// # }
13088/// ```
13089pub struct ProjectDatabaseDocumentRollbackCall<'a, C>
13090where
13091    C: 'a,
13092{
13093    hub: &'a Firestore<C>,
13094    _request: RollbackRequest,
13095    _database: String,
13096    _delegate: Option<&'a mut dyn common::Delegate>,
13097    _additional_params: HashMap<String, String>,
13098    _scopes: BTreeSet<String>,
13099}
13100
13101impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRollbackCall<'a, C> {}
13102
13103impl<'a, C> ProjectDatabaseDocumentRollbackCall<'a, C>
13104where
13105    C: common::Connector,
13106{
13107    /// Perform the operation you have build so far.
13108    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
13109        use std::borrow::Cow;
13110        use std::io::{Read, Seek};
13111
13112        use common::{url::Params, ToParts};
13113        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13114
13115        let mut dd = common::DefaultDelegate;
13116        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13117        dlg.begin(common::MethodInfo {
13118            id: "firestore.projects.databases.documents.rollback",
13119            http_method: hyper::Method::POST,
13120        });
13121
13122        for &field in ["alt", "database"].iter() {
13123            if self._additional_params.contains_key(field) {
13124                dlg.finished(false);
13125                return Err(common::Error::FieldClash(field));
13126            }
13127        }
13128
13129        let mut params = Params::with_capacity(4 + self._additional_params.len());
13130        params.push("database", self._database);
13131
13132        params.extend(self._additional_params.iter());
13133
13134        params.push("alt", "json");
13135        let mut url = self.hub._base_url.clone() + "v1/{+database}/documents:rollback";
13136        if self._scopes.is_empty() {
13137            self._scopes
13138                .insert(Scope::CloudPlatform.as_ref().to_string());
13139        }
13140
13141        #[allow(clippy::single_element_loop)]
13142        for &(find_this, param_name) in [("{+database}", "database")].iter() {
13143            url = params.uri_replacement(url, param_name, find_this, true);
13144        }
13145        {
13146            let to_remove = ["database"];
13147            params.remove_params(&to_remove);
13148        }
13149
13150        let url = params.parse_with_url(&url);
13151
13152        let mut json_mime_type = mime::APPLICATION_JSON;
13153        let mut request_value_reader = {
13154            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13155            common::remove_json_null_values(&mut value);
13156            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13157            serde_json::to_writer(&mut dst, &value).unwrap();
13158            dst
13159        };
13160        let request_size = request_value_reader
13161            .seek(std::io::SeekFrom::End(0))
13162            .unwrap();
13163        request_value_reader
13164            .seek(std::io::SeekFrom::Start(0))
13165            .unwrap();
13166
13167        loop {
13168            let token = match self
13169                .hub
13170                .auth
13171                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13172                .await
13173            {
13174                Ok(token) => token,
13175                Err(e) => match dlg.token(e) {
13176                    Ok(token) => token,
13177                    Err(e) => {
13178                        dlg.finished(false);
13179                        return Err(common::Error::MissingToken(e));
13180                    }
13181                },
13182            };
13183            request_value_reader
13184                .seek(std::io::SeekFrom::Start(0))
13185                .unwrap();
13186            let mut req_result = {
13187                let client = &self.hub.client;
13188                dlg.pre_request();
13189                let mut req_builder = hyper::Request::builder()
13190                    .method(hyper::Method::POST)
13191                    .uri(url.as_str())
13192                    .header(USER_AGENT, self.hub._user_agent.clone());
13193
13194                if let Some(token) = token.as_ref() {
13195                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13196                }
13197
13198                let request = req_builder
13199                    .header(CONTENT_TYPE, json_mime_type.to_string())
13200                    .header(CONTENT_LENGTH, request_size as u64)
13201                    .body(common::to_body(
13202                        request_value_reader.get_ref().clone().into(),
13203                    ));
13204
13205                client.request(request.unwrap()).await
13206            };
13207
13208            match req_result {
13209                Err(err) => {
13210                    if let common::Retry::After(d) = dlg.http_error(&err) {
13211                        sleep(d).await;
13212                        continue;
13213                    }
13214                    dlg.finished(false);
13215                    return Err(common::Error::HttpError(err));
13216                }
13217                Ok(res) => {
13218                    let (mut parts, body) = res.into_parts();
13219                    let mut body = common::Body::new(body);
13220                    if !parts.status.is_success() {
13221                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13222                        let error = serde_json::from_str(&common::to_string(&bytes));
13223                        let response = common::to_response(parts, bytes.into());
13224
13225                        if let common::Retry::After(d) =
13226                            dlg.http_failure(&response, error.as_ref().ok())
13227                        {
13228                            sleep(d).await;
13229                            continue;
13230                        }
13231
13232                        dlg.finished(false);
13233
13234                        return Err(match error {
13235                            Ok(value) => common::Error::BadRequest(value),
13236                            _ => common::Error::Failure(response),
13237                        });
13238                    }
13239                    let response = {
13240                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13241                        let encoded = common::to_string(&bytes);
13242                        match serde_json::from_str(&encoded) {
13243                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13244                            Err(error) => {
13245                                dlg.response_json_decode_error(&encoded, &error);
13246                                return Err(common::Error::JsonDecodeError(
13247                                    encoded.to_string(),
13248                                    error,
13249                                ));
13250                            }
13251                        }
13252                    };
13253
13254                    dlg.finished(true);
13255                    return Ok(response);
13256                }
13257            }
13258        }
13259    }
13260
13261    ///
13262    /// Sets the *request* property to the given value.
13263    ///
13264    /// Even though the property as already been set when instantiating this call,
13265    /// we provide this method for API completeness.
13266    pub fn request(
13267        mut self,
13268        new_value: RollbackRequest,
13269    ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
13270        self._request = new_value;
13271        self
13272    }
13273    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
13274    ///
13275    /// Sets the *database* path property to the given value.
13276    ///
13277    /// Even though the property as already been set when instantiating this call,
13278    /// we provide this method for API completeness.
13279    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
13280        self._database = new_value.to_string();
13281        self
13282    }
13283    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13284    /// while executing the actual API request.
13285    ///
13286    /// ````text
13287    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13288    /// ````
13289    ///
13290    /// Sets the *delegate* property to the given value.
13291    pub fn delegate(
13292        mut self,
13293        new_value: &'a mut dyn common::Delegate,
13294    ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
13295        self._delegate = Some(new_value);
13296        self
13297    }
13298
13299    /// Set any additional parameter of the query string used in the request.
13300    /// It should be used to set parameters which are not yet available through their own
13301    /// setters.
13302    ///
13303    /// Please note that this method must not be used to set any of the known parameters
13304    /// which have their own setter method. If done anyway, the request will fail.
13305    ///
13306    /// # Additional Parameters
13307    ///
13308    /// * *$.xgafv* (query-string) - V1 error format.
13309    /// * *access_token* (query-string) - OAuth access token.
13310    /// * *alt* (query-string) - Data format for response.
13311    /// * *callback* (query-string) - JSONP
13312    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13313    /// * *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.
13314    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13315    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13316    /// * *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.
13317    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13318    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13319    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentRollbackCall<'a, C>
13320    where
13321        T: AsRef<str>,
13322    {
13323        self._additional_params
13324            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13325        self
13326    }
13327
13328    /// Identifies the authorization scope for the method you are building.
13329    ///
13330    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13331    /// [`Scope::CloudPlatform`].
13332    ///
13333    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13334    /// tokens for more than one scope.
13335    ///
13336    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13337    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13338    /// sufficient, a read-write scope will do as well.
13339    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentRollbackCall<'a, C>
13340    where
13341        St: AsRef<str>,
13342    {
13343        self._scopes.insert(String::from(scope.as_ref()));
13344        self
13345    }
13346    /// Identifies the authorization scope(s) for the method you are building.
13347    ///
13348    /// See [`Self::add_scope()`] for details.
13349    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentRollbackCall<'a, C>
13350    where
13351        I: IntoIterator<Item = St>,
13352        St: AsRef<str>,
13353    {
13354        self._scopes
13355            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13356        self
13357    }
13358
13359    /// Removes all scopes, and no default scope will be used either.
13360    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13361    /// for details).
13362    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
13363        self._scopes.clear();
13364        self
13365    }
13366}
13367
13368/// Runs an aggregation query. Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of AggregationResult server-side. High-Level Example: ``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); ```
13369///
13370/// A builder for the *databases.documents.runAggregationQuery* method supported by a *project* resource.
13371/// It is not used directly, but through a [`ProjectMethods`] instance.
13372///
13373/// # Example
13374///
13375/// Instantiate a resource method builder
13376///
13377/// ```test_harness,no_run
13378/// # extern crate hyper;
13379/// # extern crate hyper_rustls;
13380/// # extern crate google_firestore1 as firestore1;
13381/// use firestore1::api::RunAggregationQueryRequest;
13382/// # async fn dox() {
13383/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13384///
13385/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13386/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13387/// #     .with_native_roots()
13388/// #     .unwrap()
13389/// #     .https_only()
13390/// #     .enable_http2()
13391/// #     .build();
13392///
13393/// # let executor = hyper_util::rt::TokioExecutor::new();
13394/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13395/// #     secret,
13396/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13397/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13398/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13399/// #     ),
13400/// # ).build().await.unwrap();
13401///
13402/// # let client = hyper_util::client::legacy::Client::builder(
13403/// #     hyper_util::rt::TokioExecutor::new()
13404/// # )
13405/// # .build(
13406/// #     hyper_rustls::HttpsConnectorBuilder::new()
13407/// #         .with_native_roots()
13408/// #         .unwrap()
13409/// #         .https_or_http()
13410/// #         .enable_http2()
13411/// #         .build()
13412/// # );
13413/// # let mut hub = Firestore::new(client, auth);
13414/// // As the method needs a request, you would usually fill it with the desired information
13415/// // into the respective structure. Some of the parts shown here might not be applicable !
13416/// // Values shown here are possibly random and not representative !
13417/// let mut req = RunAggregationQueryRequest::default();
13418///
13419/// // You can configure optional parameters by calling the respective setters at will, and
13420/// // execute the final call using `doit()`.
13421/// // Values shown here are possibly random and not representative !
13422/// let result = hub.projects().databases_documents_run_aggregation_query(req, "parent")
13423///              .doit().await;
13424/// # }
13425/// ```
13426pub struct ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
13427where
13428    C: 'a,
13429{
13430    hub: &'a Firestore<C>,
13431    _request: RunAggregationQueryRequest,
13432    _parent: String,
13433    _delegate: Option<&'a mut dyn common::Delegate>,
13434    _additional_params: HashMap<String, String>,
13435    _scopes: BTreeSet<String>,
13436}
13437
13438impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {}
13439
13440impl<'a, C> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
13441where
13442    C: common::Connector,
13443{
13444    /// Perform the operation you have build so far.
13445    pub async fn doit(mut self) -> common::Result<(common::Response, RunAggregationQueryResponse)> {
13446        use std::borrow::Cow;
13447        use std::io::{Read, Seek};
13448
13449        use common::{url::Params, ToParts};
13450        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13451
13452        let mut dd = common::DefaultDelegate;
13453        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13454        dlg.begin(common::MethodInfo {
13455            id: "firestore.projects.databases.documents.runAggregationQuery",
13456            http_method: hyper::Method::POST,
13457        });
13458
13459        for &field in ["alt", "parent"].iter() {
13460            if self._additional_params.contains_key(field) {
13461                dlg.finished(false);
13462                return Err(common::Error::FieldClash(field));
13463            }
13464        }
13465
13466        let mut params = Params::with_capacity(4 + self._additional_params.len());
13467        params.push("parent", self._parent);
13468
13469        params.extend(self._additional_params.iter());
13470
13471        params.push("alt", "json");
13472        let mut url = self.hub._base_url.clone() + "v1/{+parent}:runAggregationQuery";
13473        if self._scopes.is_empty() {
13474            self._scopes
13475                .insert(Scope::CloudPlatform.as_ref().to_string());
13476        }
13477
13478        #[allow(clippy::single_element_loop)]
13479        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13480            url = params.uri_replacement(url, param_name, find_this, true);
13481        }
13482        {
13483            let to_remove = ["parent"];
13484            params.remove_params(&to_remove);
13485        }
13486
13487        let url = params.parse_with_url(&url);
13488
13489        let mut json_mime_type = mime::APPLICATION_JSON;
13490        let mut request_value_reader = {
13491            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13492            common::remove_json_null_values(&mut value);
13493            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13494            serde_json::to_writer(&mut dst, &value).unwrap();
13495            dst
13496        };
13497        let request_size = request_value_reader
13498            .seek(std::io::SeekFrom::End(0))
13499            .unwrap();
13500        request_value_reader
13501            .seek(std::io::SeekFrom::Start(0))
13502            .unwrap();
13503
13504        loop {
13505            let token = match self
13506                .hub
13507                .auth
13508                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13509                .await
13510            {
13511                Ok(token) => token,
13512                Err(e) => match dlg.token(e) {
13513                    Ok(token) => token,
13514                    Err(e) => {
13515                        dlg.finished(false);
13516                        return Err(common::Error::MissingToken(e));
13517                    }
13518                },
13519            };
13520            request_value_reader
13521                .seek(std::io::SeekFrom::Start(0))
13522                .unwrap();
13523            let mut req_result = {
13524                let client = &self.hub.client;
13525                dlg.pre_request();
13526                let mut req_builder = hyper::Request::builder()
13527                    .method(hyper::Method::POST)
13528                    .uri(url.as_str())
13529                    .header(USER_AGENT, self.hub._user_agent.clone());
13530
13531                if let Some(token) = token.as_ref() {
13532                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13533                }
13534
13535                let request = req_builder
13536                    .header(CONTENT_TYPE, json_mime_type.to_string())
13537                    .header(CONTENT_LENGTH, request_size as u64)
13538                    .body(common::to_body(
13539                        request_value_reader.get_ref().clone().into(),
13540                    ));
13541
13542                client.request(request.unwrap()).await
13543            };
13544
13545            match req_result {
13546                Err(err) => {
13547                    if let common::Retry::After(d) = dlg.http_error(&err) {
13548                        sleep(d).await;
13549                        continue;
13550                    }
13551                    dlg.finished(false);
13552                    return Err(common::Error::HttpError(err));
13553                }
13554                Ok(res) => {
13555                    let (mut parts, body) = res.into_parts();
13556                    let mut body = common::Body::new(body);
13557                    if !parts.status.is_success() {
13558                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13559                        let error = serde_json::from_str(&common::to_string(&bytes));
13560                        let response = common::to_response(parts, bytes.into());
13561
13562                        if let common::Retry::After(d) =
13563                            dlg.http_failure(&response, error.as_ref().ok())
13564                        {
13565                            sleep(d).await;
13566                            continue;
13567                        }
13568
13569                        dlg.finished(false);
13570
13571                        return Err(match error {
13572                            Ok(value) => common::Error::BadRequest(value),
13573                            _ => common::Error::Failure(response),
13574                        });
13575                    }
13576                    let response = {
13577                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13578                        let encoded = common::to_string(&bytes);
13579                        match serde_json::from_str(&encoded) {
13580                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13581                            Err(error) => {
13582                                dlg.response_json_decode_error(&encoded, &error);
13583                                return Err(common::Error::JsonDecodeError(
13584                                    encoded.to_string(),
13585                                    error,
13586                                ));
13587                            }
13588                        }
13589                    };
13590
13591                    dlg.finished(true);
13592                    return Ok(response);
13593                }
13594            }
13595        }
13596    }
13597
13598    ///
13599    /// Sets the *request* property to the given value.
13600    ///
13601    /// Even though the property as already been set when instantiating this call,
13602    /// we provide this method for API completeness.
13603    pub fn request(
13604        mut self,
13605        new_value: RunAggregationQueryRequest,
13606    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
13607        self._request = new_value;
13608        self
13609    }
13610    /// Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
13611    ///
13612    /// Sets the *parent* path property to the given value.
13613    ///
13614    /// Even though the property as already been set when instantiating this call,
13615    /// we provide this method for API completeness.
13616    pub fn parent(
13617        mut self,
13618        new_value: &str,
13619    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
13620        self._parent = new_value.to_string();
13621        self
13622    }
13623    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13624    /// while executing the actual API request.
13625    ///
13626    /// ````text
13627    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13628    /// ````
13629    ///
13630    /// Sets the *delegate* property to the given value.
13631    pub fn delegate(
13632        mut self,
13633        new_value: &'a mut dyn common::Delegate,
13634    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
13635        self._delegate = Some(new_value);
13636        self
13637    }
13638
13639    /// Set any additional parameter of the query string used in the request.
13640    /// It should be used to set parameters which are not yet available through their own
13641    /// setters.
13642    ///
13643    /// Please note that this method must not be used to set any of the known parameters
13644    /// which have their own setter method. If done anyway, the request will fail.
13645    ///
13646    /// # Additional Parameters
13647    ///
13648    /// * *$.xgafv* (query-string) - V1 error format.
13649    /// * *access_token* (query-string) - OAuth access token.
13650    /// * *alt* (query-string) - Data format for response.
13651    /// * *callback* (query-string) - JSONP
13652    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13653    /// * *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.
13654    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13655    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13656    /// * *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.
13657    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13658    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13659    pub fn param<T>(
13660        mut self,
13661        name: T,
13662        value: T,
13663    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
13664    where
13665        T: AsRef<str>,
13666    {
13667        self._additional_params
13668            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13669        self
13670    }
13671
13672    /// Identifies the authorization scope for the method you are building.
13673    ///
13674    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13675    /// [`Scope::CloudPlatform`].
13676    ///
13677    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13678    /// tokens for more than one scope.
13679    ///
13680    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13681    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13682    /// sufficient, a read-write scope will do as well.
13683    pub fn add_scope<St>(
13684        mut self,
13685        scope: St,
13686    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
13687    where
13688        St: AsRef<str>,
13689    {
13690        self._scopes.insert(String::from(scope.as_ref()));
13691        self
13692    }
13693    /// Identifies the authorization scope(s) for the method you are building.
13694    ///
13695    /// See [`Self::add_scope()`] for details.
13696    pub fn add_scopes<I, St>(
13697        mut self,
13698        scopes: I,
13699    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
13700    where
13701        I: IntoIterator<Item = St>,
13702        St: AsRef<str>,
13703    {
13704        self._scopes
13705            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13706        self
13707    }
13708
13709    /// Removes all scopes, and no default scope will be used either.
13710    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13711    /// for details).
13712    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
13713        self._scopes.clear();
13714        self
13715    }
13716}
13717
13718/// Runs a query.
13719///
13720/// A builder for the *databases.documents.runQuery* method supported by a *project* resource.
13721/// It is not used directly, but through a [`ProjectMethods`] instance.
13722///
13723/// # Example
13724///
13725/// Instantiate a resource method builder
13726///
13727/// ```test_harness,no_run
13728/// # extern crate hyper;
13729/// # extern crate hyper_rustls;
13730/// # extern crate google_firestore1 as firestore1;
13731/// use firestore1::api::RunQueryRequest;
13732/// # async fn dox() {
13733/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13734///
13735/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13736/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13737/// #     .with_native_roots()
13738/// #     .unwrap()
13739/// #     .https_only()
13740/// #     .enable_http2()
13741/// #     .build();
13742///
13743/// # let executor = hyper_util::rt::TokioExecutor::new();
13744/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13745/// #     secret,
13746/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13747/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13748/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13749/// #     ),
13750/// # ).build().await.unwrap();
13751///
13752/// # let client = hyper_util::client::legacy::Client::builder(
13753/// #     hyper_util::rt::TokioExecutor::new()
13754/// # )
13755/// # .build(
13756/// #     hyper_rustls::HttpsConnectorBuilder::new()
13757/// #         .with_native_roots()
13758/// #         .unwrap()
13759/// #         .https_or_http()
13760/// #         .enable_http2()
13761/// #         .build()
13762/// # );
13763/// # let mut hub = Firestore::new(client, auth);
13764/// // As the method needs a request, you would usually fill it with the desired information
13765/// // into the respective structure. Some of the parts shown here might not be applicable !
13766/// // Values shown here are possibly random and not representative !
13767/// let mut req = RunQueryRequest::default();
13768///
13769/// // You can configure optional parameters by calling the respective setters at will, and
13770/// // execute the final call using `doit()`.
13771/// // Values shown here are possibly random and not representative !
13772/// let result = hub.projects().databases_documents_run_query(req, "parent")
13773///              .doit().await;
13774/// # }
13775/// ```
13776pub struct ProjectDatabaseDocumentRunQueryCall<'a, C>
13777where
13778    C: 'a,
13779{
13780    hub: &'a Firestore<C>,
13781    _request: RunQueryRequest,
13782    _parent: String,
13783    _delegate: Option<&'a mut dyn common::Delegate>,
13784    _additional_params: HashMap<String, String>,
13785    _scopes: BTreeSet<String>,
13786}
13787
13788impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRunQueryCall<'a, C> {}
13789
13790impl<'a, C> ProjectDatabaseDocumentRunQueryCall<'a, C>
13791where
13792    C: common::Connector,
13793{
13794    /// Perform the operation you have build so far.
13795    pub async fn doit(mut self) -> common::Result<(common::Response, RunQueryResponse)> {
13796        use std::borrow::Cow;
13797        use std::io::{Read, Seek};
13798
13799        use common::{url::Params, ToParts};
13800        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13801
13802        let mut dd = common::DefaultDelegate;
13803        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13804        dlg.begin(common::MethodInfo {
13805            id: "firestore.projects.databases.documents.runQuery",
13806            http_method: hyper::Method::POST,
13807        });
13808
13809        for &field in ["alt", "parent"].iter() {
13810            if self._additional_params.contains_key(field) {
13811                dlg.finished(false);
13812                return Err(common::Error::FieldClash(field));
13813            }
13814        }
13815
13816        let mut params = Params::with_capacity(4 + self._additional_params.len());
13817        params.push("parent", self._parent);
13818
13819        params.extend(self._additional_params.iter());
13820
13821        params.push("alt", "json");
13822        let mut url = self.hub._base_url.clone() + "v1/{+parent}:runQuery";
13823        if self._scopes.is_empty() {
13824            self._scopes
13825                .insert(Scope::CloudPlatform.as_ref().to_string());
13826        }
13827
13828        #[allow(clippy::single_element_loop)]
13829        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13830            url = params.uri_replacement(url, param_name, find_this, true);
13831        }
13832        {
13833            let to_remove = ["parent"];
13834            params.remove_params(&to_remove);
13835        }
13836
13837        let url = params.parse_with_url(&url);
13838
13839        let mut json_mime_type = mime::APPLICATION_JSON;
13840        let mut request_value_reader = {
13841            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13842            common::remove_json_null_values(&mut value);
13843            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13844            serde_json::to_writer(&mut dst, &value).unwrap();
13845            dst
13846        };
13847        let request_size = request_value_reader
13848            .seek(std::io::SeekFrom::End(0))
13849            .unwrap();
13850        request_value_reader
13851            .seek(std::io::SeekFrom::Start(0))
13852            .unwrap();
13853
13854        loop {
13855            let token = match self
13856                .hub
13857                .auth
13858                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13859                .await
13860            {
13861                Ok(token) => token,
13862                Err(e) => match dlg.token(e) {
13863                    Ok(token) => token,
13864                    Err(e) => {
13865                        dlg.finished(false);
13866                        return Err(common::Error::MissingToken(e));
13867                    }
13868                },
13869            };
13870            request_value_reader
13871                .seek(std::io::SeekFrom::Start(0))
13872                .unwrap();
13873            let mut req_result = {
13874                let client = &self.hub.client;
13875                dlg.pre_request();
13876                let mut req_builder = hyper::Request::builder()
13877                    .method(hyper::Method::POST)
13878                    .uri(url.as_str())
13879                    .header(USER_AGENT, self.hub._user_agent.clone());
13880
13881                if let Some(token) = token.as_ref() {
13882                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13883                }
13884
13885                let request = req_builder
13886                    .header(CONTENT_TYPE, json_mime_type.to_string())
13887                    .header(CONTENT_LENGTH, request_size as u64)
13888                    .body(common::to_body(
13889                        request_value_reader.get_ref().clone().into(),
13890                    ));
13891
13892                client.request(request.unwrap()).await
13893            };
13894
13895            match req_result {
13896                Err(err) => {
13897                    if let common::Retry::After(d) = dlg.http_error(&err) {
13898                        sleep(d).await;
13899                        continue;
13900                    }
13901                    dlg.finished(false);
13902                    return Err(common::Error::HttpError(err));
13903                }
13904                Ok(res) => {
13905                    let (mut parts, body) = res.into_parts();
13906                    let mut body = common::Body::new(body);
13907                    if !parts.status.is_success() {
13908                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13909                        let error = serde_json::from_str(&common::to_string(&bytes));
13910                        let response = common::to_response(parts, bytes.into());
13911
13912                        if let common::Retry::After(d) =
13913                            dlg.http_failure(&response, error.as_ref().ok())
13914                        {
13915                            sleep(d).await;
13916                            continue;
13917                        }
13918
13919                        dlg.finished(false);
13920
13921                        return Err(match error {
13922                            Ok(value) => common::Error::BadRequest(value),
13923                            _ => common::Error::Failure(response),
13924                        });
13925                    }
13926                    let response = {
13927                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13928                        let encoded = common::to_string(&bytes);
13929                        match serde_json::from_str(&encoded) {
13930                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13931                            Err(error) => {
13932                                dlg.response_json_decode_error(&encoded, &error);
13933                                return Err(common::Error::JsonDecodeError(
13934                                    encoded.to_string(),
13935                                    error,
13936                                ));
13937                            }
13938                        }
13939                    };
13940
13941                    dlg.finished(true);
13942                    return Ok(response);
13943                }
13944            }
13945        }
13946    }
13947
13948    ///
13949    /// Sets the *request* property to the given value.
13950    ///
13951    /// Even though the property as already been set when instantiating this call,
13952    /// we provide this method for API completeness.
13953    pub fn request(
13954        mut self,
13955        new_value: RunQueryRequest,
13956    ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
13957        self._request = new_value;
13958        self
13959    }
13960    /// Required. The parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
13961    ///
13962    /// Sets the *parent* path property to the given value.
13963    ///
13964    /// Even though the property as already been set when instantiating this call,
13965    /// we provide this method for API completeness.
13966    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
13967        self._parent = new_value.to_string();
13968        self
13969    }
13970    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13971    /// while executing the actual API request.
13972    ///
13973    /// ````text
13974    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13975    /// ````
13976    ///
13977    /// Sets the *delegate* property to the given value.
13978    pub fn delegate(
13979        mut self,
13980        new_value: &'a mut dyn common::Delegate,
13981    ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
13982        self._delegate = Some(new_value);
13983        self
13984    }
13985
13986    /// Set any additional parameter of the query string used in the request.
13987    /// It should be used to set parameters which are not yet available through their own
13988    /// setters.
13989    ///
13990    /// Please note that this method must not be used to set any of the known parameters
13991    /// which have their own setter method. If done anyway, the request will fail.
13992    ///
13993    /// # Additional Parameters
13994    ///
13995    /// * *$.xgafv* (query-string) - V1 error format.
13996    /// * *access_token* (query-string) - OAuth access token.
13997    /// * *alt* (query-string) - Data format for response.
13998    /// * *callback* (query-string) - JSONP
13999    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14000    /// * *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.
14001    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14002    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14003    /// * *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.
14004    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14005    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14006    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
14007    where
14008        T: AsRef<str>,
14009    {
14010        self._additional_params
14011            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14012        self
14013    }
14014
14015    /// Identifies the authorization scope for the method you are building.
14016    ///
14017    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14018    /// [`Scope::CloudPlatform`].
14019    ///
14020    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14021    /// tokens for more than one scope.
14022    ///
14023    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14024    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14025    /// sufficient, a read-write scope will do as well.
14026    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
14027    where
14028        St: AsRef<str>,
14029    {
14030        self._scopes.insert(String::from(scope.as_ref()));
14031        self
14032    }
14033    /// Identifies the authorization scope(s) for the method you are building.
14034    ///
14035    /// See [`Self::add_scope()`] for details.
14036    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
14037    where
14038        I: IntoIterator<Item = St>,
14039        St: AsRef<str>,
14040    {
14041        self._scopes
14042            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14043        self
14044    }
14045
14046    /// Removes all scopes, and no default scope will be used either.
14047    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14048    /// for details).
14049    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
14050        self._scopes.clear();
14051        self
14052    }
14053}
14054
14055/// Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).
14056///
14057/// A builder for the *databases.documents.write* method supported by a *project* resource.
14058/// It is not used directly, but through a [`ProjectMethods`] instance.
14059///
14060/// # Example
14061///
14062/// Instantiate a resource method builder
14063///
14064/// ```test_harness,no_run
14065/// # extern crate hyper;
14066/// # extern crate hyper_rustls;
14067/// # extern crate google_firestore1 as firestore1;
14068/// use firestore1::api::WriteRequest;
14069/// # async fn dox() {
14070/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14071///
14072/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14073/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14074/// #     .with_native_roots()
14075/// #     .unwrap()
14076/// #     .https_only()
14077/// #     .enable_http2()
14078/// #     .build();
14079///
14080/// # let executor = hyper_util::rt::TokioExecutor::new();
14081/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14082/// #     secret,
14083/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14084/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14085/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14086/// #     ),
14087/// # ).build().await.unwrap();
14088///
14089/// # let client = hyper_util::client::legacy::Client::builder(
14090/// #     hyper_util::rt::TokioExecutor::new()
14091/// # )
14092/// # .build(
14093/// #     hyper_rustls::HttpsConnectorBuilder::new()
14094/// #         .with_native_roots()
14095/// #         .unwrap()
14096/// #         .https_or_http()
14097/// #         .enable_http2()
14098/// #         .build()
14099/// # );
14100/// # let mut hub = Firestore::new(client, auth);
14101/// // As the method needs a request, you would usually fill it with the desired information
14102/// // into the respective structure. Some of the parts shown here might not be applicable !
14103/// // Values shown here are possibly random and not representative !
14104/// let mut req = WriteRequest::default();
14105///
14106/// // You can configure optional parameters by calling the respective setters at will, and
14107/// // execute the final call using `doit()`.
14108/// // Values shown here are possibly random and not representative !
14109/// let result = hub.projects().databases_documents_write(req, "database")
14110///              .doit().await;
14111/// # }
14112/// ```
14113pub struct ProjectDatabaseDocumentWriteCall<'a, C>
14114where
14115    C: 'a,
14116{
14117    hub: &'a Firestore<C>,
14118    _request: WriteRequest,
14119    _database: String,
14120    _delegate: Option<&'a mut dyn common::Delegate>,
14121    _additional_params: HashMap<String, String>,
14122    _scopes: BTreeSet<String>,
14123}
14124
14125impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentWriteCall<'a, C> {}
14126
14127impl<'a, C> ProjectDatabaseDocumentWriteCall<'a, C>
14128where
14129    C: common::Connector,
14130{
14131    /// Perform the operation you have build so far.
14132    pub async fn doit(mut self) -> common::Result<(common::Response, WriteResponse)> {
14133        use std::borrow::Cow;
14134        use std::io::{Read, Seek};
14135
14136        use common::{url::Params, ToParts};
14137        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14138
14139        let mut dd = common::DefaultDelegate;
14140        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14141        dlg.begin(common::MethodInfo {
14142            id: "firestore.projects.databases.documents.write",
14143            http_method: hyper::Method::POST,
14144        });
14145
14146        for &field in ["alt", "database"].iter() {
14147            if self._additional_params.contains_key(field) {
14148                dlg.finished(false);
14149                return Err(common::Error::FieldClash(field));
14150            }
14151        }
14152
14153        let mut params = Params::with_capacity(4 + self._additional_params.len());
14154        params.push("database", self._database);
14155
14156        params.extend(self._additional_params.iter());
14157
14158        params.push("alt", "json");
14159        let mut url = self.hub._base_url.clone() + "v1/{+database}/documents:write";
14160        if self._scopes.is_empty() {
14161            self._scopes
14162                .insert(Scope::CloudPlatform.as_ref().to_string());
14163        }
14164
14165        #[allow(clippy::single_element_loop)]
14166        for &(find_this, param_name) in [("{+database}", "database")].iter() {
14167            url = params.uri_replacement(url, param_name, find_this, true);
14168        }
14169        {
14170            let to_remove = ["database"];
14171            params.remove_params(&to_remove);
14172        }
14173
14174        let url = params.parse_with_url(&url);
14175
14176        let mut json_mime_type = mime::APPLICATION_JSON;
14177        let mut request_value_reader = {
14178            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14179            common::remove_json_null_values(&mut value);
14180            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14181            serde_json::to_writer(&mut dst, &value).unwrap();
14182            dst
14183        };
14184        let request_size = request_value_reader
14185            .seek(std::io::SeekFrom::End(0))
14186            .unwrap();
14187        request_value_reader
14188            .seek(std::io::SeekFrom::Start(0))
14189            .unwrap();
14190
14191        loop {
14192            let token = match self
14193                .hub
14194                .auth
14195                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14196                .await
14197            {
14198                Ok(token) => token,
14199                Err(e) => match dlg.token(e) {
14200                    Ok(token) => token,
14201                    Err(e) => {
14202                        dlg.finished(false);
14203                        return Err(common::Error::MissingToken(e));
14204                    }
14205                },
14206            };
14207            request_value_reader
14208                .seek(std::io::SeekFrom::Start(0))
14209                .unwrap();
14210            let mut req_result = {
14211                let client = &self.hub.client;
14212                dlg.pre_request();
14213                let mut req_builder = hyper::Request::builder()
14214                    .method(hyper::Method::POST)
14215                    .uri(url.as_str())
14216                    .header(USER_AGENT, self.hub._user_agent.clone());
14217
14218                if let Some(token) = token.as_ref() {
14219                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14220                }
14221
14222                let request = req_builder
14223                    .header(CONTENT_TYPE, json_mime_type.to_string())
14224                    .header(CONTENT_LENGTH, request_size as u64)
14225                    .body(common::to_body(
14226                        request_value_reader.get_ref().clone().into(),
14227                    ));
14228
14229                client.request(request.unwrap()).await
14230            };
14231
14232            match req_result {
14233                Err(err) => {
14234                    if let common::Retry::After(d) = dlg.http_error(&err) {
14235                        sleep(d).await;
14236                        continue;
14237                    }
14238                    dlg.finished(false);
14239                    return Err(common::Error::HttpError(err));
14240                }
14241                Ok(res) => {
14242                    let (mut parts, body) = res.into_parts();
14243                    let mut body = common::Body::new(body);
14244                    if !parts.status.is_success() {
14245                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14246                        let error = serde_json::from_str(&common::to_string(&bytes));
14247                        let response = common::to_response(parts, bytes.into());
14248
14249                        if let common::Retry::After(d) =
14250                            dlg.http_failure(&response, error.as_ref().ok())
14251                        {
14252                            sleep(d).await;
14253                            continue;
14254                        }
14255
14256                        dlg.finished(false);
14257
14258                        return Err(match error {
14259                            Ok(value) => common::Error::BadRequest(value),
14260                            _ => common::Error::Failure(response),
14261                        });
14262                    }
14263                    let response = {
14264                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14265                        let encoded = common::to_string(&bytes);
14266                        match serde_json::from_str(&encoded) {
14267                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14268                            Err(error) => {
14269                                dlg.response_json_decode_error(&encoded, &error);
14270                                return Err(common::Error::JsonDecodeError(
14271                                    encoded.to_string(),
14272                                    error,
14273                                ));
14274                            }
14275                        }
14276                    };
14277
14278                    dlg.finished(true);
14279                    return Ok(response);
14280                }
14281            }
14282        }
14283    }
14284
14285    ///
14286    /// Sets the *request* property to the given value.
14287    ///
14288    /// Even though the property as already been set when instantiating this call,
14289    /// we provide this method for API completeness.
14290    pub fn request(mut self, new_value: WriteRequest) -> ProjectDatabaseDocumentWriteCall<'a, C> {
14291        self._request = new_value;
14292        self
14293    }
14294    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. This is only required in the first message.
14295    ///
14296    /// Sets the *database* path property to the given value.
14297    ///
14298    /// Even though the property as already been set when instantiating this call,
14299    /// we provide this method for API completeness.
14300    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentWriteCall<'a, C> {
14301        self._database = new_value.to_string();
14302        self
14303    }
14304    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14305    /// while executing the actual API request.
14306    ///
14307    /// ````text
14308    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14309    /// ````
14310    ///
14311    /// Sets the *delegate* property to the given value.
14312    pub fn delegate(
14313        mut self,
14314        new_value: &'a mut dyn common::Delegate,
14315    ) -> ProjectDatabaseDocumentWriteCall<'a, C> {
14316        self._delegate = Some(new_value);
14317        self
14318    }
14319
14320    /// Set any additional parameter of the query string used in the request.
14321    /// It should be used to set parameters which are not yet available through their own
14322    /// setters.
14323    ///
14324    /// Please note that this method must not be used to set any of the known parameters
14325    /// which have their own setter method. If done anyway, the request will fail.
14326    ///
14327    /// # Additional Parameters
14328    ///
14329    /// * *$.xgafv* (query-string) - V1 error format.
14330    /// * *access_token* (query-string) - OAuth access token.
14331    /// * *alt* (query-string) - Data format for response.
14332    /// * *callback* (query-string) - JSONP
14333    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14334    /// * *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.
14335    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14336    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14337    /// * *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.
14338    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14339    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14340    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentWriteCall<'a, C>
14341    where
14342        T: AsRef<str>,
14343    {
14344        self._additional_params
14345            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14346        self
14347    }
14348
14349    /// Identifies the authorization scope for the method you are building.
14350    ///
14351    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14352    /// [`Scope::CloudPlatform`].
14353    ///
14354    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14355    /// tokens for more than one scope.
14356    ///
14357    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14358    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14359    /// sufficient, a read-write scope will do as well.
14360    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentWriteCall<'a, C>
14361    where
14362        St: AsRef<str>,
14363    {
14364        self._scopes.insert(String::from(scope.as_ref()));
14365        self
14366    }
14367    /// Identifies the authorization scope(s) for the method you are building.
14368    ///
14369    /// See [`Self::add_scope()`] for details.
14370    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentWriteCall<'a, C>
14371    where
14372        I: IntoIterator<Item = St>,
14373        St: AsRef<str>,
14374    {
14375        self._scopes
14376            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14377        self
14378    }
14379
14380    /// Removes all scopes, and no default scope will be used either.
14381    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14382    /// for details).
14383    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentWriteCall<'a, C> {
14384        self._scopes.clear();
14385        self
14386    }
14387}
14388
14389/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
14390///
14391/// A builder for the *databases.operations.cancel* method supported by a *project* resource.
14392/// It is not used directly, but through a [`ProjectMethods`] instance.
14393///
14394/// # Example
14395///
14396/// Instantiate a resource method builder
14397///
14398/// ```test_harness,no_run
14399/// # extern crate hyper;
14400/// # extern crate hyper_rustls;
14401/// # extern crate google_firestore1 as firestore1;
14402/// use firestore1::api::GoogleLongrunningCancelOperationRequest;
14403/// # async fn dox() {
14404/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14405///
14406/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14407/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14408/// #     .with_native_roots()
14409/// #     .unwrap()
14410/// #     .https_only()
14411/// #     .enable_http2()
14412/// #     .build();
14413///
14414/// # let executor = hyper_util::rt::TokioExecutor::new();
14415/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14416/// #     secret,
14417/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14418/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14419/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14420/// #     ),
14421/// # ).build().await.unwrap();
14422///
14423/// # let client = hyper_util::client::legacy::Client::builder(
14424/// #     hyper_util::rt::TokioExecutor::new()
14425/// # )
14426/// # .build(
14427/// #     hyper_rustls::HttpsConnectorBuilder::new()
14428/// #         .with_native_roots()
14429/// #         .unwrap()
14430/// #         .https_or_http()
14431/// #         .enable_http2()
14432/// #         .build()
14433/// # );
14434/// # let mut hub = Firestore::new(client, auth);
14435/// // As the method needs a request, you would usually fill it with the desired information
14436/// // into the respective structure. Some of the parts shown here might not be applicable !
14437/// // Values shown here are possibly random and not representative !
14438/// let mut req = GoogleLongrunningCancelOperationRequest::default();
14439///
14440/// // You can configure optional parameters by calling the respective setters at will, and
14441/// // execute the final call using `doit()`.
14442/// // Values shown here are possibly random and not representative !
14443/// let result = hub.projects().databases_operations_cancel(req, "name")
14444///              .doit().await;
14445/// # }
14446/// ```
14447pub struct ProjectDatabaseOperationCancelCall<'a, C>
14448where
14449    C: 'a,
14450{
14451    hub: &'a Firestore<C>,
14452    _request: GoogleLongrunningCancelOperationRequest,
14453    _name: String,
14454    _delegate: Option<&'a mut dyn common::Delegate>,
14455    _additional_params: HashMap<String, String>,
14456    _scopes: BTreeSet<String>,
14457}
14458
14459impl<'a, C> common::CallBuilder for ProjectDatabaseOperationCancelCall<'a, C> {}
14460
14461impl<'a, C> ProjectDatabaseOperationCancelCall<'a, C>
14462where
14463    C: common::Connector,
14464{
14465    /// Perform the operation you have build so far.
14466    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
14467        use std::borrow::Cow;
14468        use std::io::{Read, Seek};
14469
14470        use common::{url::Params, ToParts};
14471        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14472
14473        let mut dd = common::DefaultDelegate;
14474        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14475        dlg.begin(common::MethodInfo {
14476            id: "firestore.projects.databases.operations.cancel",
14477            http_method: hyper::Method::POST,
14478        });
14479
14480        for &field in ["alt", "name"].iter() {
14481            if self._additional_params.contains_key(field) {
14482                dlg.finished(false);
14483                return Err(common::Error::FieldClash(field));
14484            }
14485        }
14486
14487        let mut params = Params::with_capacity(4 + self._additional_params.len());
14488        params.push("name", self._name);
14489
14490        params.extend(self._additional_params.iter());
14491
14492        params.push("alt", "json");
14493        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
14494        if self._scopes.is_empty() {
14495            self._scopes
14496                .insert(Scope::CloudPlatform.as_ref().to_string());
14497        }
14498
14499        #[allow(clippy::single_element_loop)]
14500        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14501            url = params.uri_replacement(url, param_name, find_this, true);
14502        }
14503        {
14504            let to_remove = ["name"];
14505            params.remove_params(&to_remove);
14506        }
14507
14508        let url = params.parse_with_url(&url);
14509
14510        let mut json_mime_type = mime::APPLICATION_JSON;
14511        let mut request_value_reader = {
14512            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14513            common::remove_json_null_values(&mut value);
14514            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14515            serde_json::to_writer(&mut dst, &value).unwrap();
14516            dst
14517        };
14518        let request_size = request_value_reader
14519            .seek(std::io::SeekFrom::End(0))
14520            .unwrap();
14521        request_value_reader
14522            .seek(std::io::SeekFrom::Start(0))
14523            .unwrap();
14524
14525        loop {
14526            let token = match self
14527                .hub
14528                .auth
14529                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14530                .await
14531            {
14532                Ok(token) => token,
14533                Err(e) => match dlg.token(e) {
14534                    Ok(token) => token,
14535                    Err(e) => {
14536                        dlg.finished(false);
14537                        return Err(common::Error::MissingToken(e));
14538                    }
14539                },
14540            };
14541            request_value_reader
14542                .seek(std::io::SeekFrom::Start(0))
14543                .unwrap();
14544            let mut req_result = {
14545                let client = &self.hub.client;
14546                dlg.pre_request();
14547                let mut req_builder = hyper::Request::builder()
14548                    .method(hyper::Method::POST)
14549                    .uri(url.as_str())
14550                    .header(USER_AGENT, self.hub._user_agent.clone());
14551
14552                if let Some(token) = token.as_ref() {
14553                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14554                }
14555
14556                let request = req_builder
14557                    .header(CONTENT_TYPE, json_mime_type.to_string())
14558                    .header(CONTENT_LENGTH, request_size as u64)
14559                    .body(common::to_body(
14560                        request_value_reader.get_ref().clone().into(),
14561                    ));
14562
14563                client.request(request.unwrap()).await
14564            };
14565
14566            match req_result {
14567                Err(err) => {
14568                    if let common::Retry::After(d) = dlg.http_error(&err) {
14569                        sleep(d).await;
14570                        continue;
14571                    }
14572                    dlg.finished(false);
14573                    return Err(common::Error::HttpError(err));
14574                }
14575                Ok(res) => {
14576                    let (mut parts, body) = res.into_parts();
14577                    let mut body = common::Body::new(body);
14578                    if !parts.status.is_success() {
14579                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14580                        let error = serde_json::from_str(&common::to_string(&bytes));
14581                        let response = common::to_response(parts, bytes.into());
14582
14583                        if let common::Retry::After(d) =
14584                            dlg.http_failure(&response, error.as_ref().ok())
14585                        {
14586                            sleep(d).await;
14587                            continue;
14588                        }
14589
14590                        dlg.finished(false);
14591
14592                        return Err(match error {
14593                            Ok(value) => common::Error::BadRequest(value),
14594                            _ => common::Error::Failure(response),
14595                        });
14596                    }
14597                    let response = {
14598                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14599                        let encoded = common::to_string(&bytes);
14600                        match serde_json::from_str(&encoded) {
14601                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14602                            Err(error) => {
14603                                dlg.response_json_decode_error(&encoded, &error);
14604                                return Err(common::Error::JsonDecodeError(
14605                                    encoded.to_string(),
14606                                    error,
14607                                ));
14608                            }
14609                        }
14610                    };
14611
14612                    dlg.finished(true);
14613                    return Ok(response);
14614                }
14615            }
14616        }
14617    }
14618
14619    ///
14620    /// Sets the *request* property to the given value.
14621    ///
14622    /// Even though the property as already been set when instantiating this call,
14623    /// we provide this method for API completeness.
14624    pub fn request(
14625        mut self,
14626        new_value: GoogleLongrunningCancelOperationRequest,
14627    ) -> ProjectDatabaseOperationCancelCall<'a, C> {
14628        self._request = new_value;
14629        self
14630    }
14631    /// The name of the operation resource to be cancelled.
14632    ///
14633    /// Sets the *name* path property to the given value.
14634    ///
14635    /// Even though the property as already been set when instantiating this call,
14636    /// we provide this method for API completeness.
14637    pub fn name(mut self, new_value: &str) -> ProjectDatabaseOperationCancelCall<'a, C> {
14638        self._name = new_value.to_string();
14639        self
14640    }
14641    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14642    /// while executing the actual API request.
14643    ///
14644    /// ````text
14645    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14646    /// ````
14647    ///
14648    /// Sets the *delegate* property to the given value.
14649    pub fn delegate(
14650        mut self,
14651        new_value: &'a mut dyn common::Delegate,
14652    ) -> ProjectDatabaseOperationCancelCall<'a, C> {
14653        self._delegate = Some(new_value);
14654        self
14655    }
14656
14657    /// Set any additional parameter of the query string used in the request.
14658    /// It should be used to set parameters which are not yet available through their own
14659    /// setters.
14660    ///
14661    /// Please note that this method must not be used to set any of the known parameters
14662    /// which have their own setter method. If done anyway, the request will fail.
14663    ///
14664    /// # Additional Parameters
14665    ///
14666    /// * *$.xgafv* (query-string) - V1 error format.
14667    /// * *access_token* (query-string) - OAuth access token.
14668    /// * *alt* (query-string) - Data format for response.
14669    /// * *callback* (query-string) - JSONP
14670    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14671    /// * *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.
14672    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14673    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14674    /// * *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.
14675    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14676    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14677    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseOperationCancelCall<'a, C>
14678    where
14679        T: AsRef<str>,
14680    {
14681        self._additional_params
14682            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14683        self
14684    }
14685
14686    /// Identifies the authorization scope for the method you are building.
14687    ///
14688    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14689    /// [`Scope::CloudPlatform`].
14690    ///
14691    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14692    /// tokens for more than one scope.
14693    ///
14694    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14695    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14696    /// sufficient, a read-write scope will do as well.
14697    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseOperationCancelCall<'a, C>
14698    where
14699        St: AsRef<str>,
14700    {
14701        self._scopes.insert(String::from(scope.as_ref()));
14702        self
14703    }
14704    /// Identifies the authorization scope(s) for the method you are building.
14705    ///
14706    /// See [`Self::add_scope()`] for details.
14707    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseOperationCancelCall<'a, C>
14708    where
14709        I: IntoIterator<Item = St>,
14710        St: AsRef<str>,
14711    {
14712        self._scopes
14713            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14714        self
14715    }
14716
14717    /// Removes all scopes, and no default scope will be used either.
14718    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14719    /// for details).
14720    pub fn clear_scopes(mut self) -> ProjectDatabaseOperationCancelCall<'a, C> {
14721        self._scopes.clear();
14722        self
14723    }
14724}
14725
14726/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
14727///
14728/// A builder for the *databases.operations.delete* method supported by a *project* resource.
14729/// It is not used directly, but through a [`ProjectMethods`] instance.
14730///
14731/// # Example
14732///
14733/// Instantiate a resource method builder
14734///
14735/// ```test_harness,no_run
14736/// # extern crate hyper;
14737/// # extern crate hyper_rustls;
14738/// # extern crate google_firestore1 as firestore1;
14739/// # async fn dox() {
14740/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14741///
14742/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14743/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14744/// #     .with_native_roots()
14745/// #     .unwrap()
14746/// #     .https_only()
14747/// #     .enable_http2()
14748/// #     .build();
14749///
14750/// # let executor = hyper_util::rt::TokioExecutor::new();
14751/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14752/// #     secret,
14753/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14754/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14755/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14756/// #     ),
14757/// # ).build().await.unwrap();
14758///
14759/// # let client = hyper_util::client::legacy::Client::builder(
14760/// #     hyper_util::rt::TokioExecutor::new()
14761/// # )
14762/// # .build(
14763/// #     hyper_rustls::HttpsConnectorBuilder::new()
14764/// #         .with_native_roots()
14765/// #         .unwrap()
14766/// #         .https_or_http()
14767/// #         .enable_http2()
14768/// #         .build()
14769/// # );
14770/// # let mut hub = Firestore::new(client, auth);
14771/// // You can configure optional parameters by calling the respective setters at will, and
14772/// // execute the final call using `doit()`.
14773/// // Values shown here are possibly random and not representative !
14774/// let result = hub.projects().databases_operations_delete("name")
14775///              .doit().await;
14776/// # }
14777/// ```
14778pub struct ProjectDatabaseOperationDeleteCall<'a, C>
14779where
14780    C: 'a,
14781{
14782    hub: &'a Firestore<C>,
14783    _name: String,
14784    _delegate: Option<&'a mut dyn common::Delegate>,
14785    _additional_params: HashMap<String, String>,
14786    _scopes: BTreeSet<String>,
14787}
14788
14789impl<'a, C> common::CallBuilder for ProjectDatabaseOperationDeleteCall<'a, C> {}
14790
14791impl<'a, C> ProjectDatabaseOperationDeleteCall<'a, C>
14792where
14793    C: common::Connector,
14794{
14795    /// Perform the operation you have build so far.
14796    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
14797        use std::borrow::Cow;
14798        use std::io::{Read, Seek};
14799
14800        use common::{url::Params, ToParts};
14801        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14802
14803        let mut dd = common::DefaultDelegate;
14804        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14805        dlg.begin(common::MethodInfo {
14806            id: "firestore.projects.databases.operations.delete",
14807            http_method: hyper::Method::DELETE,
14808        });
14809
14810        for &field in ["alt", "name"].iter() {
14811            if self._additional_params.contains_key(field) {
14812                dlg.finished(false);
14813                return Err(common::Error::FieldClash(field));
14814            }
14815        }
14816
14817        let mut params = Params::with_capacity(3 + self._additional_params.len());
14818        params.push("name", self._name);
14819
14820        params.extend(self._additional_params.iter());
14821
14822        params.push("alt", "json");
14823        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14824        if self._scopes.is_empty() {
14825            self._scopes
14826                .insert(Scope::CloudPlatform.as_ref().to_string());
14827        }
14828
14829        #[allow(clippy::single_element_loop)]
14830        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14831            url = params.uri_replacement(url, param_name, find_this, true);
14832        }
14833        {
14834            let to_remove = ["name"];
14835            params.remove_params(&to_remove);
14836        }
14837
14838        let url = params.parse_with_url(&url);
14839
14840        loop {
14841            let token = match self
14842                .hub
14843                .auth
14844                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14845                .await
14846            {
14847                Ok(token) => token,
14848                Err(e) => match dlg.token(e) {
14849                    Ok(token) => token,
14850                    Err(e) => {
14851                        dlg.finished(false);
14852                        return Err(common::Error::MissingToken(e));
14853                    }
14854                },
14855            };
14856            let mut req_result = {
14857                let client = &self.hub.client;
14858                dlg.pre_request();
14859                let mut req_builder = hyper::Request::builder()
14860                    .method(hyper::Method::DELETE)
14861                    .uri(url.as_str())
14862                    .header(USER_AGENT, self.hub._user_agent.clone());
14863
14864                if let Some(token) = token.as_ref() {
14865                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14866                }
14867
14868                let request = req_builder
14869                    .header(CONTENT_LENGTH, 0_u64)
14870                    .body(common::to_body::<String>(None));
14871
14872                client.request(request.unwrap()).await
14873            };
14874
14875            match req_result {
14876                Err(err) => {
14877                    if let common::Retry::After(d) = dlg.http_error(&err) {
14878                        sleep(d).await;
14879                        continue;
14880                    }
14881                    dlg.finished(false);
14882                    return Err(common::Error::HttpError(err));
14883                }
14884                Ok(res) => {
14885                    let (mut parts, body) = res.into_parts();
14886                    let mut body = common::Body::new(body);
14887                    if !parts.status.is_success() {
14888                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14889                        let error = serde_json::from_str(&common::to_string(&bytes));
14890                        let response = common::to_response(parts, bytes.into());
14891
14892                        if let common::Retry::After(d) =
14893                            dlg.http_failure(&response, error.as_ref().ok())
14894                        {
14895                            sleep(d).await;
14896                            continue;
14897                        }
14898
14899                        dlg.finished(false);
14900
14901                        return Err(match error {
14902                            Ok(value) => common::Error::BadRequest(value),
14903                            _ => common::Error::Failure(response),
14904                        });
14905                    }
14906                    let response = {
14907                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14908                        let encoded = common::to_string(&bytes);
14909                        match serde_json::from_str(&encoded) {
14910                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14911                            Err(error) => {
14912                                dlg.response_json_decode_error(&encoded, &error);
14913                                return Err(common::Error::JsonDecodeError(
14914                                    encoded.to_string(),
14915                                    error,
14916                                ));
14917                            }
14918                        }
14919                    };
14920
14921                    dlg.finished(true);
14922                    return Ok(response);
14923                }
14924            }
14925        }
14926    }
14927
14928    /// The name of the operation resource to be deleted.
14929    ///
14930    /// Sets the *name* path property to the given value.
14931    ///
14932    /// Even though the property as already been set when instantiating this call,
14933    /// we provide this method for API completeness.
14934    pub fn name(mut self, new_value: &str) -> ProjectDatabaseOperationDeleteCall<'a, C> {
14935        self._name = new_value.to_string();
14936        self
14937    }
14938    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14939    /// while executing the actual API request.
14940    ///
14941    /// ````text
14942    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14943    /// ````
14944    ///
14945    /// Sets the *delegate* property to the given value.
14946    pub fn delegate(
14947        mut self,
14948        new_value: &'a mut dyn common::Delegate,
14949    ) -> ProjectDatabaseOperationDeleteCall<'a, C> {
14950        self._delegate = Some(new_value);
14951        self
14952    }
14953
14954    /// Set any additional parameter of the query string used in the request.
14955    /// It should be used to set parameters which are not yet available through their own
14956    /// setters.
14957    ///
14958    /// Please note that this method must not be used to set any of the known parameters
14959    /// which have their own setter method. If done anyway, the request will fail.
14960    ///
14961    /// # Additional Parameters
14962    ///
14963    /// * *$.xgafv* (query-string) - V1 error format.
14964    /// * *access_token* (query-string) - OAuth access token.
14965    /// * *alt* (query-string) - Data format for response.
14966    /// * *callback* (query-string) - JSONP
14967    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14968    /// * *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.
14969    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14970    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14971    /// * *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.
14972    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14973    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14974    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseOperationDeleteCall<'a, C>
14975    where
14976        T: AsRef<str>,
14977    {
14978        self._additional_params
14979            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14980        self
14981    }
14982
14983    /// Identifies the authorization scope for the method you are building.
14984    ///
14985    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14986    /// [`Scope::CloudPlatform`].
14987    ///
14988    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14989    /// tokens for more than one scope.
14990    ///
14991    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14992    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14993    /// sufficient, a read-write scope will do as well.
14994    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseOperationDeleteCall<'a, C>
14995    where
14996        St: AsRef<str>,
14997    {
14998        self._scopes.insert(String::from(scope.as_ref()));
14999        self
15000    }
15001    /// Identifies the authorization scope(s) for the method you are building.
15002    ///
15003    /// See [`Self::add_scope()`] for details.
15004    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseOperationDeleteCall<'a, C>
15005    where
15006        I: IntoIterator<Item = St>,
15007        St: AsRef<str>,
15008    {
15009        self._scopes
15010            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15011        self
15012    }
15013
15014    /// Removes all scopes, and no default scope will be used either.
15015    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15016    /// for details).
15017    pub fn clear_scopes(mut self) -> ProjectDatabaseOperationDeleteCall<'a, C> {
15018        self._scopes.clear();
15019        self
15020    }
15021}
15022
15023/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
15024///
15025/// A builder for the *databases.operations.get* method supported by a *project* resource.
15026/// It is not used directly, but through a [`ProjectMethods`] instance.
15027///
15028/// # Example
15029///
15030/// Instantiate a resource method builder
15031///
15032/// ```test_harness,no_run
15033/// # extern crate hyper;
15034/// # extern crate hyper_rustls;
15035/// # extern crate google_firestore1 as firestore1;
15036/// # async fn dox() {
15037/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15038///
15039/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15040/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15041/// #     .with_native_roots()
15042/// #     .unwrap()
15043/// #     .https_only()
15044/// #     .enable_http2()
15045/// #     .build();
15046///
15047/// # let executor = hyper_util::rt::TokioExecutor::new();
15048/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15049/// #     secret,
15050/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15051/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15052/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15053/// #     ),
15054/// # ).build().await.unwrap();
15055///
15056/// # let client = hyper_util::client::legacy::Client::builder(
15057/// #     hyper_util::rt::TokioExecutor::new()
15058/// # )
15059/// # .build(
15060/// #     hyper_rustls::HttpsConnectorBuilder::new()
15061/// #         .with_native_roots()
15062/// #         .unwrap()
15063/// #         .https_or_http()
15064/// #         .enable_http2()
15065/// #         .build()
15066/// # );
15067/// # let mut hub = Firestore::new(client, auth);
15068/// // You can configure optional parameters by calling the respective setters at will, and
15069/// // execute the final call using `doit()`.
15070/// // Values shown here are possibly random and not representative !
15071/// let result = hub.projects().databases_operations_get("name")
15072///              .doit().await;
15073/// # }
15074/// ```
15075pub struct ProjectDatabaseOperationGetCall<'a, C>
15076where
15077    C: 'a,
15078{
15079    hub: &'a Firestore<C>,
15080    _name: String,
15081    _delegate: Option<&'a mut dyn common::Delegate>,
15082    _additional_params: HashMap<String, String>,
15083    _scopes: BTreeSet<String>,
15084}
15085
15086impl<'a, C> common::CallBuilder for ProjectDatabaseOperationGetCall<'a, C> {}
15087
15088impl<'a, C> ProjectDatabaseOperationGetCall<'a, C>
15089where
15090    C: common::Connector,
15091{
15092    /// Perform the operation you have build so far.
15093    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
15094        use std::borrow::Cow;
15095        use std::io::{Read, Seek};
15096
15097        use common::{url::Params, ToParts};
15098        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15099
15100        let mut dd = common::DefaultDelegate;
15101        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15102        dlg.begin(common::MethodInfo {
15103            id: "firestore.projects.databases.operations.get",
15104            http_method: hyper::Method::GET,
15105        });
15106
15107        for &field in ["alt", "name"].iter() {
15108            if self._additional_params.contains_key(field) {
15109                dlg.finished(false);
15110                return Err(common::Error::FieldClash(field));
15111            }
15112        }
15113
15114        let mut params = Params::with_capacity(3 + self._additional_params.len());
15115        params.push("name", self._name);
15116
15117        params.extend(self._additional_params.iter());
15118
15119        params.push("alt", "json");
15120        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15121        if self._scopes.is_empty() {
15122            self._scopes
15123                .insert(Scope::CloudPlatform.as_ref().to_string());
15124        }
15125
15126        #[allow(clippy::single_element_loop)]
15127        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15128            url = params.uri_replacement(url, param_name, find_this, true);
15129        }
15130        {
15131            let to_remove = ["name"];
15132            params.remove_params(&to_remove);
15133        }
15134
15135        let url = params.parse_with_url(&url);
15136
15137        loop {
15138            let token = match self
15139                .hub
15140                .auth
15141                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15142                .await
15143            {
15144                Ok(token) => token,
15145                Err(e) => match dlg.token(e) {
15146                    Ok(token) => token,
15147                    Err(e) => {
15148                        dlg.finished(false);
15149                        return Err(common::Error::MissingToken(e));
15150                    }
15151                },
15152            };
15153            let mut req_result = {
15154                let client = &self.hub.client;
15155                dlg.pre_request();
15156                let mut req_builder = hyper::Request::builder()
15157                    .method(hyper::Method::GET)
15158                    .uri(url.as_str())
15159                    .header(USER_AGENT, self.hub._user_agent.clone());
15160
15161                if let Some(token) = token.as_ref() {
15162                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15163                }
15164
15165                let request = req_builder
15166                    .header(CONTENT_LENGTH, 0_u64)
15167                    .body(common::to_body::<String>(None));
15168
15169                client.request(request.unwrap()).await
15170            };
15171
15172            match req_result {
15173                Err(err) => {
15174                    if let common::Retry::After(d) = dlg.http_error(&err) {
15175                        sleep(d).await;
15176                        continue;
15177                    }
15178                    dlg.finished(false);
15179                    return Err(common::Error::HttpError(err));
15180                }
15181                Ok(res) => {
15182                    let (mut parts, body) = res.into_parts();
15183                    let mut body = common::Body::new(body);
15184                    if !parts.status.is_success() {
15185                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15186                        let error = serde_json::from_str(&common::to_string(&bytes));
15187                        let response = common::to_response(parts, bytes.into());
15188
15189                        if let common::Retry::After(d) =
15190                            dlg.http_failure(&response, error.as_ref().ok())
15191                        {
15192                            sleep(d).await;
15193                            continue;
15194                        }
15195
15196                        dlg.finished(false);
15197
15198                        return Err(match error {
15199                            Ok(value) => common::Error::BadRequest(value),
15200                            _ => common::Error::Failure(response),
15201                        });
15202                    }
15203                    let response = {
15204                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15205                        let encoded = common::to_string(&bytes);
15206                        match serde_json::from_str(&encoded) {
15207                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15208                            Err(error) => {
15209                                dlg.response_json_decode_error(&encoded, &error);
15210                                return Err(common::Error::JsonDecodeError(
15211                                    encoded.to_string(),
15212                                    error,
15213                                ));
15214                            }
15215                        }
15216                    };
15217
15218                    dlg.finished(true);
15219                    return Ok(response);
15220                }
15221            }
15222        }
15223    }
15224
15225    /// The name of the operation resource.
15226    ///
15227    /// Sets the *name* path property to the given value.
15228    ///
15229    /// Even though the property as already been set when instantiating this call,
15230    /// we provide this method for API completeness.
15231    pub fn name(mut self, new_value: &str) -> ProjectDatabaseOperationGetCall<'a, C> {
15232        self._name = new_value.to_string();
15233        self
15234    }
15235    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15236    /// while executing the actual API request.
15237    ///
15238    /// ````text
15239    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15240    /// ````
15241    ///
15242    /// Sets the *delegate* property to the given value.
15243    pub fn delegate(
15244        mut self,
15245        new_value: &'a mut dyn common::Delegate,
15246    ) -> ProjectDatabaseOperationGetCall<'a, C> {
15247        self._delegate = Some(new_value);
15248        self
15249    }
15250
15251    /// Set any additional parameter of the query string used in the request.
15252    /// It should be used to set parameters which are not yet available through their own
15253    /// setters.
15254    ///
15255    /// Please note that this method must not be used to set any of the known parameters
15256    /// which have their own setter method. If done anyway, the request will fail.
15257    ///
15258    /// # Additional Parameters
15259    ///
15260    /// * *$.xgafv* (query-string) - V1 error format.
15261    /// * *access_token* (query-string) - OAuth access token.
15262    /// * *alt* (query-string) - Data format for response.
15263    /// * *callback* (query-string) - JSONP
15264    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15265    /// * *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.
15266    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15267    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15268    /// * *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.
15269    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15270    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15271    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseOperationGetCall<'a, C>
15272    where
15273        T: AsRef<str>,
15274    {
15275        self._additional_params
15276            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15277        self
15278    }
15279
15280    /// Identifies the authorization scope for the method you are building.
15281    ///
15282    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15283    /// [`Scope::CloudPlatform`].
15284    ///
15285    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15286    /// tokens for more than one scope.
15287    ///
15288    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15289    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15290    /// sufficient, a read-write scope will do as well.
15291    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseOperationGetCall<'a, C>
15292    where
15293        St: AsRef<str>,
15294    {
15295        self._scopes.insert(String::from(scope.as_ref()));
15296        self
15297    }
15298    /// Identifies the authorization scope(s) for the method you are building.
15299    ///
15300    /// See [`Self::add_scope()`] for details.
15301    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseOperationGetCall<'a, C>
15302    where
15303        I: IntoIterator<Item = St>,
15304        St: AsRef<str>,
15305    {
15306        self._scopes
15307            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15308        self
15309    }
15310
15311    /// Removes all scopes, and no default scope will be used either.
15312    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15313    /// for details).
15314    pub fn clear_scopes(mut self) -> ProjectDatabaseOperationGetCall<'a, C> {
15315        self._scopes.clear();
15316        self
15317    }
15318}
15319
15320/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
15321///
15322/// A builder for the *databases.operations.list* method supported by a *project* resource.
15323/// It is not used directly, but through a [`ProjectMethods`] instance.
15324///
15325/// # Example
15326///
15327/// Instantiate a resource method builder
15328///
15329/// ```test_harness,no_run
15330/// # extern crate hyper;
15331/// # extern crate hyper_rustls;
15332/// # extern crate google_firestore1 as firestore1;
15333/// # async fn dox() {
15334/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15335///
15336/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15337/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15338/// #     .with_native_roots()
15339/// #     .unwrap()
15340/// #     .https_only()
15341/// #     .enable_http2()
15342/// #     .build();
15343///
15344/// # let executor = hyper_util::rt::TokioExecutor::new();
15345/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15346/// #     secret,
15347/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15348/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15349/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15350/// #     ),
15351/// # ).build().await.unwrap();
15352///
15353/// # let client = hyper_util::client::legacy::Client::builder(
15354/// #     hyper_util::rt::TokioExecutor::new()
15355/// # )
15356/// # .build(
15357/// #     hyper_rustls::HttpsConnectorBuilder::new()
15358/// #         .with_native_roots()
15359/// #         .unwrap()
15360/// #         .https_or_http()
15361/// #         .enable_http2()
15362/// #         .build()
15363/// # );
15364/// # let mut hub = Firestore::new(client, auth);
15365/// // You can configure optional parameters by calling the respective setters at will, and
15366/// // execute the final call using `doit()`.
15367/// // Values shown here are possibly random and not representative !
15368/// let result = hub.projects().databases_operations_list("name")
15369///              .return_partial_success(false)
15370///              .page_token("vero")
15371///              .page_size(-88)
15372///              .filter("Stet")
15373///              .doit().await;
15374/// # }
15375/// ```
15376pub struct ProjectDatabaseOperationListCall<'a, C>
15377where
15378    C: 'a,
15379{
15380    hub: &'a Firestore<C>,
15381    _name: String,
15382    _return_partial_success: Option<bool>,
15383    _page_token: Option<String>,
15384    _page_size: Option<i32>,
15385    _filter: Option<String>,
15386    _delegate: Option<&'a mut dyn common::Delegate>,
15387    _additional_params: HashMap<String, String>,
15388    _scopes: BTreeSet<String>,
15389}
15390
15391impl<'a, C> common::CallBuilder for ProjectDatabaseOperationListCall<'a, C> {}
15392
15393impl<'a, C> ProjectDatabaseOperationListCall<'a, C>
15394where
15395    C: common::Connector,
15396{
15397    /// Perform the operation you have build so far.
15398    pub async fn doit(
15399        mut self,
15400    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
15401        use std::borrow::Cow;
15402        use std::io::{Read, Seek};
15403
15404        use common::{url::Params, ToParts};
15405        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15406
15407        let mut dd = common::DefaultDelegate;
15408        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15409        dlg.begin(common::MethodInfo {
15410            id: "firestore.projects.databases.operations.list",
15411            http_method: hyper::Method::GET,
15412        });
15413
15414        for &field in [
15415            "alt",
15416            "name",
15417            "returnPartialSuccess",
15418            "pageToken",
15419            "pageSize",
15420            "filter",
15421        ]
15422        .iter()
15423        {
15424            if self._additional_params.contains_key(field) {
15425                dlg.finished(false);
15426                return Err(common::Error::FieldClash(field));
15427            }
15428        }
15429
15430        let mut params = Params::with_capacity(7 + self._additional_params.len());
15431        params.push("name", self._name);
15432        if let Some(value) = self._return_partial_success.as_ref() {
15433            params.push("returnPartialSuccess", value.to_string());
15434        }
15435        if let Some(value) = self._page_token.as_ref() {
15436            params.push("pageToken", value);
15437        }
15438        if let Some(value) = self._page_size.as_ref() {
15439            params.push("pageSize", value.to_string());
15440        }
15441        if let Some(value) = self._filter.as_ref() {
15442            params.push("filter", value);
15443        }
15444
15445        params.extend(self._additional_params.iter());
15446
15447        params.push("alt", "json");
15448        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
15449        if self._scopes.is_empty() {
15450            self._scopes
15451                .insert(Scope::CloudPlatform.as_ref().to_string());
15452        }
15453
15454        #[allow(clippy::single_element_loop)]
15455        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15456            url = params.uri_replacement(url, param_name, find_this, true);
15457        }
15458        {
15459            let to_remove = ["name"];
15460            params.remove_params(&to_remove);
15461        }
15462
15463        let url = params.parse_with_url(&url);
15464
15465        loop {
15466            let token = match self
15467                .hub
15468                .auth
15469                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15470                .await
15471            {
15472                Ok(token) => token,
15473                Err(e) => match dlg.token(e) {
15474                    Ok(token) => token,
15475                    Err(e) => {
15476                        dlg.finished(false);
15477                        return Err(common::Error::MissingToken(e));
15478                    }
15479                },
15480            };
15481            let mut req_result = {
15482                let client = &self.hub.client;
15483                dlg.pre_request();
15484                let mut req_builder = hyper::Request::builder()
15485                    .method(hyper::Method::GET)
15486                    .uri(url.as_str())
15487                    .header(USER_AGENT, self.hub._user_agent.clone());
15488
15489                if let Some(token) = token.as_ref() {
15490                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15491                }
15492
15493                let request = req_builder
15494                    .header(CONTENT_LENGTH, 0_u64)
15495                    .body(common::to_body::<String>(None));
15496
15497                client.request(request.unwrap()).await
15498            };
15499
15500            match req_result {
15501                Err(err) => {
15502                    if let common::Retry::After(d) = dlg.http_error(&err) {
15503                        sleep(d).await;
15504                        continue;
15505                    }
15506                    dlg.finished(false);
15507                    return Err(common::Error::HttpError(err));
15508                }
15509                Ok(res) => {
15510                    let (mut parts, body) = res.into_parts();
15511                    let mut body = common::Body::new(body);
15512                    if !parts.status.is_success() {
15513                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15514                        let error = serde_json::from_str(&common::to_string(&bytes));
15515                        let response = common::to_response(parts, bytes.into());
15516
15517                        if let common::Retry::After(d) =
15518                            dlg.http_failure(&response, error.as_ref().ok())
15519                        {
15520                            sleep(d).await;
15521                            continue;
15522                        }
15523
15524                        dlg.finished(false);
15525
15526                        return Err(match error {
15527                            Ok(value) => common::Error::BadRequest(value),
15528                            _ => common::Error::Failure(response),
15529                        });
15530                    }
15531                    let response = {
15532                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15533                        let encoded = common::to_string(&bytes);
15534                        match serde_json::from_str(&encoded) {
15535                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15536                            Err(error) => {
15537                                dlg.response_json_decode_error(&encoded, &error);
15538                                return Err(common::Error::JsonDecodeError(
15539                                    encoded.to_string(),
15540                                    error,
15541                                ));
15542                            }
15543                        }
15544                    };
15545
15546                    dlg.finished(true);
15547                    return Ok(response);
15548                }
15549            }
15550        }
15551    }
15552
15553    /// The name of the operation's parent resource.
15554    ///
15555    /// Sets the *name* path property to the given value.
15556    ///
15557    /// Even though the property as already been set when instantiating this call,
15558    /// we provide this method for API completeness.
15559    pub fn name(mut self, new_value: &str) -> ProjectDatabaseOperationListCall<'a, C> {
15560        self._name = new_value.to_string();
15561        self
15562    }
15563    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
15564    ///
15565    /// Sets the *return partial success* query property to the given value.
15566    pub fn return_partial_success(
15567        mut self,
15568        new_value: bool,
15569    ) -> ProjectDatabaseOperationListCall<'a, C> {
15570        self._return_partial_success = Some(new_value);
15571        self
15572    }
15573    /// The standard list page token.
15574    ///
15575    /// Sets the *page token* query property to the given value.
15576    pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseOperationListCall<'a, C> {
15577        self._page_token = Some(new_value.to_string());
15578        self
15579    }
15580    /// The standard list page size.
15581    ///
15582    /// Sets the *page size* query property to the given value.
15583    pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseOperationListCall<'a, C> {
15584        self._page_size = Some(new_value);
15585        self
15586    }
15587    /// The standard list filter.
15588    ///
15589    /// Sets the *filter* query property to the given value.
15590    pub fn filter(mut self, new_value: &str) -> ProjectDatabaseOperationListCall<'a, C> {
15591        self._filter = Some(new_value.to_string());
15592        self
15593    }
15594    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15595    /// while executing the actual API request.
15596    ///
15597    /// ````text
15598    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15599    /// ````
15600    ///
15601    /// Sets the *delegate* property to the given value.
15602    pub fn delegate(
15603        mut self,
15604        new_value: &'a mut dyn common::Delegate,
15605    ) -> ProjectDatabaseOperationListCall<'a, C> {
15606        self._delegate = Some(new_value);
15607        self
15608    }
15609
15610    /// Set any additional parameter of the query string used in the request.
15611    /// It should be used to set parameters which are not yet available through their own
15612    /// setters.
15613    ///
15614    /// Please note that this method must not be used to set any of the known parameters
15615    /// which have their own setter method. If done anyway, the request will fail.
15616    ///
15617    /// # Additional Parameters
15618    ///
15619    /// * *$.xgafv* (query-string) - V1 error format.
15620    /// * *access_token* (query-string) - OAuth access token.
15621    /// * *alt* (query-string) - Data format for response.
15622    /// * *callback* (query-string) - JSONP
15623    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15624    /// * *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.
15625    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15626    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15627    /// * *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.
15628    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15629    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15630    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseOperationListCall<'a, C>
15631    where
15632        T: AsRef<str>,
15633    {
15634        self._additional_params
15635            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15636        self
15637    }
15638
15639    /// Identifies the authorization scope for the method you are building.
15640    ///
15641    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15642    /// [`Scope::CloudPlatform`].
15643    ///
15644    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15645    /// tokens for more than one scope.
15646    ///
15647    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15648    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15649    /// sufficient, a read-write scope will do as well.
15650    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseOperationListCall<'a, C>
15651    where
15652        St: AsRef<str>,
15653    {
15654        self._scopes.insert(String::from(scope.as_ref()));
15655        self
15656    }
15657    /// Identifies the authorization scope(s) for the method you are building.
15658    ///
15659    /// See [`Self::add_scope()`] for details.
15660    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseOperationListCall<'a, C>
15661    where
15662        I: IntoIterator<Item = St>,
15663        St: AsRef<str>,
15664    {
15665        self._scopes
15666            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15667        self
15668    }
15669
15670    /// Removes all scopes, and no default scope will be used either.
15671    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15672    /// for details).
15673    pub fn clear_scopes(mut self) -> ProjectDatabaseOperationListCall<'a, C> {
15674        self._scopes.clear();
15675        self
15676    }
15677}
15678
15679/// Create a user creds.
15680///
15681/// A builder for the *databases.userCreds.create* method supported by a *project* resource.
15682/// It is not used directly, but through a [`ProjectMethods`] instance.
15683///
15684/// # Example
15685///
15686/// Instantiate a resource method builder
15687///
15688/// ```test_harness,no_run
15689/// # extern crate hyper;
15690/// # extern crate hyper_rustls;
15691/// # extern crate google_firestore1 as firestore1;
15692/// use firestore1::api::GoogleFirestoreAdminV1UserCreds;
15693/// # async fn dox() {
15694/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15695///
15696/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15697/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15698/// #     .with_native_roots()
15699/// #     .unwrap()
15700/// #     .https_only()
15701/// #     .enable_http2()
15702/// #     .build();
15703///
15704/// # let executor = hyper_util::rt::TokioExecutor::new();
15705/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15706/// #     secret,
15707/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15708/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15709/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15710/// #     ),
15711/// # ).build().await.unwrap();
15712///
15713/// # let client = hyper_util::client::legacy::Client::builder(
15714/// #     hyper_util::rt::TokioExecutor::new()
15715/// # )
15716/// # .build(
15717/// #     hyper_rustls::HttpsConnectorBuilder::new()
15718/// #         .with_native_roots()
15719/// #         .unwrap()
15720/// #         .https_or_http()
15721/// #         .enable_http2()
15722/// #         .build()
15723/// # );
15724/// # let mut hub = Firestore::new(client, auth);
15725/// // As the method needs a request, you would usually fill it with the desired information
15726/// // into the respective structure. Some of the parts shown here might not be applicable !
15727/// // Values shown here are possibly random and not representative !
15728/// let mut req = GoogleFirestoreAdminV1UserCreds::default();
15729///
15730/// // You can configure optional parameters by calling the respective setters at will, and
15731/// // execute the final call using `doit()`.
15732/// // Values shown here are possibly random and not representative !
15733/// let result = hub.projects().databases_user_creds_create(req, "parent")
15734///              .user_creds_id("elitr")
15735///              .doit().await;
15736/// # }
15737/// ```
15738pub struct ProjectDatabaseUserCredCreateCall<'a, C>
15739where
15740    C: 'a,
15741{
15742    hub: &'a Firestore<C>,
15743    _request: GoogleFirestoreAdminV1UserCreds,
15744    _parent: String,
15745    _user_creds_id: Option<String>,
15746    _delegate: Option<&'a mut dyn common::Delegate>,
15747    _additional_params: HashMap<String, String>,
15748    _scopes: BTreeSet<String>,
15749}
15750
15751impl<'a, C> common::CallBuilder for ProjectDatabaseUserCredCreateCall<'a, C> {}
15752
15753impl<'a, C> ProjectDatabaseUserCredCreateCall<'a, C>
15754where
15755    C: common::Connector,
15756{
15757    /// Perform the operation you have build so far.
15758    pub async fn doit(
15759        mut self,
15760    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1UserCreds)> {
15761        use std::borrow::Cow;
15762        use std::io::{Read, Seek};
15763
15764        use common::{url::Params, ToParts};
15765        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15766
15767        let mut dd = common::DefaultDelegate;
15768        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15769        dlg.begin(common::MethodInfo {
15770            id: "firestore.projects.databases.userCreds.create",
15771            http_method: hyper::Method::POST,
15772        });
15773
15774        for &field in ["alt", "parent", "userCredsId"].iter() {
15775            if self._additional_params.contains_key(field) {
15776                dlg.finished(false);
15777                return Err(common::Error::FieldClash(field));
15778            }
15779        }
15780
15781        let mut params = Params::with_capacity(5 + self._additional_params.len());
15782        params.push("parent", self._parent);
15783        if let Some(value) = self._user_creds_id.as_ref() {
15784            params.push("userCredsId", value);
15785        }
15786
15787        params.extend(self._additional_params.iter());
15788
15789        params.push("alt", "json");
15790        let mut url = self.hub._base_url.clone() + "v1/{+parent}/userCreds";
15791        if self._scopes.is_empty() {
15792            self._scopes
15793                .insert(Scope::CloudPlatform.as_ref().to_string());
15794        }
15795
15796        #[allow(clippy::single_element_loop)]
15797        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15798            url = params.uri_replacement(url, param_name, find_this, true);
15799        }
15800        {
15801            let to_remove = ["parent"];
15802            params.remove_params(&to_remove);
15803        }
15804
15805        let url = params.parse_with_url(&url);
15806
15807        let mut json_mime_type = mime::APPLICATION_JSON;
15808        let mut request_value_reader = {
15809            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15810            common::remove_json_null_values(&mut value);
15811            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15812            serde_json::to_writer(&mut dst, &value).unwrap();
15813            dst
15814        };
15815        let request_size = request_value_reader
15816            .seek(std::io::SeekFrom::End(0))
15817            .unwrap();
15818        request_value_reader
15819            .seek(std::io::SeekFrom::Start(0))
15820            .unwrap();
15821
15822        loop {
15823            let token = match self
15824                .hub
15825                .auth
15826                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15827                .await
15828            {
15829                Ok(token) => token,
15830                Err(e) => match dlg.token(e) {
15831                    Ok(token) => token,
15832                    Err(e) => {
15833                        dlg.finished(false);
15834                        return Err(common::Error::MissingToken(e));
15835                    }
15836                },
15837            };
15838            request_value_reader
15839                .seek(std::io::SeekFrom::Start(0))
15840                .unwrap();
15841            let mut req_result = {
15842                let client = &self.hub.client;
15843                dlg.pre_request();
15844                let mut req_builder = hyper::Request::builder()
15845                    .method(hyper::Method::POST)
15846                    .uri(url.as_str())
15847                    .header(USER_AGENT, self.hub._user_agent.clone());
15848
15849                if let Some(token) = token.as_ref() {
15850                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15851                }
15852
15853                let request = req_builder
15854                    .header(CONTENT_TYPE, json_mime_type.to_string())
15855                    .header(CONTENT_LENGTH, request_size as u64)
15856                    .body(common::to_body(
15857                        request_value_reader.get_ref().clone().into(),
15858                    ));
15859
15860                client.request(request.unwrap()).await
15861            };
15862
15863            match req_result {
15864                Err(err) => {
15865                    if let common::Retry::After(d) = dlg.http_error(&err) {
15866                        sleep(d).await;
15867                        continue;
15868                    }
15869                    dlg.finished(false);
15870                    return Err(common::Error::HttpError(err));
15871                }
15872                Ok(res) => {
15873                    let (mut parts, body) = res.into_parts();
15874                    let mut body = common::Body::new(body);
15875                    if !parts.status.is_success() {
15876                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15877                        let error = serde_json::from_str(&common::to_string(&bytes));
15878                        let response = common::to_response(parts, bytes.into());
15879
15880                        if let common::Retry::After(d) =
15881                            dlg.http_failure(&response, error.as_ref().ok())
15882                        {
15883                            sleep(d).await;
15884                            continue;
15885                        }
15886
15887                        dlg.finished(false);
15888
15889                        return Err(match error {
15890                            Ok(value) => common::Error::BadRequest(value),
15891                            _ => common::Error::Failure(response),
15892                        });
15893                    }
15894                    let response = {
15895                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15896                        let encoded = common::to_string(&bytes);
15897                        match serde_json::from_str(&encoded) {
15898                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15899                            Err(error) => {
15900                                dlg.response_json_decode_error(&encoded, &error);
15901                                return Err(common::Error::JsonDecodeError(
15902                                    encoded.to_string(),
15903                                    error,
15904                                ));
15905                            }
15906                        }
15907                    };
15908
15909                    dlg.finished(true);
15910                    return Ok(response);
15911                }
15912            }
15913        }
15914    }
15915
15916    ///
15917    /// Sets the *request* property to the given value.
15918    ///
15919    /// Even though the property as already been set when instantiating this call,
15920    /// we provide this method for API completeness.
15921    pub fn request(
15922        mut self,
15923        new_value: GoogleFirestoreAdminV1UserCreds,
15924    ) -> ProjectDatabaseUserCredCreateCall<'a, C> {
15925        self._request = new_value;
15926        self
15927    }
15928    /// Required. A parent name of the form `projects/{project_id}/databases/{database_id}`
15929    ///
15930    /// Sets the *parent* path property to the given value.
15931    ///
15932    /// Even though the property as already been set when instantiating this call,
15933    /// we provide this method for API completeness.
15934    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseUserCredCreateCall<'a, C> {
15935        self._parent = new_value.to_string();
15936        self
15937    }
15938    /// Required. The ID to use for the user creds, which will become the final component of the user creds's resource name. This value should be 4-63 characters. Valid characters are /a-z-/ with first character a letter and the last a letter or a number. Must not be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
15939    ///
15940    /// Sets the *user creds id* query property to the given value.
15941    pub fn user_creds_id(mut self, new_value: &str) -> ProjectDatabaseUserCredCreateCall<'a, C> {
15942        self._user_creds_id = Some(new_value.to_string());
15943        self
15944    }
15945    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15946    /// while executing the actual API request.
15947    ///
15948    /// ````text
15949    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15950    /// ````
15951    ///
15952    /// Sets the *delegate* property to the given value.
15953    pub fn delegate(
15954        mut self,
15955        new_value: &'a mut dyn common::Delegate,
15956    ) -> ProjectDatabaseUserCredCreateCall<'a, C> {
15957        self._delegate = Some(new_value);
15958        self
15959    }
15960
15961    /// Set any additional parameter of the query string used in the request.
15962    /// It should be used to set parameters which are not yet available through their own
15963    /// setters.
15964    ///
15965    /// Please note that this method must not be used to set any of the known parameters
15966    /// which have their own setter method. If done anyway, the request will fail.
15967    ///
15968    /// # Additional Parameters
15969    ///
15970    /// * *$.xgafv* (query-string) - V1 error format.
15971    /// * *access_token* (query-string) - OAuth access token.
15972    /// * *alt* (query-string) - Data format for response.
15973    /// * *callback* (query-string) - JSONP
15974    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15975    /// * *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.
15976    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15977    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15978    /// * *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.
15979    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15980    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15981    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseUserCredCreateCall<'a, C>
15982    where
15983        T: AsRef<str>,
15984    {
15985        self._additional_params
15986            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15987        self
15988    }
15989
15990    /// Identifies the authorization scope for the method you are building.
15991    ///
15992    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15993    /// [`Scope::CloudPlatform`].
15994    ///
15995    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15996    /// tokens for more than one scope.
15997    ///
15998    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15999    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16000    /// sufficient, a read-write scope will do as well.
16001    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseUserCredCreateCall<'a, C>
16002    where
16003        St: AsRef<str>,
16004    {
16005        self._scopes.insert(String::from(scope.as_ref()));
16006        self
16007    }
16008    /// Identifies the authorization scope(s) for the method you are building.
16009    ///
16010    /// See [`Self::add_scope()`] for details.
16011    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseUserCredCreateCall<'a, C>
16012    where
16013        I: IntoIterator<Item = St>,
16014        St: AsRef<str>,
16015    {
16016        self._scopes
16017            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16018        self
16019    }
16020
16021    /// Removes all scopes, and no default scope will be used either.
16022    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16023    /// for details).
16024    pub fn clear_scopes(mut self) -> ProjectDatabaseUserCredCreateCall<'a, C> {
16025        self._scopes.clear();
16026        self
16027    }
16028}
16029
16030/// Deletes a user creds.
16031///
16032/// A builder for the *databases.userCreds.delete* method supported by a *project* resource.
16033/// It is not used directly, but through a [`ProjectMethods`] instance.
16034///
16035/// # Example
16036///
16037/// Instantiate a resource method builder
16038///
16039/// ```test_harness,no_run
16040/// # extern crate hyper;
16041/// # extern crate hyper_rustls;
16042/// # extern crate google_firestore1 as firestore1;
16043/// # async fn dox() {
16044/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16045///
16046/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16047/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16048/// #     .with_native_roots()
16049/// #     .unwrap()
16050/// #     .https_only()
16051/// #     .enable_http2()
16052/// #     .build();
16053///
16054/// # let executor = hyper_util::rt::TokioExecutor::new();
16055/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16056/// #     secret,
16057/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16058/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16059/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16060/// #     ),
16061/// # ).build().await.unwrap();
16062///
16063/// # let client = hyper_util::client::legacy::Client::builder(
16064/// #     hyper_util::rt::TokioExecutor::new()
16065/// # )
16066/// # .build(
16067/// #     hyper_rustls::HttpsConnectorBuilder::new()
16068/// #         .with_native_roots()
16069/// #         .unwrap()
16070/// #         .https_or_http()
16071/// #         .enable_http2()
16072/// #         .build()
16073/// # );
16074/// # let mut hub = Firestore::new(client, auth);
16075/// // You can configure optional parameters by calling the respective setters at will, and
16076/// // execute the final call using `doit()`.
16077/// // Values shown here are possibly random and not representative !
16078/// let result = hub.projects().databases_user_creds_delete("name")
16079///              .doit().await;
16080/// # }
16081/// ```
16082pub struct ProjectDatabaseUserCredDeleteCall<'a, C>
16083where
16084    C: 'a,
16085{
16086    hub: &'a Firestore<C>,
16087    _name: String,
16088    _delegate: Option<&'a mut dyn common::Delegate>,
16089    _additional_params: HashMap<String, String>,
16090    _scopes: BTreeSet<String>,
16091}
16092
16093impl<'a, C> common::CallBuilder for ProjectDatabaseUserCredDeleteCall<'a, C> {}
16094
16095impl<'a, C> ProjectDatabaseUserCredDeleteCall<'a, C>
16096where
16097    C: common::Connector,
16098{
16099    /// Perform the operation you have build so far.
16100    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
16101        use std::borrow::Cow;
16102        use std::io::{Read, Seek};
16103
16104        use common::{url::Params, ToParts};
16105        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16106
16107        let mut dd = common::DefaultDelegate;
16108        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16109        dlg.begin(common::MethodInfo {
16110            id: "firestore.projects.databases.userCreds.delete",
16111            http_method: hyper::Method::DELETE,
16112        });
16113
16114        for &field in ["alt", "name"].iter() {
16115            if self._additional_params.contains_key(field) {
16116                dlg.finished(false);
16117                return Err(common::Error::FieldClash(field));
16118            }
16119        }
16120
16121        let mut params = Params::with_capacity(3 + self._additional_params.len());
16122        params.push("name", self._name);
16123
16124        params.extend(self._additional_params.iter());
16125
16126        params.push("alt", "json");
16127        let mut url = self.hub._base_url.clone() + "v1/{+name}";
16128        if self._scopes.is_empty() {
16129            self._scopes
16130                .insert(Scope::CloudPlatform.as_ref().to_string());
16131        }
16132
16133        #[allow(clippy::single_element_loop)]
16134        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16135            url = params.uri_replacement(url, param_name, find_this, true);
16136        }
16137        {
16138            let to_remove = ["name"];
16139            params.remove_params(&to_remove);
16140        }
16141
16142        let url = params.parse_with_url(&url);
16143
16144        loop {
16145            let token = match self
16146                .hub
16147                .auth
16148                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16149                .await
16150            {
16151                Ok(token) => token,
16152                Err(e) => match dlg.token(e) {
16153                    Ok(token) => token,
16154                    Err(e) => {
16155                        dlg.finished(false);
16156                        return Err(common::Error::MissingToken(e));
16157                    }
16158                },
16159            };
16160            let mut req_result = {
16161                let client = &self.hub.client;
16162                dlg.pre_request();
16163                let mut req_builder = hyper::Request::builder()
16164                    .method(hyper::Method::DELETE)
16165                    .uri(url.as_str())
16166                    .header(USER_AGENT, self.hub._user_agent.clone());
16167
16168                if let Some(token) = token.as_ref() {
16169                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16170                }
16171
16172                let request = req_builder
16173                    .header(CONTENT_LENGTH, 0_u64)
16174                    .body(common::to_body::<String>(None));
16175
16176                client.request(request.unwrap()).await
16177            };
16178
16179            match req_result {
16180                Err(err) => {
16181                    if let common::Retry::After(d) = dlg.http_error(&err) {
16182                        sleep(d).await;
16183                        continue;
16184                    }
16185                    dlg.finished(false);
16186                    return Err(common::Error::HttpError(err));
16187                }
16188                Ok(res) => {
16189                    let (mut parts, body) = res.into_parts();
16190                    let mut body = common::Body::new(body);
16191                    if !parts.status.is_success() {
16192                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16193                        let error = serde_json::from_str(&common::to_string(&bytes));
16194                        let response = common::to_response(parts, bytes.into());
16195
16196                        if let common::Retry::After(d) =
16197                            dlg.http_failure(&response, error.as_ref().ok())
16198                        {
16199                            sleep(d).await;
16200                            continue;
16201                        }
16202
16203                        dlg.finished(false);
16204
16205                        return Err(match error {
16206                            Ok(value) => common::Error::BadRequest(value),
16207                            _ => common::Error::Failure(response),
16208                        });
16209                    }
16210                    let response = {
16211                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16212                        let encoded = common::to_string(&bytes);
16213                        match serde_json::from_str(&encoded) {
16214                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16215                            Err(error) => {
16216                                dlg.response_json_decode_error(&encoded, &error);
16217                                return Err(common::Error::JsonDecodeError(
16218                                    encoded.to_string(),
16219                                    error,
16220                                ));
16221                            }
16222                        }
16223                    };
16224
16225                    dlg.finished(true);
16226                    return Ok(response);
16227                }
16228            }
16229        }
16230    }
16231
16232    /// Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
16233    ///
16234    /// Sets the *name* path property to the given value.
16235    ///
16236    /// Even though the property as already been set when instantiating this call,
16237    /// we provide this method for API completeness.
16238    pub fn name(mut self, new_value: &str) -> ProjectDatabaseUserCredDeleteCall<'a, C> {
16239        self._name = new_value.to_string();
16240        self
16241    }
16242    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16243    /// while executing the actual API request.
16244    ///
16245    /// ````text
16246    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16247    /// ````
16248    ///
16249    /// Sets the *delegate* property to the given value.
16250    pub fn delegate(
16251        mut self,
16252        new_value: &'a mut dyn common::Delegate,
16253    ) -> ProjectDatabaseUserCredDeleteCall<'a, C> {
16254        self._delegate = Some(new_value);
16255        self
16256    }
16257
16258    /// Set any additional parameter of the query string used in the request.
16259    /// It should be used to set parameters which are not yet available through their own
16260    /// setters.
16261    ///
16262    /// Please note that this method must not be used to set any of the known parameters
16263    /// which have their own setter method. If done anyway, the request will fail.
16264    ///
16265    /// # Additional Parameters
16266    ///
16267    /// * *$.xgafv* (query-string) - V1 error format.
16268    /// * *access_token* (query-string) - OAuth access token.
16269    /// * *alt* (query-string) - Data format for response.
16270    /// * *callback* (query-string) - JSONP
16271    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16272    /// * *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.
16273    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16274    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16275    /// * *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.
16276    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16277    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16278    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseUserCredDeleteCall<'a, C>
16279    where
16280        T: AsRef<str>,
16281    {
16282        self._additional_params
16283            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16284        self
16285    }
16286
16287    /// Identifies the authorization scope for the method you are building.
16288    ///
16289    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16290    /// [`Scope::CloudPlatform`].
16291    ///
16292    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16293    /// tokens for more than one scope.
16294    ///
16295    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16296    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16297    /// sufficient, a read-write scope will do as well.
16298    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseUserCredDeleteCall<'a, C>
16299    where
16300        St: AsRef<str>,
16301    {
16302        self._scopes.insert(String::from(scope.as_ref()));
16303        self
16304    }
16305    /// Identifies the authorization scope(s) for the method you are building.
16306    ///
16307    /// See [`Self::add_scope()`] for details.
16308    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseUserCredDeleteCall<'a, C>
16309    where
16310        I: IntoIterator<Item = St>,
16311        St: AsRef<str>,
16312    {
16313        self._scopes
16314            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16315        self
16316    }
16317
16318    /// Removes all scopes, and no default scope will be used either.
16319    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16320    /// for details).
16321    pub fn clear_scopes(mut self) -> ProjectDatabaseUserCredDeleteCall<'a, C> {
16322        self._scopes.clear();
16323        self
16324    }
16325}
16326
16327/// Disables a user creds. No-op if the user creds are already disabled.
16328///
16329/// A builder for the *databases.userCreds.disable* method supported by a *project* resource.
16330/// It is not used directly, but through a [`ProjectMethods`] instance.
16331///
16332/// # Example
16333///
16334/// Instantiate a resource method builder
16335///
16336/// ```test_harness,no_run
16337/// # extern crate hyper;
16338/// # extern crate hyper_rustls;
16339/// # extern crate google_firestore1 as firestore1;
16340/// use firestore1::api::GoogleFirestoreAdminV1DisableUserCredsRequest;
16341/// # async fn dox() {
16342/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16343///
16344/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16345/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16346/// #     .with_native_roots()
16347/// #     .unwrap()
16348/// #     .https_only()
16349/// #     .enable_http2()
16350/// #     .build();
16351///
16352/// # let executor = hyper_util::rt::TokioExecutor::new();
16353/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16354/// #     secret,
16355/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16356/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16357/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16358/// #     ),
16359/// # ).build().await.unwrap();
16360///
16361/// # let client = hyper_util::client::legacy::Client::builder(
16362/// #     hyper_util::rt::TokioExecutor::new()
16363/// # )
16364/// # .build(
16365/// #     hyper_rustls::HttpsConnectorBuilder::new()
16366/// #         .with_native_roots()
16367/// #         .unwrap()
16368/// #         .https_or_http()
16369/// #         .enable_http2()
16370/// #         .build()
16371/// # );
16372/// # let mut hub = Firestore::new(client, auth);
16373/// // As the method needs a request, you would usually fill it with the desired information
16374/// // into the respective structure. Some of the parts shown here might not be applicable !
16375/// // Values shown here are possibly random and not representative !
16376/// let mut req = GoogleFirestoreAdminV1DisableUserCredsRequest::default();
16377///
16378/// // You can configure optional parameters by calling the respective setters at will, and
16379/// // execute the final call using `doit()`.
16380/// // Values shown here are possibly random and not representative !
16381/// let result = hub.projects().databases_user_creds_disable(req, "name")
16382///              .doit().await;
16383/// # }
16384/// ```
16385pub struct ProjectDatabaseUserCredDisableCall<'a, C>
16386where
16387    C: 'a,
16388{
16389    hub: &'a Firestore<C>,
16390    _request: GoogleFirestoreAdminV1DisableUserCredsRequest,
16391    _name: String,
16392    _delegate: Option<&'a mut dyn common::Delegate>,
16393    _additional_params: HashMap<String, String>,
16394    _scopes: BTreeSet<String>,
16395}
16396
16397impl<'a, C> common::CallBuilder for ProjectDatabaseUserCredDisableCall<'a, C> {}
16398
16399impl<'a, C> ProjectDatabaseUserCredDisableCall<'a, C>
16400where
16401    C: common::Connector,
16402{
16403    /// Perform the operation you have build so far.
16404    pub async fn doit(
16405        mut self,
16406    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1UserCreds)> {
16407        use std::borrow::Cow;
16408        use std::io::{Read, Seek};
16409
16410        use common::{url::Params, ToParts};
16411        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16412
16413        let mut dd = common::DefaultDelegate;
16414        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16415        dlg.begin(common::MethodInfo {
16416            id: "firestore.projects.databases.userCreds.disable",
16417            http_method: hyper::Method::POST,
16418        });
16419
16420        for &field in ["alt", "name"].iter() {
16421            if self._additional_params.contains_key(field) {
16422                dlg.finished(false);
16423                return Err(common::Error::FieldClash(field));
16424            }
16425        }
16426
16427        let mut params = Params::with_capacity(4 + self._additional_params.len());
16428        params.push("name", self._name);
16429
16430        params.extend(self._additional_params.iter());
16431
16432        params.push("alt", "json");
16433        let mut url = self.hub._base_url.clone() + "v1/{+name}:disable";
16434        if self._scopes.is_empty() {
16435            self._scopes
16436                .insert(Scope::CloudPlatform.as_ref().to_string());
16437        }
16438
16439        #[allow(clippy::single_element_loop)]
16440        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16441            url = params.uri_replacement(url, param_name, find_this, true);
16442        }
16443        {
16444            let to_remove = ["name"];
16445            params.remove_params(&to_remove);
16446        }
16447
16448        let url = params.parse_with_url(&url);
16449
16450        let mut json_mime_type = mime::APPLICATION_JSON;
16451        let mut request_value_reader = {
16452            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16453            common::remove_json_null_values(&mut value);
16454            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16455            serde_json::to_writer(&mut dst, &value).unwrap();
16456            dst
16457        };
16458        let request_size = request_value_reader
16459            .seek(std::io::SeekFrom::End(0))
16460            .unwrap();
16461        request_value_reader
16462            .seek(std::io::SeekFrom::Start(0))
16463            .unwrap();
16464
16465        loop {
16466            let token = match self
16467                .hub
16468                .auth
16469                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16470                .await
16471            {
16472                Ok(token) => token,
16473                Err(e) => match dlg.token(e) {
16474                    Ok(token) => token,
16475                    Err(e) => {
16476                        dlg.finished(false);
16477                        return Err(common::Error::MissingToken(e));
16478                    }
16479                },
16480            };
16481            request_value_reader
16482                .seek(std::io::SeekFrom::Start(0))
16483                .unwrap();
16484            let mut req_result = {
16485                let client = &self.hub.client;
16486                dlg.pre_request();
16487                let mut req_builder = hyper::Request::builder()
16488                    .method(hyper::Method::POST)
16489                    .uri(url.as_str())
16490                    .header(USER_AGENT, self.hub._user_agent.clone());
16491
16492                if let Some(token) = token.as_ref() {
16493                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16494                }
16495
16496                let request = req_builder
16497                    .header(CONTENT_TYPE, json_mime_type.to_string())
16498                    .header(CONTENT_LENGTH, request_size as u64)
16499                    .body(common::to_body(
16500                        request_value_reader.get_ref().clone().into(),
16501                    ));
16502
16503                client.request(request.unwrap()).await
16504            };
16505
16506            match req_result {
16507                Err(err) => {
16508                    if let common::Retry::After(d) = dlg.http_error(&err) {
16509                        sleep(d).await;
16510                        continue;
16511                    }
16512                    dlg.finished(false);
16513                    return Err(common::Error::HttpError(err));
16514                }
16515                Ok(res) => {
16516                    let (mut parts, body) = res.into_parts();
16517                    let mut body = common::Body::new(body);
16518                    if !parts.status.is_success() {
16519                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16520                        let error = serde_json::from_str(&common::to_string(&bytes));
16521                        let response = common::to_response(parts, bytes.into());
16522
16523                        if let common::Retry::After(d) =
16524                            dlg.http_failure(&response, error.as_ref().ok())
16525                        {
16526                            sleep(d).await;
16527                            continue;
16528                        }
16529
16530                        dlg.finished(false);
16531
16532                        return Err(match error {
16533                            Ok(value) => common::Error::BadRequest(value),
16534                            _ => common::Error::Failure(response),
16535                        });
16536                    }
16537                    let response = {
16538                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16539                        let encoded = common::to_string(&bytes);
16540                        match serde_json::from_str(&encoded) {
16541                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16542                            Err(error) => {
16543                                dlg.response_json_decode_error(&encoded, &error);
16544                                return Err(common::Error::JsonDecodeError(
16545                                    encoded.to_string(),
16546                                    error,
16547                                ));
16548                            }
16549                        }
16550                    };
16551
16552                    dlg.finished(true);
16553                    return Ok(response);
16554                }
16555            }
16556        }
16557    }
16558
16559    ///
16560    /// Sets the *request* property to the given value.
16561    ///
16562    /// Even though the property as already been set when instantiating this call,
16563    /// we provide this method for API completeness.
16564    pub fn request(
16565        mut self,
16566        new_value: GoogleFirestoreAdminV1DisableUserCredsRequest,
16567    ) -> ProjectDatabaseUserCredDisableCall<'a, C> {
16568        self._request = new_value;
16569        self
16570    }
16571    /// Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
16572    ///
16573    /// Sets the *name* path property to the given value.
16574    ///
16575    /// Even though the property as already been set when instantiating this call,
16576    /// we provide this method for API completeness.
16577    pub fn name(mut self, new_value: &str) -> ProjectDatabaseUserCredDisableCall<'a, C> {
16578        self._name = new_value.to_string();
16579        self
16580    }
16581    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16582    /// while executing the actual API request.
16583    ///
16584    /// ````text
16585    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16586    /// ````
16587    ///
16588    /// Sets the *delegate* property to the given value.
16589    pub fn delegate(
16590        mut self,
16591        new_value: &'a mut dyn common::Delegate,
16592    ) -> ProjectDatabaseUserCredDisableCall<'a, C> {
16593        self._delegate = Some(new_value);
16594        self
16595    }
16596
16597    /// Set any additional parameter of the query string used in the request.
16598    /// It should be used to set parameters which are not yet available through their own
16599    /// setters.
16600    ///
16601    /// Please note that this method must not be used to set any of the known parameters
16602    /// which have their own setter method. If done anyway, the request will fail.
16603    ///
16604    /// # Additional Parameters
16605    ///
16606    /// * *$.xgafv* (query-string) - V1 error format.
16607    /// * *access_token* (query-string) - OAuth access token.
16608    /// * *alt* (query-string) - Data format for response.
16609    /// * *callback* (query-string) - JSONP
16610    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16611    /// * *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.
16612    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16613    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16614    /// * *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.
16615    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16616    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16617    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseUserCredDisableCall<'a, C>
16618    where
16619        T: AsRef<str>,
16620    {
16621        self._additional_params
16622            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16623        self
16624    }
16625
16626    /// Identifies the authorization scope for the method you are building.
16627    ///
16628    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16629    /// [`Scope::CloudPlatform`].
16630    ///
16631    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16632    /// tokens for more than one scope.
16633    ///
16634    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16635    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16636    /// sufficient, a read-write scope will do as well.
16637    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseUserCredDisableCall<'a, C>
16638    where
16639        St: AsRef<str>,
16640    {
16641        self._scopes.insert(String::from(scope.as_ref()));
16642        self
16643    }
16644    /// Identifies the authorization scope(s) for the method you are building.
16645    ///
16646    /// See [`Self::add_scope()`] for details.
16647    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseUserCredDisableCall<'a, C>
16648    where
16649        I: IntoIterator<Item = St>,
16650        St: AsRef<str>,
16651    {
16652        self._scopes
16653            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16654        self
16655    }
16656
16657    /// Removes all scopes, and no default scope will be used either.
16658    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16659    /// for details).
16660    pub fn clear_scopes(mut self) -> ProjectDatabaseUserCredDisableCall<'a, C> {
16661        self._scopes.clear();
16662        self
16663    }
16664}
16665
16666/// Enables a user creds. No-op if the user creds are already enabled.
16667///
16668/// A builder for the *databases.userCreds.enable* method supported by a *project* resource.
16669/// It is not used directly, but through a [`ProjectMethods`] instance.
16670///
16671/// # Example
16672///
16673/// Instantiate a resource method builder
16674///
16675/// ```test_harness,no_run
16676/// # extern crate hyper;
16677/// # extern crate hyper_rustls;
16678/// # extern crate google_firestore1 as firestore1;
16679/// use firestore1::api::GoogleFirestoreAdminV1EnableUserCredsRequest;
16680/// # async fn dox() {
16681/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16682///
16683/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16684/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16685/// #     .with_native_roots()
16686/// #     .unwrap()
16687/// #     .https_only()
16688/// #     .enable_http2()
16689/// #     .build();
16690///
16691/// # let executor = hyper_util::rt::TokioExecutor::new();
16692/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16693/// #     secret,
16694/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16695/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16696/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16697/// #     ),
16698/// # ).build().await.unwrap();
16699///
16700/// # let client = hyper_util::client::legacy::Client::builder(
16701/// #     hyper_util::rt::TokioExecutor::new()
16702/// # )
16703/// # .build(
16704/// #     hyper_rustls::HttpsConnectorBuilder::new()
16705/// #         .with_native_roots()
16706/// #         .unwrap()
16707/// #         .https_or_http()
16708/// #         .enable_http2()
16709/// #         .build()
16710/// # );
16711/// # let mut hub = Firestore::new(client, auth);
16712/// // As the method needs a request, you would usually fill it with the desired information
16713/// // into the respective structure. Some of the parts shown here might not be applicable !
16714/// // Values shown here are possibly random and not representative !
16715/// let mut req = GoogleFirestoreAdminV1EnableUserCredsRequest::default();
16716///
16717/// // You can configure optional parameters by calling the respective setters at will, and
16718/// // execute the final call using `doit()`.
16719/// // Values shown here are possibly random and not representative !
16720/// let result = hub.projects().databases_user_creds_enable(req, "name")
16721///              .doit().await;
16722/// # }
16723/// ```
16724pub struct ProjectDatabaseUserCredEnableCall<'a, C>
16725where
16726    C: 'a,
16727{
16728    hub: &'a Firestore<C>,
16729    _request: GoogleFirestoreAdminV1EnableUserCredsRequest,
16730    _name: String,
16731    _delegate: Option<&'a mut dyn common::Delegate>,
16732    _additional_params: HashMap<String, String>,
16733    _scopes: BTreeSet<String>,
16734}
16735
16736impl<'a, C> common::CallBuilder for ProjectDatabaseUserCredEnableCall<'a, C> {}
16737
16738impl<'a, C> ProjectDatabaseUserCredEnableCall<'a, C>
16739where
16740    C: common::Connector,
16741{
16742    /// Perform the operation you have build so far.
16743    pub async fn doit(
16744        mut self,
16745    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1UserCreds)> {
16746        use std::borrow::Cow;
16747        use std::io::{Read, Seek};
16748
16749        use common::{url::Params, ToParts};
16750        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16751
16752        let mut dd = common::DefaultDelegate;
16753        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16754        dlg.begin(common::MethodInfo {
16755            id: "firestore.projects.databases.userCreds.enable",
16756            http_method: hyper::Method::POST,
16757        });
16758
16759        for &field in ["alt", "name"].iter() {
16760            if self._additional_params.contains_key(field) {
16761                dlg.finished(false);
16762                return Err(common::Error::FieldClash(field));
16763            }
16764        }
16765
16766        let mut params = Params::with_capacity(4 + self._additional_params.len());
16767        params.push("name", self._name);
16768
16769        params.extend(self._additional_params.iter());
16770
16771        params.push("alt", "json");
16772        let mut url = self.hub._base_url.clone() + "v1/{+name}:enable";
16773        if self._scopes.is_empty() {
16774            self._scopes
16775                .insert(Scope::CloudPlatform.as_ref().to_string());
16776        }
16777
16778        #[allow(clippy::single_element_loop)]
16779        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16780            url = params.uri_replacement(url, param_name, find_this, true);
16781        }
16782        {
16783            let to_remove = ["name"];
16784            params.remove_params(&to_remove);
16785        }
16786
16787        let url = params.parse_with_url(&url);
16788
16789        let mut json_mime_type = mime::APPLICATION_JSON;
16790        let mut request_value_reader = {
16791            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16792            common::remove_json_null_values(&mut value);
16793            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16794            serde_json::to_writer(&mut dst, &value).unwrap();
16795            dst
16796        };
16797        let request_size = request_value_reader
16798            .seek(std::io::SeekFrom::End(0))
16799            .unwrap();
16800        request_value_reader
16801            .seek(std::io::SeekFrom::Start(0))
16802            .unwrap();
16803
16804        loop {
16805            let token = match self
16806                .hub
16807                .auth
16808                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16809                .await
16810            {
16811                Ok(token) => token,
16812                Err(e) => match dlg.token(e) {
16813                    Ok(token) => token,
16814                    Err(e) => {
16815                        dlg.finished(false);
16816                        return Err(common::Error::MissingToken(e));
16817                    }
16818                },
16819            };
16820            request_value_reader
16821                .seek(std::io::SeekFrom::Start(0))
16822                .unwrap();
16823            let mut req_result = {
16824                let client = &self.hub.client;
16825                dlg.pre_request();
16826                let mut req_builder = hyper::Request::builder()
16827                    .method(hyper::Method::POST)
16828                    .uri(url.as_str())
16829                    .header(USER_AGENT, self.hub._user_agent.clone());
16830
16831                if let Some(token) = token.as_ref() {
16832                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16833                }
16834
16835                let request = req_builder
16836                    .header(CONTENT_TYPE, json_mime_type.to_string())
16837                    .header(CONTENT_LENGTH, request_size as u64)
16838                    .body(common::to_body(
16839                        request_value_reader.get_ref().clone().into(),
16840                    ));
16841
16842                client.request(request.unwrap()).await
16843            };
16844
16845            match req_result {
16846                Err(err) => {
16847                    if let common::Retry::After(d) = dlg.http_error(&err) {
16848                        sleep(d).await;
16849                        continue;
16850                    }
16851                    dlg.finished(false);
16852                    return Err(common::Error::HttpError(err));
16853                }
16854                Ok(res) => {
16855                    let (mut parts, body) = res.into_parts();
16856                    let mut body = common::Body::new(body);
16857                    if !parts.status.is_success() {
16858                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16859                        let error = serde_json::from_str(&common::to_string(&bytes));
16860                        let response = common::to_response(parts, bytes.into());
16861
16862                        if let common::Retry::After(d) =
16863                            dlg.http_failure(&response, error.as_ref().ok())
16864                        {
16865                            sleep(d).await;
16866                            continue;
16867                        }
16868
16869                        dlg.finished(false);
16870
16871                        return Err(match error {
16872                            Ok(value) => common::Error::BadRequest(value),
16873                            _ => common::Error::Failure(response),
16874                        });
16875                    }
16876                    let response = {
16877                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16878                        let encoded = common::to_string(&bytes);
16879                        match serde_json::from_str(&encoded) {
16880                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16881                            Err(error) => {
16882                                dlg.response_json_decode_error(&encoded, &error);
16883                                return Err(common::Error::JsonDecodeError(
16884                                    encoded.to_string(),
16885                                    error,
16886                                ));
16887                            }
16888                        }
16889                    };
16890
16891                    dlg.finished(true);
16892                    return Ok(response);
16893                }
16894            }
16895        }
16896    }
16897
16898    ///
16899    /// Sets the *request* property to the given value.
16900    ///
16901    /// Even though the property as already been set when instantiating this call,
16902    /// we provide this method for API completeness.
16903    pub fn request(
16904        mut self,
16905        new_value: GoogleFirestoreAdminV1EnableUserCredsRequest,
16906    ) -> ProjectDatabaseUserCredEnableCall<'a, C> {
16907        self._request = new_value;
16908        self
16909    }
16910    /// Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
16911    ///
16912    /// Sets the *name* path property to the given value.
16913    ///
16914    /// Even though the property as already been set when instantiating this call,
16915    /// we provide this method for API completeness.
16916    pub fn name(mut self, new_value: &str) -> ProjectDatabaseUserCredEnableCall<'a, C> {
16917        self._name = new_value.to_string();
16918        self
16919    }
16920    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16921    /// while executing the actual API request.
16922    ///
16923    /// ````text
16924    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16925    /// ````
16926    ///
16927    /// Sets the *delegate* property to the given value.
16928    pub fn delegate(
16929        mut self,
16930        new_value: &'a mut dyn common::Delegate,
16931    ) -> ProjectDatabaseUserCredEnableCall<'a, C> {
16932        self._delegate = Some(new_value);
16933        self
16934    }
16935
16936    /// Set any additional parameter of the query string used in the request.
16937    /// It should be used to set parameters which are not yet available through their own
16938    /// setters.
16939    ///
16940    /// Please note that this method must not be used to set any of the known parameters
16941    /// which have their own setter method. If done anyway, the request will fail.
16942    ///
16943    /// # Additional Parameters
16944    ///
16945    /// * *$.xgafv* (query-string) - V1 error format.
16946    /// * *access_token* (query-string) - OAuth access token.
16947    /// * *alt* (query-string) - Data format for response.
16948    /// * *callback* (query-string) - JSONP
16949    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16950    /// * *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.
16951    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16952    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16953    /// * *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.
16954    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16955    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16956    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseUserCredEnableCall<'a, C>
16957    where
16958        T: AsRef<str>,
16959    {
16960        self._additional_params
16961            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16962        self
16963    }
16964
16965    /// Identifies the authorization scope for the method you are building.
16966    ///
16967    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16968    /// [`Scope::CloudPlatform`].
16969    ///
16970    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16971    /// tokens for more than one scope.
16972    ///
16973    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16974    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16975    /// sufficient, a read-write scope will do as well.
16976    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseUserCredEnableCall<'a, C>
16977    where
16978        St: AsRef<str>,
16979    {
16980        self._scopes.insert(String::from(scope.as_ref()));
16981        self
16982    }
16983    /// Identifies the authorization scope(s) for the method you are building.
16984    ///
16985    /// See [`Self::add_scope()`] for details.
16986    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseUserCredEnableCall<'a, C>
16987    where
16988        I: IntoIterator<Item = St>,
16989        St: AsRef<str>,
16990    {
16991        self._scopes
16992            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16993        self
16994    }
16995
16996    /// Removes all scopes, and no default scope will be used either.
16997    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16998    /// for details).
16999    pub fn clear_scopes(mut self) -> ProjectDatabaseUserCredEnableCall<'a, C> {
17000        self._scopes.clear();
17001        self
17002    }
17003}
17004
17005/// Gets a user creds resource. Note that the returned resource does not contain the secret value itself.
17006///
17007/// A builder for the *databases.userCreds.get* method supported by a *project* resource.
17008/// It is not used directly, but through a [`ProjectMethods`] instance.
17009///
17010/// # Example
17011///
17012/// Instantiate a resource method builder
17013///
17014/// ```test_harness,no_run
17015/// # extern crate hyper;
17016/// # extern crate hyper_rustls;
17017/// # extern crate google_firestore1 as firestore1;
17018/// # async fn dox() {
17019/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17020///
17021/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17022/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17023/// #     .with_native_roots()
17024/// #     .unwrap()
17025/// #     .https_only()
17026/// #     .enable_http2()
17027/// #     .build();
17028///
17029/// # let executor = hyper_util::rt::TokioExecutor::new();
17030/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17031/// #     secret,
17032/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17033/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17034/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17035/// #     ),
17036/// # ).build().await.unwrap();
17037///
17038/// # let client = hyper_util::client::legacy::Client::builder(
17039/// #     hyper_util::rt::TokioExecutor::new()
17040/// # )
17041/// # .build(
17042/// #     hyper_rustls::HttpsConnectorBuilder::new()
17043/// #         .with_native_roots()
17044/// #         .unwrap()
17045/// #         .https_or_http()
17046/// #         .enable_http2()
17047/// #         .build()
17048/// # );
17049/// # let mut hub = Firestore::new(client, auth);
17050/// // You can configure optional parameters by calling the respective setters at will, and
17051/// // execute the final call using `doit()`.
17052/// // Values shown here are possibly random and not representative !
17053/// let result = hub.projects().databases_user_creds_get("name")
17054///              .doit().await;
17055/// # }
17056/// ```
17057pub struct ProjectDatabaseUserCredGetCall<'a, C>
17058where
17059    C: 'a,
17060{
17061    hub: &'a Firestore<C>,
17062    _name: String,
17063    _delegate: Option<&'a mut dyn common::Delegate>,
17064    _additional_params: HashMap<String, String>,
17065    _scopes: BTreeSet<String>,
17066}
17067
17068impl<'a, C> common::CallBuilder for ProjectDatabaseUserCredGetCall<'a, C> {}
17069
17070impl<'a, C> ProjectDatabaseUserCredGetCall<'a, C>
17071where
17072    C: common::Connector,
17073{
17074    /// Perform the operation you have build so far.
17075    pub async fn doit(
17076        mut self,
17077    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1UserCreds)> {
17078        use std::borrow::Cow;
17079        use std::io::{Read, Seek};
17080
17081        use common::{url::Params, ToParts};
17082        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17083
17084        let mut dd = common::DefaultDelegate;
17085        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17086        dlg.begin(common::MethodInfo {
17087            id: "firestore.projects.databases.userCreds.get",
17088            http_method: hyper::Method::GET,
17089        });
17090
17091        for &field in ["alt", "name"].iter() {
17092            if self._additional_params.contains_key(field) {
17093                dlg.finished(false);
17094                return Err(common::Error::FieldClash(field));
17095            }
17096        }
17097
17098        let mut params = Params::with_capacity(3 + self._additional_params.len());
17099        params.push("name", self._name);
17100
17101        params.extend(self._additional_params.iter());
17102
17103        params.push("alt", "json");
17104        let mut url = self.hub._base_url.clone() + "v1/{+name}";
17105        if self._scopes.is_empty() {
17106            self._scopes
17107                .insert(Scope::CloudPlatform.as_ref().to_string());
17108        }
17109
17110        #[allow(clippy::single_element_loop)]
17111        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17112            url = params.uri_replacement(url, param_name, find_this, true);
17113        }
17114        {
17115            let to_remove = ["name"];
17116            params.remove_params(&to_remove);
17117        }
17118
17119        let url = params.parse_with_url(&url);
17120
17121        loop {
17122            let token = match self
17123                .hub
17124                .auth
17125                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17126                .await
17127            {
17128                Ok(token) => token,
17129                Err(e) => match dlg.token(e) {
17130                    Ok(token) => token,
17131                    Err(e) => {
17132                        dlg.finished(false);
17133                        return Err(common::Error::MissingToken(e));
17134                    }
17135                },
17136            };
17137            let mut req_result = {
17138                let client = &self.hub.client;
17139                dlg.pre_request();
17140                let mut req_builder = hyper::Request::builder()
17141                    .method(hyper::Method::GET)
17142                    .uri(url.as_str())
17143                    .header(USER_AGENT, self.hub._user_agent.clone());
17144
17145                if let Some(token) = token.as_ref() {
17146                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17147                }
17148
17149                let request = req_builder
17150                    .header(CONTENT_LENGTH, 0_u64)
17151                    .body(common::to_body::<String>(None));
17152
17153                client.request(request.unwrap()).await
17154            };
17155
17156            match req_result {
17157                Err(err) => {
17158                    if let common::Retry::After(d) = dlg.http_error(&err) {
17159                        sleep(d).await;
17160                        continue;
17161                    }
17162                    dlg.finished(false);
17163                    return Err(common::Error::HttpError(err));
17164                }
17165                Ok(res) => {
17166                    let (mut parts, body) = res.into_parts();
17167                    let mut body = common::Body::new(body);
17168                    if !parts.status.is_success() {
17169                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17170                        let error = serde_json::from_str(&common::to_string(&bytes));
17171                        let response = common::to_response(parts, bytes.into());
17172
17173                        if let common::Retry::After(d) =
17174                            dlg.http_failure(&response, error.as_ref().ok())
17175                        {
17176                            sleep(d).await;
17177                            continue;
17178                        }
17179
17180                        dlg.finished(false);
17181
17182                        return Err(match error {
17183                            Ok(value) => common::Error::BadRequest(value),
17184                            _ => common::Error::Failure(response),
17185                        });
17186                    }
17187                    let response = {
17188                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17189                        let encoded = common::to_string(&bytes);
17190                        match serde_json::from_str(&encoded) {
17191                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17192                            Err(error) => {
17193                                dlg.response_json_decode_error(&encoded, &error);
17194                                return Err(common::Error::JsonDecodeError(
17195                                    encoded.to_string(),
17196                                    error,
17197                                ));
17198                            }
17199                        }
17200                    };
17201
17202                    dlg.finished(true);
17203                    return Ok(response);
17204                }
17205            }
17206        }
17207    }
17208
17209    /// Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
17210    ///
17211    /// Sets the *name* path property to the given value.
17212    ///
17213    /// Even though the property as already been set when instantiating this call,
17214    /// we provide this method for API completeness.
17215    pub fn name(mut self, new_value: &str) -> ProjectDatabaseUserCredGetCall<'a, C> {
17216        self._name = new_value.to_string();
17217        self
17218    }
17219    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17220    /// while executing the actual API request.
17221    ///
17222    /// ````text
17223    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17224    /// ````
17225    ///
17226    /// Sets the *delegate* property to the given value.
17227    pub fn delegate(
17228        mut self,
17229        new_value: &'a mut dyn common::Delegate,
17230    ) -> ProjectDatabaseUserCredGetCall<'a, C> {
17231        self._delegate = Some(new_value);
17232        self
17233    }
17234
17235    /// Set any additional parameter of the query string used in the request.
17236    /// It should be used to set parameters which are not yet available through their own
17237    /// setters.
17238    ///
17239    /// Please note that this method must not be used to set any of the known parameters
17240    /// which have their own setter method. If done anyway, the request will fail.
17241    ///
17242    /// # Additional Parameters
17243    ///
17244    /// * *$.xgafv* (query-string) - V1 error format.
17245    /// * *access_token* (query-string) - OAuth access token.
17246    /// * *alt* (query-string) - Data format for response.
17247    /// * *callback* (query-string) - JSONP
17248    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17249    /// * *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.
17250    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17251    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17252    /// * *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.
17253    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17254    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17255    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseUserCredGetCall<'a, C>
17256    where
17257        T: AsRef<str>,
17258    {
17259        self._additional_params
17260            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17261        self
17262    }
17263
17264    /// Identifies the authorization scope for the method you are building.
17265    ///
17266    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17267    /// [`Scope::CloudPlatform`].
17268    ///
17269    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17270    /// tokens for more than one scope.
17271    ///
17272    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17273    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17274    /// sufficient, a read-write scope will do as well.
17275    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseUserCredGetCall<'a, C>
17276    where
17277        St: AsRef<str>,
17278    {
17279        self._scopes.insert(String::from(scope.as_ref()));
17280        self
17281    }
17282    /// Identifies the authorization scope(s) for the method you are building.
17283    ///
17284    /// See [`Self::add_scope()`] for details.
17285    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseUserCredGetCall<'a, C>
17286    where
17287        I: IntoIterator<Item = St>,
17288        St: AsRef<str>,
17289    {
17290        self._scopes
17291            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17292        self
17293    }
17294
17295    /// Removes all scopes, and no default scope will be used either.
17296    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17297    /// for details).
17298    pub fn clear_scopes(mut self) -> ProjectDatabaseUserCredGetCall<'a, C> {
17299        self._scopes.clear();
17300        self
17301    }
17302}
17303
17304/// List all user creds in the database. Note that the returned resource does not contain the secret value itself.
17305///
17306/// A builder for the *databases.userCreds.list* method supported by a *project* resource.
17307/// It is not used directly, but through a [`ProjectMethods`] instance.
17308///
17309/// # Example
17310///
17311/// Instantiate a resource method builder
17312///
17313/// ```test_harness,no_run
17314/// # extern crate hyper;
17315/// # extern crate hyper_rustls;
17316/// # extern crate google_firestore1 as firestore1;
17317/// # async fn dox() {
17318/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17319///
17320/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17321/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17322/// #     .with_native_roots()
17323/// #     .unwrap()
17324/// #     .https_only()
17325/// #     .enable_http2()
17326/// #     .build();
17327///
17328/// # let executor = hyper_util::rt::TokioExecutor::new();
17329/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17330/// #     secret,
17331/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17332/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17333/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17334/// #     ),
17335/// # ).build().await.unwrap();
17336///
17337/// # let client = hyper_util::client::legacy::Client::builder(
17338/// #     hyper_util::rt::TokioExecutor::new()
17339/// # )
17340/// # .build(
17341/// #     hyper_rustls::HttpsConnectorBuilder::new()
17342/// #         .with_native_roots()
17343/// #         .unwrap()
17344/// #         .https_or_http()
17345/// #         .enable_http2()
17346/// #         .build()
17347/// # );
17348/// # let mut hub = Firestore::new(client, auth);
17349/// // You can configure optional parameters by calling the respective setters at will, and
17350/// // execute the final call using `doit()`.
17351/// // Values shown here are possibly random and not representative !
17352/// let result = hub.projects().databases_user_creds_list("parent")
17353///              .doit().await;
17354/// # }
17355/// ```
17356pub struct ProjectDatabaseUserCredListCall<'a, C>
17357where
17358    C: 'a,
17359{
17360    hub: &'a Firestore<C>,
17361    _parent: String,
17362    _delegate: Option<&'a mut dyn common::Delegate>,
17363    _additional_params: HashMap<String, String>,
17364    _scopes: BTreeSet<String>,
17365}
17366
17367impl<'a, C> common::CallBuilder for ProjectDatabaseUserCredListCall<'a, C> {}
17368
17369impl<'a, C> ProjectDatabaseUserCredListCall<'a, C>
17370where
17371    C: common::Connector,
17372{
17373    /// Perform the operation you have build so far.
17374    pub async fn doit(
17375        mut self,
17376    ) -> common::Result<(
17377        common::Response,
17378        GoogleFirestoreAdminV1ListUserCredsResponse,
17379    )> {
17380        use std::borrow::Cow;
17381        use std::io::{Read, Seek};
17382
17383        use common::{url::Params, ToParts};
17384        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17385
17386        let mut dd = common::DefaultDelegate;
17387        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17388        dlg.begin(common::MethodInfo {
17389            id: "firestore.projects.databases.userCreds.list",
17390            http_method: hyper::Method::GET,
17391        });
17392
17393        for &field in ["alt", "parent"].iter() {
17394            if self._additional_params.contains_key(field) {
17395                dlg.finished(false);
17396                return Err(common::Error::FieldClash(field));
17397            }
17398        }
17399
17400        let mut params = Params::with_capacity(3 + self._additional_params.len());
17401        params.push("parent", self._parent);
17402
17403        params.extend(self._additional_params.iter());
17404
17405        params.push("alt", "json");
17406        let mut url = self.hub._base_url.clone() + "v1/{+parent}/userCreds";
17407        if self._scopes.is_empty() {
17408            self._scopes
17409                .insert(Scope::CloudPlatform.as_ref().to_string());
17410        }
17411
17412        #[allow(clippy::single_element_loop)]
17413        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17414            url = params.uri_replacement(url, param_name, find_this, true);
17415        }
17416        {
17417            let to_remove = ["parent"];
17418            params.remove_params(&to_remove);
17419        }
17420
17421        let url = params.parse_with_url(&url);
17422
17423        loop {
17424            let token = match self
17425                .hub
17426                .auth
17427                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17428                .await
17429            {
17430                Ok(token) => token,
17431                Err(e) => match dlg.token(e) {
17432                    Ok(token) => token,
17433                    Err(e) => {
17434                        dlg.finished(false);
17435                        return Err(common::Error::MissingToken(e));
17436                    }
17437                },
17438            };
17439            let mut req_result = {
17440                let client = &self.hub.client;
17441                dlg.pre_request();
17442                let mut req_builder = hyper::Request::builder()
17443                    .method(hyper::Method::GET)
17444                    .uri(url.as_str())
17445                    .header(USER_AGENT, self.hub._user_agent.clone());
17446
17447                if let Some(token) = token.as_ref() {
17448                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17449                }
17450
17451                let request = req_builder
17452                    .header(CONTENT_LENGTH, 0_u64)
17453                    .body(common::to_body::<String>(None));
17454
17455                client.request(request.unwrap()).await
17456            };
17457
17458            match req_result {
17459                Err(err) => {
17460                    if let common::Retry::After(d) = dlg.http_error(&err) {
17461                        sleep(d).await;
17462                        continue;
17463                    }
17464                    dlg.finished(false);
17465                    return Err(common::Error::HttpError(err));
17466                }
17467                Ok(res) => {
17468                    let (mut parts, body) = res.into_parts();
17469                    let mut body = common::Body::new(body);
17470                    if !parts.status.is_success() {
17471                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17472                        let error = serde_json::from_str(&common::to_string(&bytes));
17473                        let response = common::to_response(parts, bytes.into());
17474
17475                        if let common::Retry::After(d) =
17476                            dlg.http_failure(&response, error.as_ref().ok())
17477                        {
17478                            sleep(d).await;
17479                            continue;
17480                        }
17481
17482                        dlg.finished(false);
17483
17484                        return Err(match error {
17485                            Ok(value) => common::Error::BadRequest(value),
17486                            _ => common::Error::Failure(response),
17487                        });
17488                    }
17489                    let response = {
17490                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17491                        let encoded = common::to_string(&bytes);
17492                        match serde_json::from_str(&encoded) {
17493                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17494                            Err(error) => {
17495                                dlg.response_json_decode_error(&encoded, &error);
17496                                return Err(common::Error::JsonDecodeError(
17497                                    encoded.to_string(),
17498                                    error,
17499                                ));
17500                            }
17501                        }
17502                    };
17503
17504                    dlg.finished(true);
17505                    return Ok(response);
17506                }
17507            }
17508        }
17509    }
17510
17511    /// Required. A parent database name of the form `projects/{project_id}/databases/{database_id}`
17512    ///
17513    /// Sets the *parent* path property to the given value.
17514    ///
17515    /// Even though the property as already been set when instantiating this call,
17516    /// we provide this method for API completeness.
17517    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseUserCredListCall<'a, C> {
17518        self._parent = new_value.to_string();
17519        self
17520    }
17521    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17522    /// while executing the actual API request.
17523    ///
17524    /// ````text
17525    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17526    /// ````
17527    ///
17528    /// Sets the *delegate* property to the given value.
17529    pub fn delegate(
17530        mut self,
17531        new_value: &'a mut dyn common::Delegate,
17532    ) -> ProjectDatabaseUserCredListCall<'a, C> {
17533        self._delegate = Some(new_value);
17534        self
17535    }
17536
17537    /// Set any additional parameter of the query string used in the request.
17538    /// It should be used to set parameters which are not yet available through their own
17539    /// setters.
17540    ///
17541    /// Please note that this method must not be used to set any of the known parameters
17542    /// which have their own setter method. If done anyway, the request will fail.
17543    ///
17544    /// # Additional Parameters
17545    ///
17546    /// * *$.xgafv* (query-string) - V1 error format.
17547    /// * *access_token* (query-string) - OAuth access token.
17548    /// * *alt* (query-string) - Data format for response.
17549    /// * *callback* (query-string) - JSONP
17550    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17551    /// * *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.
17552    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17553    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17554    /// * *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.
17555    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17556    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17557    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseUserCredListCall<'a, C>
17558    where
17559        T: AsRef<str>,
17560    {
17561        self._additional_params
17562            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17563        self
17564    }
17565
17566    /// Identifies the authorization scope for the method you are building.
17567    ///
17568    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17569    /// [`Scope::CloudPlatform`].
17570    ///
17571    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17572    /// tokens for more than one scope.
17573    ///
17574    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17575    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17576    /// sufficient, a read-write scope will do as well.
17577    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseUserCredListCall<'a, C>
17578    where
17579        St: AsRef<str>,
17580    {
17581        self._scopes.insert(String::from(scope.as_ref()));
17582        self
17583    }
17584    /// Identifies the authorization scope(s) for the method you are building.
17585    ///
17586    /// See [`Self::add_scope()`] for details.
17587    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseUserCredListCall<'a, C>
17588    where
17589        I: IntoIterator<Item = St>,
17590        St: AsRef<str>,
17591    {
17592        self._scopes
17593            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17594        self
17595    }
17596
17597    /// Removes all scopes, and no default scope will be used either.
17598    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17599    /// for details).
17600    pub fn clear_scopes(mut self) -> ProjectDatabaseUserCredListCall<'a, C> {
17601        self._scopes.clear();
17602        self
17603    }
17604}
17605
17606/// Resets the password of a user creds.
17607///
17608/// A builder for the *databases.userCreds.resetPassword* method supported by a *project* resource.
17609/// It is not used directly, but through a [`ProjectMethods`] instance.
17610///
17611/// # Example
17612///
17613/// Instantiate a resource method builder
17614///
17615/// ```test_harness,no_run
17616/// # extern crate hyper;
17617/// # extern crate hyper_rustls;
17618/// # extern crate google_firestore1 as firestore1;
17619/// use firestore1::api::GoogleFirestoreAdminV1ResetUserPasswordRequest;
17620/// # async fn dox() {
17621/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17622///
17623/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17624/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17625/// #     .with_native_roots()
17626/// #     .unwrap()
17627/// #     .https_only()
17628/// #     .enable_http2()
17629/// #     .build();
17630///
17631/// # let executor = hyper_util::rt::TokioExecutor::new();
17632/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17633/// #     secret,
17634/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17635/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17636/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17637/// #     ),
17638/// # ).build().await.unwrap();
17639///
17640/// # let client = hyper_util::client::legacy::Client::builder(
17641/// #     hyper_util::rt::TokioExecutor::new()
17642/// # )
17643/// # .build(
17644/// #     hyper_rustls::HttpsConnectorBuilder::new()
17645/// #         .with_native_roots()
17646/// #         .unwrap()
17647/// #         .https_or_http()
17648/// #         .enable_http2()
17649/// #         .build()
17650/// # );
17651/// # let mut hub = Firestore::new(client, auth);
17652/// // As the method needs a request, you would usually fill it with the desired information
17653/// // into the respective structure. Some of the parts shown here might not be applicable !
17654/// // Values shown here are possibly random and not representative !
17655/// let mut req = GoogleFirestoreAdminV1ResetUserPasswordRequest::default();
17656///
17657/// // You can configure optional parameters by calling the respective setters at will, and
17658/// // execute the final call using `doit()`.
17659/// // Values shown here are possibly random and not representative !
17660/// let result = hub.projects().databases_user_creds_reset_password(req, "name")
17661///              .doit().await;
17662/// # }
17663/// ```
17664pub struct ProjectDatabaseUserCredResetPasswordCall<'a, C>
17665where
17666    C: 'a,
17667{
17668    hub: &'a Firestore<C>,
17669    _request: GoogleFirestoreAdminV1ResetUserPasswordRequest,
17670    _name: String,
17671    _delegate: Option<&'a mut dyn common::Delegate>,
17672    _additional_params: HashMap<String, String>,
17673    _scopes: BTreeSet<String>,
17674}
17675
17676impl<'a, C> common::CallBuilder for ProjectDatabaseUserCredResetPasswordCall<'a, C> {}
17677
17678impl<'a, C> ProjectDatabaseUserCredResetPasswordCall<'a, C>
17679where
17680    C: common::Connector,
17681{
17682    /// Perform the operation you have build so far.
17683    pub async fn doit(
17684        mut self,
17685    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1UserCreds)> {
17686        use std::borrow::Cow;
17687        use std::io::{Read, Seek};
17688
17689        use common::{url::Params, ToParts};
17690        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17691
17692        let mut dd = common::DefaultDelegate;
17693        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17694        dlg.begin(common::MethodInfo {
17695            id: "firestore.projects.databases.userCreds.resetPassword",
17696            http_method: hyper::Method::POST,
17697        });
17698
17699        for &field in ["alt", "name"].iter() {
17700            if self._additional_params.contains_key(field) {
17701                dlg.finished(false);
17702                return Err(common::Error::FieldClash(field));
17703            }
17704        }
17705
17706        let mut params = Params::with_capacity(4 + self._additional_params.len());
17707        params.push("name", self._name);
17708
17709        params.extend(self._additional_params.iter());
17710
17711        params.push("alt", "json");
17712        let mut url = self.hub._base_url.clone() + "v1/{+name}:resetPassword";
17713        if self._scopes.is_empty() {
17714            self._scopes
17715                .insert(Scope::CloudPlatform.as_ref().to_string());
17716        }
17717
17718        #[allow(clippy::single_element_loop)]
17719        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17720            url = params.uri_replacement(url, param_name, find_this, true);
17721        }
17722        {
17723            let to_remove = ["name"];
17724            params.remove_params(&to_remove);
17725        }
17726
17727        let url = params.parse_with_url(&url);
17728
17729        let mut json_mime_type = mime::APPLICATION_JSON;
17730        let mut request_value_reader = {
17731            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17732            common::remove_json_null_values(&mut value);
17733            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17734            serde_json::to_writer(&mut dst, &value).unwrap();
17735            dst
17736        };
17737        let request_size = request_value_reader
17738            .seek(std::io::SeekFrom::End(0))
17739            .unwrap();
17740        request_value_reader
17741            .seek(std::io::SeekFrom::Start(0))
17742            .unwrap();
17743
17744        loop {
17745            let token = match self
17746                .hub
17747                .auth
17748                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17749                .await
17750            {
17751                Ok(token) => token,
17752                Err(e) => match dlg.token(e) {
17753                    Ok(token) => token,
17754                    Err(e) => {
17755                        dlg.finished(false);
17756                        return Err(common::Error::MissingToken(e));
17757                    }
17758                },
17759            };
17760            request_value_reader
17761                .seek(std::io::SeekFrom::Start(0))
17762                .unwrap();
17763            let mut req_result = {
17764                let client = &self.hub.client;
17765                dlg.pre_request();
17766                let mut req_builder = hyper::Request::builder()
17767                    .method(hyper::Method::POST)
17768                    .uri(url.as_str())
17769                    .header(USER_AGENT, self.hub._user_agent.clone());
17770
17771                if let Some(token) = token.as_ref() {
17772                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17773                }
17774
17775                let request = req_builder
17776                    .header(CONTENT_TYPE, json_mime_type.to_string())
17777                    .header(CONTENT_LENGTH, request_size as u64)
17778                    .body(common::to_body(
17779                        request_value_reader.get_ref().clone().into(),
17780                    ));
17781
17782                client.request(request.unwrap()).await
17783            };
17784
17785            match req_result {
17786                Err(err) => {
17787                    if let common::Retry::After(d) = dlg.http_error(&err) {
17788                        sleep(d).await;
17789                        continue;
17790                    }
17791                    dlg.finished(false);
17792                    return Err(common::Error::HttpError(err));
17793                }
17794                Ok(res) => {
17795                    let (mut parts, body) = res.into_parts();
17796                    let mut body = common::Body::new(body);
17797                    if !parts.status.is_success() {
17798                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17799                        let error = serde_json::from_str(&common::to_string(&bytes));
17800                        let response = common::to_response(parts, bytes.into());
17801
17802                        if let common::Retry::After(d) =
17803                            dlg.http_failure(&response, error.as_ref().ok())
17804                        {
17805                            sleep(d).await;
17806                            continue;
17807                        }
17808
17809                        dlg.finished(false);
17810
17811                        return Err(match error {
17812                            Ok(value) => common::Error::BadRequest(value),
17813                            _ => common::Error::Failure(response),
17814                        });
17815                    }
17816                    let response = {
17817                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17818                        let encoded = common::to_string(&bytes);
17819                        match serde_json::from_str(&encoded) {
17820                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17821                            Err(error) => {
17822                                dlg.response_json_decode_error(&encoded, &error);
17823                                return Err(common::Error::JsonDecodeError(
17824                                    encoded.to_string(),
17825                                    error,
17826                                ));
17827                            }
17828                        }
17829                    };
17830
17831                    dlg.finished(true);
17832                    return Ok(response);
17833                }
17834            }
17835        }
17836    }
17837
17838    ///
17839    /// Sets the *request* property to the given value.
17840    ///
17841    /// Even though the property as already been set when instantiating this call,
17842    /// we provide this method for API completeness.
17843    pub fn request(
17844        mut self,
17845        new_value: GoogleFirestoreAdminV1ResetUserPasswordRequest,
17846    ) -> ProjectDatabaseUserCredResetPasswordCall<'a, C> {
17847        self._request = new_value;
17848        self
17849    }
17850    /// Required. A name of the form `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
17851    ///
17852    /// Sets the *name* path property to the given value.
17853    ///
17854    /// Even though the property as already been set when instantiating this call,
17855    /// we provide this method for API completeness.
17856    pub fn name(mut self, new_value: &str) -> ProjectDatabaseUserCredResetPasswordCall<'a, C> {
17857        self._name = new_value.to_string();
17858        self
17859    }
17860    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17861    /// while executing the actual API request.
17862    ///
17863    /// ````text
17864    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17865    /// ````
17866    ///
17867    /// Sets the *delegate* property to the given value.
17868    pub fn delegate(
17869        mut self,
17870        new_value: &'a mut dyn common::Delegate,
17871    ) -> ProjectDatabaseUserCredResetPasswordCall<'a, C> {
17872        self._delegate = Some(new_value);
17873        self
17874    }
17875
17876    /// Set any additional parameter of the query string used in the request.
17877    /// It should be used to set parameters which are not yet available through their own
17878    /// setters.
17879    ///
17880    /// Please note that this method must not be used to set any of the known parameters
17881    /// which have their own setter method. If done anyway, the request will fail.
17882    ///
17883    /// # Additional Parameters
17884    ///
17885    /// * *$.xgafv* (query-string) - V1 error format.
17886    /// * *access_token* (query-string) - OAuth access token.
17887    /// * *alt* (query-string) - Data format for response.
17888    /// * *callback* (query-string) - JSONP
17889    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17890    /// * *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.
17891    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17892    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17893    /// * *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.
17894    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17895    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17896    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseUserCredResetPasswordCall<'a, C>
17897    where
17898        T: AsRef<str>,
17899    {
17900        self._additional_params
17901            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17902        self
17903    }
17904
17905    /// Identifies the authorization scope for the method you are building.
17906    ///
17907    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17908    /// [`Scope::CloudPlatform`].
17909    ///
17910    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17911    /// tokens for more than one scope.
17912    ///
17913    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17914    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17915    /// sufficient, a read-write scope will do as well.
17916    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseUserCredResetPasswordCall<'a, C>
17917    where
17918        St: AsRef<str>,
17919    {
17920        self._scopes.insert(String::from(scope.as_ref()));
17921        self
17922    }
17923    /// Identifies the authorization scope(s) for the method you are building.
17924    ///
17925    /// See [`Self::add_scope()`] for details.
17926    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseUserCredResetPasswordCall<'a, C>
17927    where
17928        I: IntoIterator<Item = St>,
17929        St: AsRef<str>,
17930    {
17931        self._scopes
17932            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17933        self
17934    }
17935
17936    /// Removes all scopes, and no default scope will be used either.
17937    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17938    /// for details).
17939    pub fn clear_scopes(mut self) -> ProjectDatabaseUserCredResetPasswordCall<'a, C> {
17940        self._scopes.clear();
17941        self
17942    }
17943}
17944
17945/// Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated after the underlying system starts to process the request will not be deleted. The bulk delete occurs in the background and its progress can be monitored and managed via the Operation resource that is created. For more details on bulk delete behavior, refer to: https://cloud.google.com/firestore/docs/manage-data/bulk-delete
17946///
17947/// A builder for the *databases.bulkDeleteDocuments* method supported by a *project* resource.
17948/// It is not used directly, but through a [`ProjectMethods`] instance.
17949///
17950/// # Example
17951///
17952/// Instantiate a resource method builder
17953///
17954/// ```test_harness,no_run
17955/// # extern crate hyper;
17956/// # extern crate hyper_rustls;
17957/// # extern crate google_firestore1 as firestore1;
17958/// use firestore1::api::GoogleFirestoreAdminV1BulkDeleteDocumentsRequest;
17959/// # async fn dox() {
17960/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17961///
17962/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17963/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17964/// #     .with_native_roots()
17965/// #     .unwrap()
17966/// #     .https_only()
17967/// #     .enable_http2()
17968/// #     .build();
17969///
17970/// # let executor = hyper_util::rt::TokioExecutor::new();
17971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17972/// #     secret,
17973/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17974/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17975/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17976/// #     ),
17977/// # ).build().await.unwrap();
17978///
17979/// # let client = hyper_util::client::legacy::Client::builder(
17980/// #     hyper_util::rt::TokioExecutor::new()
17981/// # )
17982/// # .build(
17983/// #     hyper_rustls::HttpsConnectorBuilder::new()
17984/// #         .with_native_roots()
17985/// #         .unwrap()
17986/// #         .https_or_http()
17987/// #         .enable_http2()
17988/// #         .build()
17989/// # );
17990/// # let mut hub = Firestore::new(client, auth);
17991/// // As the method needs a request, you would usually fill it with the desired information
17992/// // into the respective structure. Some of the parts shown here might not be applicable !
17993/// // Values shown here are possibly random and not representative !
17994/// let mut req = GoogleFirestoreAdminV1BulkDeleteDocumentsRequest::default();
17995///
17996/// // You can configure optional parameters by calling the respective setters at will, and
17997/// // execute the final call using `doit()`.
17998/// // Values shown here are possibly random and not representative !
17999/// let result = hub.projects().databases_bulk_delete_documents(req, "name")
18000///              .doit().await;
18001/// # }
18002/// ```
18003pub struct ProjectDatabaseBulkDeleteDocumentCall<'a, C>
18004where
18005    C: 'a,
18006{
18007    hub: &'a Firestore<C>,
18008    _request: GoogleFirestoreAdminV1BulkDeleteDocumentsRequest,
18009    _name: String,
18010    _delegate: Option<&'a mut dyn common::Delegate>,
18011    _additional_params: HashMap<String, String>,
18012    _scopes: BTreeSet<String>,
18013}
18014
18015impl<'a, C> common::CallBuilder for ProjectDatabaseBulkDeleteDocumentCall<'a, C> {}
18016
18017impl<'a, C> ProjectDatabaseBulkDeleteDocumentCall<'a, C>
18018where
18019    C: common::Connector,
18020{
18021    /// Perform the operation you have build so far.
18022    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
18023        use std::borrow::Cow;
18024        use std::io::{Read, Seek};
18025
18026        use common::{url::Params, ToParts};
18027        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18028
18029        let mut dd = common::DefaultDelegate;
18030        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18031        dlg.begin(common::MethodInfo {
18032            id: "firestore.projects.databases.bulkDeleteDocuments",
18033            http_method: hyper::Method::POST,
18034        });
18035
18036        for &field in ["alt", "name"].iter() {
18037            if self._additional_params.contains_key(field) {
18038                dlg.finished(false);
18039                return Err(common::Error::FieldClash(field));
18040            }
18041        }
18042
18043        let mut params = Params::with_capacity(4 + self._additional_params.len());
18044        params.push("name", self._name);
18045
18046        params.extend(self._additional_params.iter());
18047
18048        params.push("alt", "json");
18049        let mut url = self.hub._base_url.clone() + "v1/{+name}:bulkDeleteDocuments";
18050        if self._scopes.is_empty() {
18051            self._scopes
18052                .insert(Scope::CloudPlatform.as_ref().to_string());
18053        }
18054
18055        #[allow(clippy::single_element_loop)]
18056        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18057            url = params.uri_replacement(url, param_name, find_this, true);
18058        }
18059        {
18060            let to_remove = ["name"];
18061            params.remove_params(&to_remove);
18062        }
18063
18064        let url = params.parse_with_url(&url);
18065
18066        let mut json_mime_type = mime::APPLICATION_JSON;
18067        let mut request_value_reader = {
18068            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18069            common::remove_json_null_values(&mut value);
18070            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18071            serde_json::to_writer(&mut dst, &value).unwrap();
18072            dst
18073        };
18074        let request_size = request_value_reader
18075            .seek(std::io::SeekFrom::End(0))
18076            .unwrap();
18077        request_value_reader
18078            .seek(std::io::SeekFrom::Start(0))
18079            .unwrap();
18080
18081        loop {
18082            let token = match self
18083                .hub
18084                .auth
18085                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18086                .await
18087            {
18088                Ok(token) => token,
18089                Err(e) => match dlg.token(e) {
18090                    Ok(token) => token,
18091                    Err(e) => {
18092                        dlg.finished(false);
18093                        return Err(common::Error::MissingToken(e));
18094                    }
18095                },
18096            };
18097            request_value_reader
18098                .seek(std::io::SeekFrom::Start(0))
18099                .unwrap();
18100            let mut req_result = {
18101                let client = &self.hub.client;
18102                dlg.pre_request();
18103                let mut req_builder = hyper::Request::builder()
18104                    .method(hyper::Method::POST)
18105                    .uri(url.as_str())
18106                    .header(USER_AGENT, self.hub._user_agent.clone());
18107
18108                if let Some(token) = token.as_ref() {
18109                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18110                }
18111
18112                let request = req_builder
18113                    .header(CONTENT_TYPE, json_mime_type.to_string())
18114                    .header(CONTENT_LENGTH, request_size as u64)
18115                    .body(common::to_body(
18116                        request_value_reader.get_ref().clone().into(),
18117                    ));
18118
18119                client.request(request.unwrap()).await
18120            };
18121
18122            match req_result {
18123                Err(err) => {
18124                    if let common::Retry::After(d) = dlg.http_error(&err) {
18125                        sleep(d).await;
18126                        continue;
18127                    }
18128                    dlg.finished(false);
18129                    return Err(common::Error::HttpError(err));
18130                }
18131                Ok(res) => {
18132                    let (mut parts, body) = res.into_parts();
18133                    let mut body = common::Body::new(body);
18134                    if !parts.status.is_success() {
18135                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18136                        let error = serde_json::from_str(&common::to_string(&bytes));
18137                        let response = common::to_response(parts, bytes.into());
18138
18139                        if let common::Retry::After(d) =
18140                            dlg.http_failure(&response, error.as_ref().ok())
18141                        {
18142                            sleep(d).await;
18143                            continue;
18144                        }
18145
18146                        dlg.finished(false);
18147
18148                        return Err(match error {
18149                            Ok(value) => common::Error::BadRequest(value),
18150                            _ => common::Error::Failure(response),
18151                        });
18152                    }
18153                    let response = {
18154                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18155                        let encoded = common::to_string(&bytes);
18156                        match serde_json::from_str(&encoded) {
18157                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18158                            Err(error) => {
18159                                dlg.response_json_decode_error(&encoded, &error);
18160                                return Err(common::Error::JsonDecodeError(
18161                                    encoded.to_string(),
18162                                    error,
18163                                ));
18164                            }
18165                        }
18166                    };
18167
18168                    dlg.finished(true);
18169                    return Ok(response);
18170                }
18171            }
18172        }
18173    }
18174
18175    ///
18176    /// Sets the *request* property to the given value.
18177    ///
18178    /// Even though the property as already been set when instantiating this call,
18179    /// we provide this method for API completeness.
18180    pub fn request(
18181        mut self,
18182        new_value: GoogleFirestoreAdminV1BulkDeleteDocumentsRequest,
18183    ) -> ProjectDatabaseBulkDeleteDocumentCall<'a, C> {
18184        self._request = new_value;
18185        self
18186    }
18187    /// Required. Database to operate. Should be of the form: `projects/{project_id}/databases/{database_id}`.
18188    ///
18189    /// Sets the *name* path property to the given value.
18190    ///
18191    /// Even though the property as already been set when instantiating this call,
18192    /// we provide this method for API completeness.
18193    pub fn name(mut self, new_value: &str) -> ProjectDatabaseBulkDeleteDocumentCall<'a, C> {
18194        self._name = new_value.to_string();
18195        self
18196    }
18197    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18198    /// while executing the actual API request.
18199    ///
18200    /// ````text
18201    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18202    /// ````
18203    ///
18204    /// Sets the *delegate* property to the given value.
18205    pub fn delegate(
18206        mut self,
18207        new_value: &'a mut dyn common::Delegate,
18208    ) -> ProjectDatabaseBulkDeleteDocumentCall<'a, C> {
18209        self._delegate = Some(new_value);
18210        self
18211    }
18212
18213    /// Set any additional parameter of the query string used in the request.
18214    /// It should be used to set parameters which are not yet available through their own
18215    /// setters.
18216    ///
18217    /// Please note that this method must not be used to set any of the known parameters
18218    /// which have their own setter method. If done anyway, the request will fail.
18219    ///
18220    /// # Additional Parameters
18221    ///
18222    /// * *$.xgafv* (query-string) - V1 error format.
18223    /// * *access_token* (query-string) - OAuth access token.
18224    /// * *alt* (query-string) - Data format for response.
18225    /// * *callback* (query-string) - JSONP
18226    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18227    /// * *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.
18228    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18229    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18230    /// * *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.
18231    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18232    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18233    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseBulkDeleteDocumentCall<'a, C>
18234    where
18235        T: AsRef<str>,
18236    {
18237        self._additional_params
18238            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18239        self
18240    }
18241
18242    /// Identifies the authorization scope for the method you are building.
18243    ///
18244    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18245    /// [`Scope::CloudPlatform`].
18246    ///
18247    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18248    /// tokens for more than one scope.
18249    ///
18250    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18251    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18252    /// sufficient, a read-write scope will do as well.
18253    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseBulkDeleteDocumentCall<'a, C>
18254    where
18255        St: AsRef<str>,
18256    {
18257        self._scopes.insert(String::from(scope.as_ref()));
18258        self
18259    }
18260    /// Identifies the authorization scope(s) for the method you are building.
18261    ///
18262    /// See [`Self::add_scope()`] for details.
18263    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseBulkDeleteDocumentCall<'a, C>
18264    where
18265        I: IntoIterator<Item = St>,
18266        St: AsRef<str>,
18267    {
18268        self._scopes
18269            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18270        self
18271    }
18272
18273    /// Removes all scopes, and no default scope will be used either.
18274    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18275    /// for details).
18276    pub fn clear_scopes(mut self) -> ProjectDatabaseBulkDeleteDocumentCall<'a, C> {
18277        self._scopes.clear();
18278        self
18279    }
18280}
18281
18282/// Creates a new database by cloning an existing one. The new database must be in the same cloud region or multi-region location as the existing database. This behaves similar to FirestoreAdmin.CreateDatabase except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing database. The long-running operation can be used to track the progress of the clone, with the Operation's metadata field type being the CloneDatabaseMetadata. The response type is the Database if the clone was successful. The new database is not readable or writeable until the LRO has completed.
18283///
18284/// A builder for the *databases.clone* method supported by a *project* resource.
18285/// It is not used directly, but through a [`ProjectMethods`] instance.
18286///
18287/// # Example
18288///
18289/// Instantiate a resource method builder
18290///
18291/// ```test_harness,no_run
18292/// # extern crate hyper;
18293/// # extern crate hyper_rustls;
18294/// # extern crate google_firestore1 as firestore1;
18295/// use firestore1::api::GoogleFirestoreAdminV1CloneDatabaseRequest;
18296/// # async fn dox() {
18297/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18298///
18299/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18300/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18301/// #     .with_native_roots()
18302/// #     .unwrap()
18303/// #     .https_only()
18304/// #     .enable_http2()
18305/// #     .build();
18306///
18307/// # let executor = hyper_util::rt::TokioExecutor::new();
18308/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18309/// #     secret,
18310/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18311/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18312/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18313/// #     ),
18314/// # ).build().await.unwrap();
18315///
18316/// # let client = hyper_util::client::legacy::Client::builder(
18317/// #     hyper_util::rt::TokioExecutor::new()
18318/// # )
18319/// # .build(
18320/// #     hyper_rustls::HttpsConnectorBuilder::new()
18321/// #         .with_native_roots()
18322/// #         .unwrap()
18323/// #         .https_or_http()
18324/// #         .enable_http2()
18325/// #         .build()
18326/// # );
18327/// # let mut hub = Firestore::new(client, auth);
18328/// // As the method needs a request, you would usually fill it with the desired information
18329/// // into the respective structure. Some of the parts shown here might not be applicable !
18330/// // Values shown here are possibly random and not representative !
18331/// let mut req = GoogleFirestoreAdminV1CloneDatabaseRequest::default();
18332///
18333/// // You can configure optional parameters by calling the respective setters at will, and
18334/// // execute the final call using `doit()`.
18335/// // Values shown here are possibly random and not representative !
18336/// let result = hub.projects().databases_clone(req, "parent")
18337///              .doit().await;
18338/// # }
18339/// ```
18340pub struct ProjectDatabaseCloneCall<'a, C>
18341where
18342    C: 'a,
18343{
18344    hub: &'a Firestore<C>,
18345    _request: GoogleFirestoreAdminV1CloneDatabaseRequest,
18346    _parent: String,
18347    _delegate: Option<&'a mut dyn common::Delegate>,
18348    _additional_params: HashMap<String, String>,
18349    _scopes: BTreeSet<String>,
18350}
18351
18352impl<'a, C> common::CallBuilder for ProjectDatabaseCloneCall<'a, C> {}
18353
18354impl<'a, C> ProjectDatabaseCloneCall<'a, C>
18355where
18356    C: common::Connector,
18357{
18358    /// Perform the operation you have build so far.
18359    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
18360        use std::borrow::Cow;
18361        use std::io::{Read, Seek};
18362
18363        use common::{url::Params, ToParts};
18364        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18365
18366        let mut dd = common::DefaultDelegate;
18367        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18368        dlg.begin(common::MethodInfo {
18369            id: "firestore.projects.databases.clone",
18370            http_method: hyper::Method::POST,
18371        });
18372
18373        for &field in ["alt", "parent"].iter() {
18374            if self._additional_params.contains_key(field) {
18375                dlg.finished(false);
18376                return Err(common::Error::FieldClash(field));
18377            }
18378        }
18379
18380        let mut params = Params::with_capacity(4 + self._additional_params.len());
18381        params.push("parent", self._parent);
18382
18383        params.extend(self._additional_params.iter());
18384
18385        params.push("alt", "json");
18386        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases:clone";
18387        if self._scopes.is_empty() {
18388            self._scopes
18389                .insert(Scope::CloudPlatform.as_ref().to_string());
18390        }
18391
18392        #[allow(clippy::single_element_loop)]
18393        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18394            url = params.uri_replacement(url, param_name, find_this, true);
18395        }
18396        {
18397            let to_remove = ["parent"];
18398            params.remove_params(&to_remove);
18399        }
18400
18401        let url = params.parse_with_url(&url);
18402
18403        let mut json_mime_type = mime::APPLICATION_JSON;
18404        let mut request_value_reader = {
18405            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18406            common::remove_json_null_values(&mut value);
18407            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18408            serde_json::to_writer(&mut dst, &value).unwrap();
18409            dst
18410        };
18411        let request_size = request_value_reader
18412            .seek(std::io::SeekFrom::End(0))
18413            .unwrap();
18414        request_value_reader
18415            .seek(std::io::SeekFrom::Start(0))
18416            .unwrap();
18417
18418        loop {
18419            let token = match self
18420                .hub
18421                .auth
18422                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18423                .await
18424            {
18425                Ok(token) => token,
18426                Err(e) => match dlg.token(e) {
18427                    Ok(token) => token,
18428                    Err(e) => {
18429                        dlg.finished(false);
18430                        return Err(common::Error::MissingToken(e));
18431                    }
18432                },
18433            };
18434            request_value_reader
18435                .seek(std::io::SeekFrom::Start(0))
18436                .unwrap();
18437            let mut req_result = {
18438                let client = &self.hub.client;
18439                dlg.pre_request();
18440                let mut req_builder = hyper::Request::builder()
18441                    .method(hyper::Method::POST)
18442                    .uri(url.as_str())
18443                    .header(USER_AGENT, self.hub._user_agent.clone());
18444
18445                if let Some(token) = token.as_ref() {
18446                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18447                }
18448
18449                let request = req_builder
18450                    .header(CONTENT_TYPE, json_mime_type.to_string())
18451                    .header(CONTENT_LENGTH, request_size as u64)
18452                    .body(common::to_body(
18453                        request_value_reader.get_ref().clone().into(),
18454                    ));
18455
18456                client.request(request.unwrap()).await
18457            };
18458
18459            match req_result {
18460                Err(err) => {
18461                    if let common::Retry::After(d) = dlg.http_error(&err) {
18462                        sleep(d).await;
18463                        continue;
18464                    }
18465                    dlg.finished(false);
18466                    return Err(common::Error::HttpError(err));
18467                }
18468                Ok(res) => {
18469                    let (mut parts, body) = res.into_parts();
18470                    let mut body = common::Body::new(body);
18471                    if !parts.status.is_success() {
18472                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18473                        let error = serde_json::from_str(&common::to_string(&bytes));
18474                        let response = common::to_response(parts, bytes.into());
18475
18476                        if let common::Retry::After(d) =
18477                            dlg.http_failure(&response, error.as_ref().ok())
18478                        {
18479                            sleep(d).await;
18480                            continue;
18481                        }
18482
18483                        dlg.finished(false);
18484
18485                        return Err(match error {
18486                            Ok(value) => common::Error::BadRequest(value),
18487                            _ => common::Error::Failure(response),
18488                        });
18489                    }
18490                    let response = {
18491                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18492                        let encoded = common::to_string(&bytes);
18493                        match serde_json::from_str(&encoded) {
18494                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18495                            Err(error) => {
18496                                dlg.response_json_decode_error(&encoded, &error);
18497                                return Err(common::Error::JsonDecodeError(
18498                                    encoded.to_string(),
18499                                    error,
18500                                ));
18501                            }
18502                        }
18503                    };
18504
18505                    dlg.finished(true);
18506                    return Ok(response);
18507                }
18508            }
18509        }
18510    }
18511
18512    ///
18513    /// Sets the *request* property to the given value.
18514    ///
18515    /// Even though the property as already been set when instantiating this call,
18516    /// we provide this method for API completeness.
18517    pub fn request(
18518        mut self,
18519        new_value: GoogleFirestoreAdminV1CloneDatabaseRequest,
18520    ) -> ProjectDatabaseCloneCall<'a, C> {
18521        self._request = new_value;
18522        self
18523    }
18524    /// Required. The project to clone the database in. Format is `projects/{project_id}`.
18525    ///
18526    /// Sets the *parent* path property to the given value.
18527    ///
18528    /// Even though the property as already been set when instantiating this call,
18529    /// we provide this method for API completeness.
18530    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseCloneCall<'a, C> {
18531        self._parent = new_value.to_string();
18532        self
18533    }
18534    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18535    /// while executing the actual API request.
18536    ///
18537    /// ````text
18538    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18539    /// ````
18540    ///
18541    /// Sets the *delegate* property to the given value.
18542    pub fn delegate(
18543        mut self,
18544        new_value: &'a mut dyn common::Delegate,
18545    ) -> ProjectDatabaseCloneCall<'a, C> {
18546        self._delegate = Some(new_value);
18547        self
18548    }
18549
18550    /// Set any additional parameter of the query string used in the request.
18551    /// It should be used to set parameters which are not yet available through their own
18552    /// setters.
18553    ///
18554    /// Please note that this method must not be used to set any of the known parameters
18555    /// which have their own setter method. If done anyway, the request will fail.
18556    ///
18557    /// # Additional Parameters
18558    ///
18559    /// * *$.xgafv* (query-string) - V1 error format.
18560    /// * *access_token* (query-string) - OAuth access token.
18561    /// * *alt* (query-string) - Data format for response.
18562    /// * *callback* (query-string) - JSONP
18563    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18564    /// * *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.
18565    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18566    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18567    /// * *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.
18568    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18569    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18570    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseCloneCall<'a, C>
18571    where
18572        T: AsRef<str>,
18573    {
18574        self._additional_params
18575            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18576        self
18577    }
18578
18579    /// Identifies the authorization scope for the method you are building.
18580    ///
18581    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18582    /// [`Scope::CloudPlatform`].
18583    ///
18584    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18585    /// tokens for more than one scope.
18586    ///
18587    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18588    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18589    /// sufficient, a read-write scope will do as well.
18590    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseCloneCall<'a, C>
18591    where
18592        St: AsRef<str>,
18593    {
18594        self._scopes.insert(String::from(scope.as_ref()));
18595        self
18596    }
18597    /// Identifies the authorization scope(s) for the method you are building.
18598    ///
18599    /// See [`Self::add_scope()`] for details.
18600    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseCloneCall<'a, C>
18601    where
18602        I: IntoIterator<Item = St>,
18603        St: AsRef<str>,
18604    {
18605        self._scopes
18606            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18607        self
18608    }
18609
18610    /// Removes all scopes, and no default scope will be used either.
18611    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18612    /// for details).
18613    pub fn clear_scopes(mut self) -> ProjectDatabaseCloneCall<'a, C> {
18614        self._scopes.clear();
18615        self
18616    }
18617}
18618
18619/// Create a database.
18620///
18621/// A builder for the *databases.create* method supported by a *project* resource.
18622/// It is not used directly, but through a [`ProjectMethods`] instance.
18623///
18624/// # Example
18625///
18626/// Instantiate a resource method builder
18627///
18628/// ```test_harness,no_run
18629/// # extern crate hyper;
18630/// # extern crate hyper_rustls;
18631/// # extern crate google_firestore1 as firestore1;
18632/// use firestore1::api::GoogleFirestoreAdminV1Database;
18633/// # async fn dox() {
18634/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18635///
18636/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18637/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18638/// #     .with_native_roots()
18639/// #     .unwrap()
18640/// #     .https_only()
18641/// #     .enable_http2()
18642/// #     .build();
18643///
18644/// # let executor = hyper_util::rt::TokioExecutor::new();
18645/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18646/// #     secret,
18647/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18648/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18649/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18650/// #     ),
18651/// # ).build().await.unwrap();
18652///
18653/// # let client = hyper_util::client::legacy::Client::builder(
18654/// #     hyper_util::rt::TokioExecutor::new()
18655/// # )
18656/// # .build(
18657/// #     hyper_rustls::HttpsConnectorBuilder::new()
18658/// #         .with_native_roots()
18659/// #         .unwrap()
18660/// #         .https_or_http()
18661/// #         .enable_http2()
18662/// #         .build()
18663/// # );
18664/// # let mut hub = Firestore::new(client, auth);
18665/// // As the method needs a request, you would usually fill it with the desired information
18666/// // into the respective structure. Some of the parts shown here might not be applicable !
18667/// // Values shown here are possibly random and not representative !
18668/// let mut req = GoogleFirestoreAdminV1Database::default();
18669///
18670/// // You can configure optional parameters by calling the respective setters at will, and
18671/// // execute the final call using `doit()`.
18672/// // Values shown here are possibly random and not representative !
18673/// let result = hub.projects().databases_create(req, "parent")
18674///              .database_id("erat")
18675///              .doit().await;
18676/// # }
18677/// ```
18678pub struct ProjectDatabaseCreateCall<'a, C>
18679where
18680    C: 'a,
18681{
18682    hub: &'a Firestore<C>,
18683    _request: GoogleFirestoreAdminV1Database,
18684    _parent: String,
18685    _database_id: Option<String>,
18686    _delegate: Option<&'a mut dyn common::Delegate>,
18687    _additional_params: HashMap<String, String>,
18688    _scopes: BTreeSet<String>,
18689}
18690
18691impl<'a, C> common::CallBuilder for ProjectDatabaseCreateCall<'a, C> {}
18692
18693impl<'a, C> ProjectDatabaseCreateCall<'a, C>
18694where
18695    C: common::Connector,
18696{
18697    /// Perform the operation you have build so far.
18698    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
18699        use std::borrow::Cow;
18700        use std::io::{Read, Seek};
18701
18702        use common::{url::Params, ToParts};
18703        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18704
18705        let mut dd = common::DefaultDelegate;
18706        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18707        dlg.begin(common::MethodInfo {
18708            id: "firestore.projects.databases.create",
18709            http_method: hyper::Method::POST,
18710        });
18711
18712        for &field in ["alt", "parent", "databaseId"].iter() {
18713            if self._additional_params.contains_key(field) {
18714                dlg.finished(false);
18715                return Err(common::Error::FieldClash(field));
18716            }
18717        }
18718
18719        let mut params = Params::with_capacity(5 + self._additional_params.len());
18720        params.push("parent", self._parent);
18721        if let Some(value) = self._database_id.as_ref() {
18722            params.push("databaseId", value);
18723        }
18724
18725        params.extend(self._additional_params.iter());
18726
18727        params.push("alt", "json");
18728        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases";
18729        if self._scopes.is_empty() {
18730            self._scopes
18731                .insert(Scope::CloudPlatform.as_ref().to_string());
18732        }
18733
18734        #[allow(clippy::single_element_loop)]
18735        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18736            url = params.uri_replacement(url, param_name, find_this, true);
18737        }
18738        {
18739            let to_remove = ["parent"];
18740            params.remove_params(&to_remove);
18741        }
18742
18743        let url = params.parse_with_url(&url);
18744
18745        let mut json_mime_type = mime::APPLICATION_JSON;
18746        let mut request_value_reader = {
18747            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18748            common::remove_json_null_values(&mut value);
18749            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18750            serde_json::to_writer(&mut dst, &value).unwrap();
18751            dst
18752        };
18753        let request_size = request_value_reader
18754            .seek(std::io::SeekFrom::End(0))
18755            .unwrap();
18756        request_value_reader
18757            .seek(std::io::SeekFrom::Start(0))
18758            .unwrap();
18759
18760        loop {
18761            let token = match self
18762                .hub
18763                .auth
18764                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18765                .await
18766            {
18767                Ok(token) => token,
18768                Err(e) => match dlg.token(e) {
18769                    Ok(token) => token,
18770                    Err(e) => {
18771                        dlg.finished(false);
18772                        return Err(common::Error::MissingToken(e));
18773                    }
18774                },
18775            };
18776            request_value_reader
18777                .seek(std::io::SeekFrom::Start(0))
18778                .unwrap();
18779            let mut req_result = {
18780                let client = &self.hub.client;
18781                dlg.pre_request();
18782                let mut req_builder = hyper::Request::builder()
18783                    .method(hyper::Method::POST)
18784                    .uri(url.as_str())
18785                    .header(USER_AGENT, self.hub._user_agent.clone());
18786
18787                if let Some(token) = token.as_ref() {
18788                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18789                }
18790
18791                let request = req_builder
18792                    .header(CONTENT_TYPE, json_mime_type.to_string())
18793                    .header(CONTENT_LENGTH, request_size as u64)
18794                    .body(common::to_body(
18795                        request_value_reader.get_ref().clone().into(),
18796                    ));
18797
18798                client.request(request.unwrap()).await
18799            };
18800
18801            match req_result {
18802                Err(err) => {
18803                    if let common::Retry::After(d) = dlg.http_error(&err) {
18804                        sleep(d).await;
18805                        continue;
18806                    }
18807                    dlg.finished(false);
18808                    return Err(common::Error::HttpError(err));
18809                }
18810                Ok(res) => {
18811                    let (mut parts, body) = res.into_parts();
18812                    let mut body = common::Body::new(body);
18813                    if !parts.status.is_success() {
18814                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18815                        let error = serde_json::from_str(&common::to_string(&bytes));
18816                        let response = common::to_response(parts, bytes.into());
18817
18818                        if let common::Retry::After(d) =
18819                            dlg.http_failure(&response, error.as_ref().ok())
18820                        {
18821                            sleep(d).await;
18822                            continue;
18823                        }
18824
18825                        dlg.finished(false);
18826
18827                        return Err(match error {
18828                            Ok(value) => common::Error::BadRequest(value),
18829                            _ => common::Error::Failure(response),
18830                        });
18831                    }
18832                    let response = {
18833                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18834                        let encoded = common::to_string(&bytes);
18835                        match serde_json::from_str(&encoded) {
18836                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18837                            Err(error) => {
18838                                dlg.response_json_decode_error(&encoded, &error);
18839                                return Err(common::Error::JsonDecodeError(
18840                                    encoded.to_string(),
18841                                    error,
18842                                ));
18843                            }
18844                        }
18845                    };
18846
18847                    dlg.finished(true);
18848                    return Ok(response);
18849                }
18850            }
18851        }
18852    }
18853
18854    ///
18855    /// Sets the *request* property to the given value.
18856    ///
18857    /// Even though the property as already been set when instantiating this call,
18858    /// we provide this method for API completeness.
18859    pub fn request(
18860        mut self,
18861        new_value: GoogleFirestoreAdminV1Database,
18862    ) -> ProjectDatabaseCreateCall<'a, C> {
18863        self._request = new_value;
18864        self
18865    }
18866    /// Required. A parent name of the form `projects/{project_id}`
18867    ///
18868    /// Sets the *parent* path property to the given value.
18869    ///
18870    /// Even though the property as already been set when instantiating this call,
18871    /// we provide this method for API completeness.
18872    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseCreateCall<'a, C> {
18873        self._parent = new_value.to_string();
18874        self
18875    }
18876    /// Required. The ID to use for the database, which will become the final component of the database's resource name. This value should be 4-63 characters. Valid characters are /a-z-/ with first character a letter and the last a letter or a number. Must not be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. "(default)" database ID is also valid if the database is Standard edition.
18877    ///
18878    /// Sets the *database id* query property to the given value.
18879    pub fn database_id(mut self, new_value: &str) -> ProjectDatabaseCreateCall<'a, C> {
18880        self._database_id = Some(new_value.to_string());
18881        self
18882    }
18883    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18884    /// while executing the actual API request.
18885    ///
18886    /// ````text
18887    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18888    /// ````
18889    ///
18890    /// Sets the *delegate* property to the given value.
18891    pub fn delegate(
18892        mut self,
18893        new_value: &'a mut dyn common::Delegate,
18894    ) -> ProjectDatabaseCreateCall<'a, C> {
18895        self._delegate = Some(new_value);
18896        self
18897    }
18898
18899    /// Set any additional parameter of the query string used in the request.
18900    /// It should be used to set parameters which are not yet available through their own
18901    /// setters.
18902    ///
18903    /// Please note that this method must not be used to set any of the known parameters
18904    /// which have their own setter method. If done anyway, the request will fail.
18905    ///
18906    /// # Additional Parameters
18907    ///
18908    /// * *$.xgafv* (query-string) - V1 error format.
18909    /// * *access_token* (query-string) - OAuth access token.
18910    /// * *alt* (query-string) - Data format for response.
18911    /// * *callback* (query-string) - JSONP
18912    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18913    /// * *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.
18914    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18915    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18916    /// * *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.
18917    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18918    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18919    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseCreateCall<'a, C>
18920    where
18921        T: AsRef<str>,
18922    {
18923        self._additional_params
18924            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18925        self
18926    }
18927
18928    /// Identifies the authorization scope for the method you are building.
18929    ///
18930    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18931    /// [`Scope::CloudPlatform`].
18932    ///
18933    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18934    /// tokens for more than one scope.
18935    ///
18936    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18937    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18938    /// sufficient, a read-write scope will do as well.
18939    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseCreateCall<'a, C>
18940    where
18941        St: AsRef<str>,
18942    {
18943        self._scopes.insert(String::from(scope.as_ref()));
18944        self
18945    }
18946    /// Identifies the authorization scope(s) for the method you are building.
18947    ///
18948    /// See [`Self::add_scope()`] for details.
18949    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseCreateCall<'a, C>
18950    where
18951        I: IntoIterator<Item = St>,
18952        St: AsRef<str>,
18953    {
18954        self._scopes
18955            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18956        self
18957    }
18958
18959    /// Removes all scopes, and no default scope will be used either.
18960    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18961    /// for details).
18962    pub fn clear_scopes(mut self) -> ProjectDatabaseCreateCall<'a, C> {
18963        self._scopes.clear();
18964        self
18965    }
18966}
18967
18968/// Deletes a database.
18969///
18970/// A builder for the *databases.delete* method supported by a *project* resource.
18971/// It is not used directly, but through a [`ProjectMethods`] instance.
18972///
18973/// # Example
18974///
18975/// Instantiate a resource method builder
18976///
18977/// ```test_harness,no_run
18978/// # extern crate hyper;
18979/// # extern crate hyper_rustls;
18980/// # extern crate google_firestore1 as firestore1;
18981/// # async fn dox() {
18982/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18983///
18984/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18985/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18986/// #     .with_native_roots()
18987/// #     .unwrap()
18988/// #     .https_only()
18989/// #     .enable_http2()
18990/// #     .build();
18991///
18992/// # let executor = hyper_util::rt::TokioExecutor::new();
18993/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18994/// #     secret,
18995/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18996/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18997/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18998/// #     ),
18999/// # ).build().await.unwrap();
19000///
19001/// # let client = hyper_util::client::legacy::Client::builder(
19002/// #     hyper_util::rt::TokioExecutor::new()
19003/// # )
19004/// # .build(
19005/// #     hyper_rustls::HttpsConnectorBuilder::new()
19006/// #         .with_native_roots()
19007/// #         .unwrap()
19008/// #         .https_or_http()
19009/// #         .enable_http2()
19010/// #         .build()
19011/// # );
19012/// # let mut hub = Firestore::new(client, auth);
19013/// // You can configure optional parameters by calling the respective setters at will, and
19014/// // execute the final call using `doit()`.
19015/// // Values shown here are possibly random and not representative !
19016/// let result = hub.projects().databases_delete("name")
19017///              .etag("amet.")
19018///              .doit().await;
19019/// # }
19020/// ```
19021pub struct ProjectDatabaseDeleteCall<'a, C>
19022where
19023    C: 'a,
19024{
19025    hub: &'a Firestore<C>,
19026    _name: String,
19027    _etag: Option<String>,
19028    _delegate: Option<&'a mut dyn common::Delegate>,
19029    _additional_params: HashMap<String, String>,
19030    _scopes: BTreeSet<String>,
19031}
19032
19033impl<'a, C> common::CallBuilder for ProjectDatabaseDeleteCall<'a, C> {}
19034
19035impl<'a, C> ProjectDatabaseDeleteCall<'a, C>
19036where
19037    C: common::Connector,
19038{
19039    /// Perform the operation you have build so far.
19040    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
19041        use std::borrow::Cow;
19042        use std::io::{Read, Seek};
19043
19044        use common::{url::Params, ToParts};
19045        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19046
19047        let mut dd = common::DefaultDelegate;
19048        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19049        dlg.begin(common::MethodInfo {
19050            id: "firestore.projects.databases.delete",
19051            http_method: hyper::Method::DELETE,
19052        });
19053
19054        for &field in ["alt", "name", "etag"].iter() {
19055            if self._additional_params.contains_key(field) {
19056                dlg.finished(false);
19057                return Err(common::Error::FieldClash(field));
19058            }
19059        }
19060
19061        let mut params = Params::with_capacity(4 + self._additional_params.len());
19062        params.push("name", self._name);
19063        if let Some(value) = self._etag.as_ref() {
19064            params.push("etag", value);
19065        }
19066
19067        params.extend(self._additional_params.iter());
19068
19069        params.push("alt", "json");
19070        let mut url = self.hub._base_url.clone() + "v1/{+name}";
19071        if self._scopes.is_empty() {
19072            self._scopes
19073                .insert(Scope::CloudPlatform.as_ref().to_string());
19074        }
19075
19076        #[allow(clippy::single_element_loop)]
19077        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19078            url = params.uri_replacement(url, param_name, find_this, true);
19079        }
19080        {
19081            let to_remove = ["name"];
19082            params.remove_params(&to_remove);
19083        }
19084
19085        let url = params.parse_with_url(&url);
19086
19087        loop {
19088            let token = match self
19089                .hub
19090                .auth
19091                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19092                .await
19093            {
19094                Ok(token) => token,
19095                Err(e) => match dlg.token(e) {
19096                    Ok(token) => token,
19097                    Err(e) => {
19098                        dlg.finished(false);
19099                        return Err(common::Error::MissingToken(e));
19100                    }
19101                },
19102            };
19103            let mut req_result = {
19104                let client = &self.hub.client;
19105                dlg.pre_request();
19106                let mut req_builder = hyper::Request::builder()
19107                    .method(hyper::Method::DELETE)
19108                    .uri(url.as_str())
19109                    .header(USER_AGENT, self.hub._user_agent.clone());
19110
19111                if let Some(token) = token.as_ref() {
19112                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19113                }
19114
19115                let request = req_builder
19116                    .header(CONTENT_LENGTH, 0_u64)
19117                    .body(common::to_body::<String>(None));
19118
19119                client.request(request.unwrap()).await
19120            };
19121
19122            match req_result {
19123                Err(err) => {
19124                    if let common::Retry::After(d) = dlg.http_error(&err) {
19125                        sleep(d).await;
19126                        continue;
19127                    }
19128                    dlg.finished(false);
19129                    return Err(common::Error::HttpError(err));
19130                }
19131                Ok(res) => {
19132                    let (mut parts, body) = res.into_parts();
19133                    let mut body = common::Body::new(body);
19134                    if !parts.status.is_success() {
19135                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19136                        let error = serde_json::from_str(&common::to_string(&bytes));
19137                        let response = common::to_response(parts, bytes.into());
19138
19139                        if let common::Retry::After(d) =
19140                            dlg.http_failure(&response, error.as_ref().ok())
19141                        {
19142                            sleep(d).await;
19143                            continue;
19144                        }
19145
19146                        dlg.finished(false);
19147
19148                        return Err(match error {
19149                            Ok(value) => common::Error::BadRequest(value),
19150                            _ => common::Error::Failure(response),
19151                        });
19152                    }
19153                    let response = {
19154                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19155                        let encoded = common::to_string(&bytes);
19156                        match serde_json::from_str(&encoded) {
19157                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19158                            Err(error) => {
19159                                dlg.response_json_decode_error(&encoded, &error);
19160                                return Err(common::Error::JsonDecodeError(
19161                                    encoded.to_string(),
19162                                    error,
19163                                ));
19164                            }
19165                        }
19166                    };
19167
19168                    dlg.finished(true);
19169                    return Ok(response);
19170                }
19171            }
19172        }
19173    }
19174
19175    /// Required. A name of the form `projects/{project_id}/databases/{database_id}`
19176    ///
19177    /// Sets the *name* path property to the given value.
19178    ///
19179    /// Even though the property as already been set when instantiating this call,
19180    /// we provide this method for API completeness.
19181    pub fn name(mut self, new_value: &str) -> ProjectDatabaseDeleteCall<'a, C> {
19182        self._name = new_value.to_string();
19183        self
19184    }
19185    /// The current etag of the Database. If an etag is provided and does not match the current etag of the database, deletion will be blocked and a FAILED_PRECONDITION error will be returned.
19186    ///
19187    /// Sets the *etag* query property to the given value.
19188    pub fn etag(mut self, new_value: &str) -> ProjectDatabaseDeleteCall<'a, C> {
19189        self._etag = Some(new_value.to_string());
19190        self
19191    }
19192    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19193    /// while executing the actual API request.
19194    ///
19195    /// ````text
19196    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19197    /// ````
19198    ///
19199    /// Sets the *delegate* property to the given value.
19200    pub fn delegate(
19201        mut self,
19202        new_value: &'a mut dyn common::Delegate,
19203    ) -> ProjectDatabaseDeleteCall<'a, C> {
19204        self._delegate = Some(new_value);
19205        self
19206    }
19207
19208    /// Set any additional parameter of the query string used in the request.
19209    /// It should be used to set parameters which are not yet available through their own
19210    /// setters.
19211    ///
19212    /// Please note that this method must not be used to set any of the known parameters
19213    /// which have their own setter method. If done anyway, the request will fail.
19214    ///
19215    /// # Additional Parameters
19216    ///
19217    /// * *$.xgafv* (query-string) - V1 error format.
19218    /// * *access_token* (query-string) - OAuth access token.
19219    /// * *alt* (query-string) - Data format for response.
19220    /// * *callback* (query-string) - JSONP
19221    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19222    /// * *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.
19223    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19224    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19225    /// * *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.
19226    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19227    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19228    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDeleteCall<'a, C>
19229    where
19230        T: AsRef<str>,
19231    {
19232        self._additional_params
19233            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19234        self
19235    }
19236
19237    /// Identifies the authorization scope for the method you are building.
19238    ///
19239    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19240    /// [`Scope::CloudPlatform`].
19241    ///
19242    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19243    /// tokens for more than one scope.
19244    ///
19245    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19246    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19247    /// sufficient, a read-write scope will do as well.
19248    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDeleteCall<'a, C>
19249    where
19250        St: AsRef<str>,
19251    {
19252        self._scopes.insert(String::from(scope.as_ref()));
19253        self
19254    }
19255    /// Identifies the authorization scope(s) for the method you are building.
19256    ///
19257    /// See [`Self::add_scope()`] for details.
19258    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDeleteCall<'a, C>
19259    where
19260        I: IntoIterator<Item = St>,
19261        St: AsRef<str>,
19262    {
19263        self._scopes
19264            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19265        self
19266    }
19267
19268    /// Removes all scopes, and no default scope will be used either.
19269    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19270    /// for details).
19271    pub fn clear_scopes(mut self) -> ProjectDatabaseDeleteCall<'a, C> {
19272        self._scopes.clear();
19273        self
19274    }
19275}
19276
19277/// Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage. For more details on export behavior and output format, refer to: https://cloud.google.com/firestore/docs/manage-data/export-import
19278///
19279/// A builder for the *databases.exportDocuments* method supported by a *project* resource.
19280/// It is not used directly, but through a [`ProjectMethods`] instance.
19281///
19282/// # Example
19283///
19284/// Instantiate a resource method builder
19285///
19286/// ```test_harness,no_run
19287/// # extern crate hyper;
19288/// # extern crate hyper_rustls;
19289/// # extern crate google_firestore1 as firestore1;
19290/// use firestore1::api::GoogleFirestoreAdminV1ExportDocumentsRequest;
19291/// # async fn dox() {
19292/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19293///
19294/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19295/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19296/// #     .with_native_roots()
19297/// #     .unwrap()
19298/// #     .https_only()
19299/// #     .enable_http2()
19300/// #     .build();
19301///
19302/// # let executor = hyper_util::rt::TokioExecutor::new();
19303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19304/// #     secret,
19305/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19306/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19307/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19308/// #     ),
19309/// # ).build().await.unwrap();
19310///
19311/// # let client = hyper_util::client::legacy::Client::builder(
19312/// #     hyper_util::rt::TokioExecutor::new()
19313/// # )
19314/// # .build(
19315/// #     hyper_rustls::HttpsConnectorBuilder::new()
19316/// #         .with_native_roots()
19317/// #         .unwrap()
19318/// #         .https_or_http()
19319/// #         .enable_http2()
19320/// #         .build()
19321/// # );
19322/// # let mut hub = Firestore::new(client, auth);
19323/// // As the method needs a request, you would usually fill it with the desired information
19324/// // into the respective structure. Some of the parts shown here might not be applicable !
19325/// // Values shown here are possibly random and not representative !
19326/// let mut req = GoogleFirestoreAdminV1ExportDocumentsRequest::default();
19327///
19328/// // You can configure optional parameters by calling the respective setters at will, and
19329/// // execute the final call using `doit()`.
19330/// // Values shown here are possibly random and not representative !
19331/// let result = hub.projects().databases_export_documents(req, "name")
19332///              .doit().await;
19333/// # }
19334/// ```
19335pub struct ProjectDatabaseExportDocumentCall<'a, C>
19336where
19337    C: 'a,
19338{
19339    hub: &'a Firestore<C>,
19340    _request: GoogleFirestoreAdminV1ExportDocumentsRequest,
19341    _name: String,
19342    _delegate: Option<&'a mut dyn common::Delegate>,
19343    _additional_params: HashMap<String, String>,
19344    _scopes: BTreeSet<String>,
19345}
19346
19347impl<'a, C> common::CallBuilder for ProjectDatabaseExportDocumentCall<'a, C> {}
19348
19349impl<'a, C> ProjectDatabaseExportDocumentCall<'a, C>
19350where
19351    C: common::Connector,
19352{
19353    /// Perform the operation you have build so far.
19354    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
19355        use std::borrow::Cow;
19356        use std::io::{Read, Seek};
19357
19358        use common::{url::Params, ToParts};
19359        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19360
19361        let mut dd = common::DefaultDelegate;
19362        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19363        dlg.begin(common::MethodInfo {
19364            id: "firestore.projects.databases.exportDocuments",
19365            http_method: hyper::Method::POST,
19366        });
19367
19368        for &field in ["alt", "name"].iter() {
19369            if self._additional_params.contains_key(field) {
19370                dlg.finished(false);
19371                return Err(common::Error::FieldClash(field));
19372            }
19373        }
19374
19375        let mut params = Params::with_capacity(4 + self._additional_params.len());
19376        params.push("name", self._name);
19377
19378        params.extend(self._additional_params.iter());
19379
19380        params.push("alt", "json");
19381        let mut url = self.hub._base_url.clone() + "v1/{+name}:exportDocuments";
19382        if self._scopes.is_empty() {
19383            self._scopes
19384                .insert(Scope::CloudPlatform.as_ref().to_string());
19385        }
19386
19387        #[allow(clippy::single_element_loop)]
19388        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19389            url = params.uri_replacement(url, param_name, find_this, true);
19390        }
19391        {
19392            let to_remove = ["name"];
19393            params.remove_params(&to_remove);
19394        }
19395
19396        let url = params.parse_with_url(&url);
19397
19398        let mut json_mime_type = mime::APPLICATION_JSON;
19399        let mut request_value_reader = {
19400            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19401            common::remove_json_null_values(&mut value);
19402            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19403            serde_json::to_writer(&mut dst, &value).unwrap();
19404            dst
19405        };
19406        let request_size = request_value_reader
19407            .seek(std::io::SeekFrom::End(0))
19408            .unwrap();
19409        request_value_reader
19410            .seek(std::io::SeekFrom::Start(0))
19411            .unwrap();
19412
19413        loop {
19414            let token = match self
19415                .hub
19416                .auth
19417                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19418                .await
19419            {
19420                Ok(token) => token,
19421                Err(e) => match dlg.token(e) {
19422                    Ok(token) => token,
19423                    Err(e) => {
19424                        dlg.finished(false);
19425                        return Err(common::Error::MissingToken(e));
19426                    }
19427                },
19428            };
19429            request_value_reader
19430                .seek(std::io::SeekFrom::Start(0))
19431                .unwrap();
19432            let mut req_result = {
19433                let client = &self.hub.client;
19434                dlg.pre_request();
19435                let mut req_builder = hyper::Request::builder()
19436                    .method(hyper::Method::POST)
19437                    .uri(url.as_str())
19438                    .header(USER_AGENT, self.hub._user_agent.clone());
19439
19440                if let Some(token) = token.as_ref() {
19441                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19442                }
19443
19444                let request = req_builder
19445                    .header(CONTENT_TYPE, json_mime_type.to_string())
19446                    .header(CONTENT_LENGTH, request_size as u64)
19447                    .body(common::to_body(
19448                        request_value_reader.get_ref().clone().into(),
19449                    ));
19450
19451                client.request(request.unwrap()).await
19452            };
19453
19454            match req_result {
19455                Err(err) => {
19456                    if let common::Retry::After(d) = dlg.http_error(&err) {
19457                        sleep(d).await;
19458                        continue;
19459                    }
19460                    dlg.finished(false);
19461                    return Err(common::Error::HttpError(err));
19462                }
19463                Ok(res) => {
19464                    let (mut parts, body) = res.into_parts();
19465                    let mut body = common::Body::new(body);
19466                    if !parts.status.is_success() {
19467                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19468                        let error = serde_json::from_str(&common::to_string(&bytes));
19469                        let response = common::to_response(parts, bytes.into());
19470
19471                        if let common::Retry::After(d) =
19472                            dlg.http_failure(&response, error.as_ref().ok())
19473                        {
19474                            sleep(d).await;
19475                            continue;
19476                        }
19477
19478                        dlg.finished(false);
19479
19480                        return Err(match error {
19481                            Ok(value) => common::Error::BadRequest(value),
19482                            _ => common::Error::Failure(response),
19483                        });
19484                    }
19485                    let response = {
19486                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19487                        let encoded = common::to_string(&bytes);
19488                        match serde_json::from_str(&encoded) {
19489                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19490                            Err(error) => {
19491                                dlg.response_json_decode_error(&encoded, &error);
19492                                return Err(common::Error::JsonDecodeError(
19493                                    encoded.to_string(),
19494                                    error,
19495                                ));
19496                            }
19497                        }
19498                    };
19499
19500                    dlg.finished(true);
19501                    return Ok(response);
19502                }
19503            }
19504        }
19505    }
19506
19507    ///
19508    /// Sets the *request* property to the given value.
19509    ///
19510    /// Even though the property as already been set when instantiating this call,
19511    /// we provide this method for API completeness.
19512    pub fn request(
19513        mut self,
19514        new_value: GoogleFirestoreAdminV1ExportDocumentsRequest,
19515    ) -> ProjectDatabaseExportDocumentCall<'a, C> {
19516        self._request = new_value;
19517        self
19518    }
19519    /// Required. Database to export. Should be of the form: `projects/{project_id}/databases/{database_id}`.
19520    ///
19521    /// Sets the *name* path property to the given value.
19522    ///
19523    /// Even though the property as already been set when instantiating this call,
19524    /// we provide this method for API completeness.
19525    pub fn name(mut self, new_value: &str) -> ProjectDatabaseExportDocumentCall<'a, C> {
19526        self._name = new_value.to_string();
19527        self
19528    }
19529    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19530    /// while executing the actual API request.
19531    ///
19532    /// ````text
19533    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19534    /// ````
19535    ///
19536    /// Sets the *delegate* property to the given value.
19537    pub fn delegate(
19538        mut self,
19539        new_value: &'a mut dyn common::Delegate,
19540    ) -> ProjectDatabaseExportDocumentCall<'a, C> {
19541        self._delegate = Some(new_value);
19542        self
19543    }
19544
19545    /// Set any additional parameter of the query string used in the request.
19546    /// It should be used to set parameters which are not yet available through their own
19547    /// setters.
19548    ///
19549    /// Please note that this method must not be used to set any of the known parameters
19550    /// which have their own setter method. If done anyway, the request will fail.
19551    ///
19552    /// # Additional Parameters
19553    ///
19554    /// * *$.xgafv* (query-string) - V1 error format.
19555    /// * *access_token* (query-string) - OAuth access token.
19556    /// * *alt* (query-string) - Data format for response.
19557    /// * *callback* (query-string) - JSONP
19558    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19559    /// * *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.
19560    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19561    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19562    /// * *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.
19563    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19564    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19565    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseExportDocumentCall<'a, C>
19566    where
19567        T: AsRef<str>,
19568    {
19569        self._additional_params
19570            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19571        self
19572    }
19573
19574    /// Identifies the authorization scope for the method you are building.
19575    ///
19576    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19577    /// [`Scope::CloudPlatform`].
19578    ///
19579    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19580    /// tokens for more than one scope.
19581    ///
19582    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19583    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19584    /// sufficient, a read-write scope will do as well.
19585    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseExportDocumentCall<'a, C>
19586    where
19587        St: AsRef<str>,
19588    {
19589        self._scopes.insert(String::from(scope.as_ref()));
19590        self
19591    }
19592    /// Identifies the authorization scope(s) for the method you are building.
19593    ///
19594    /// See [`Self::add_scope()`] for details.
19595    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseExportDocumentCall<'a, C>
19596    where
19597        I: IntoIterator<Item = St>,
19598        St: AsRef<str>,
19599    {
19600        self._scopes
19601            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19602        self
19603    }
19604
19605    /// Removes all scopes, and no default scope will be used either.
19606    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19607    /// for details).
19608    pub fn clear_scopes(mut self) -> ProjectDatabaseExportDocumentCall<'a, C> {
19609        self._scopes.clear();
19610        self
19611    }
19612}
19613
19614/// Gets information about a database.
19615///
19616/// A builder for the *databases.get* method supported by a *project* resource.
19617/// It is not used directly, but through a [`ProjectMethods`] instance.
19618///
19619/// # Example
19620///
19621/// Instantiate a resource method builder
19622///
19623/// ```test_harness,no_run
19624/// # extern crate hyper;
19625/// # extern crate hyper_rustls;
19626/// # extern crate google_firestore1 as firestore1;
19627/// # async fn dox() {
19628/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19629///
19630/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19631/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19632/// #     .with_native_roots()
19633/// #     .unwrap()
19634/// #     .https_only()
19635/// #     .enable_http2()
19636/// #     .build();
19637///
19638/// # let executor = hyper_util::rt::TokioExecutor::new();
19639/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19640/// #     secret,
19641/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19642/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19643/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19644/// #     ),
19645/// # ).build().await.unwrap();
19646///
19647/// # let client = hyper_util::client::legacy::Client::builder(
19648/// #     hyper_util::rt::TokioExecutor::new()
19649/// # )
19650/// # .build(
19651/// #     hyper_rustls::HttpsConnectorBuilder::new()
19652/// #         .with_native_roots()
19653/// #         .unwrap()
19654/// #         .https_or_http()
19655/// #         .enable_http2()
19656/// #         .build()
19657/// # );
19658/// # let mut hub = Firestore::new(client, auth);
19659/// // You can configure optional parameters by calling the respective setters at will, and
19660/// // execute the final call using `doit()`.
19661/// // Values shown here are possibly random and not representative !
19662/// let result = hub.projects().databases_get("name")
19663///              .doit().await;
19664/// # }
19665/// ```
19666pub struct ProjectDatabaseGetCall<'a, C>
19667where
19668    C: 'a,
19669{
19670    hub: &'a Firestore<C>,
19671    _name: String,
19672    _delegate: Option<&'a mut dyn common::Delegate>,
19673    _additional_params: HashMap<String, String>,
19674    _scopes: BTreeSet<String>,
19675}
19676
19677impl<'a, C> common::CallBuilder for ProjectDatabaseGetCall<'a, C> {}
19678
19679impl<'a, C> ProjectDatabaseGetCall<'a, C>
19680where
19681    C: common::Connector,
19682{
19683    /// Perform the operation you have build so far.
19684    pub async fn doit(
19685        mut self,
19686    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1Database)> {
19687        use std::borrow::Cow;
19688        use std::io::{Read, Seek};
19689
19690        use common::{url::Params, ToParts};
19691        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19692
19693        let mut dd = common::DefaultDelegate;
19694        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19695        dlg.begin(common::MethodInfo {
19696            id: "firestore.projects.databases.get",
19697            http_method: hyper::Method::GET,
19698        });
19699
19700        for &field in ["alt", "name"].iter() {
19701            if self._additional_params.contains_key(field) {
19702                dlg.finished(false);
19703                return Err(common::Error::FieldClash(field));
19704            }
19705        }
19706
19707        let mut params = Params::with_capacity(3 + self._additional_params.len());
19708        params.push("name", self._name);
19709
19710        params.extend(self._additional_params.iter());
19711
19712        params.push("alt", "json");
19713        let mut url = self.hub._base_url.clone() + "v1/{+name}";
19714        if self._scopes.is_empty() {
19715            self._scopes
19716                .insert(Scope::CloudPlatform.as_ref().to_string());
19717        }
19718
19719        #[allow(clippy::single_element_loop)]
19720        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19721            url = params.uri_replacement(url, param_name, find_this, true);
19722        }
19723        {
19724            let to_remove = ["name"];
19725            params.remove_params(&to_remove);
19726        }
19727
19728        let url = params.parse_with_url(&url);
19729
19730        loop {
19731            let token = match self
19732                .hub
19733                .auth
19734                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19735                .await
19736            {
19737                Ok(token) => token,
19738                Err(e) => match dlg.token(e) {
19739                    Ok(token) => token,
19740                    Err(e) => {
19741                        dlg.finished(false);
19742                        return Err(common::Error::MissingToken(e));
19743                    }
19744                },
19745            };
19746            let mut req_result = {
19747                let client = &self.hub.client;
19748                dlg.pre_request();
19749                let mut req_builder = hyper::Request::builder()
19750                    .method(hyper::Method::GET)
19751                    .uri(url.as_str())
19752                    .header(USER_AGENT, self.hub._user_agent.clone());
19753
19754                if let Some(token) = token.as_ref() {
19755                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19756                }
19757
19758                let request = req_builder
19759                    .header(CONTENT_LENGTH, 0_u64)
19760                    .body(common::to_body::<String>(None));
19761
19762                client.request(request.unwrap()).await
19763            };
19764
19765            match req_result {
19766                Err(err) => {
19767                    if let common::Retry::After(d) = dlg.http_error(&err) {
19768                        sleep(d).await;
19769                        continue;
19770                    }
19771                    dlg.finished(false);
19772                    return Err(common::Error::HttpError(err));
19773                }
19774                Ok(res) => {
19775                    let (mut parts, body) = res.into_parts();
19776                    let mut body = common::Body::new(body);
19777                    if !parts.status.is_success() {
19778                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19779                        let error = serde_json::from_str(&common::to_string(&bytes));
19780                        let response = common::to_response(parts, bytes.into());
19781
19782                        if let common::Retry::After(d) =
19783                            dlg.http_failure(&response, error.as_ref().ok())
19784                        {
19785                            sleep(d).await;
19786                            continue;
19787                        }
19788
19789                        dlg.finished(false);
19790
19791                        return Err(match error {
19792                            Ok(value) => common::Error::BadRequest(value),
19793                            _ => common::Error::Failure(response),
19794                        });
19795                    }
19796                    let response = {
19797                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19798                        let encoded = common::to_string(&bytes);
19799                        match serde_json::from_str(&encoded) {
19800                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19801                            Err(error) => {
19802                                dlg.response_json_decode_error(&encoded, &error);
19803                                return Err(common::Error::JsonDecodeError(
19804                                    encoded.to_string(),
19805                                    error,
19806                                ));
19807                            }
19808                        }
19809                    };
19810
19811                    dlg.finished(true);
19812                    return Ok(response);
19813                }
19814            }
19815        }
19816    }
19817
19818    /// Required. A name of the form `projects/{project_id}/databases/{database_id}`
19819    ///
19820    /// Sets the *name* path property to the given value.
19821    ///
19822    /// Even though the property as already been set when instantiating this call,
19823    /// we provide this method for API completeness.
19824    pub fn name(mut self, new_value: &str) -> ProjectDatabaseGetCall<'a, C> {
19825        self._name = new_value.to_string();
19826        self
19827    }
19828    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19829    /// while executing the actual API request.
19830    ///
19831    /// ````text
19832    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19833    /// ````
19834    ///
19835    /// Sets the *delegate* property to the given value.
19836    pub fn delegate(
19837        mut self,
19838        new_value: &'a mut dyn common::Delegate,
19839    ) -> ProjectDatabaseGetCall<'a, C> {
19840        self._delegate = Some(new_value);
19841        self
19842    }
19843
19844    /// Set any additional parameter of the query string used in the request.
19845    /// It should be used to set parameters which are not yet available through their own
19846    /// setters.
19847    ///
19848    /// Please note that this method must not be used to set any of the known parameters
19849    /// which have their own setter method. If done anyway, the request will fail.
19850    ///
19851    /// # Additional Parameters
19852    ///
19853    /// * *$.xgafv* (query-string) - V1 error format.
19854    /// * *access_token* (query-string) - OAuth access token.
19855    /// * *alt* (query-string) - Data format for response.
19856    /// * *callback* (query-string) - JSONP
19857    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19858    /// * *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.
19859    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19860    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19861    /// * *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.
19862    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19863    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19864    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseGetCall<'a, C>
19865    where
19866        T: AsRef<str>,
19867    {
19868        self._additional_params
19869            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19870        self
19871    }
19872
19873    /// Identifies the authorization scope for the method you are building.
19874    ///
19875    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19876    /// [`Scope::CloudPlatform`].
19877    ///
19878    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19879    /// tokens for more than one scope.
19880    ///
19881    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19882    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19883    /// sufficient, a read-write scope will do as well.
19884    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseGetCall<'a, C>
19885    where
19886        St: AsRef<str>,
19887    {
19888        self._scopes.insert(String::from(scope.as_ref()));
19889        self
19890    }
19891    /// Identifies the authorization scope(s) for the method you are building.
19892    ///
19893    /// See [`Self::add_scope()`] for details.
19894    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseGetCall<'a, C>
19895    where
19896        I: IntoIterator<Item = St>,
19897        St: AsRef<str>,
19898    {
19899        self._scopes
19900            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19901        self
19902    }
19903
19904    /// Removes all scopes, and no default scope will be used either.
19905    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19906    /// for details).
19907    pub fn clear_scopes(mut self) -> ProjectDatabaseGetCall<'a, C> {
19908        self._scopes.clear();
19909        self
19910    }
19911}
19912
19913/// Imports documents into Google Cloud Firestore. Existing documents with the same name are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Firestore.
19914///
19915/// A builder for the *databases.importDocuments* method supported by a *project* resource.
19916/// It is not used directly, but through a [`ProjectMethods`] instance.
19917///
19918/// # Example
19919///
19920/// Instantiate a resource method builder
19921///
19922/// ```test_harness,no_run
19923/// # extern crate hyper;
19924/// # extern crate hyper_rustls;
19925/// # extern crate google_firestore1 as firestore1;
19926/// use firestore1::api::GoogleFirestoreAdminV1ImportDocumentsRequest;
19927/// # async fn dox() {
19928/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19929///
19930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19931/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19932/// #     .with_native_roots()
19933/// #     .unwrap()
19934/// #     .https_only()
19935/// #     .enable_http2()
19936/// #     .build();
19937///
19938/// # let executor = hyper_util::rt::TokioExecutor::new();
19939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19940/// #     secret,
19941/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19942/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19943/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19944/// #     ),
19945/// # ).build().await.unwrap();
19946///
19947/// # let client = hyper_util::client::legacy::Client::builder(
19948/// #     hyper_util::rt::TokioExecutor::new()
19949/// # )
19950/// # .build(
19951/// #     hyper_rustls::HttpsConnectorBuilder::new()
19952/// #         .with_native_roots()
19953/// #         .unwrap()
19954/// #         .https_or_http()
19955/// #         .enable_http2()
19956/// #         .build()
19957/// # );
19958/// # let mut hub = Firestore::new(client, auth);
19959/// // As the method needs a request, you would usually fill it with the desired information
19960/// // into the respective structure. Some of the parts shown here might not be applicable !
19961/// // Values shown here are possibly random and not representative !
19962/// let mut req = GoogleFirestoreAdminV1ImportDocumentsRequest::default();
19963///
19964/// // You can configure optional parameters by calling the respective setters at will, and
19965/// // execute the final call using `doit()`.
19966/// // Values shown here are possibly random and not representative !
19967/// let result = hub.projects().databases_import_documents(req, "name")
19968///              .doit().await;
19969/// # }
19970/// ```
19971pub struct ProjectDatabaseImportDocumentCall<'a, C>
19972where
19973    C: 'a,
19974{
19975    hub: &'a Firestore<C>,
19976    _request: GoogleFirestoreAdminV1ImportDocumentsRequest,
19977    _name: String,
19978    _delegate: Option<&'a mut dyn common::Delegate>,
19979    _additional_params: HashMap<String, String>,
19980    _scopes: BTreeSet<String>,
19981}
19982
19983impl<'a, C> common::CallBuilder for ProjectDatabaseImportDocumentCall<'a, C> {}
19984
19985impl<'a, C> ProjectDatabaseImportDocumentCall<'a, C>
19986where
19987    C: common::Connector,
19988{
19989    /// Perform the operation you have build so far.
19990    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
19991        use std::borrow::Cow;
19992        use std::io::{Read, Seek};
19993
19994        use common::{url::Params, ToParts};
19995        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19996
19997        let mut dd = common::DefaultDelegate;
19998        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19999        dlg.begin(common::MethodInfo {
20000            id: "firestore.projects.databases.importDocuments",
20001            http_method: hyper::Method::POST,
20002        });
20003
20004        for &field in ["alt", "name"].iter() {
20005            if self._additional_params.contains_key(field) {
20006                dlg.finished(false);
20007                return Err(common::Error::FieldClash(field));
20008            }
20009        }
20010
20011        let mut params = Params::with_capacity(4 + self._additional_params.len());
20012        params.push("name", self._name);
20013
20014        params.extend(self._additional_params.iter());
20015
20016        params.push("alt", "json");
20017        let mut url = self.hub._base_url.clone() + "v1/{+name}:importDocuments";
20018        if self._scopes.is_empty() {
20019            self._scopes
20020                .insert(Scope::CloudPlatform.as_ref().to_string());
20021        }
20022
20023        #[allow(clippy::single_element_loop)]
20024        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20025            url = params.uri_replacement(url, param_name, find_this, true);
20026        }
20027        {
20028            let to_remove = ["name"];
20029            params.remove_params(&to_remove);
20030        }
20031
20032        let url = params.parse_with_url(&url);
20033
20034        let mut json_mime_type = mime::APPLICATION_JSON;
20035        let mut request_value_reader = {
20036            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20037            common::remove_json_null_values(&mut value);
20038            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20039            serde_json::to_writer(&mut dst, &value).unwrap();
20040            dst
20041        };
20042        let request_size = request_value_reader
20043            .seek(std::io::SeekFrom::End(0))
20044            .unwrap();
20045        request_value_reader
20046            .seek(std::io::SeekFrom::Start(0))
20047            .unwrap();
20048
20049        loop {
20050            let token = match self
20051                .hub
20052                .auth
20053                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20054                .await
20055            {
20056                Ok(token) => token,
20057                Err(e) => match dlg.token(e) {
20058                    Ok(token) => token,
20059                    Err(e) => {
20060                        dlg.finished(false);
20061                        return Err(common::Error::MissingToken(e));
20062                    }
20063                },
20064            };
20065            request_value_reader
20066                .seek(std::io::SeekFrom::Start(0))
20067                .unwrap();
20068            let mut req_result = {
20069                let client = &self.hub.client;
20070                dlg.pre_request();
20071                let mut req_builder = hyper::Request::builder()
20072                    .method(hyper::Method::POST)
20073                    .uri(url.as_str())
20074                    .header(USER_AGENT, self.hub._user_agent.clone());
20075
20076                if let Some(token) = token.as_ref() {
20077                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20078                }
20079
20080                let request = req_builder
20081                    .header(CONTENT_TYPE, json_mime_type.to_string())
20082                    .header(CONTENT_LENGTH, request_size as u64)
20083                    .body(common::to_body(
20084                        request_value_reader.get_ref().clone().into(),
20085                    ));
20086
20087                client.request(request.unwrap()).await
20088            };
20089
20090            match req_result {
20091                Err(err) => {
20092                    if let common::Retry::After(d) = dlg.http_error(&err) {
20093                        sleep(d).await;
20094                        continue;
20095                    }
20096                    dlg.finished(false);
20097                    return Err(common::Error::HttpError(err));
20098                }
20099                Ok(res) => {
20100                    let (mut parts, body) = res.into_parts();
20101                    let mut body = common::Body::new(body);
20102                    if !parts.status.is_success() {
20103                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20104                        let error = serde_json::from_str(&common::to_string(&bytes));
20105                        let response = common::to_response(parts, bytes.into());
20106
20107                        if let common::Retry::After(d) =
20108                            dlg.http_failure(&response, error.as_ref().ok())
20109                        {
20110                            sleep(d).await;
20111                            continue;
20112                        }
20113
20114                        dlg.finished(false);
20115
20116                        return Err(match error {
20117                            Ok(value) => common::Error::BadRequest(value),
20118                            _ => common::Error::Failure(response),
20119                        });
20120                    }
20121                    let response = {
20122                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20123                        let encoded = common::to_string(&bytes);
20124                        match serde_json::from_str(&encoded) {
20125                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20126                            Err(error) => {
20127                                dlg.response_json_decode_error(&encoded, &error);
20128                                return Err(common::Error::JsonDecodeError(
20129                                    encoded.to_string(),
20130                                    error,
20131                                ));
20132                            }
20133                        }
20134                    };
20135
20136                    dlg.finished(true);
20137                    return Ok(response);
20138                }
20139            }
20140        }
20141    }
20142
20143    ///
20144    /// Sets the *request* property to the given value.
20145    ///
20146    /// Even though the property as already been set when instantiating this call,
20147    /// we provide this method for API completeness.
20148    pub fn request(
20149        mut self,
20150        new_value: GoogleFirestoreAdminV1ImportDocumentsRequest,
20151    ) -> ProjectDatabaseImportDocumentCall<'a, C> {
20152        self._request = new_value;
20153        self
20154    }
20155    /// Required. Database to import into. Should be of the form: `projects/{project_id}/databases/{database_id}`.
20156    ///
20157    /// Sets the *name* path property to the given value.
20158    ///
20159    /// Even though the property as already been set when instantiating this call,
20160    /// we provide this method for API completeness.
20161    pub fn name(mut self, new_value: &str) -> ProjectDatabaseImportDocumentCall<'a, C> {
20162        self._name = new_value.to_string();
20163        self
20164    }
20165    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20166    /// while executing the actual API request.
20167    ///
20168    /// ````text
20169    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20170    /// ````
20171    ///
20172    /// Sets the *delegate* property to the given value.
20173    pub fn delegate(
20174        mut self,
20175        new_value: &'a mut dyn common::Delegate,
20176    ) -> ProjectDatabaseImportDocumentCall<'a, C> {
20177        self._delegate = Some(new_value);
20178        self
20179    }
20180
20181    /// Set any additional parameter of the query string used in the request.
20182    /// It should be used to set parameters which are not yet available through their own
20183    /// setters.
20184    ///
20185    /// Please note that this method must not be used to set any of the known parameters
20186    /// which have their own setter method. If done anyway, the request will fail.
20187    ///
20188    /// # Additional Parameters
20189    ///
20190    /// * *$.xgafv* (query-string) - V1 error format.
20191    /// * *access_token* (query-string) - OAuth access token.
20192    /// * *alt* (query-string) - Data format for response.
20193    /// * *callback* (query-string) - JSONP
20194    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20195    /// * *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.
20196    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20197    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20198    /// * *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.
20199    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20200    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20201    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseImportDocumentCall<'a, C>
20202    where
20203        T: AsRef<str>,
20204    {
20205        self._additional_params
20206            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20207        self
20208    }
20209
20210    /// Identifies the authorization scope for the method you are building.
20211    ///
20212    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20213    /// [`Scope::CloudPlatform`].
20214    ///
20215    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20216    /// tokens for more than one scope.
20217    ///
20218    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20219    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20220    /// sufficient, a read-write scope will do as well.
20221    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseImportDocumentCall<'a, C>
20222    where
20223        St: AsRef<str>,
20224    {
20225        self._scopes.insert(String::from(scope.as_ref()));
20226        self
20227    }
20228    /// Identifies the authorization scope(s) for the method you are building.
20229    ///
20230    /// See [`Self::add_scope()`] for details.
20231    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseImportDocumentCall<'a, C>
20232    where
20233        I: IntoIterator<Item = St>,
20234        St: AsRef<str>,
20235    {
20236        self._scopes
20237            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20238        self
20239    }
20240
20241    /// Removes all scopes, and no default scope will be used either.
20242    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20243    /// for details).
20244    pub fn clear_scopes(mut self) -> ProjectDatabaseImportDocumentCall<'a, C> {
20245        self._scopes.clear();
20246        self
20247    }
20248}
20249
20250/// List all the databases in the project.
20251///
20252/// A builder for the *databases.list* method supported by a *project* resource.
20253/// It is not used directly, but through a [`ProjectMethods`] instance.
20254///
20255/// # Example
20256///
20257/// Instantiate a resource method builder
20258///
20259/// ```test_harness,no_run
20260/// # extern crate hyper;
20261/// # extern crate hyper_rustls;
20262/// # extern crate google_firestore1 as firestore1;
20263/// # async fn dox() {
20264/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20265///
20266/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20267/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20268/// #     .with_native_roots()
20269/// #     .unwrap()
20270/// #     .https_only()
20271/// #     .enable_http2()
20272/// #     .build();
20273///
20274/// # let executor = hyper_util::rt::TokioExecutor::new();
20275/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20276/// #     secret,
20277/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20278/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20279/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20280/// #     ),
20281/// # ).build().await.unwrap();
20282///
20283/// # let client = hyper_util::client::legacy::Client::builder(
20284/// #     hyper_util::rt::TokioExecutor::new()
20285/// # )
20286/// # .build(
20287/// #     hyper_rustls::HttpsConnectorBuilder::new()
20288/// #         .with_native_roots()
20289/// #         .unwrap()
20290/// #         .https_or_http()
20291/// #         .enable_http2()
20292/// #         .build()
20293/// # );
20294/// # let mut hub = Firestore::new(client, auth);
20295/// // You can configure optional parameters by calling the respective setters at will, and
20296/// // execute the final call using `doit()`.
20297/// // Values shown here are possibly random and not representative !
20298/// let result = hub.projects().databases_list("parent")
20299///              .show_deleted(false)
20300///              .doit().await;
20301/// # }
20302/// ```
20303pub struct ProjectDatabaseListCall<'a, C>
20304where
20305    C: 'a,
20306{
20307    hub: &'a Firestore<C>,
20308    _parent: String,
20309    _show_deleted: Option<bool>,
20310    _delegate: Option<&'a mut dyn common::Delegate>,
20311    _additional_params: HashMap<String, String>,
20312    _scopes: BTreeSet<String>,
20313}
20314
20315impl<'a, C> common::CallBuilder for ProjectDatabaseListCall<'a, C> {}
20316
20317impl<'a, C> ProjectDatabaseListCall<'a, C>
20318where
20319    C: common::Connector,
20320{
20321    /// Perform the operation you have build so far.
20322    pub async fn doit(
20323        mut self,
20324    ) -> common::Result<(
20325        common::Response,
20326        GoogleFirestoreAdminV1ListDatabasesResponse,
20327    )> {
20328        use std::borrow::Cow;
20329        use std::io::{Read, Seek};
20330
20331        use common::{url::Params, ToParts};
20332        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20333
20334        let mut dd = common::DefaultDelegate;
20335        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20336        dlg.begin(common::MethodInfo {
20337            id: "firestore.projects.databases.list",
20338            http_method: hyper::Method::GET,
20339        });
20340
20341        for &field in ["alt", "parent", "showDeleted"].iter() {
20342            if self._additional_params.contains_key(field) {
20343                dlg.finished(false);
20344                return Err(common::Error::FieldClash(field));
20345            }
20346        }
20347
20348        let mut params = Params::with_capacity(4 + self._additional_params.len());
20349        params.push("parent", self._parent);
20350        if let Some(value) = self._show_deleted.as_ref() {
20351            params.push("showDeleted", value.to_string());
20352        }
20353
20354        params.extend(self._additional_params.iter());
20355
20356        params.push("alt", "json");
20357        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases";
20358        if self._scopes.is_empty() {
20359            self._scopes
20360                .insert(Scope::CloudPlatform.as_ref().to_string());
20361        }
20362
20363        #[allow(clippy::single_element_loop)]
20364        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20365            url = params.uri_replacement(url, param_name, find_this, true);
20366        }
20367        {
20368            let to_remove = ["parent"];
20369            params.remove_params(&to_remove);
20370        }
20371
20372        let url = params.parse_with_url(&url);
20373
20374        loop {
20375            let token = match self
20376                .hub
20377                .auth
20378                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20379                .await
20380            {
20381                Ok(token) => token,
20382                Err(e) => match dlg.token(e) {
20383                    Ok(token) => token,
20384                    Err(e) => {
20385                        dlg.finished(false);
20386                        return Err(common::Error::MissingToken(e));
20387                    }
20388                },
20389            };
20390            let mut req_result = {
20391                let client = &self.hub.client;
20392                dlg.pre_request();
20393                let mut req_builder = hyper::Request::builder()
20394                    .method(hyper::Method::GET)
20395                    .uri(url.as_str())
20396                    .header(USER_AGENT, self.hub._user_agent.clone());
20397
20398                if let Some(token) = token.as_ref() {
20399                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20400                }
20401
20402                let request = req_builder
20403                    .header(CONTENT_LENGTH, 0_u64)
20404                    .body(common::to_body::<String>(None));
20405
20406                client.request(request.unwrap()).await
20407            };
20408
20409            match req_result {
20410                Err(err) => {
20411                    if let common::Retry::After(d) = dlg.http_error(&err) {
20412                        sleep(d).await;
20413                        continue;
20414                    }
20415                    dlg.finished(false);
20416                    return Err(common::Error::HttpError(err));
20417                }
20418                Ok(res) => {
20419                    let (mut parts, body) = res.into_parts();
20420                    let mut body = common::Body::new(body);
20421                    if !parts.status.is_success() {
20422                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20423                        let error = serde_json::from_str(&common::to_string(&bytes));
20424                        let response = common::to_response(parts, bytes.into());
20425
20426                        if let common::Retry::After(d) =
20427                            dlg.http_failure(&response, error.as_ref().ok())
20428                        {
20429                            sleep(d).await;
20430                            continue;
20431                        }
20432
20433                        dlg.finished(false);
20434
20435                        return Err(match error {
20436                            Ok(value) => common::Error::BadRequest(value),
20437                            _ => common::Error::Failure(response),
20438                        });
20439                    }
20440                    let response = {
20441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20442                        let encoded = common::to_string(&bytes);
20443                        match serde_json::from_str(&encoded) {
20444                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20445                            Err(error) => {
20446                                dlg.response_json_decode_error(&encoded, &error);
20447                                return Err(common::Error::JsonDecodeError(
20448                                    encoded.to_string(),
20449                                    error,
20450                                ));
20451                            }
20452                        }
20453                    };
20454
20455                    dlg.finished(true);
20456                    return Ok(response);
20457                }
20458            }
20459        }
20460    }
20461
20462    /// Required. A parent name of the form `projects/{project_id}`
20463    ///
20464    /// Sets the *parent* path property to the given value.
20465    ///
20466    /// Even though the property as already been set when instantiating this call,
20467    /// we provide this method for API completeness.
20468    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseListCall<'a, C> {
20469        self._parent = new_value.to_string();
20470        self
20471    }
20472    /// If true, also returns deleted resources.
20473    ///
20474    /// Sets the *show deleted* query property to the given value.
20475    pub fn show_deleted(mut self, new_value: bool) -> ProjectDatabaseListCall<'a, C> {
20476        self._show_deleted = Some(new_value);
20477        self
20478    }
20479    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20480    /// while executing the actual API request.
20481    ///
20482    /// ````text
20483    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20484    /// ````
20485    ///
20486    /// Sets the *delegate* property to the given value.
20487    pub fn delegate(
20488        mut self,
20489        new_value: &'a mut dyn common::Delegate,
20490    ) -> ProjectDatabaseListCall<'a, C> {
20491        self._delegate = Some(new_value);
20492        self
20493    }
20494
20495    /// Set any additional parameter of the query string used in the request.
20496    /// It should be used to set parameters which are not yet available through their own
20497    /// setters.
20498    ///
20499    /// Please note that this method must not be used to set any of the known parameters
20500    /// which have their own setter method. If done anyway, the request will fail.
20501    ///
20502    /// # Additional Parameters
20503    ///
20504    /// * *$.xgafv* (query-string) - V1 error format.
20505    /// * *access_token* (query-string) - OAuth access token.
20506    /// * *alt* (query-string) - Data format for response.
20507    /// * *callback* (query-string) - JSONP
20508    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20509    /// * *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.
20510    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20511    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20512    /// * *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.
20513    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20514    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20515    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseListCall<'a, C>
20516    where
20517        T: AsRef<str>,
20518    {
20519        self._additional_params
20520            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20521        self
20522    }
20523
20524    /// Identifies the authorization scope for the method you are building.
20525    ///
20526    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20527    /// [`Scope::CloudPlatform`].
20528    ///
20529    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20530    /// tokens for more than one scope.
20531    ///
20532    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20533    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20534    /// sufficient, a read-write scope will do as well.
20535    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseListCall<'a, C>
20536    where
20537        St: AsRef<str>,
20538    {
20539        self._scopes.insert(String::from(scope.as_ref()));
20540        self
20541    }
20542    /// Identifies the authorization scope(s) for the method you are building.
20543    ///
20544    /// See [`Self::add_scope()`] for details.
20545    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseListCall<'a, C>
20546    where
20547        I: IntoIterator<Item = St>,
20548        St: AsRef<str>,
20549    {
20550        self._scopes
20551            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20552        self
20553    }
20554
20555    /// Removes all scopes, and no default scope will be used either.
20556    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20557    /// for details).
20558    pub fn clear_scopes(mut self) -> ProjectDatabaseListCall<'a, C> {
20559        self._scopes.clear();
20560        self
20561    }
20562}
20563
20564/// Updates a database.
20565///
20566/// A builder for the *databases.patch* method supported by a *project* resource.
20567/// It is not used directly, but through a [`ProjectMethods`] instance.
20568///
20569/// # Example
20570///
20571/// Instantiate a resource method builder
20572///
20573/// ```test_harness,no_run
20574/// # extern crate hyper;
20575/// # extern crate hyper_rustls;
20576/// # extern crate google_firestore1 as firestore1;
20577/// use firestore1::api::GoogleFirestoreAdminV1Database;
20578/// # async fn dox() {
20579/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20580///
20581/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20582/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20583/// #     .with_native_roots()
20584/// #     .unwrap()
20585/// #     .https_only()
20586/// #     .enable_http2()
20587/// #     .build();
20588///
20589/// # let executor = hyper_util::rt::TokioExecutor::new();
20590/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20591/// #     secret,
20592/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20593/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20594/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20595/// #     ),
20596/// # ).build().await.unwrap();
20597///
20598/// # let client = hyper_util::client::legacy::Client::builder(
20599/// #     hyper_util::rt::TokioExecutor::new()
20600/// # )
20601/// # .build(
20602/// #     hyper_rustls::HttpsConnectorBuilder::new()
20603/// #         .with_native_roots()
20604/// #         .unwrap()
20605/// #         .https_or_http()
20606/// #         .enable_http2()
20607/// #         .build()
20608/// # );
20609/// # let mut hub = Firestore::new(client, auth);
20610/// // As the method needs a request, you would usually fill it with the desired information
20611/// // into the respective structure. Some of the parts shown here might not be applicable !
20612/// // Values shown here are possibly random and not representative !
20613/// let mut req = GoogleFirestoreAdminV1Database::default();
20614///
20615/// // You can configure optional parameters by calling the respective setters at will, and
20616/// // execute the final call using `doit()`.
20617/// // Values shown here are possibly random and not representative !
20618/// let result = hub.projects().databases_patch(req, "name")
20619///              .update_mask(FieldMask::new::<&str>(&[]))
20620///              .doit().await;
20621/// # }
20622/// ```
20623pub struct ProjectDatabasePatchCall<'a, C>
20624where
20625    C: 'a,
20626{
20627    hub: &'a Firestore<C>,
20628    _request: GoogleFirestoreAdminV1Database,
20629    _name: String,
20630    _update_mask: Option<common::FieldMask>,
20631    _delegate: Option<&'a mut dyn common::Delegate>,
20632    _additional_params: HashMap<String, String>,
20633    _scopes: BTreeSet<String>,
20634}
20635
20636impl<'a, C> common::CallBuilder for ProjectDatabasePatchCall<'a, C> {}
20637
20638impl<'a, C> ProjectDatabasePatchCall<'a, C>
20639where
20640    C: common::Connector,
20641{
20642    /// Perform the operation you have build so far.
20643    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
20644        use std::borrow::Cow;
20645        use std::io::{Read, Seek};
20646
20647        use common::{url::Params, ToParts};
20648        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20649
20650        let mut dd = common::DefaultDelegate;
20651        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20652        dlg.begin(common::MethodInfo {
20653            id: "firestore.projects.databases.patch",
20654            http_method: hyper::Method::PATCH,
20655        });
20656
20657        for &field in ["alt", "name", "updateMask"].iter() {
20658            if self._additional_params.contains_key(field) {
20659                dlg.finished(false);
20660                return Err(common::Error::FieldClash(field));
20661            }
20662        }
20663
20664        let mut params = Params::with_capacity(5 + self._additional_params.len());
20665        params.push("name", self._name);
20666        if let Some(value) = self._update_mask.as_ref() {
20667            params.push("updateMask", value.to_string());
20668        }
20669
20670        params.extend(self._additional_params.iter());
20671
20672        params.push("alt", "json");
20673        let mut url = self.hub._base_url.clone() + "v1/{+name}";
20674        if self._scopes.is_empty() {
20675            self._scopes
20676                .insert(Scope::CloudPlatform.as_ref().to_string());
20677        }
20678
20679        #[allow(clippy::single_element_loop)]
20680        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20681            url = params.uri_replacement(url, param_name, find_this, true);
20682        }
20683        {
20684            let to_remove = ["name"];
20685            params.remove_params(&to_remove);
20686        }
20687
20688        let url = params.parse_with_url(&url);
20689
20690        let mut json_mime_type = mime::APPLICATION_JSON;
20691        let mut request_value_reader = {
20692            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20693            common::remove_json_null_values(&mut value);
20694            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20695            serde_json::to_writer(&mut dst, &value).unwrap();
20696            dst
20697        };
20698        let request_size = request_value_reader
20699            .seek(std::io::SeekFrom::End(0))
20700            .unwrap();
20701        request_value_reader
20702            .seek(std::io::SeekFrom::Start(0))
20703            .unwrap();
20704
20705        loop {
20706            let token = match self
20707                .hub
20708                .auth
20709                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20710                .await
20711            {
20712                Ok(token) => token,
20713                Err(e) => match dlg.token(e) {
20714                    Ok(token) => token,
20715                    Err(e) => {
20716                        dlg.finished(false);
20717                        return Err(common::Error::MissingToken(e));
20718                    }
20719                },
20720            };
20721            request_value_reader
20722                .seek(std::io::SeekFrom::Start(0))
20723                .unwrap();
20724            let mut req_result = {
20725                let client = &self.hub.client;
20726                dlg.pre_request();
20727                let mut req_builder = hyper::Request::builder()
20728                    .method(hyper::Method::PATCH)
20729                    .uri(url.as_str())
20730                    .header(USER_AGENT, self.hub._user_agent.clone());
20731
20732                if let Some(token) = token.as_ref() {
20733                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20734                }
20735
20736                let request = req_builder
20737                    .header(CONTENT_TYPE, json_mime_type.to_string())
20738                    .header(CONTENT_LENGTH, request_size as u64)
20739                    .body(common::to_body(
20740                        request_value_reader.get_ref().clone().into(),
20741                    ));
20742
20743                client.request(request.unwrap()).await
20744            };
20745
20746            match req_result {
20747                Err(err) => {
20748                    if let common::Retry::After(d) = dlg.http_error(&err) {
20749                        sleep(d).await;
20750                        continue;
20751                    }
20752                    dlg.finished(false);
20753                    return Err(common::Error::HttpError(err));
20754                }
20755                Ok(res) => {
20756                    let (mut parts, body) = res.into_parts();
20757                    let mut body = common::Body::new(body);
20758                    if !parts.status.is_success() {
20759                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20760                        let error = serde_json::from_str(&common::to_string(&bytes));
20761                        let response = common::to_response(parts, bytes.into());
20762
20763                        if let common::Retry::After(d) =
20764                            dlg.http_failure(&response, error.as_ref().ok())
20765                        {
20766                            sleep(d).await;
20767                            continue;
20768                        }
20769
20770                        dlg.finished(false);
20771
20772                        return Err(match error {
20773                            Ok(value) => common::Error::BadRequest(value),
20774                            _ => common::Error::Failure(response),
20775                        });
20776                    }
20777                    let response = {
20778                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20779                        let encoded = common::to_string(&bytes);
20780                        match serde_json::from_str(&encoded) {
20781                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20782                            Err(error) => {
20783                                dlg.response_json_decode_error(&encoded, &error);
20784                                return Err(common::Error::JsonDecodeError(
20785                                    encoded.to_string(),
20786                                    error,
20787                                ));
20788                            }
20789                        }
20790                    };
20791
20792                    dlg.finished(true);
20793                    return Ok(response);
20794                }
20795            }
20796        }
20797    }
20798
20799    ///
20800    /// Sets the *request* property to the given value.
20801    ///
20802    /// Even though the property as already been set when instantiating this call,
20803    /// we provide this method for API completeness.
20804    pub fn request(
20805        mut self,
20806        new_value: GoogleFirestoreAdminV1Database,
20807    ) -> ProjectDatabasePatchCall<'a, C> {
20808        self._request = new_value;
20809        self
20810    }
20811    /// The resource name of the Database. Format: `projects/{project}/databases/{database}`
20812    ///
20813    /// Sets the *name* path property to the given value.
20814    ///
20815    /// Even though the property as already been set when instantiating this call,
20816    /// we provide this method for API completeness.
20817    pub fn name(mut self, new_value: &str) -> ProjectDatabasePatchCall<'a, C> {
20818        self._name = new_value.to_string();
20819        self
20820    }
20821    /// The list of fields to be updated.
20822    ///
20823    /// Sets the *update mask* query property to the given value.
20824    pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectDatabasePatchCall<'a, C> {
20825        self._update_mask = Some(new_value);
20826        self
20827    }
20828    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20829    /// while executing the actual API request.
20830    ///
20831    /// ````text
20832    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20833    /// ````
20834    ///
20835    /// Sets the *delegate* property to the given value.
20836    pub fn delegate(
20837        mut self,
20838        new_value: &'a mut dyn common::Delegate,
20839    ) -> ProjectDatabasePatchCall<'a, C> {
20840        self._delegate = Some(new_value);
20841        self
20842    }
20843
20844    /// Set any additional parameter of the query string used in the request.
20845    /// It should be used to set parameters which are not yet available through their own
20846    /// setters.
20847    ///
20848    /// Please note that this method must not be used to set any of the known parameters
20849    /// which have their own setter method. If done anyway, the request will fail.
20850    ///
20851    /// # Additional Parameters
20852    ///
20853    /// * *$.xgafv* (query-string) - V1 error format.
20854    /// * *access_token* (query-string) - OAuth access token.
20855    /// * *alt* (query-string) - Data format for response.
20856    /// * *callback* (query-string) - JSONP
20857    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20858    /// * *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.
20859    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20860    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20861    /// * *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.
20862    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20863    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20864    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabasePatchCall<'a, C>
20865    where
20866        T: AsRef<str>,
20867    {
20868        self._additional_params
20869            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20870        self
20871    }
20872
20873    /// Identifies the authorization scope for the method you are building.
20874    ///
20875    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20876    /// [`Scope::CloudPlatform`].
20877    ///
20878    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20879    /// tokens for more than one scope.
20880    ///
20881    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20882    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20883    /// sufficient, a read-write scope will do as well.
20884    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabasePatchCall<'a, C>
20885    where
20886        St: AsRef<str>,
20887    {
20888        self._scopes.insert(String::from(scope.as_ref()));
20889        self
20890    }
20891    /// Identifies the authorization scope(s) for the method you are building.
20892    ///
20893    /// See [`Self::add_scope()`] for details.
20894    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabasePatchCall<'a, C>
20895    where
20896        I: IntoIterator<Item = St>,
20897        St: AsRef<str>,
20898    {
20899        self._scopes
20900            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20901        self
20902    }
20903
20904    /// Removes all scopes, and no default scope will be used either.
20905    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20906    /// for details).
20907    pub fn clear_scopes(mut self) -> ProjectDatabasePatchCall<'a, C> {
20908        self._scopes.clear();
20909        self
20910    }
20911}
20912
20913/// Creates a new database by restoring from an existing backup. The new database must be in the same cloud region or multi-region location as the existing backup. This behaves similar to FirestoreAdmin.CreateDatabase except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing backup. The long-running operation can be used to track the progress of the restore, with the Operation's metadata field type being the RestoreDatabaseMetadata. The response type is the Database if the restore was successful. The new database is not readable or writeable until the LRO has completed.
20914///
20915/// A builder for the *databases.restore* method supported by a *project* resource.
20916/// It is not used directly, but through a [`ProjectMethods`] instance.
20917///
20918/// # Example
20919///
20920/// Instantiate a resource method builder
20921///
20922/// ```test_harness,no_run
20923/// # extern crate hyper;
20924/// # extern crate hyper_rustls;
20925/// # extern crate google_firestore1 as firestore1;
20926/// use firestore1::api::GoogleFirestoreAdminV1RestoreDatabaseRequest;
20927/// # async fn dox() {
20928/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20929///
20930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20931/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20932/// #     .with_native_roots()
20933/// #     .unwrap()
20934/// #     .https_only()
20935/// #     .enable_http2()
20936/// #     .build();
20937///
20938/// # let executor = hyper_util::rt::TokioExecutor::new();
20939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20940/// #     secret,
20941/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20942/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20943/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20944/// #     ),
20945/// # ).build().await.unwrap();
20946///
20947/// # let client = hyper_util::client::legacy::Client::builder(
20948/// #     hyper_util::rt::TokioExecutor::new()
20949/// # )
20950/// # .build(
20951/// #     hyper_rustls::HttpsConnectorBuilder::new()
20952/// #         .with_native_roots()
20953/// #         .unwrap()
20954/// #         .https_or_http()
20955/// #         .enable_http2()
20956/// #         .build()
20957/// # );
20958/// # let mut hub = Firestore::new(client, auth);
20959/// // As the method needs a request, you would usually fill it with the desired information
20960/// // into the respective structure. Some of the parts shown here might not be applicable !
20961/// // Values shown here are possibly random and not representative !
20962/// let mut req = GoogleFirestoreAdminV1RestoreDatabaseRequest::default();
20963///
20964/// // You can configure optional parameters by calling the respective setters at will, and
20965/// // execute the final call using `doit()`.
20966/// // Values shown here are possibly random and not representative !
20967/// let result = hub.projects().databases_restore(req, "parent")
20968///              .doit().await;
20969/// # }
20970/// ```
20971pub struct ProjectDatabaseRestoreCall<'a, C>
20972where
20973    C: 'a,
20974{
20975    hub: &'a Firestore<C>,
20976    _request: GoogleFirestoreAdminV1RestoreDatabaseRequest,
20977    _parent: String,
20978    _delegate: Option<&'a mut dyn common::Delegate>,
20979    _additional_params: HashMap<String, String>,
20980    _scopes: BTreeSet<String>,
20981}
20982
20983impl<'a, C> common::CallBuilder for ProjectDatabaseRestoreCall<'a, C> {}
20984
20985impl<'a, C> ProjectDatabaseRestoreCall<'a, C>
20986where
20987    C: common::Connector,
20988{
20989    /// Perform the operation you have build so far.
20990    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
20991        use std::borrow::Cow;
20992        use std::io::{Read, Seek};
20993
20994        use common::{url::Params, ToParts};
20995        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20996
20997        let mut dd = common::DefaultDelegate;
20998        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20999        dlg.begin(common::MethodInfo {
21000            id: "firestore.projects.databases.restore",
21001            http_method: hyper::Method::POST,
21002        });
21003
21004        for &field in ["alt", "parent"].iter() {
21005            if self._additional_params.contains_key(field) {
21006                dlg.finished(false);
21007                return Err(common::Error::FieldClash(field));
21008            }
21009        }
21010
21011        let mut params = Params::with_capacity(4 + self._additional_params.len());
21012        params.push("parent", self._parent);
21013
21014        params.extend(self._additional_params.iter());
21015
21016        params.push("alt", "json");
21017        let mut url = self.hub._base_url.clone() + "v1/{+parent}/databases:restore";
21018        if self._scopes.is_empty() {
21019            self._scopes
21020                .insert(Scope::CloudPlatform.as_ref().to_string());
21021        }
21022
21023        #[allow(clippy::single_element_loop)]
21024        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21025            url = params.uri_replacement(url, param_name, find_this, true);
21026        }
21027        {
21028            let to_remove = ["parent"];
21029            params.remove_params(&to_remove);
21030        }
21031
21032        let url = params.parse_with_url(&url);
21033
21034        let mut json_mime_type = mime::APPLICATION_JSON;
21035        let mut request_value_reader = {
21036            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21037            common::remove_json_null_values(&mut value);
21038            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21039            serde_json::to_writer(&mut dst, &value).unwrap();
21040            dst
21041        };
21042        let request_size = request_value_reader
21043            .seek(std::io::SeekFrom::End(0))
21044            .unwrap();
21045        request_value_reader
21046            .seek(std::io::SeekFrom::Start(0))
21047            .unwrap();
21048
21049        loop {
21050            let token = match self
21051                .hub
21052                .auth
21053                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21054                .await
21055            {
21056                Ok(token) => token,
21057                Err(e) => match dlg.token(e) {
21058                    Ok(token) => token,
21059                    Err(e) => {
21060                        dlg.finished(false);
21061                        return Err(common::Error::MissingToken(e));
21062                    }
21063                },
21064            };
21065            request_value_reader
21066                .seek(std::io::SeekFrom::Start(0))
21067                .unwrap();
21068            let mut req_result = {
21069                let client = &self.hub.client;
21070                dlg.pre_request();
21071                let mut req_builder = hyper::Request::builder()
21072                    .method(hyper::Method::POST)
21073                    .uri(url.as_str())
21074                    .header(USER_AGENT, self.hub._user_agent.clone());
21075
21076                if let Some(token) = token.as_ref() {
21077                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21078                }
21079
21080                let request = req_builder
21081                    .header(CONTENT_TYPE, json_mime_type.to_string())
21082                    .header(CONTENT_LENGTH, request_size as u64)
21083                    .body(common::to_body(
21084                        request_value_reader.get_ref().clone().into(),
21085                    ));
21086
21087                client.request(request.unwrap()).await
21088            };
21089
21090            match req_result {
21091                Err(err) => {
21092                    if let common::Retry::After(d) = dlg.http_error(&err) {
21093                        sleep(d).await;
21094                        continue;
21095                    }
21096                    dlg.finished(false);
21097                    return Err(common::Error::HttpError(err));
21098                }
21099                Ok(res) => {
21100                    let (mut parts, body) = res.into_parts();
21101                    let mut body = common::Body::new(body);
21102                    if !parts.status.is_success() {
21103                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21104                        let error = serde_json::from_str(&common::to_string(&bytes));
21105                        let response = common::to_response(parts, bytes.into());
21106
21107                        if let common::Retry::After(d) =
21108                            dlg.http_failure(&response, error.as_ref().ok())
21109                        {
21110                            sleep(d).await;
21111                            continue;
21112                        }
21113
21114                        dlg.finished(false);
21115
21116                        return Err(match error {
21117                            Ok(value) => common::Error::BadRequest(value),
21118                            _ => common::Error::Failure(response),
21119                        });
21120                    }
21121                    let response = {
21122                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21123                        let encoded = common::to_string(&bytes);
21124                        match serde_json::from_str(&encoded) {
21125                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21126                            Err(error) => {
21127                                dlg.response_json_decode_error(&encoded, &error);
21128                                return Err(common::Error::JsonDecodeError(
21129                                    encoded.to_string(),
21130                                    error,
21131                                ));
21132                            }
21133                        }
21134                    };
21135
21136                    dlg.finished(true);
21137                    return Ok(response);
21138                }
21139            }
21140        }
21141    }
21142
21143    ///
21144    /// Sets the *request* property to the given value.
21145    ///
21146    /// Even though the property as already been set when instantiating this call,
21147    /// we provide this method for API completeness.
21148    pub fn request(
21149        mut self,
21150        new_value: GoogleFirestoreAdminV1RestoreDatabaseRequest,
21151    ) -> ProjectDatabaseRestoreCall<'a, C> {
21152        self._request = new_value;
21153        self
21154    }
21155    /// Required. The project to restore the database in. Format is `projects/{project_id}`.
21156    ///
21157    /// Sets the *parent* path property to the given value.
21158    ///
21159    /// Even though the property as already been set when instantiating this call,
21160    /// we provide this method for API completeness.
21161    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseRestoreCall<'a, C> {
21162        self._parent = new_value.to_string();
21163        self
21164    }
21165    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21166    /// while executing the actual API request.
21167    ///
21168    /// ````text
21169    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21170    /// ````
21171    ///
21172    /// Sets the *delegate* property to the given value.
21173    pub fn delegate(
21174        mut self,
21175        new_value: &'a mut dyn common::Delegate,
21176    ) -> ProjectDatabaseRestoreCall<'a, C> {
21177        self._delegate = Some(new_value);
21178        self
21179    }
21180
21181    /// Set any additional parameter of the query string used in the request.
21182    /// It should be used to set parameters which are not yet available through their own
21183    /// setters.
21184    ///
21185    /// Please note that this method must not be used to set any of the known parameters
21186    /// which have their own setter method. If done anyway, the request will fail.
21187    ///
21188    /// # Additional Parameters
21189    ///
21190    /// * *$.xgafv* (query-string) - V1 error format.
21191    /// * *access_token* (query-string) - OAuth access token.
21192    /// * *alt* (query-string) - Data format for response.
21193    /// * *callback* (query-string) - JSONP
21194    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21195    /// * *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.
21196    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21197    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21198    /// * *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.
21199    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21200    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21201    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseRestoreCall<'a, C>
21202    where
21203        T: AsRef<str>,
21204    {
21205        self._additional_params
21206            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21207        self
21208    }
21209
21210    /// Identifies the authorization scope for the method you are building.
21211    ///
21212    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21213    /// [`Scope::CloudPlatform`].
21214    ///
21215    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21216    /// tokens for more than one scope.
21217    ///
21218    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21219    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21220    /// sufficient, a read-write scope will do as well.
21221    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseRestoreCall<'a, C>
21222    where
21223        St: AsRef<str>,
21224    {
21225        self._scopes.insert(String::from(scope.as_ref()));
21226        self
21227    }
21228    /// Identifies the authorization scope(s) for the method you are building.
21229    ///
21230    /// See [`Self::add_scope()`] for details.
21231    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseRestoreCall<'a, C>
21232    where
21233        I: IntoIterator<Item = St>,
21234        St: AsRef<str>,
21235    {
21236        self._scopes
21237            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21238        self
21239    }
21240
21241    /// Removes all scopes, and no default scope will be used either.
21242    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21243    /// for details).
21244    pub fn clear_scopes(mut self) -> ProjectDatabaseRestoreCall<'a, C> {
21245        self._scopes.clear();
21246        self
21247    }
21248}
21249
21250/// Deletes a backup.
21251///
21252/// A builder for the *locations.backups.delete* method supported by a *project* resource.
21253/// It is not used directly, but through a [`ProjectMethods`] instance.
21254///
21255/// # Example
21256///
21257/// Instantiate a resource method builder
21258///
21259/// ```test_harness,no_run
21260/// # extern crate hyper;
21261/// # extern crate hyper_rustls;
21262/// # extern crate google_firestore1 as firestore1;
21263/// # async fn dox() {
21264/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21265///
21266/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21267/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21268/// #     .with_native_roots()
21269/// #     .unwrap()
21270/// #     .https_only()
21271/// #     .enable_http2()
21272/// #     .build();
21273///
21274/// # let executor = hyper_util::rt::TokioExecutor::new();
21275/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21276/// #     secret,
21277/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21278/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21279/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21280/// #     ),
21281/// # ).build().await.unwrap();
21282///
21283/// # let client = hyper_util::client::legacy::Client::builder(
21284/// #     hyper_util::rt::TokioExecutor::new()
21285/// # )
21286/// # .build(
21287/// #     hyper_rustls::HttpsConnectorBuilder::new()
21288/// #         .with_native_roots()
21289/// #         .unwrap()
21290/// #         .https_or_http()
21291/// #         .enable_http2()
21292/// #         .build()
21293/// # );
21294/// # let mut hub = Firestore::new(client, auth);
21295/// // You can configure optional parameters by calling the respective setters at will, and
21296/// // execute the final call using `doit()`.
21297/// // Values shown here are possibly random and not representative !
21298/// let result = hub.projects().locations_backups_delete("name")
21299///              .doit().await;
21300/// # }
21301/// ```
21302pub struct ProjectLocationBackupDeleteCall<'a, C>
21303where
21304    C: 'a,
21305{
21306    hub: &'a Firestore<C>,
21307    _name: String,
21308    _delegate: Option<&'a mut dyn common::Delegate>,
21309    _additional_params: HashMap<String, String>,
21310    _scopes: BTreeSet<String>,
21311}
21312
21313impl<'a, C> common::CallBuilder for ProjectLocationBackupDeleteCall<'a, C> {}
21314
21315impl<'a, C> ProjectLocationBackupDeleteCall<'a, C>
21316where
21317    C: common::Connector,
21318{
21319    /// Perform the operation you have build so far.
21320    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
21321        use std::borrow::Cow;
21322        use std::io::{Read, Seek};
21323
21324        use common::{url::Params, ToParts};
21325        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21326
21327        let mut dd = common::DefaultDelegate;
21328        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21329        dlg.begin(common::MethodInfo {
21330            id: "firestore.projects.locations.backups.delete",
21331            http_method: hyper::Method::DELETE,
21332        });
21333
21334        for &field in ["alt", "name"].iter() {
21335            if self._additional_params.contains_key(field) {
21336                dlg.finished(false);
21337                return Err(common::Error::FieldClash(field));
21338            }
21339        }
21340
21341        let mut params = Params::with_capacity(3 + self._additional_params.len());
21342        params.push("name", self._name);
21343
21344        params.extend(self._additional_params.iter());
21345
21346        params.push("alt", "json");
21347        let mut url = self.hub._base_url.clone() + "v1/{+name}";
21348        if self._scopes.is_empty() {
21349            self._scopes
21350                .insert(Scope::CloudPlatform.as_ref().to_string());
21351        }
21352
21353        #[allow(clippy::single_element_loop)]
21354        for &(find_this, param_name) in [("{+name}", "name")].iter() {
21355            url = params.uri_replacement(url, param_name, find_this, true);
21356        }
21357        {
21358            let to_remove = ["name"];
21359            params.remove_params(&to_remove);
21360        }
21361
21362        let url = params.parse_with_url(&url);
21363
21364        loop {
21365            let token = match self
21366                .hub
21367                .auth
21368                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21369                .await
21370            {
21371                Ok(token) => token,
21372                Err(e) => match dlg.token(e) {
21373                    Ok(token) => token,
21374                    Err(e) => {
21375                        dlg.finished(false);
21376                        return Err(common::Error::MissingToken(e));
21377                    }
21378                },
21379            };
21380            let mut req_result = {
21381                let client = &self.hub.client;
21382                dlg.pre_request();
21383                let mut req_builder = hyper::Request::builder()
21384                    .method(hyper::Method::DELETE)
21385                    .uri(url.as_str())
21386                    .header(USER_AGENT, self.hub._user_agent.clone());
21387
21388                if let Some(token) = token.as_ref() {
21389                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21390                }
21391
21392                let request = req_builder
21393                    .header(CONTENT_LENGTH, 0_u64)
21394                    .body(common::to_body::<String>(None));
21395
21396                client.request(request.unwrap()).await
21397            };
21398
21399            match req_result {
21400                Err(err) => {
21401                    if let common::Retry::After(d) = dlg.http_error(&err) {
21402                        sleep(d).await;
21403                        continue;
21404                    }
21405                    dlg.finished(false);
21406                    return Err(common::Error::HttpError(err));
21407                }
21408                Ok(res) => {
21409                    let (mut parts, body) = res.into_parts();
21410                    let mut body = common::Body::new(body);
21411                    if !parts.status.is_success() {
21412                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21413                        let error = serde_json::from_str(&common::to_string(&bytes));
21414                        let response = common::to_response(parts, bytes.into());
21415
21416                        if let common::Retry::After(d) =
21417                            dlg.http_failure(&response, error.as_ref().ok())
21418                        {
21419                            sleep(d).await;
21420                            continue;
21421                        }
21422
21423                        dlg.finished(false);
21424
21425                        return Err(match error {
21426                            Ok(value) => common::Error::BadRequest(value),
21427                            _ => common::Error::Failure(response),
21428                        });
21429                    }
21430                    let response = {
21431                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21432                        let encoded = common::to_string(&bytes);
21433                        match serde_json::from_str(&encoded) {
21434                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21435                            Err(error) => {
21436                                dlg.response_json_decode_error(&encoded, &error);
21437                                return Err(common::Error::JsonDecodeError(
21438                                    encoded.to_string(),
21439                                    error,
21440                                ));
21441                            }
21442                        }
21443                    };
21444
21445                    dlg.finished(true);
21446                    return Ok(response);
21447                }
21448            }
21449        }
21450    }
21451
21452    /// Required. Name of the backup to delete. format is `projects/{project}/locations/{location}/backups/{backup}`.
21453    ///
21454    /// Sets the *name* path property to the given value.
21455    ///
21456    /// Even though the property as already been set when instantiating this call,
21457    /// we provide this method for API completeness.
21458    pub fn name(mut self, new_value: &str) -> ProjectLocationBackupDeleteCall<'a, C> {
21459        self._name = new_value.to_string();
21460        self
21461    }
21462    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21463    /// while executing the actual API request.
21464    ///
21465    /// ````text
21466    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21467    /// ````
21468    ///
21469    /// Sets the *delegate* property to the given value.
21470    pub fn delegate(
21471        mut self,
21472        new_value: &'a mut dyn common::Delegate,
21473    ) -> ProjectLocationBackupDeleteCall<'a, C> {
21474        self._delegate = Some(new_value);
21475        self
21476    }
21477
21478    /// Set any additional parameter of the query string used in the request.
21479    /// It should be used to set parameters which are not yet available through their own
21480    /// setters.
21481    ///
21482    /// Please note that this method must not be used to set any of the known parameters
21483    /// which have their own setter method. If done anyway, the request will fail.
21484    ///
21485    /// # Additional Parameters
21486    ///
21487    /// * *$.xgafv* (query-string) - V1 error format.
21488    /// * *access_token* (query-string) - OAuth access token.
21489    /// * *alt* (query-string) - Data format for response.
21490    /// * *callback* (query-string) - JSONP
21491    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21492    /// * *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.
21493    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21494    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21495    /// * *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.
21496    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21497    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21498    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupDeleteCall<'a, C>
21499    where
21500        T: AsRef<str>,
21501    {
21502        self._additional_params
21503            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21504        self
21505    }
21506
21507    /// Identifies the authorization scope for the method you are building.
21508    ///
21509    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21510    /// [`Scope::CloudPlatform`].
21511    ///
21512    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21513    /// tokens for more than one scope.
21514    ///
21515    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21516    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21517    /// sufficient, a read-write scope will do as well.
21518    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupDeleteCall<'a, C>
21519    where
21520        St: AsRef<str>,
21521    {
21522        self._scopes.insert(String::from(scope.as_ref()));
21523        self
21524    }
21525    /// Identifies the authorization scope(s) for the method you are building.
21526    ///
21527    /// See [`Self::add_scope()`] for details.
21528    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupDeleteCall<'a, C>
21529    where
21530        I: IntoIterator<Item = St>,
21531        St: AsRef<str>,
21532    {
21533        self._scopes
21534            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21535        self
21536    }
21537
21538    /// Removes all scopes, and no default scope will be used either.
21539    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21540    /// for details).
21541    pub fn clear_scopes(mut self) -> ProjectLocationBackupDeleteCall<'a, C> {
21542        self._scopes.clear();
21543        self
21544    }
21545}
21546
21547/// Gets information about a backup.
21548///
21549/// A builder for the *locations.backups.get* method supported by a *project* resource.
21550/// It is not used directly, but through a [`ProjectMethods`] instance.
21551///
21552/// # Example
21553///
21554/// Instantiate a resource method builder
21555///
21556/// ```test_harness,no_run
21557/// # extern crate hyper;
21558/// # extern crate hyper_rustls;
21559/// # extern crate google_firestore1 as firestore1;
21560/// # async fn dox() {
21561/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21562///
21563/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21564/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21565/// #     .with_native_roots()
21566/// #     .unwrap()
21567/// #     .https_only()
21568/// #     .enable_http2()
21569/// #     .build();
21570///
21571/// # let executor = hyper_util::rt::TokioExecutor::new();
21572/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21573/// #     secret,
21574/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21575/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21576/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21577/// #     ),
21578/// # ).build().await.unwrap();
21579///
21580/// # let client = hyper_util::client::legacy::Client::builder(
21581/// #     hyper_util::rt::TokioExecutor::new()
21582/// # )
21583/// # .build(
21584/// #     hyper_rustls::HttpsConnectorBuilder::new()
21585/// #         .with_native_roots()
21586/// #         .unwrap()
21587/// #         .https_or_http()
21588/// #         .enable_http2()
21589/// #         .build()
21590/// # );
21591/// # let mut hub = Firestore::new(client, auth);
21592/// // You can configure optional parameters by calling the respective setters at will, and
21593/// // execute the final call using `doit()`.
21594/// // Values shown here are possibly random and not representative !
21595/// let result = hub.projects().locations_backups_get("name")
21596///              .doit().await;
21597/// # }
21598/// ```
21599pub struct ProjectLocationBackupGetCall<'a, C>
21600where
21601    C: 'a,
21602{
21603    hub: &'a Firestore<C>,
21604    _name: String,
21605    _delegate: Option<&'a mut dyn common::Delegate>,
21606    _additional_params: HashMap<String, String>,
21607    _scopes: BTreeSet<String>,
21608}
21609
21610impl<'a, C> common::CallBuilder for ProjectLocationBackupGetCall<'a, C> {}
21611
21612impl<'a, C> ProjectLocationBackupGetCall<'a, C>
21613where
21614    C: common::Connector,
21615{
21616    /// Perform the operation you have build so far.
21617    pub async fn doit(
21618        mut self,
21619    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1Backup)> {
21620        use std::borrow::Cow;
21621        use std::io::{Read, Seek};
21622
21623        use common::{url::Params, ToParts};
21624        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21625
21626        let mut dd = common::DefaultDelegate;
21627        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21628        dlg.begin(common::MethodInfo {
21629            id: "firestore.projects.locations.backups.get",
21630            http_method: hyper::Method::GET,
21631        });
21632
21633        for &field in ["alt", "name"].iter() {
21634            if self._additional_params.contains_key(field) {
21635                dlg.finished(false);
21636                return Err(common::Error::FieldClash(field));
21637            }
21638        }
21639
21640        let mut params = Params::with_capacity(3 + self._additional_params.len());
21641        params.push("name", self._name);
21642
21643        params.extend(self._additional_params.iter());
21644
21645        params.push("alt", "json");
21646        let mut url = self.hub._base_url.clone() + "v1/{+name}";
21647        if self._scopes.is_empty() {
21648            self._scopes
21649                .insert(Scope::CloudPlatform.as_ref().to_string());
21650        }
21651
21652        #[allow(clippy::single_element_loop)]
21653        for &(find_this, param_name) in [("{+name}", "name")].iter() {
21654            url = params.uri_replacement(url, param_name, find_this, true);
21655        }
21656        {
21657            let to_remove = ["name"];
21658            params.remove_params(&to_remove);
21659        }
21660
21661        let url = params.parse_with_url(&url);
21662
21663        loop {
21664            let token = match self
21665                .hub
21666                .auth
21667                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21668                .await
21669            {
21670                Ok(token) => token,
21671                Err(e) => match dlg.token(e) {
21672                    Ok(token) => token,
21673                    Err(e) => {
21674                        dlg.finished(false);
21675                        return Err(common::Error::MissingToken(e));
21676                    }
21677                },
21678            };
21679            let mut req_result = {
21680                let client = &self.hub.client;
21681                dlg.pre_request();
21682                let mut req_builder = hyper::Request::builder()
21683                    .method(hyper::Method::GET)
21684                    .uri(url.as_str())
21685                    .header(USER_AGENT, self.hub._user_agent.clone());
21686
21687                if let Some(token) = token.as_ref() {
21688                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21689                }
21690
21691                let request = req_builder
21692                    .header(CONTENT_LENGTH, 0_u64)
21693                    .body(common::to_body::<String>(None));
21694
21695                client.request(request.unwrap()).await
21696            };
21697
21698            match req_result {
21699                Err(err) => {
21700                    if let common::Retry::After(d) = dlg.http_error(&err) {
21701                        sleep(d).await;
21702                        continue;
21703                    }
21704                    dlg.finished(false);
21705                    return Err(common::Error::HttpError(err));
21706                }
21707                Ok(res) => {
21708                    let (mut parts, body) = res.into_parts();
21709                    let mut body = common::Body::new(body);
21710                    if !parts.status.is_success() {
21711                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21712                        let error = serde_json::from_str(&common::to_string(&bytes));
21713                        let response = common::to_response(parts, bytes.into());
21714
21715                        if let common::Retry::After(d) =
21716                            dlg.http_failure(&response, error.as_ref().ok())
21717                        {
21718                            sleep(d).await;
21719                            continue;
21720                        }
21721
21722                        dlg.finished(false);
21723
21724                        return Err(match error {
21725                            Ok(value) => common::Error::BadRequest(value),
21726                            _ => common::Error::Failure(response),
21727                        });
21728                    }
21729                    let response = {
21730                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21731                        let encoded = common::to_string(&bytes);
21732                        match serde_json::from_str(&encoded) {
21733                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21734                            Err(error) => {
21735                                dlg.response_json_decode_error(&encoded, &error);
21736                                return Err(common::Error::JsonDecodeError(
21737                                    encoded.to_string(),
21738                                    error,
21739                                ));
21740                            }
21741                        }
21742                    };
21743
21744                    dlg.finished(true);
21745                    return Ok(response);
21746                }
21747            }
21748        }
21749    }
21750
21751    /// Required. Name of the backup to fetch. Format is `projects/{project}/locations/{location}/backups/{backup}`.
21752    ///
21753    /// Sets the *name* path property to the given value.
21754    ///
21755    /// Even though the property as already been set when instantiating this call,
21756    /// we provide this method for API completeness.
21757    pub fn name(mut self, new_value: &str) -> ProjectLocationBackupGetCall<'a, C> {
21758        self._name = new_value.to_string();
21759        self
21760    }
21761    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21762    /// while executing the actual API request.
21763    ///
21764    /// ````text
21765    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21766    /// ````
21767    ///
21768    /// Sets the *delegate* property to the given value.
21769    pub fn delegate(
21770        mut self,
21771        new_value: &'a mut dyn common::Delegate,
21772    ) -> ProjectLocationBackupGetCall<'a, C> {
21773        self._delegate = Some(new_value);
21774        self
21775    }
21776
21777    /// Set any additional parameter of the query string used in the request.
21778    /// It should be used to set parameters which are not yet available through their own
21779    /// setters.
21780    ///
21781    /// Please note that this method must not be used to set any of the known parameters
21782    /// which have their own setter method. If done anyway, the request will fail.
21783    ///
21784    /// # Additional Parameters
21785    ///
21786    /// * *$.xgafv* (query-string) - V1 error format.
21787    /// * *access_token* (query-string) - OAuth access token.
21788    /// * *alt* (query-string) - Data format for response.
21789    /// * *callback* (query-string) - JSONP
21790    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21791    /// * *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.
21792    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21793    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21794    /// * *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.
21795    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21796    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21797    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupGetCall<'a, C>
21798    where
21799        T: AsRef<str>,
21800    {
21801        self._additional_params
21802            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21803        self
21804    }
21805
21806    /// Identifies the authorization scope for the method you are building.
21807    ///
21808    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21809    /// [`Scope::CloudPlatform`].
21810    ///
21811    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21812    /// tokens for more than one scope.
21813    ///
21814    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21815    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21816    /// sufficient, a read-write scope will do as well.
21817    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupGetCall<'a, C>
21818    where
21819        St: AsRef<str>,
21820    {
21821        self._scopes.insert(String::from(scope.as_ref()));
21822        self
21823    }
21824    /// Identifies the authorization scope(s) for the method you are building.
21825    ///
21826    /// See [`Self::add_scope()`] for details.
21827    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupGetCall<'a, C>
21828    where
21829        I: IntoIterator<Item = St>,
21830        St: AsRef<str>,
21831    {
21832        self._scopes
21833            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21834        self
21835    }
21836
21837    /// Removes all scopes, and no default scope will be used either.
21838    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21839    /// for details).
21840    pub fn clear_scopes(mut self) -> ProjectLocationBackupGetCall<'a, C> {
21841        self._scopes.clear();
21842        self
21843    }
21844}
21845
21846/// Lists all the backups.
21847///
21848/// A builder for the *locations.backups.list* method supported by a *project* resource.
21849/// It is not used directly, but through a [`ProjectMethods`] instance.
21850///
21851/// # Example
21852///
21853/// Instantiate a resource method builder
21854///
21855/// ```test_harness,no_run
21856/// # extern crate hyper;
21857/// # extern crate hyper_rustls;
21858/// # extern crate google_firestore1 as firestore1;
21859/// # async fn dox() {
21860/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21861///
21862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21863/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21864/// #     .with_native_roots()
21865/// #     .unwrap()
21866/// #     .https_only()
21867/// #     .enable_http2()
21868/// #     .build();
21869///
21870/// # let executor = hyper_util::rt::TokioExecutor::new();
21871/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21872/// #     secret,
21873/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21874/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21875/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21876/// #     ),
21877/// # ).build().await.unwrap();
21878///
21879/// # let client = hyper_util::client::legacy::Client::builder(
21880/// #     hyper_util::rt::TokioExecutor::new()
21881/// # )
21882/// # .build(
21883/// #     hyper_rustls::HttpsConnectorBuilder::new()
21884/// #         .with_native_roots()
21885/// #         .unwrap()
21886/// #         .https_or_http()
21887/// #         .enable_http2()
21888/// #         .build()
21889/// # );
21890/// # let mut hub = Firestore::new(client, auth);
21891/// // You can configure optional parameters by calling the respective setters at will, and
21892/// // execute the final call using `doit()`.
21893/// // Values shown here are possibly random and not representative !
21894/// let result = hub.projects().locations_backups_list("parent")
21895///              .filter("voluptua.")
21896///              .doit().await;
21897/// # }
21898/// ```
21899pub struct ProjectLocationBackupListCall<'a, C>
21900where
21901    C: 'a,
21902{
21903    hub: &'a Firestore<C>,
21904    _parent: String,
21905    _filter: Option<String>,
21906    _delegate: Option<&'a mut dyn common::Delegate>,
21907    _additional_params: HashMap<String, String>,
21908    _scopes: BTreeSet<String>,
21909}
21910
21911impl<'a, C> common::CallBuilder for ProjectLocationBackupListCall<'a, C> {}
21912
21913impl<'a, C> ProjectLocationBackupListCall<'a, C>
21914where
21915    C: common::Connector,
21916{
21917    /// Perform the operation you have build so far.
21918    pub async fn doit(
21919        mut self,
21920    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1ListBackupsResponse)> {
21921        use std::borrow::Cow;
21922        use std::io::{Read, Seek};
21923
21924        use common::{url::Params, ToParts};
21925        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21926
21927        let mut dd = common::DefaultDelegate;
21928        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21929        dlg.begin(common::MethodInfo {
21930            id: "firestore.projects.locations.backups.list",
21931            http_method: hyper::Method::GET,
21932        });
21933
21934        for &field in ["alt", "parent", "filter"].iter() {
21935            if self._additional_params.contains_key(field) {
21936                dlg.finished(false);
21937                return Err(common::Error::FieldClash(field));
21938            }
21939        }
21940
21941        let mut params = Params::with_capacity(4 + self._additional_params.len());
21942        params.push("parent", self._parent);
21943        if let Some(value) = self._filter.as_ref() {
21944            params.push("filter", value);
21945        }
21946
21947        params.extend(self._additional_params.iter());
21948
21949        params.push("alt", "json");
21950        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
21951        if self._scopes.is_empty() {
21952            self._scopes
21953                .insert(Scope::CloudPlatform.as_ref().to_string());
21954        }
21955
21956        #[allow(clippy::single_element_loop)]
21957        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21958            url = params.uri_replacement(url, param_name, find_this, true);
21959        }
21960        {
21961            let to_remove = ["parent"];
21962            params.remove_params(&to_remove);
21963        }
21964
21965        let url = params.parse_with_url(&url);
21966
21967        loop {
21968            let token = match self
21969                .hub
21970                .auth
21971                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21972                .await
21973            {
21974                Ok(token) => token,
21975                Err(e) => match dlg.token(e) {
21976                    Ok(token) => token,
21977                    Err(e) => {
21978                        dlg.finished(false);
21979                        return Err(common::Error::MissingToken(e));
21980                    }
21981                },
21982            };
21983            let mut req_result = {
21984                let client = &self.hub.client;
21985                dlg.pre_request();
21986                let mut req_builder = hyper::Request::builder()
21987                    .method(hyper::Method::GET)
21988                    .uri(url.as_str())
21989                    .header(USER_AGENT, self.hub._user_agent.clone());
21990
21991                if let Some(token) = token.as_ref() {
21992                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21993                }
21994
21995                let request = req_builder
21996                    .header(CONTENT_LENGTH, 0_u64)
21997                    .body(common::to_body::<String>(None));
21998
21999                client.request(request.unwrap()).await
22000            };
22001
22002            match req_result {
22003                Err(err) => {
22004                    if let common::Retry::After(d) = dlg.http_error(&err) {
22005                        sleep(d).await;
22006                        continue;
22007                    }
22008                    dlg.finished(false);
22009                    return Err(common::Error::HttpError(err));
22010                }
22011                Ok(res) => {
22012                    let (mut parts, body) = res.into_parts();
22013                    let mut body = common::Body::new(body);
22014                    if !parts.status.is_success() {
22015                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22016                        let error = serde_json::from_str(&common::to_string(&bytes));
22017                        let response = common::to_response(parts, bytes.into());
22018
22019                        if let common::Retry::After(d) =
22020                            dlg.http_failure(&response, error.as_ref().ok())
22021                        {
22022                            sleep(d).await;
22023                            continue;
22024                        }
22025
22026                        dlg.finished(false);
22027
22028                        return Err(match error {
22029                            Ok(value) => common::Error::BadRequest(value),
22030                            _ => common::Error::Failure(response),
22031                        });
22032                    }
22033                    let response = {
22034                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22035                        let encoded = common::to_string(&bytes);
22036                        match serde_json::from_str(&encoded) {
22037                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22038                            Err(error) => {
22039                                dlg.response_json_decode_error(&encoded, &error);
22040                                return Err(common::Error::JsonDecodeError(
22041                                    encoded.to_string(),
22042                                    error,
22043                                ));
22044                            }
22045                        }
22046                    };
22047
22048                    dlg.finished(true);
22049                    return Ok(response);
22050                }
22051            }
22052        }
22053    }
22054
22055    /// Required. The location to list backups from. Format is `projects/{project}/locations/{location}`. Use `{location} = '-'` to list backups from all locations for the given project. This allows listing backups from a single location or from all locations.
22056    ///
22057    /// Sets the *parent* path property to the given value.
22058    ///
22059    /// Even though the property as already been set when instantiating this call,
22060    /// we provide this method for API completeness.
22061    pub fn parent(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
22062        self._parent = new_value.to_string();
22063        self
22064    }
22065    /// An expression that filters the list of returned backups. A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. Colon `:` is the contains operator. Filter rules are not case sensitive. The following fields in the Backup are eligible for filtering: * `database_uid` (supports `=` only)
22066    ///
22067    /// Sets the *filter* query property to the given value.
22068    pub fn filter(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
22069        self._filter = Some(new_value.to_string());
22070        self
22071    }
22072    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22073    /// while executing the actual API request.
22074    ///
22075    /// ````text
22076    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22077    /// ````
22078    ///
22079    /// Sets the *delegate* property to the given value.
22080    pub fn delegate(
22081        mut self,
22082        new_value: &'a mut dyn common::Delegate,
22083    ) -> ProjectLocationBackupListCall<'a, C> {
22084        self._delegate = Some(new_value);
22085        self
22086    }
22087
22088    /// Set any additional parameter of the query string used in the request.
22089    /// It should be used to set parameters which are not yet available through their own
22090    /// setters.
22091    ///
22092    /// Please note that this method must not be used to set any of the known parameters
22093    /// which have their own setter method. If done anyway, the request will fail.
22094    ///
22095    /// # Additional Parameters
22096    ///
22097    /// * *$.xgafv* (query-string) - V1 error format.
22098    /// * *access_token* (query-string) - OAuth access token.
22099    /// * *alt* (query-string) - Data format for response.
22100    /// * *callback* (query-string) - JSONP
22101    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22102    /// * *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.
22103    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22104    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22105    /// * *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.
22106    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22107    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22108    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupListCall<'a, C>
22109    where
22110        T: AsRef<str>,
22111    {
22112        self._additional_params
22113            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22114        self
22115    }
22116
22117    /// Identifies the authorization scope for the method you are building.
22118    ///
22119    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22120    /// [`Scope::CloudPlatform`].
22121    ///
22122    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22123    /// tokens for more than one scope.
22124    ///
22125    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22126    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22127    /// sufficient, a read-write scope will do as well.
22128    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupListCall<'a, C>
22129    where
22130        St: AsRef<str>,
22131    {
22132        self._scopes.insert(String::from(scope.as_ref()));
22133        self
22134    }
22135    /// Identifies the authorization scope(s) for the method you are building.
22136    ///
22137    /// See [`Self::add_scope()`] for details.
22138    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupListCall<'a, C>
22139    where
22140        I: IntoIterator<Item = St>,
22141        St: AsRef<str>,
22142    {
22143        self._scopes
22144            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22145        self
22146    }
22147
22148    /// Removes all scopes, and no default scope will be used either.
22149    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22150    /// for details).
22151    pub fn clear_scopes(mut self) -> ProjectLocationBackupListCall<'a, C> {
22152        self._scopes.clear();
22153        self
22154    }
22155}
22156
22157/// Gets information about a location.
22158///
22159/// A builder for the *locations.get* method supported by a *project* resource.
22160/// It is not used directly, but through a [`ProjectMethods`] instance.
22161///
22162/// # Example
22163///
22164/// Instantiate a resource method builder
22165///
22166/// ```test_harness,no_run
22167/// # extern crate hyper;
22168/// # extern crate hyper_rustls;
22169/// # extern crate google_firestore1 as firestore1;
22170/// # async fn dox() {
22171/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22172///
22173/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22174/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22175/// #     .with_native_roots()
22176/// #     .unwrap()
22177/// #     .https_only()
22178/// #     .enable_http2()
22179/// #     .build();
22180///
22181/// # let executor = hyper_util::rt::TokioExecutor::new();
22182/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22183/// #     secret,
22184/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22185/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22186/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22187/// #     ),
22188/// # ).build().await.unwrap();
22189///
22190/// # let client = hyper_util::client::legacy::Client::builder(
22191/// #     hyper_util::rt::TokioExecutor::new()
22192/// # )
22193/// # .build(
22194/// #     hyper_rustls::HttpsConnectorBuilder::new()
22195/// #         .with_native_roots()
22196/// #         .unwrap()
22197/// #         .https_or_http()
22198/// #         .enable_http2()
22199/// #         .build()
22200/// # );
22201/// # let mut hub = Firestore::new(client, auth);
22202/// // You can configure optional parameters by calling the respective setters at will, and
22203/// // execute the final call using `doit()`.
22204/// // Values shown here are possibly random and not representative !
22205/// let result = hub.projects().locations_get("name")
22206///              .doit().await;
22207/// # }
22208/// ```
22209pub struct ProjectLocationGetCall<'a, C>
22210where
22211    C: 'a,
22212{
22213    hub: &'a Firestore<C>,
22214    _name: String,
22215    _delegate: Option<&'a mut dyn common::Delegate>,
22216    _additional_params: HashMap<String, String>,
22217    _scopes: BTreeSet<String>,
22218}
22219
22220impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
22221
22222impl<'a, C> ProjectLocationGetCall<'a, C>
22223where
22224    C: common::Connector,
22225{
22226    /// Perform the operation you have build so far.
22227    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
22228        use std::borrow::Cow;
22229        use std::io::{Read, Seek};
22230
22231        use common::{url::Params, ToParts};
22232        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22233
22234        let mut dd = common::DefaultDelegate;
22235        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22236        dlg.begin(common::MethodInfo {
22237            id: "firestore.projects.locations.get",
22238            http_method: hyper::Method::GET,
22239        });
22240
22241        for &field in ["alt", "name"].iter() {
22242            if self._additional_params.contains_key(field) {
22243                dlg.finished(false);
22244                return Err(common::Error::FieldClash(field));
22245            }
22246        }
22247
22248        let mut params = Params::with_capacity(3 + self._additional_params.len());
22249        params.push("name", self._name);
22250
22251        params.extend(self._additional_params.iter());
22252
22253        params.push("alt", "json");
22254        let mut url = self.hub._base_url.clone() + "v1/{+name}";
22255        if self._scopes.is_empty() {
22256            self._scopes
22257                .insert(Scope::CloudPlatform.as_ref().to_string());
22258        }
22259
22260        #[allow(clippy::single_element_loop)]
22261        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22262            url = params.uri_replacement(url, param_name, find_this, true);
22263        }
22264        {
22265            let to_remove = ["name"];
22266            params.remove_params(&to_remove);
22267        }
22268
22269        let url = params.parse_with_url(&url);
22270
22271        loop {
22272            let token = match self
22273                .hub
22274                .auth
22275                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22276                .await
22277            {
22278                Ok(token) => token,
22279                Err(e) => match dlg.token(e) {
22280                    Ok(token) => token,
22281                    Err(e) => {
22282                        dlg.finished(false);
22283                        return Err(common::Error::MissingToken(e));
22284                    }
22285                },
22286            };
22287            let mut req_result = {
22288                let client = &self.hub.client;
22289                dlg.pre_request();
22290                let mut req_builder = hyper::Request::builder()
22291                    .method(hyper::Method::GET)
22292                    .uri(url.as_str())
22293                    .header(USER_AGENT, self.hub._user_agent.clone());
22294
22295                if let Some(token) = token.as_ref() {
22296                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22297                }
22298
22299                let request = req_builder
22300                    .header(CONTENT_LENGTH, 0_u64)
22301                    .body(common::to_body::<String>(None));
22302
22303                client.request(request.unwrap()).await
22304            };
22305
22306            match req_result {
22307                Err(err) => {
22308                    if let common::Retry::After(d) = dlg.http_error(&err) {
22309                        sleep(d).await;
22310                        continue;
22311                    }
22312                    dlg.finished(false);
22313                    return Err(common::Error::HttpError(err));
22314                }
22315                Ok(res) => {
22316                    let (mut parts, body) = res.into_parts();
22317                    let mut body = common::Body::new(body);
22318                    if !parts.status.is_success() {
22319                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22320                        let error = serde_json::from_str(&common::to_string(&bytes));
22321                        let response = common::to_response(parts, bytes.into());
22322
22323                        if let common::Retry::After(d) =
22324                            dlg.http_failure(&response, error.as_ref().ok())
22325                        {
22326                            sleep(d).await;
22327                            continue;
22328                        }
22329
22330                        dlg.finished(false);
22331
22332                        return Err(match error {
22333                            Ok(value) => common::Error::BadRequest(value),
22334                            _ => common::Error::Failure(response),
22335                        });
22336                    }
22337                    let response = {
22338                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22339                        let encoded = common::to_string(&bytes);
22340                        match serde_json::from_str(&encoded) {
22341                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22342                            Err(error) => {
22343                                dlg.response_json_decode_error(&encoded, &error);
22344                                return Err(common::Error::JsonDecodeError(
22345                                    encoded.to_string(),
22346                                    error,
22347                                ));
22348                            }
22349                        }
22350                    };
22351
22352                    dlg.finished(true);
22353                    return Ok(response);
22354                }
22355            }
22356        }
22357    }
22358
22359    /// Resource name for the location.
22360    ///
22361    /// Sets the *name* path property to the given value.
22362    ///
22363    /// Even though the property as already been set when instantiating this call,
22364    /// we provide this method for API completeness.
22365    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
22366        self._name = new_value.to_string();
22367        self
22368    }
22369    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22370    /// while executing the actual API request.
22371    ///
22372    /// ````text
22373    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22374    /// ````
22375    ///
22376    /// Sets the *delegate* property to the given value.
22377    pub fn delegate(
22378        mut self,
22379        new_value: &'a mut dyn common::Delegate,
22380    ) -> ProjectLocationGetCall<'a, C> {
22381        self._delegate = Some(new_value);
22382        self
22383    }
22384
22385    /// Set any additional parameter of the query string used in the request.
22386    /// It should be used to set parameters which are not yet available through their own
22387    /// setters.
22388    ///
22389    /// Please note that this method must not be used to set any of the known parameters
22390    /// which have their own setter method. If done anyway, the request will fail.
22391    ///
22392    /// # Additional Parameters
22393    ///
22394    /// * *$.xgafv* (query-string) - V1 error format.
22395    /// * *access_token* (query-string) - OAuth access token.
22396    /// * *alt* (query-string) - Data format for response.
22397    /// * *callback* (query-string) - JSONP
22398    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22399    /// * *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.
22400    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22401    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22402    /// * *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.
22403    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22404    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22405    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
22406    where
22407        T: AsRef<str>,
22408    {
22409        self._additional_params
22410            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22411        self
22412    }
22413
22414    /// Identifies the authorization scope for the method you are building.
22415    ///
22416    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22417    /// [`Scope::CloudPlatform`].
22418    ///
22419    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22420    /// tokens for more than one scope.
22421    ///
22422    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22423    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22424    /// sufficient, a read-write scope will do as well.
22425    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
22426    where
22427        St: AsRef<str>,
22428    {
22429        self._scopes.insert(String::from(scope.as_ref()));
22430        self
22431    }
22432    /// Identifies the authorization scope(s) for the method you are building.
22433    ///
22434    /// See [`Self::add_scope()`] for details.
22435    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
22436    where
22437        I: IntoIterator<Item = St>,
22438        St: AsRef<str>,
22439    {
22440        self._scopes
22441            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22442        self
22443    }
22444
22445    /// Removes all scopes, and no default scope will be used either.
22446    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22447    /// for details).
22448    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
22449        self._scopes.clear();
22450        self
22451    }
22452}
22453
22454/// Lists information about the supported locations for this service.
22455///
22456/// A builder for the *locations.list* method supported by a *project* resource.
22457/// It is not used directly, but through a [`ProjectMethods`] instance.
22458///
22459/// # Example
22460///
22461/// Instantiate a resource method builder
22462///
22463/// ```test_harness,no_run
22464/// # extern crate hyper;
22465/// # extern crate hyper_rustls;
22466/// # extern crate google_firestore1 as firestore1;
22467/// # async fn dox() {
22468/// # use firestore1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22469///
22470/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22471/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22472/// #     .with_native_roots()
22473/// #     .unwrap()
22474/// #     .https_only()
22475/// #     .enable_http2()
22476/// #     .build();
22477///
22478/// # let executor = hyper_util::rt::TokioExecutor::new();
22479/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22480/// #     secret,
22481/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22482/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22483/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22484/// #     ),
22485/// # ).build().await.unwrap();
22486///
22487/// # let client = hyper_util::client::legacy::Client::builder(
22488/// #     hyper_util::rt::TokioExecutor::new()
22489/// # )
22490/// # .build(
22491/// #     hyper_rustls::HttpsConnectorBuilder::new()
22492/// #         .with_native_roots()
22493/// #         .unwrap()
22494/// #         .https_or_http()
22495/// #         .enable_http2()
22496/// #         .build()
22497/// # );
22498/// # let mut hub = Firestore::new(client, auth);
22499/// // You can configure optional parameters by calling the respective setters at will, and
22500/// // execute the final call using `doit()`.
22501/// // Values shown here are possibly random and not representative !
22502/// let result = hub.projects().locations_list("name")
22503///              .page_token("sadipscing")
22504///              .page_size(-6)
22505///              .filter("invidunt")
22506///              .add_extra_location_types("no")
22507///              .doit().await;
22508/// # }
22509/// ```
22510pub struct ProjectLocationListCall<'a, C>
22511where
22512    C: 'a,
22513{
22514    hub: &'a Firestore<C>,
22515    _name: String,
22516    _page_token: Option<String>,
22517    _page_size: Option<i32>,
22518    _filter: Option<String>,
22519    _extra_location_types: Vec<String>,
22520    _delegate: Option<&'a mut dyn common::Delegate>,
22521    _additional_params: HashMap<String, String>,
22522    _scopes: BTreeSet<String>,
22523}
22524
22525impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
22526
22527impl<'a, C> ProjectLocationListCall<'a, C>
22528where
22529    C: common::Connector,
22530{
22531    /// Perform the operation you have build so far.
22532    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
22533        use std::borrow::Cow;
22534        use std::io::{Read, Seek};
22535
22536        use common::{url::Params, ToParts};
22537        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22538
22539        let mut dd = common::DefaultDelegate;
22540        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22541        dlg.begin(common::MethodInfo {
22542            id: "firestore.projects.locations.list",
22543            http_method: hyper::Method::GET,
22544        });
22545
22546        for &field in [
22547            "alt",
22548            "name",
22549            "pageToken",
22550            "pageSize",
22551            "filter",
22552            "extraLocationTypes",
22553        ]
22554        .iter()
22555        {
22556            if self._additional_params.contains_key(field) {
22557                dlg.finished(false);
22558                return Err(common::Error::FieldClash(field));
22559            }
22560        }
22561
22562        let mut params = Params::with_capacity(7 + self._additional_params.len());
22563        params.push("name", self._name);
22564        if let Some(value) = self._page_token.as_ref() {
22565            params.push("pageToken", value);
22566        }
22567        if let Some(value) = self._page_size.as_ref() {
22568            params.push("pageSize", value.to_string());
22569        }
22570        if let Some(value) = self._filter.as_ref() {
22571            params.push("filter", value);
22572        }
22573        if !self._extra_location_types.is_empty() {
22574            for f in self._extra_location_types.iter() {
22575                params.push("extraLocationTypes", f);
22576            }
22577        }
22578
22579        params.extend(self._additional_params.iter());
22580
22581        params.push("alt", "json");
22582        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
22583        if self._scopes.is_empty() {
22584            self._scopes
22585                .insert(Scope::CloudPlatform.as_ref().to_string());
22586        }
22587
22588        #[allow(clippy::single_element_loop)]
22589        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22590            url = params.uri_replacement(url, param_name, find_this, true);
22591        }
22592        {
22593            let to_remove = ["name"];
22594            params.remove_params(&to_remove);
22595        }
22596
22597        let url = params.parse_with_url(&url);
22598
22599        loop {
22600            let token = match self
22601                .hub
22602                .auth
22603                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22604                .await
22605            {
22606                Ok(token) => token,
22607                Err(e) => match dlg.token(e) {
22608                    Ok(token) => token,
22609                    Err(e) => {
22610                        dlg.finished(false);
22611                        return Err(common::Error::MissingToken(e));
22612                    }
22613                },
22614            };
22615            let mut req_result = {
22616                let client = &self.hub.client;
22617                dlg.pre_request();
22618                let mut req_builder = hyper::Request::builder()
22619                    .method(hyper::Method::GET)
22620                    .uri(url.as_str())
22621                    .header(USER_AGENT, self.hub._user_agent.clone());
22622
22623                if let Some(token) = token.as_ref() {
22624                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22625                }
22626
22627                let request = req_builder
22628                    .header(CONTENT_LENGTH, 0_u64)
22629                    .body(common::to_body::<String>(None));
22630
22631                client.request(request.unwrap()).await
22632            };
22633
22634            match req_result {
22635                Err(err) => {
22636                    if let common::Retry::After(d) = dlg.http_error(&err) {
22637                        sleep(d).await;
22638                        continue;
22639                    }
22640                    dlg.finished(false);
22641                    return Err(common::Error::HttpError(err));
22642                }
22643                Ok(res) => {
22644                    let (mut parts, body) = res.into_parts();
22645                    let mut body = common::Body::new(body);
22646                    if !parts.status.is_success() {
22647                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22648                        let error = serde_json::from_str(&common::to_string(&bytes));
22649                        let response = common::to_response(parts, bytes.into());
22650
22651                        if let common::Retry::After(d) =
22652                            dlg.http_failure(&response, error.as_ref().ok())
22653                        {
22654                            sleep(d).await;
22655                            continue;
22656                        }
22657
22658                        dlg.finished(false);
22659
22660                        return Err(match error {
22661                            Ok(value) => common::Error::BadRequest(value),
22662                            _ => common::Error::Failure(response),
22663                        });
22664                    }
22665                    let response = {
22666                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22667                        let encoded = common::to_string(&bytes);
22668                        match serde_json::from_str(&encoded) {
22669                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22670                            Err(error) => {
22671                                dlg.response_json_decode_error(&encoded, &error);
22672                                return Err(common::Error::JsonDecodeError(
22673                                    encoded.to_string(),
22674                                    error,
22675                                ));
22676                            }
22677                        }
22678                    };
22679
22680                    dlg.finished(true);
22681                    return Ok(response);
22682                }
22683            }
22684        }
22685    }
22686
22687    /// The resource that owns the locations collection, if applicable.
22688    ///
22689    /// Sets the *name* path property to the given value.
22690    ///
22691    /// Even though the property as already been set when instantiating this call,
22692    /// we provide this method for API completeness.
22693    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
22694        self._name = new_value.to_string();
22695        self
22696    }
22697    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
22698    ///
22699    /// Sets the *page token* query property to the given value.
22700    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
22701        self._page_token = Some(new_value.to_string());
22702        self
22703    }
22704    /// The maximum number of results to return. If not set, the service selects a default.
22705    ///
22706    /// Sets the *page size* query property to the given value.
22707    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
22708        self._page_size = Some(new_value);
22709        self
22710    }
22711    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
22712    ///
22713    /// Sets the *filter* query property to the given value.
22714    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
22715        self._filter = Some(new_value.to_string());
22716        self
22717    }
22718    /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
22719    ///
22720    /// Append the given value to the *extra location types* query property.
22721    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
22722    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
22723        self._extra_location_types.push(new_value.to_string());
22724        self
22725    }
22726    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22727    /// while executing the actual API request.
22728    ///
22729    /// ````text
22730    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22731    /// ````
22732    ///
22733    /// Sets the *delegate* property to the given value.
22734    pub fn delegate(
22735        mut self,
22736        new_value: &'a mut dyn common::Delegate,
22737    ) -> ProjectLocationListCall<'a, C> {
22738        self._delegate = Some(new_value);
22739        self
22740    }
22741
22742    /// Set any additional parameter of the query string used in the request.
22743    /// It should be used to set parameters which are not yet available through their own
22744    /// setters.
22745    ///
22746    /// Please note that this method must not be used to set any of the known parameters
22747    /// which have their own setter method. If done anyway, the request will fail.
22748    ///
22749    /// # Additional Parameters
22750    ///
22751    /// * *$.xgafv* (query-string) - V1 error format.
22752    /// * *access_token* (query-string) - OAuth access token.
22753    /// * *alt* (query-string) - Data format for response.
22754    /// * *callback* (query-string) - JSONP
22755    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22756    /// * *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.
22757    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22758    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22759    /// * *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.
22760    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22761    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22762    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
22763    where
22764        T: AsRef<str>,
22765    {
22766        self._additional_params
22767            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22768        self
22769    }
22770
22771    /// Identifies the authorization scope for the method you are building.
22772    ///
22773    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22774    /// [`Scope::CloudPlatform`].
22775    ///
22776    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22777    /// tokens for more than one scope.
22778    ///
22779    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22780    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22781    /// sufficient, a read-write scope will do as well.
22782    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
22783    where
22784        St: AsRef<str>,
22785    {
22786        self._scopes.insert(String::from(scope.as_ref()));
22787        self
22788    }
22789    /// Identifies the authorization scope(s) for the method you are building.
22790    ///
22791    /// See [`Self::add_scope()`] for details.
22792    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
22793    where
22794        I: IntoIterator<Item = St>,
22795        St: AsRef<str>,
22796    {
22797        self._scopes
22798            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22799        self
22800    }
22801
22802    /// Removes all scopes, and no default scope will be used either.
22803    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22804    /// for details).
22805    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
22806        self._scopes.clear();
22807        self
22808    }
22809}