google_firestore1_beta1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18
19    /// 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_beta1 as firestore1_beta1;
53/// use firestore1_beta1::api::GoogleFirestoreAdminV1beta1Index;
54/// use firestore1_beta1::{Result, Error};
55/// # async fn dox() {
56/// use firestore1_beta1::{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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67///     secret,
68///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69/// ).build().await.unwrap();
70///
71/// let client = hyper_util::client::legacy::Client::builder(
72///     hyper_util::rt::TokioExecutor::new()
73/// )
74/// .build(
75///     hyper_rustls::HttpsConnectorBuilder::new()
76///         .with_native_roots()
77///         .unwrap()
78///         .https_or_http()
79///         .enable_http1()
80///         .build()
81/// );
82/// let mut hub = Firestore::new(client, auth);
83/// // As the method needs a request, you would usually fill it with the desired information
84/// // into the respective structure. Some of the parts shown here might not be applicable !
85/// // Values shown here are possibly random and not representative !
86/// let mut req = GoogleFirestoreAdminV1beta1Index::default();
87///
88/// // You can configure optional parameters by calling the respective setters at will, and
89/// // execute the final call using `doit()`.
90/// // Values shown here are possibly random and not representative !
91/// let result = hub.projects().databases_indexes_create(req, "parent")
92///              .doit().await;
93///
94/// match result {
95///     Err(e) => match e {
96///         // The Error enum provides details about what exactly happened.
97///         // You can also just use its `Debug`, `Display` or `Error` traits
98///          Error::HttpError(_)
99///         |Error::Io(_)
100///         |Error::MissingAPIKey
101///         |Error::MissingToken(_)
102///         |Error::Cancelled
103///         |Error::UploadSizeLimitExceeded(_, _)
104///         |Error::Failure(_)
105///         |Error::BadRequest(_)
106///         |Error::FieldClash(_)
107///         |Error::JsonDecodeError(_, _) => println!("{}", e),
108///     },
109///     Ok(res) => println!("Success: {:?}", res),
110/// }
111/// # }
112/// ```
113#[derive(Clone)]
114pub struct Firestore<C> {
115    pub client: common::Client<C>,
116    pub auth: Box<dyn common::GetToken>,
117    _user_agent: String,
118    _base_url: String,
119    _root_url: String,
120}
121
122impl<C> common::Hub for Firestore<C> {}
123
124impl<'a, C> Firestore<C> {
125    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Firestore<C> {
126        Firestore {
127            client,
128            auth: Box::new(auth),
129            _user_agent: "google-api-rust-client/6.0.0".to_string(),
130            _base_url: "https://firestore.googleapis.com/".to_string(),
131            _root_url: "https://firestore.googleapis.com/".to_string(),
132        }
133    }
134
135    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
136        ProjectMethods { hub: self }
137    }
138
139    /// Set the user-agent header field to use in all requests to the server.
140    /// It defaults to `google-api-rust-client/6.0.0`.
141    ///
142    /// Returns the previously set user-agent.
143    pub fn user_agent(&mut self, agent_name: String) -> String {
144        std::mem::replace(&mut self._user_agent, agent_name)
145    }
146
147    /// Set the base url to use in all requests to the server.
148    /// It defaults to `https://firestore.googleapis.com/`.
149    ///
150    /// Returns the previously set base url.
151    pub fn base_url(&mut self, new_base_url: String) -> String {
152        std::mem::replace(&mut self._base_url, new_base_url)
153    }
154
155    /// Set the root url to use in all requests to the server.
156    /// It defaults to `https://firestore.googleapis.com/`.
157    ///
158    /// Returns the previously set root url.
159    pub fn root_url(&mut self, new_root_url: String) -> String {
160        std::mem::replace(&mut self._root_url, new_root_url)
161    }
162}
163
164// ############
165// SCHEMAS ###
166// ##########
167/// Defines an aggregation that produces a single result.
168///
169/// This type is not used in any activity, and only used as *part* of another schema.
170///
171#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
172#[serde_with::serde_as]
173#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
174pub struct Aggregation {
175    /// 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.
176    pub alias: Option<String>,
177    /// Average aggregator.
178    pub avg: Option<Avg>,
179    /// Count aggregator.
180    pub count: Option<Count>,
181    /// Sum aggregator.
182    pub sum: Option<Sum>,
183}
184
185impl common::Part for Aggregation {}
186
187/// 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.
188///
189/// This type is not used in any activity, and only used as *part* of another schema.
190///
191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
192#[serde_with::serde_as]
193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
194pub struct AggregationResult {
195    /// 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.
196    #[serde(rename = "aggregateFields")]
197    pub aggregate_fields: Option<HashMap<String, Value>>,
198}
199
200impl common::Part for AggregationResult {}
201
202/// An array value.
203///
204/// This type is not used in any activity, and only used as *part* of another schema.
205///
206#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
207#[serde_with::serde_as]
208#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
209pub struct ArrayValue {
210    /// Values in the array.
211    pub values: Option<Vec<Value>>,
212}
213
214impl common::Part for ArrayValue {}
215
216/// 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.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct Avg {
224    /// The field to aggregate on.
225    pub field: Option<FieldReference>,
226}
227
228impl common::Part for Avg {}
229
230/// The request for Firestore.BatchGetDocuments.
231///
232/// # Activities
233///
234/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
235/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
236///
237/// * [databases documents batch get projects](ProjectDatabaseDocumentBatchGetCall) (request)
238#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
239#[serde_with::serde_as]
240#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
241pub struct BatchGetDocumentsRequest {
242    /// 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.
243    pub documents: Option<Vec<String>>,
244    /// 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.
245    pub mask: Option<DocumentMask>,
246    /// 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.
247    #[serde(rename = "newTransaction")]
248    pub new_transaction: Option<TransactionOptions>,
249    /// 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.
250    #[serde(rename = "readTime")]
251    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
252    /// Reads documents in a transaction.
253    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
254    pub transaction: Option<Vec<u8>>,
255}
256
257impl common::RequestValue for BatchGetDocumentsRequest {}
258
259/// The streamed response for Firestore.BatchGetDocuments.
260///
261/// # Activities
262///
263/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
264/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
265///
266/// * [databases documents batch get projects](ProjectDatabaseDocumentBatchGetCall) (response)
267#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
268#[serde_with::serde_as]
269#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
270pub struct BatchGetDocumentsResponse {
271    /// A document that was requested.
272    pub found: Option<Document>,
273    /// A document name that was requested but does not exist. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
274    pub missing: Option<String>,
275    /// 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.
276    #[serde(rename = "readTime")]
277    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
278    /// 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.
279    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
280    pub transaction: Option<Vec<u8>>,
281}
282
283impl common::ResponseResult for BatchGetDocumentsResponse {}
284
285/// The request for Firestore.BatchWrite.
286///
287/// # Activities
288///
289/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
290/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
291///
292/// * [databases documents batch write projects](ProjectDatabaseDocumentBatchWriteCall) (request)
293#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
294#[serde_with::serde_as]
295#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
296pub struct BatchWriteRequest {
297    /// Labels associated with this batch write.
298    pub labels: Option<HashMap<String, String>>,
299    /// 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.
300    pub writes: Option<Vec<Write>>,
301}
302
303impl common::RequestValue for BatchWriteRequest {}
304
305/// The response from Firestore.BatchWrite.
306///
307/// # Activities
308///
309/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
310/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
311///
312/// * [databases documents batch write projects](ProjectDatabaseDocumentBatchWriteCall) (response)
313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
314#[serde_with::serde_as]
315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
316pub struct BatchWriteResponse {
317    /// The status of applying the writes. This i-th write status corresponds to the i-th write in the request.
318    pub status: Option<Vec<Status>>,
319    /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
320    #[serde(rename = "writeResults")]
321    pub write_results: Option<Vec<WriteResult>>,
322}
323
324impl common::ResponseResult for BatchWriteResponse {}
325
326/// The request for Firestore.BeginTransaction.
327///
328/// # Activities
329///
330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
332///
333/// * [databases documents begin transaction projects](ProjectDatabaseDocumentBeginTransactionCall) (request)
334#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
335#[serde_with::serde_as]
336#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
337pub struct BeginTransactionRequest {
338    /// The options for the transaction. Defaults to a read-write transaction.
339    pub options: Option<TransactionOptions>,
340}
341
342impl common::RequestValue for BeginTransactionRequest {}
343
344/// The response for Firestore.BeginTransaction.
345///
346/// # Activities
347///
348/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
349/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
350///
351/// * [databases documents begin transaction projects](ProjectDatabaseDocumentBeginTransactionCall) (response)
352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
353#[serde_with::serde_as]
354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
355pub struct BeginTransactionResponse {
356    /// The transaction that was started.
357    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
358    pub transaction: Option<Vec<u8>>,
359}
360
361impl common::ResponseResult for BeginTransactionResponse {}
362
363/// 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`.
364///
365/// This type is not used in any activity, and only used as *part* of another schema.
366///
367#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
368#[serde_with::serde_as]
369#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
370pub struct BitSequence {
371    /// The bytes that encode the bit sequence. May have a length of zero.
372    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
373    pub bitmap: Option<Vec<u8>>,
374    /// 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.
375    pub padding: Option<i32>,
376}
377
378impl common::Part for BitSequence {}
379
380/// 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.
381///
382/// This type is not used in any activity, and only used as *part* of another schema.
383///
384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
385#[serde_with::serde_as]
386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
387pub struct BloomFilter {
388    /// The bloom filter data.
389    pub bits: Option<BitSequence>,
390    /// The number of hashes used by the algorithm.
391    #[serde(rename = "hashCount")]
392    pub hash_count: Option<i32>,
393}
394
395impl common::Part for BloomFilter {}
396
397/// A selection of a collection, such as `messages as m1`.
398///
399/// This type is not used in any activity, and only used as *part* of another schema.
400///
401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
402#[serde_with::serde_as]
403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
404pub struct CollectionSelector {
405    /// When false, selects only collections that are immediate children of the `parent` specified in the containing `RunQueryRequest`. When true, selects all descendant collections.
406    #[serde(rename = "allDescendants")]
407    pub all_descendants: Option<bool>,
408    /// The collection ID. When set, selects only collections with this ID.
409    #[serde(rename = "collectionId")]
410    pub collection_id: Option<String>,
411}
412
413impl common::Part for CollectionSelector {}
414
415/// The request for Firestore.Commit.
416///
417/// # Activities
418///
419/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
420/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
421///
422/// * [databases documents commit projects](ProjectDatabaseDocumentCommitCall) (request)
423#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
424#[serde_with::serde_as]
425#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
426pub struct CommitRequest {
427    /// If set, applies all writes in this transaction, and commits it.
428    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
429    pub transaction: Option<Vec<u8>>,
430    /// The writes to apply. Always executed atomically and in order.
431    pub writes: Option<Vec<Write>>,
432}
433
434impl common::RequestValue for CommitRequest {}
435
436/// The response for Firestore.Commit.
437///
438/// # Activities
439///
440/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
441/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
442///
443/// * [databases documents commit projects](ProjectDatabaseDocumentCommitCall) (response)
444#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
445#[serde_with::serde_as]
446#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
447pub struct CommitResponse {
448    /// 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.
449    #[serde(rename = "commitTime")]
450    pub commit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
451    /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
452    #[serde(rename = "writeResults")]
453    pub write_results: Option<Vec<WriteResult>>,
454}
455
456impl common::ResponseResult for CommitResponse {}
457
458/// A filter that merges multiple other filters using the given operator.
459///
460/// This type is not used in any activity, and only used as *part* of another schema.
461///
462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
463#[serde_with::serde_as]
464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
465pub struct CompositeFilter {
466    /// The list of filters to combine. Requires: * At least one filter is present.
467    pub filters: Option<Vec<Filter>>,
468    /// The operator for combining multiple filters.
469    pub op: Option<String>,
470}
471
472impl common::Part for CompositeFilter {}
473
474/// Count of documents that match the query. The `COUNT(*)` aggregation function operates on the entire document so it does not require a field reference.
475///
476/// This type is not used in any activity, and only used as *part* of another schema.
477///
478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
479#[serde_with::serde_as]
480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
481pub struct Count {
482    /// 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.
483    #[serde(rename = "upTo")]
484    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
485    pub up_to: Option<i64>,
486}
487
488impl common::Part for Count {}
489
490/// A position in a query result set.
491///
492/// This type is not used in any activity, and only used as *part* of another schema.
493///
494#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
495#[serde_with::serde_as]
496#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
497pub struct Cursor {
498    /// If the position is just before or just after the given values, relative to the sort order defined by the query.
499    pub before: Option<bool>,
500    /// 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.
501    pub values: Option<Vec<Value>>,
502}
503
504impl common::Part for Cursor {}
505
506/// A Firestore document. Must not exceed 1 MiB - 4 bytes.
507///
508/// # Activities
509///
510/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
511/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
512///
513/// * [databases documents create document projects](ProjectDatabaseDocumentCreateDocumentCall) (request|response)
514/// * [databases documents get projects](ProjectDatabaseDocumentGetCall) (response)
515/// * [databases documents patch projects](ProjectDatabaseDocumentPatchCall) (request|response)
516#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
517#[serde_with::serde_as]
518#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
519pub struct Document {
520    /// 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.
521    #[serde(rename = "createTime")]
522    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
523    /// 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 ``.
524    pub fields: Option<HashMap<String, Value>>,
525    /// The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
526    pub name: Option<String>,
527    /// 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.
528    #[serde(rename = "updateTime")]
529    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
530}
531
532impl common::RequestValue for Document {}
533impl common::ResponseResult for Document {}
534
535/// 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. For PipelineQueryTargets, `document` will be in the new pipeline format, For a Listen stream with both QueryTargets and PipelineQueryTargets present, if a document matches both types of queries, then a separate DocumentChange messages will be sent out one for each set.
536///
537/// This type is not used in any activity, and only used as *part* of another schema.
538///
539#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
540#[serde_with::serde_as]
541#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
542pub struct DocumentChange {
543    /// The new state of the Document. If `mask` is set, contains only fields that were updated or added.
544    pub document: Option<Document>,
545    /// A set of target IDs for targets that no longer match this document.
546    #[serde(rename = "removedTargetIds")]
547    pub removed_target_ids: Option<Vec<i32>>,
548    /// A set of target IDs of targets that match this document.
549    #[serde(rename = "targetIds")]
550    pub target_ids: Option<Vec<i32>>,
551}
552
553impl common::Part for DocumentChange {}
554
555/// 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.
556///
557/// This type is not used in any activity, and only used as *part* of another schema.
558///
559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
560#[serde_with::serde_as]
561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
562pub struct DocumentDelete {
563    /// The resource name of the Document that was deleted.
564    pub document: Option<String>,
565    /// The read timestamp at which the delete was observed. Greater or equal to the `commit_time` of the delete.
566    #[serde(rename = "readTime")]
567    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
568    /// A set of target IDs for targets that previously matched this entity.
569    #[serde(rename = "removedTargetIds")]
570    pub removed_target_ids: Option<Vec<i32>>,
571}
572
573impl common::Part for DocumentDelete {}
574
575/// 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.
576///
577/// This type is not used in any activity, and only used as *part* of another schema.
578///
579#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
580#[serde_with::serde_as]
581#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
582pub struct DocumentMask {
583    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
584    #[serde(rename = "fieldPaths")]
585    pub field_paths: Option<Vec<String>>,
586}
587
588impl common::Part for DocumentMask {}
589
590/// 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.
591///
592/// This type is not used in any activity, and only used as *part* of another schema.
593///
594#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
595#[serde_with::serde_as]
596#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
597pub struct DocumentRemove {
598    /// The resource name of the Document that has gone out of view.
599    pub document: Option<String>,
600    /// The read timestamp at which the remove was observed. Greater or equal to the `commit_time` of the change/delete/remove.
601    #[serde(rename = "readTime")]
602    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
603    /// A set of target IDs for targets that previously matched this document.
604    #[serde(rename = "removedTargetIds")]
605    pub removed_target_ids: Option<Vec<i32>>,
606}
607
608impl common::Part for DocumentRemove {}
609
610/// A transformation of a document.
611///
612/// This type is not used in any activity, and only used as *part* of another schema.
613///
614#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
615#[serde_with::serde_as]
616#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
617pub struct DocumentTransform {
618    /// The name of the document to transform.
619    pub document: Option<String>,
620    /// The list of transformations to apply to the fields of the document, in order. This must not be empty.
621    #[serde(rename = "fieldTransforms")]
622    pub field_transforms: Option<Vec<FieldTransform>>,
623}
624
625impl common::Part for DocumentTransform {}
626
627/// A target specified by a set of documents names.
628///
629/// This type is not used in any activity, and only used as *part* of another schema.
630///
631#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
632#[serde_with::serde_as]
633#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
634pub struct DocumentsTarget {
635    /// 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.
636    pub documents: Option<Vec<String>>,
637}
638
639impl common::Part for DocumentsTarget {}
640
641/// 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); }
642///
643/// # Activities
644///
645/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
646/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
647///
648/// * [databases documents delete projects](ProjectDatabaseDocumentDeleteCall) (response)
649/// * [databases documents rollback projects](ProjectDatabaseDocumentRollbackCall) (response)
650/// * [databases indexes delete projects](ProjectDatabaseIndexDeleteCall) (response)
651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
652#[serde_with::serde_as]
653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
654pub struct Empty {
655    _never_set: Option<bool>,
656}
657
658impl common::ResponseResult for Empty {}
659
660/// Execution statistics for the query.
661///
662/// This type is not used in any activity, and only used as *part* of another schema.
663///
664#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
665#[serde_with::serde_as]
666#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
667pub struct ExecutionStats {
668    /// 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" } }
669    #[serde(rename = "debugStats")]
670    pub debug_stats: Option<HashMap<String, serde_json::Value>>,
671    /// Total time to execute the query in the backend.
672    #[serde(rename = "executionDuration")]
673    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
674    pub execution_duration: Option<chrono::Duration>,
675    /// Total billable read operations.
676    #[serde(rename = "readOperations")]
677    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
678    pub read_operations: Option<i64>,
679    /// Total number of results returned, including documents, projections, aggregation results, keys.
680    #[serde(rename = "resultsReturned")]
681    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
682    pub results_returned: Option<i64>,
683}
684
685impl common::Part for ExecutionStats {}
686
687/// A digest of all the documents that match a given target.
688///
689/// This type is not used in any activity, and only used as *part* of another schema.
690///
691#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
692#[serde_with::serde_as]
693#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
694pub struct ExistenceFilter {
695    /// 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.
696    pub count: Option<i32>,
697    /// The target ID to which this filter applies.
698    #[serde(rename = "targetId")]
699    pub target_id: Option<i32>,
700    /// 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.
701    #[serde(rename = "unchangedNames")]
702    pub unchanged_names: Option<BloomFilter>,
703}
704
705impl common::Part for ExistenceFilter {}
706
707/// Explain metrics for the query.
708///
709/// This type is not used in any activity, and only used as *part* of another schema.
710///
711#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
712#[serde_with::serde_as]
713#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
714pub struct ExplainMetrics {
715    /// Aggregated stats from the execution of the query. Only present when ExplainOptions.analyze is set to true.
716    #[serde(rename = "executionStats")]
717    pub execution_stats: Option<ExecutionStats>,
718    /// Planning phase information for the query.
719    #[serde(rename = "planSummary")]
720    pub plan_summary: Option<PlanSummary>,
721}
722
723impl common::Part for ExplainMetrics {}
724
725/// Explain options for the query.
726///
727/// This type is not used in any activity, and only used as *part* of another schema.
728///
729#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
730#[serde_with::serde_as]
731#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
732pub struct ExplainOptions {
733    /// 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.
734    pub analyze: Option<bool>,
735}
736
737impl common::Part for ExplainOptions {}
738
739/// A filter on a specific field.
740///
741/// This type is not used in any activity, and only used as *part* of another schema.
742///
743#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
744#[serde_with::serde_as]
745#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
746pub struct FieldFilter {
747    /// The field to filter by.
748    pub field: Option<FieldReference>,
749    /// The operator to filter by.
750    pub op: Option<String>,
751    /// The value to compare to.
752    pub value: Option<Value>,
753}
754
755impl common::Part for FieldFilter {}
756
757/// A reference to a field in a document, ex: `stats.operations`.
758///
759/// This type is not used in any activity, and only used as *part* of another schema.
760///
761#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
762#[serde_with::serde_as]
763#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
764pub struct FieldReference {
765    /// 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.
766    #[serde(rename = "fieldPath")]
767    pub field_path: Option<String>,
768}
769
770impl common::Part for FieldReference {}
771
772/// A transformation of a field of the document.
773///
774/// This type is not used in any activity, and only used as *part* of another schema.
775///
776#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
777#[serde_with::serde_as]
778#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
779pub struct FieldTransform {
780    /// 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.
781    #[serde(rename = "appendMissingElements")]
782    pub append_missing_elements: Option<ArrayValue>,
783    /// The path of the field. See Document.fields for the field path syntax reference.
784    #[serde(rename = "fieldPath")]
785    pub field_path: Option<String>,
786    /// 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.
787    pub increment: Option<Value>,
788    /// 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.
789    pub maximum: Option<Value>,
790    /// 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.
791    pub minimum: Option<Value>,
792    /// 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.
793    #[serde(rename = "removeAllFromArray")]
794    pub remove_all_from_array: Option<ArrayValue>,
795    /// Sets the field to the given server value.
796    #[serde(rename = "setToServerValue")]
797    pub set_to_server_value: Option<String>,
798}
799
800impl common::Part for FieldTransform {}
801
802/// A filter.
803///
804/// This type is not used in any activity, and only used as *part* of another schema.
805///
806#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
807#[serde_with::serde_as]
808#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
809pub struct Filter {
810    /// A composite filter.
811    #[serde(rename = "compositeFilter")]
812    pub composite_filter: Option<CompositeFilter>,
813    /// A filter on a document field.
814    #[serde(rename = "fieldFilter")]
815    pub field_filter: Option<FieldFilter>,
816    /// A filter that takes exactly one argument.
817    #[serde(rename = "unaryFilter")]
818    pub unary_filter: Option<UnaryFilter>,
819}
820
821impl common::Part for Filter {}
822
823/// Nearest Neighbors search config.
824///
825/// This type is not used in any activity, and only used as *part* of another schema.
826///
827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
828#[serde_with::serde_as]
829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
830pub struct FindNearest {
831    /// Required. The distance measure to use, required.
832    #[serde(rename = "distanceMeasure")]
833    pub distance_measure: Option<String>,
834    /// Required. The number of nearest neighbors to return. Must be a positive integer of no more than 1000.
835    pub limit: Option<i32>,
836    /// Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.
837    #[serde(rename = "queryVector")]
838    pub query_vector: Option<Value>,
839    /// Required. An indexed vector field to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.
840    #[serde(rename = "vectorField")]
841    pub vector_field: Option<FieldReference>,
842}
843
844impl common::Part for FindNearest {}
845
846/// The request for FirestoreAdmin.ExportDocuments.
847///
848/// # Activities
849///
850/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
851/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
852///
853/// * [databases export documents projects](ProjectDatabaseExportDocumentCall) (request)
854#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
855#[serde_with::serde_as]
856#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
857pub struct GoogleFirestoreAdminV1beta1ExportDocumentsRequest {
858    /// Which collection ids to export. Unspecified means all collections.
859    #[serde(rename = "collectionIds")]
860    pub collection_ids: Option<Vec<String>>,
861    /// 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.
862    #[serde(rename = "outputUriPrefix")]
863    pub output_uri_prefix: Option<String>,
864}
865
866impl common::RequestValue for GoogleFirestoreAdminV1beta1ExportDocumentsRequest {}
867
868/// The request for FirestoreAdmin.ImportDocuments.
869///
870/// # Activities
871///
872/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
873/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
874///
875/// * [databases import documents projects](ProjectDatabaseImportDocumentCall) (request)
876#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
877#[serde_with::serde_as]
878#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
879pub struct GoogleFirestoreAdminV1beta1ImportDocumentsRequest {
880    /// Which collection ids to import. Unspecified means all collections included in the import.
881    #[serde(rename = "collectionIds")]
882    pub collection_ids: Option<Vec<String>>,
883    /// 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.v1beta1.ExportDocumentsResponse.output_uri_prefix.
884    #[serde(rename = "inputUriPrefix")]
885    pub input_uri_prefix: Option<String>,
886}
887
888impl common::RequestValue for GoogleFirestoreAdminV1beta1ImportDocumentsRequest {}
889
890/// An index definition.
891///
892/// # Activities
893///
894/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
895/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
896///
897/// * [databases indexes create projects](ProjectDatabaseIndexCreateCall) (request)
898/// * [databases indexes get projects](ProjectDatabaseIndexGetCall) (response)
899#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
900#[serde_with::serde_as]
901#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
902pub struct GoogleFirestoreAdminV1beta1Index {
903    /// The collection ID to which this index applies. Required.
904    #[serde(rename = "collectionId")]
905    pub collection_id: Option<String>,
906    /// The fields to index.
907    pub fields: Option<Vec<GoogleFirestoreAdminV1beta1IndexField>>,
908    /// The resource name of the index. Output only.
909    pub name: Option<String>,
910    /// The state of the index. Output only.
911    pub state: Option<String>,
912}
913
914impl common::RequestValue for GoogleFirestoreAdminV1beta1Index {}
915impl common::ResponseResult for GoogleFirestoreAdminV1beta1Index {}
916
917/// A field of an index.
918///
919/// This type is not used in any activity, and only used as *part* of another schema.
920///
921#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
922#[serde_with::serde_as]
923#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
924pub struct GoogleFirestoreAdminV1beta1IndexField {
925    /// The path of the field. Must match the field path specification described by google.firestore.v1beta1.Document.fields. Special field path `__name__` may be used by itself or at the end of a path. `__type__` may be used only at the end of path.
926    #[serde(rename = "fieldPath")]
927    pub field_path: Option<String>,
928    /// The field's mode.
929    pub mode: Option<String>,
930}
931
932impl common::Part for GoogleFirestoreAdminV1beta1IndexField {}
933
934/// The response for FirestoreAdmin.ListIndexes.
935///
936/// # Activities
937///
938/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
939/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
940///
941/// * [databases indexes list projects](ProjectDatabaseIndexListCall) (response)
942#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
943#[serde_with::serde_as]
944#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
945pub struct GoogleFirestoreAdminV1beta1ListIndexesResponse {
946    /// The indexes.
947    pub indexes: Option<Vec<GoogleFirestoreAdminV1beta1Index>>,
948    /// The standard List next-page token.
949    #[serde(rename = "nextPageToken")]
950    pub next_page_token: Option<String>,
951}
952
953impl common::ResponseResult for GoogleFirestoreAdminV1beta1ListIndexesResponse {}
954
955/// This resource represents a long-running operation that is the result of a network API call.
956///
957/// # Activities
958///
959/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
960/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
961///
962/// * [databases indexes create projects](ProjectDatabaseIndexCreateCall) (response)
963/// * [databases export documents projects](ProjectDatabaseExportDocumentCall) (response)
964/// * [databases import documents projects](ProjectDatabaseImportDocumentCall) (response)
965#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
966#[serde_with::serde_as]
967#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
968pub struct GoogleLongrunningOperation {
969    /// 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.
970    pub done: Option<bool>,
971    /// The error result of the operation in case of failure or cancellation.
972    pub error: Option<Status>,
973    /// 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.
974    pub metadata: Option<HashMap<String, serde_json::Value>>,
975    /// 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}`.
976    pub name: Option<String>,
977    /// 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`.
978    pub response: Option<HashMap<String, serde_json::Value>>,
979}
980
981impl common::ResponseResult for GoogleLongrunningOperation {}
982
983/// 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.
984///
985/// This type is not used in any activity, and only used as *part* of another schema.
986///
987#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
988#[serde_with::serde_as]
989#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
990pub struct LatLng {
991    /// The latitude in degrees. It must be in the range [-90.0, +90.0].
992    pub latitude: Option<f64>,
993    /// The longitude in degrees. It must be in the range [-180.0, +180.0].
994    pub longitude: Option<f64>,
995}
996
997impl common::Part for LatLng {}
998
999/// The request for Firestore.ListCollectionIds.
1000///
1001/// # Activities
1002///
1003/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1004/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1005///
1006/// * [databases documents list collection ids projects](ProjectDatabaseDocumentListCollectionIdCall) (request)
1007#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1008#[serde_with::serde_as]
1009#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1010pub struct ListCollectionIdsRequest {
1011    /// The maximum number of results to return.
1012    #[serde(rename = "pageSize")]
1013    pub page_size: Option<i32>,
1014    /// A page token. Must be a value from ListCollectionIdsResponse.
1015    #[serde(rename = "pageToken")]
1016    pub page_token: Option<String>,
1017    /// 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.
1018    #[serde(rename = "readTime")]
1019    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1020}
1021
1022impl common::RequestValue for ListCollectionIdsRequest {}
1023
1024/// The response from Firestore.ListCollectionIds.
1025///
1026/// # Activities
1027///
1028/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1029/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1030///
1031/// * [databases documents list collection ids projects](ProjectDatabaseDocumentListCollectionIdCall) (response)
1032#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1033#[serde_with::serde_as]
1034#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1035pub struct ListCollectionIdsResponse {
1036    /// The collection ids.
1037    #[serde(rename = "collectionIds")]
1038    pub collection_ids: Option<Vec<String>>,
1039    /// A page token that may be used to continue the list.
1040    #[serde(rename = "nextPageToken")]
1041    pub next_page_token: Option<String>,
1042}
1043
1044impl common::ResponseResult for ListCollectionIdsResponse {}
1045
1046/// The response for Firestore.ListDocuments.
1047///
1048/// # Activities
1049///
1050/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1051/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1052///
1053/// * [databases documents list projects](ProjectDatabaseDocumentListCall) (response)
1054/// * [databases documents list documents projects](ProjectDatabaseDocumentListDocumentCall) (response)
1055#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1056#[serde_with::serde_as]
1057#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1058pub struct ListDocumentsResponse {
1059    /// The Documents found.
1060    pub documents: Option<Vec<Document>>,
1061    /// A token to retrieve the next page of documents. If this field is omitted, there are no subsequent pages.
1062    #[serde(rename = "nextPageToken")]
1063    pub next_page_token: Option<String>,
1064}
1065
1066impl common::ResponseResult for ListDocumentsResponse {}
1067
1068/// A request for Firestore.Listen
1069///
1070/// # Activities
1071///
1072/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1073/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1074///
1075/// * [databases documents listen projects](ProjectDatabaseDocumentListenCall) (request)
1076#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1077#[serde_with::serde_as]
1078#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1079pub struct ListenRequest {
1080    /// A target to add to this stream.
1081    #[serde(rename = "addTarget")]
1082    pub add_target: Option<Target>,
1083    /// Labels associated with this target change.
1084    pub labels: Option<HashMap<String, String>>,
1085    /// The ID of a target to remove from this stream.
1086    #[serde(rename = "removeTarget")]
1087    pub remove_target: Option<i32>,
1088}
1089
1090impl common::RequestValue for ListenRequest {}
1091
1092/// The response for Firestore.Listen.
1093///
1094/// # Activities
1095///
1096/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1097/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1098///
1099/// * [databases documents listen projects](ProjectDatabaseDocumentListenCall) (response)
1100#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1101#[serde_with::serde_as]
1102#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1103pub struct ListenResponse {
1104    /// A Document has changed.
1105    #[serde(rename = "documentChange")]
1106    pub document_change: Option<DocumentChange>,
1107    /// A Document has been deleted.
1108    #[serde(rename = "documentDelete")]
1109    pub document_delete: Option<DocumentDelete>,
1110    /// A Document has been removed from a target (because it is no longer relevant to that target).
1111    #[serde(rename = "documentRemove")]
1112    pub document_remove: Option<DocumentRemove>,
1113    /// 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.
1114    pub filter: Option<ExistenceFilter>,
1115    /// Targets have changed.
1116    #[serde(rename = "targetChange")]
1117    pub target_change: Option<TargetChange>,
1118}
1119
1120impl common::ResponseResult for ListenResponse {}
1121
1122/// A map value.
1123///
1124/// This type is not used in any activity, and only used as *part* of another schema.
1125///
1126#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1127#[serde_with::serde_as]
1128#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1129pub struct MapValue {
1130    /// 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.
1131    pub fields: Option<HashMap<String, Value>>,
1132}
1133
1134impl common::Part for MapValue {}
1135
1136/// An order on a field.
1137///
1138/// This type is not used in any activity, and only used as *part* of another schema.
1139///
1140#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1141#[serde_with::serde_as]
1142#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1143pub struct Order {
1144    /// The direction to order by. Defaults to `ASCENDING`.
1145    pub direction: Option<String>,
1146    /// The field to order by.
1147    pub field: Option<FieldReference>,
1148}
1149
1150impl common::Part for Order {}
1151
1152/// The request for Firestore.PartitionQuery.
1153///
1154/// # Activities
1155///
1156/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1157/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1158///
1159/// * [databases documents partition query projects](ProjectDatabaseDocumentPartitionQueryCall) (request)
1160#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1161#[serde_with::serde_as]
1162#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1163pub struct PartitionQueryRequest {
1164    /// 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`.
1165    #[serde(rename = "pageSize")]
1166    pub page_size: Option<i32>,
1167    /// 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
1168    #[serde(rename = "pageToken")]
1169    pub page_token: Option<String>,
1170    /// 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.
1171    #[serde(rename = "partitionCount")]
1172    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1173    pub partition_count: Option<i64>,
1174    /// 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.
1175    #[serde(rename = "readTime")]
1176    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1177    /// 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.
1178    #[serde(rename = "structuredQuery")]
1179    pub structured_query: Option<StructuredQuery>,
1180}
1181
1182impl common::RequestValue for PartitionQueryRequest {}
1183
1184/// The response for Firestore.PartitionQuery.
1185///
1186/// # Activities
1187///
1188/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1189/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1190///
1191/// * [databases documents partition query projects](ProjectDatabaseDocumentPartitionQueryCall) (response)
1192#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1193#[serde_with::serde_as]
1194#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1195pub struct PartitionQueryResponse {
1196    /// 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.
1197    #[serde(rename = "nextPageToken")]
1198    pub next_page_token: Option<String>,
1199    /// 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.
1200    pub partitions: Option<Vec<Cursor>>,
1201}
1202
1203impl common::ResponseResult for PartitionQueryResponse {}
1204
1205/// Planning phase information for the query.
1206///
1207/// This type is not used in any activity, and only used as *part* of another schema.
1208///
1209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1210#[serde_with::serde_as]
1211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1212pub struct PlanSummary {
1213    /// The indexes selected for the query. For example: [ {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} ]
1214    #[serde(rename = "indexesUsed")]
1215    pub indexes_used: Option<Vec<HashMap<String, serde_json::Value>>>,
1216}
1217
1218impl common::Part for PlanSummary {}
1219
1220/// A precondition on a document, used for conditional operations.
1221///
1222/// This type is not used in any activity, and only used as *part* of another schema.
1223///
1224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1225#[serde_with::serde_as]
1226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1227pub struct Precondition {
1228    /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
1229    pub exists: Option<bool>,
1230    /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
1231    #[serde(rename = "updateTime")]
1232    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1233}
1234
1235impl common::Part for Precondition {}
1236
1237/// The projection of document's fields to return.
1238///
1239/// This type is not used in any activity, and only used as *part* of another schema.
1240///
1241#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1242#[serde_with::serde_as]
1243#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1244pub struct Projection {
1245    /// The fields to return. If empty, all fields are returned. To only return the name of the document, use `['__name__']`.
1246    pub fields: Option<Vec<FieldReference>>,
1247}
1248
1249impl common::Part for Projection {}
1250
1251/// A target specified by a query.
1252///
1253/// This type is not used in any activity, and only used as *part* of another schema.
1254///
1255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1256#[serde_with::serde_as]
1257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1258pub struct QueryTarget {
1259    /// 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`
1260    pub parent: Option<String>,
1261    /// A structured query.
1262    #[serde(rename = "structuredQuery")]
1263    pub structured_query: Option<StructuredQuery>,
1264}
1265
1266impl common::Part for QueryTarget {}
1267
1268/// Options for a transaction that can only be used to read documents.
1269///
1270/// This type is not used in any activity, and only used as *part* of another schema.
1271///
1272#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1273#[serde_with::serde_as]
1274#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1275pub struct ReadOnly {
1276    /// 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.
1277    #[serde(rename = "readTime")]
1278    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1279}
1280
1281impl common::Part for ReadOnly {}
1282
1283/// 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.
1284///
1285/// This type is not used in any activity, and only used as *part* of another schema.
1286///
1287#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1288#[serde_with::serde_as]
1289#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1290pub struct ReadWrite {
1291    /// An optional transaction to retry.
1292    #[serde(rename = "retryTransaction")]
1293    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1294    pub retry_transaction: Option<Vec<u8>>,
1295}
1296
1297impl common::Part for ReadWrite {}
1298
1299/// The request for Firestore.Rollback.
1300///
1301/// # Activities
1302///
1303/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1304/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1305///
1306/// * [databases documents rollback projects](ProjectDatabaseDocumentRollbackCall) (request)
1307#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1308#[serde_with::serde_as]
1309#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1310pub struct RollbackRequest {
1311    /// Required. The transaction to roll back.
1312    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1313    pub transaction: Option<Vec<u8>>,
1314}
1315
1316impl common::RequestValue for RollbackRequest {}
1317
1318/// The request for Firestore.RunAggregationQuery.
1319///
1320/// # Activities
1321///
1322/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1323/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1324///
1325/// * [databases documents run aggregation query projects](ProjectDatabaseDocumentRunAggregationQueryCall) (request)
1326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1327#[serde_with::serde_as]
1328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1329pub struct RunAggregationQueryRequest {
1330    /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
1331    #[serde(rename = "explainOptions")]
1332    pub explain_options: Option<ExplainOptions>,
1333    /// 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.
1334    #[serde(rename = "newTransaction")]
1335    pub new_transaction: Option<TransactionOptions>,
1336    /// 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.
1337    #[serde(rename = "readTime")]
1338    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1339    /// An aggregation query.
1340    #[serde(rename = "structuredAggregationQuery")]
1341    pub structured_aggregation_query: Option<StructuredAggregationQuery>,
1342    /// Run the aggregation within an already active transaction. The value here is the opaque transaction ID to execute the query in.
1343    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1344    pub transaction: Option<Vec<u8>>,
1345}
1346
1347impl common::RequestValue for RunAggregationQueryRequest {}
1348
1349/// The response for Firestore.RunAggregationQuery.
1350///
1351/// # Activities
1352///
1353/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1354/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1355///
1356/// * [databases documents run aggregation query projects](ProjectDatabaseDocumentRunAggregationQueryCall) (response)
1357#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1358#[serde_with::serde_as]
1359#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1360pub struct RunAggregationQueryResponse {
1361    /// 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.
1362    #[serde(rename = "explainMetrics")]
1363    pub explain_metrics: Option<ExplainMetrics>,
1364    /// 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.
1365    #[serde(rename = "readTime")]
1366    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1367    /// A single aggregation result. Not present when reporting partial progress.
1368    pub result: Option<AggregationResult>,
1369    /// 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.
1370    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1371    pub transaction: Option<Vec<u8>>,
1372}
1373
1374impl common::ResponseResult for RunAggregationQueryResponse {}
1375
1376/// The request for Firestore.RunQuery.
1377///
1378/// # Activities
1379///
1380/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1381/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1382///
1383/// * [databases documents run query projects](ProjectDatabaseDocumentRunQueryCall) (request)
1384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1385#[serde_with::serde_as]
1386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1387pub struct RunQueryRequest {
1388    /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
1389    #[serde(rename = "explainOptions")]
1390    pub explain_options: Option<ExplainOptions>,
1391    /// 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.
1392    #[serde(rename = "newTransaction")]
1393    pub new_transaction: Option<TransactionOptions>,
1394    /// 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.
1395    #[serde(rename = "readTime")]
1396    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1397    /// A structured query.
1398    #[serde(rename = "structuredQuery")]
1399    pub structured_query: Option<StructuredQuery>,
1400    /// Run the query within an already active transaction. The value here is the opaque transaction ID to execute the query in.
1401    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1402    pub transaction: Option<Vec<u8>>,
1403}
1404
1405impl common::RequestValue for RunQueryRequest {}
1406
1407/// The response for Firestore.RunQuery.
1408///
1409/// # Activities
1410///
1411/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1412/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1413///
1414/// * [databases documents run query projects](ProjectDatabaseDocumentRunQueryCall) (response)
1415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1416#[serde_with::serde_as]
1417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1418pub struct RunQueryResponse {
1419    /// A query result, not set when reporting partial progress.
1420    pub document: Option<Document>,
1421    /// If present, Firestore has completely finished the request and no more documents will be returned.
1422    pub done: Option<bool>,
1423    /// 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.
1424    #[serde(rename = "explainMetrics")]
1425    pub explain_metrics: Option<ExplainMetrics>,
1426    /// 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.
1427    #[serde(rename = "readTime")]
1428    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1429    /// The number of results that have been skipped due to an offset between the last response and the current response.
1430    #[serde(rename = "skippedResults")]
1431    pub skipped_results: Option<i32>,
1432    /// 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.
1433    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1434    pub transaction: Option<Vec<u8>>,
1435}
1436
1437impl common::ResponseResult for RunQueryResponse {}
1438
1439/// 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).
1440///
1441/// This type is not used in any activity, and only used as *part* of another schema.
1442///
1443#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1444#[serde_with::serde_as]
1445#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1446pub struct Status {
1447    /// The status code, which should be an enum value of google.rpc.Code.
1448    pub code: Option<i32>,
1449    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1450    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1451    /// 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.
1452    pub message: Option<String>,
1453}
1454
1455impl common::Part for Status {}
1456
1457/// Firestore query for running an aggregation over a StructuredQuery.
1458///
1459/// This type is not used in any activity, and only used as *part* of another schema.
1460///
1461#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1462#[serde_with::serde_as]
1463#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1464pub struct StructuredAggregationQuery {
1465    /// 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.
1466    pub aggregations: Option<Vec<Aggregation>>,
1467    /// Nested structured query.
1468    #[serde(rename = "structuredQuery")]
1469    pub structured_query: Option<StructuredQuery>,
1470}
1471
1472impl common::Part for StructuredAggregationQuery {}
1473
1474/// 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
1475///
1476/// This type is not used in any activity, and only used as *part* of another schema.
1477///
1478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1479#[serde_with::serde_as]
1480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1481pub struct StructuredQuery {
1482    /// 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.
1483    #[serde(rename = "endAt")]
1484    pub end_at: Option<Cursor>,
1485    /// Optional. A potential nearest neighbors search. Applies after all other filters and ordering. Finds the closest vector embeddings to the given query vector.
1486    #[serde(rename = "findNearest")]
1487    pub find_nearest: Option<FindNearest>,
1488    /// The collections to query.
1489    pub from: Option<Vec<CollectionSelector>>,
1490    /// 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.
1491    pub limit: Option<i32>,
1492    /// 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.
1493    pub offset: Option<i32>,
1494    /// 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`
1495    #[serde(rename = "orderBy")]
1496    pub order_by: Option<Vec<Order>>,
1497    /// 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.
1498    pub select: Option<Projection>,
1499    /// 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.
1500    #[serde(rename = "startAt")]
1501    pub start_at: Option<Cursor>,
1502    /// The filter to apply.
1503    #[serde(rename = "where")]
1504    pub where_: Option<Filter>,
1505}
1506
1507impl common::Part for StructuredQuery {}
1508
1509/// 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.
1510///
1511/// This type is not used in any activity, and only used as *part* of another schema.
1512///
1513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1514#[serde_with::serde_as]
1515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1516pub struct Sum {
1517    /// The field to aggregate on.
1518    pub field: Option<FieldReference>,
1519}
1520
1521impl common::Part for Sum {}
1522
1523/// A specification of a set of documents to listen to.
1524///
1525/// This type is not used in any activity, and only used as *part* of another schema.
1526///
1527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1528#[serde_with::serde_as]
1529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1530pub struct Target {
1531    /// A target specified by a set of document names.
1532    pub documents: Option<DocumentsTarget>,
1533    /// 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.
1534    #[serde(rename = "expectedCount")]
1535    pub expected_count: Option<i32>,
1536    /// If the target should be removed once it is current and consistent.
1537    pub once: Option<bool>,
1538    /// A target specified by a query.
1539    pub query: Option<QueryTarget>,
1540    /// Start listening after a specific `read_time`. The client must know the state of matching documents at this time.
1541    #[serde(rename = "readTime")]
1542    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1543    /// A resume token from a prior TargetChange for an identical target. Using a resume token with a different target is unsupported and may fail.
1544    #[serde(rename = "resumeToken")]
1545    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1546    pub resume_token: Option<Vec<u8>>,
1547    /// 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 `TargetChage.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.
1548    #[serde(rename = "targetId")]
1549    pub target_id: Option<i32>,
1550}
1551
1552impl common::Part for Target {}
1553
1554/// Targets being watched have changed.
1555///
1556/// This type is not used in any activity, and only used as *part* of another schema.
1557///
1558#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1559#[serde_with::serde_as]
1560#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1561pub struct TargetChange {
1562    /// The error that resulted in this change, if applicable.
1563    pub cause: Option<Status>,
1564    /// 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.
1565    #[serde(rename = "readTime")]
1566    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1567    /// 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.
1568    #[serde(rename = "resumeToken")]
1569    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1570    pub resume_token: Option<Vec<u8>>,
1571    /// The type of change that occurred.
1572    #[serde(rename = "targetChangeType")]
1573    pub target_change_type: Option<String>,
1574    /// 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.
1575    #[serde(rename = "targetIds")]
1576    pub target_ids: Option<Vec<i32>>,
1577}
1578
1579impl common::Part for TargetChange {}
1580
1581/// Options for creating a new transaction.
1582///
1583/// This type is not used in any activity, and only used as *part* of another schema.
1584///
1585#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1586#[serde_with::serde_as]
1587#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1588pub struct TransactionOptions {
1589    /// The transaction can only be used for read operations.
1590    #[serde(rename = "readOnly")]
1591    pub read_only: Option<ReadOnly>,
1592    /// The transaction can be used for both read and write operations.
1593    #[serde(rename = "readWrite")]
1594    pub read_write: Option<ReadWrite>,
1595}
1596
1597impl common::Part for TransactionOptions {}
1598
1599/// A filter with a single operand.
1600///
1601/// This type is not used in any activity, and only used as *part* of another schema.
1602///
1603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1604#[serde_with::serde_as]
1605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1606pub struct UnaryFilter {
1607    /// The field to which to apply the operator.
1608    pub field: Option<FieldReference>,
1609    /// The unary operator to apply.
1610    pub op: Option<String>,
1611}
1612
1613impl common::Part for UnaryFilter {}
1614
1615/// A message that can hold any of the supported value types.
1616///
1617/// This type is not used in any activity, and only used as *part* of another schema.
1618///
1619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1620#[serde_with::serde_as]
1621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1622pub struct Value {
1623    /// An array value. Cannot directly contain another array value, though can contain a map which contains another array.
1624    #[serde(rename = "arrayValue")]
1625    pub array_value: Option<ArrayValue>,
1626    /// A boolean value.
1627    #[serde(rename = "booleanValue")]
1628    pub boolean_value: Option<bool>,
1629    /// A bytes value. Must not exceed 1 MiB - 89 bytes. Only the first 1,500 bytes are considered by queries.
1630    #[serde(rename = "bytesValue")]
1631    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1632    pub bytes_value: Option<Vec<u8>>,
1633    /// A double value.
1634    #[serde(rename = "doubleValue")]
1635    pub double_value: Option<f64>,
1636    /// A geo point value representing a point on the surface of Earth.
1637    #[serde(rename = "geoPointValue")]
1638    pub geo_point_value: Option<LatLng>,
1639    /// An integer value.
1640    #[serde(rename = "integerValue")]
1641    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1642    pub integer_value: Option<i64>,
1643    /// A map value.
1644    #[serde(rename = "mapValue")]
1645    pub map_value: Option<MapValue>,
1646    /// A null value.
1647    #[serde(rename = "nullValue")]
1648    pub null_value: Option<String>,
1649    /// A reference to a document. For example: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1650    #[serde(rename = "referenceValue")]
1651    pub reference_value: Option<String>,
1652    /// 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.
1653    #[serde(rename = "stringValue")]
1654    pub string_value: Option<String>,
1655    /// A timestamp value. Precise only to microseconds. When stored, any additional precision is rounded down.
1656    #[serde(rename = "timestampValue")]
1657    pub timestamp_value: Option<chrono::DateTime<chrono::offset::Utc>>,
1658}
1659
1660impl common::Part for Value {}
1661
1662/// A write on a document.
1663///
1664/// This type is not used in any activity, and only used as *part* of another schema.
1665///
1666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1667#[serde_with::serde_as]
1668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1669pub struct Write {
1670    /// An optional precondition on the document. The write will fail if this is set and not met by the target document.
1671    #[serde(rename = "currentDocument")]
1672    pub current_document: Option<Precondition>,
1673    /// A document name to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1674    pub delete: Option<String>,
1675    /// Applies a transformation to a document.
1676    pub transform: Option<DocumentTransform>,
1677    /// A document to write.
1678    pub update: Option<Document>,
1679    /// 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.
1680    #[serde(rename = "updateMask")]
1681    pub update_mask: Option<DocumentMask>,
1682    /// 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.
1683    #[serde(rename = "updateTransforms")]
1684    pub update_transforms: Option<Vec<FieldTransform>>,
1685}
1686
1687impl common::Part for Write {}
1688
1689/// 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.
1690///
1691/// # Activities
1692///
1693/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1694/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1695///
1696/// * [databases documents write projects](ProjectDatabaseDocumentWriteCall) (request)
1697#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1698#[serde_with::serde_as]
1699#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1700pub struct WriteRequest {
1701    /// Labels associated with this write request.
1702    pub labels: Option<HashMap<String, String>>,
1703    /// 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.
1704    #[serde(rename = "streamId")]
1705    pub stream_id: Option<String>,
1706    /// 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.
1707    #[serde(rename = "streamToken")]
1708    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1709    pub stream_token: Option<Vec<u8>>,
1710    /// 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.
1711    pub writes: Option<Vec<Write>>,
1712}
1713
1714impl common::RequestValue for WriteRequest {}
1715
1716/// The response for Firestore.Write.
1717///
1718/// # Activities
1719///
1720/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1721/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1722///
1723/// * [databases documents write projects](ProjectDatabaseDocumentWriteCall) (response)
1724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1725#[serde_with::serde_as]
1726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1727pub struct WriteResponse {
1728    /// 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.
1729    #[serde(rename = "commitTime")]
1730    pub commit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1731    /// The ID of the stream. Only set on the first message, when a new stream was created.
1732    #[serde(rename = "streamId")]
1733    pub stream_id: Option<String>,
1734    /// 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.
1735    #[serde(rename = "streamToken")]
1736    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1737    pub stream_token: Option<Vec<u8>>,
1738    /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
1739    #[serde(rename = "writeResults")]
1740    pub write_results: Option<Vec<WriteResult>>,
1741}
1742
1743impl common::ResponseResult for WriteResponse {}
1744
1745/// The result of applying a write.
1746///
1747/// This type is not used in any activity, and only used as *part* of another schema.
1748///
1749#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1750#[serde_with::serde_as]
1751#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1752pub struct WriteResult {
1753    /// The results of applying each DocumentTransform.FieldTransform, in the same order.
1754    #[serde(rename = "transformResults")]
1755    pub transform_results: Option<Vec<Value>>,
1756    /// 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.
1757    #[serde(rename = "updateTime")]
1758    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1759}
1760
1761impl common::Part for WriteResult {}
1762
1763// ###################
1764// MethodBuilders ###
1765// #################
1766
1767/// A builder providing access to all methods supported on *project* resources.
1768/// It is not used directly, but through the [`Firestore`] hub.
1769///
1770/// # Example
1771///
1772/// Instantiate a resource builder
1773///
1774/// ```test_harness,no_run
1775/// extern crate hyper;
1776/// extern crate hyper_rustls;
1777/// extern crate google_firestore1_beta1 as firestore1_beta1;
1778///
1779/// # async fn dox() {
1780/// use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1781///
1782/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1783/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1784///     secret,
1785///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1786/// ).build().await.unwrap();
1787///
1788/// let client = hyper_util::client::legacy::Client::builder(
1789///     hyper_util::rt::TokioExecutor::new()
1790/// )
1791/// .build(
1792///     hyper_rustls::HttpsConnectorBuilder::new()
1793///         .with_native_roots()
1794///         .unwrap()
1795///         .https_or_http()
1796///         .enable_http1()
1797///         .build()
1798/// );
1799/// let mut hub = Firestore::new(client, auth);
1800/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1801/// // like `databases_documents_batch_get(...)`, `databases_documents_batch_write(...)`, `databases_documents_begin_transaction(...)`, `databases_documents_commit(...)`, `databases_documents_create_document(...)`, `databases_documents_delete(...)`, `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_import_documents(...)`, `databases_indexes_create(...)`, `databases_indexes_delete(...)`, `databases_indexes_get(...)` and `databases_indexes_list(...)`
1802/// // to build up your call.
1803/// let rb = hub.projects();
1804/// # }
1805/// ```
1806pub struct ProjectMethods<'a, C>
1807where
1808    C: 'a,
1809{
1810    hub: &'a Firestore<C>,
1811}
1812
1813impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1814
1815impl<'a, C> ProjectMethods<'a, C> {
1816    /// Create a builder to help you perform the following task:
1817    ///
1818    /// Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
1819    ///
1820    /// # Arguments
1821    ///
1822    /// * `request` - No description provided.
1823    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
1824    pub fn databases_documents_batch_get(
1825        &self,
1826        request: BatchGetDocumentsRequest,
1827        database: &str,
1828    ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
1829        ProjectDatabaseDocumentBatchGetCall {
1830            hub: self.hub,
1831            _request: request,
1832            _database: database.to_string(),
1833            _delegate: Default::default(),
1834            _additional_params: Default::default(),
1835            _scopes: Default::default(),
1836        }
1837    }
1838
1839    /// Create a builder to help you perform the following task:
1840    ///
1841    /// 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.
1842    ///
1843    /// # Arguments
1844    ///
1845    /// * `request` - No description provided.
1846    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
1847    pub fn databases_documents_batch_write(
1848        &self,
1849        request: BatchWriteRequest,
1850        database: &str,
1851    ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
1852        ProjectDatabaseDocumentBatchWriteCall {
1853            hub: self.hub,
1854            _request: request,
1855            _database: database.to_string(),
1856            _delegate: Default::default(),
1857            _additional_params: Default::default(),
1858            _scopes: Default::default(),
1859        }
1860    }
1861
1862    /// Create a builder to help you perform the following task:
1863    ///
1864    /// Starts a new transaction.
1865    ///
1866    /// # Arguments
1867    ///
1868    /// * `request` - No description provided.
1869    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
1870    pub fn databases_documents_begin_transaction(
1871        &self,
1872        request: BeginTransactionRequest,
1873        database: &str,
1874    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
1875        ProjectDatabaseDocumentBeginTransactionCall {
1876            hub: self.hub,
1877            _request: request,
1878            _database: database.to_string(),
1879            _delegate: Default::default(),
1880            _additional_params: Default::default(),
1881            _scopes: Default::default(),
1882        }
1883    }
1884
1885    /// Create a builder to help you perform the following task:
1886    ///
1887    /// Commits a transaction, while optionally updating documents.
1888    ///
1889    /// # Arguments
1890    ///
1891    /// * `request` - No description provided.
1892    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
1893    pub fn databases_documents_commit(
1894        &self,
1895        request: CommitRequest,
1896        database: &str,
1897    ) -> ProjectDatabaseDocumentCommitCall<'a, C> {
1898        ProjectDatabaseDocumentCommitCall {
1899            hub: self.hub,
1900            _request: request,
1901            _database: database.to_string(),
1902            _delegate: Default::default(),
1903            _additional_params: Default::default(),
1904            _scopes: Default::default(),
1905        }
1906    }
1907
1908    /// Create a builder to help you perform the following task:
1909    ///
1910    /// Creates a new document.
1911    ///
1912    /// # Arguments
1913    ///
1914    /// * `request` - No description provided.
1915    /// * `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}`
1916    /// * `collectionId` - Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
1917    pub fn databases_documents_create_document(
1918        &self,
1919        request: Document,
1920        parent: &str,
1921        collection_id: &str,
1922    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
1923        ProjectDatabaseDocumentCreateDocumentCall {
1924            hub: self.hub,
1925            _request: request,
1926            _parent: parent.to_string(),
1927            _collection_id: collection_id.to_string(),
1928            _mask_field_paths: Default::default(),
1929            _document_id: Default::default(),
1930            _delegate: Default::default(),
1931            _additional_params: Default::default(),
1932            _scopes: Default::default(),
1933        }
1934    }
1935
1936    /// Create a builder to help you perform the following task:
1937    ///
1938    /// Deletes a document.
1939    ///
1940    /// # Arguments
1941    ///
1942    /// * `name` - Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1943    pub fn databases_documents_delete(
1944        &self,
1945        name: &str,
1946    ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
1947        ProjectDatabaseDocumentDeleteCall {
1948            hub: self.hub,
1949            _name: name.to_string(),
1950            _current_document_update_time: Default::default(),
1951            _current_document_exists: Default::default(),
1952            _delegate: Default::default(),
1953            _additional_params: Default::default(),
1954            _scopes: Default::default(),
1955        }
1956    }
1957
1958    /// Create a builder to help you perform the following task:
1959    ///
1960    /// Gets a single document.
1961    ///
1962    /// # Arguments
1963    ///
1964    /// * `name` - Required. The resource name of the Document to get. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1965    pub fn databases_documents_get(&self, name: &str) -> ProjectDatabaseDocumentGetCall<'a, C> {
1966        ProjectDatabaseDocumentGetCall {
1967            hub: self.hub,
1968            _name: name.to_string(),
1969            _transaction: Default::default(),
1970            _read_time: Default::default(),
1971            _mask_field_paths: Default::default(),
1972            _delegate: Default::default(),
1973            _additional_params: Default::default(),
1974            _scopes: Default::default(),
1975        }
1976    }
1977
1978    /// Create a builder to help you perform the following task:
1979    ///
1980    /// Lists documents.
1981    ///
1982    /// # Arguments
1983    ///
1984    /// * `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`
1985    /// * `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`.
1986    pub fn databases_documents_list(
1987        &self,
1988        parent: &str,
1989        collection_id: &str,
1990    ) -> ProjectDatabaseDocumentListCall<'a, C> {
1991        ProjectDatabaseDocumentListCall {
1992            hub: self.hub,
1993            _parent: parent.to_string(),
1994            _collection_id: collection_id.to_string(),
1995            _transaction: Default::default(),
1996            _show_missing: Default::default(),
1997            _read_time: Default::default(),
1998            _page_token: Default::default(),
1999            _page_size: Default::default(),
2000            _order_by: Default::default(),
2001            _mask_field_paths: Default::default(),
2002            _delegate: Default::default(),
2003            _additional_params: Default::default(),
2004            _scopes: Default::default(),
2005        }
2006    }
2007
2008    /// Create a builder to help you perform the following task:
2009    ///
2010    /// Lists all the collection IDs underneath a document.
2011    ///
2012    /// # Arguments
2013    ///
2014    /// * `request` - No description provided.
2015    /// * `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`
2016    pub fn databases_documents_list_collection_ids(
2017        &self,
2018        request: ListCollectionIdsRequest,
2019        parent: &str,
2020    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
2021        ProjectDatabaseDocumentListCollectionIdCall {
2022            hub: self.hub,
2023            _request: request,
2024            _parent: parent.to_string(),
2025            _delegate: Default::default(),
2026            _additional_params: Default::default(),
2027            _scopes: Default::default(),
2028        }
2029    }
2030
2031    /// Create a builder to help you perform the following task:
2032    ///
2033    /// Lists documents.
2034    ///
2035    /// # Arguments
2036    ///
2037    /// * `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`
2038    /// * `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`.
2039    pub fn databases_documents_list_documents(
2040        &self,
2041        parent: &str,
2042        collection_id: &str,
2043    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
2044        ProjectDatabaseDocumentListDocumentCall {
2045            hub: self.hub,
2046            _parent: parent.to_string(),
2047            _collection_id: collection_id.to_string(),
2048            _transaction: Default::default(),
2049            _show_missing: Default::default(),
2050            _read_time: Default::default(),
2051            _page_token: Default::default(),
2052            _page_size: Default::default(),
2053            _order_by: Default::default(),
2054            _mask_field_paths: Default::default(),
2055            _delegate: Default::default(),
2056            _additional_params: Default::default(),
2057            _scopes: Default::default(),
2058        }
2059    }
2060
2061    /// Create a builder to help you perform the following task:
2062    ///
2063    /// Listens to changes. This method is only available via gRPC or WebChannel (not REST).
2064    ///
2065    /// # Arguments
2066    ///
2067    /// * `request` - No description provided.
2068    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2069    pub fn databases_documents_listen(
2070        &self,
2071        request: ListenRequest,
2072        database: &str,
2073    ) -> ProjectDatabaseDocumentListenCall<'a, C> {
2074        ProjectDatabaseDocumentListenCall {
2075            hub: self.hub,
2076            _request: request,
2077            _database: database.to_string(),
2078            _delegate: Default::default(),
2079            _additional_params: Default::default(),
2080            _scopes: Default::default(),
2081        }
2082    }
2083
2084    /// Create a builder to help you perform the following task:
2085    ///
2086    /// 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.
2087    ///
2088    /// # Arguments
2089    ///
2090    /// * `request` - No description provided.
2091    /// * `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.
2092    pub fn databases_documents_partition_query(
2093        &self,
2094        request: PartitionQueryRequest,
2095        parent: &str,
2096    ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
2097        ProjectDatabaseDocumentPartitionQueryCall {
2098            hub: self.hub,
2099            _request: request,
2100            _parent: parent.to_string(),
2101            _delegate: Default::default(),
2102            _additional_params: Default::default(),
2103            _scopes: Default::default(),
2104        }
2105    }
2106
2107    /// Create a builder to help you perform the following task:
2108    ///
2109    /// Updates or inserts a document.
2110    ///
2111    /// # Arguments
2112    ///
2113    /// * `request` - No description provided.
2114    /// * `name` - The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
2115    pub fn databases_documents_patch(
2116        &self,
2117        request: Document,
2118        name: &str,
2119    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
2120        ProjectDatabaseDocumentPatchCall {
2121            hub: self.hub,
2122            _request: request,
2123            _name: name.to_string(),
2124            _update_mask_field_paths: Default::default(),
2125            _mask_field_paths: Default::default(),
2126            _current_document_update_time: Default::default(),
2127            _current_document_exists: Default::default(),
2128            _delegate: Default::default(),
2129            _additional_params: Default::default(),
2130            _scopes: Default::default(),
2131        }
2132    }
2133
2134    /// Create a builder to help you perform the following task:
2135    ///
2136    /// Rolls back a transaction.
2137    ///
2138    /// # Arguments
2139    ///
2140    /// * `request` - No description provided.
2141    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2142    pub fn databases_documents_rollback(
2143        &self,
2144        request: RollbackRequest,
2145        database: &str,
2146    ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
2147        ProjectDatabaseDocumentRollbackCall {
2148            hub: self.hub,
2149            _request: request,
2150            _database: database.to_string(),
2151            _delegate: Default::default(),
2152            _additional_params: Default::default(),
2153            _scopes: Default::default(),
2154        }
2155    }
2156
2157    /// Create a builder to help you perform the following task:
2158    ///
2159    /// 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 ); ```
2160    ///
2161    /// # Arguments
2162    ///
2163    /// * `request` - No description provided.
2164    /// * `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`
2165    pub fn databases_documents_run_aggregation_query(
2166        &self,
2167        request: RunAggregationQueryRequest,
2168        parent: &str,
2169    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
2170        ProjectDatabaseDocumentRunAggregationQueryCall {
2171            hub: self.hub,
2172            _request: request,
2173            _parent: parent.to_string(),
2174            _delegate: Default::default(),
2175            _additional_params: Default::default(),
2176            _scopes: Default::default(),
2177        }
2178    }
2179
2180    /// Create a builder to help you perform the following task:
2181    ///
2182    /// Runs a query.
2183    ///
2184    /// # Arguments
2185    ///
2186    /// * `request` - No description provided.
2187    /// * `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`
2188    pub fn databases_documents_run_query(
2189        &self,
2190        request: RunQueryRequest,
2191        parent: &str,
2192    ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
2193        ProjectDatabaseDocumentRunQueryCall {
2194            hub: self.hub,
2195            _request: request,
2196            _parent: parent.to_string(),
2197            _delegate: Default::default(),
2198            _additional_params: Default::default(),
2199            _scopes: Default::default(),
2200        }
2201    }
2202
2203    /// Create a builder to help you perform the following task:
2204    ///
2205    /// Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).
2206    ///
2207    /// # Arguments
2208    ///
2209    /// * `request` - No description provided.
2210    /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. This is only required in the first message.
2211    pub fn databases_documents_write(
2212        &self,
2213        request: WriteRequest,
2214        database: &str,
2215    ) -> ProjectDatabaseDocumentWriteCall<'a, C> {
2216        ProjectDatabaseDocumentWriteCall {
2217            hub: self.hub,
2218            _request: request,
2219            _database: database.to_string(),
2220            _delegate: Default::default(),
2221            _additional_params: Default::default(),
2222            _scopes: Default::default(),
2223        }
2224    }
2225
2226    /// Create a builder to help you perform the following task:
2227    ///
2228    /// Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned google.longrunning.Operation, the state will be `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. During creation, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, removing the index with delete, then re-creating the index with create. Indexes with a single field cannot be created.
2229    ///
2230    /// # Arguments
2231    ///
2232    /// * `request` - No description provided.
2233    /// * `parent` - The name of the database this index will apply to. For example: `projects/{project_id}/databases/{database_id}`
2234    pub fn databases_indexes_create(
2235        &self,
2236        request: GoogleFirestoreAdminV1beta1Index,
2237        parent: &str,
2238    ) -> ProjectDatabaseIndexCreateCall<'a, C> {
2239        ProjectDatabaseIndexCreateCall {
2240            hub: self.hub,
2241            _request: request,
2242            _parent: parent.to_string(),
2243            _delegate: Default::default(),
2244            _additional_params: Default::default(),
2245            _scopes: Default::default(),
2246        }
2247    }
2248
2249    /// Create a builder to help you perform the following task:
2250    ///
2251    /// Deletes an index.
2252    ///
2253    /// # Arguments
2254    ///
2255    /// * `name` - The index name. For example: `projects/{project_id}/databases/{database_id}/indexes/{index_id}`
2256    pub fn databases_indexes_delete(&self, name: &str) -> ProjectDatabaseIndexDeleteCall<'a, C> {
2257        ProjectDatabaseIndexDeleteCall {
2258            hub: self.hub,
2259            _name: name.to_string(),
2260            _delegate: Default::default(),
2261            _additional_params: Default::default(),
2262            _scopes: Default::default(),
2263        }
2264    }
2265
2266    /// Create a builder to help you perform the following task:
2267    ///
2268    /// Gets an index.
2269    ///
2270    /// # Arguments
2271    ///
2272    /// * `name` - The name of the index. For example: `projects/{project_id}/databases/{database_id}/indexes/{index_id}`
2273    pub fn databases_indexes_get(&self, name: &str) -> ProjectDatabaseIndexGetCall<'a, C> {
2274        ProjectDatabaseIndexGetCall {
2275            hub: self.hub,
2276            _name: name.to_string(),
2277            _delegate: Default::default(),
2278            _additional_params: Default::default(),
2279            _scopes: Default::default(),
2280        }
2281    }
2282
2283    /// Create a builder to help you perform the following task:
2284    ///
2285    /// Lists the indexes that match the specified filters.
2286    ///
2287    /// # Arguments
2288    ///
2289    /// * `parent` - The database name. For example: `projects/{project_id}/databases/{database_id}`
2290    pub fn databases_indexes_list(&self, parent: &str) -> ProjectDatabaseIndexListCall<'a, C> {
2291        ProjectDatabaseIndexListCall {
2292            hub: self.hub,
2293            _parent: parent.to_string(),
2294            _page_token: Default::default(),
2295            _page_size: Default::default(),
2296            _filter: Default::default(),
2297            _delegate: Default::default(),
2298            _additional_params: Default::default(),
2299            _scopes: Default::default(),
2300        }
2301    }
2302
2303    /// Create a builder to help you perform the following task:
2304    ///
2305    /// 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.
2306    ///
2307    /// # Arguments
2308    ///
2309    /// * `request` - No description provided.
2310    /// * `name` - Database to export. Should be of the form: `projects/{project_id}/databases/{database_id}`.
2311    pub fn databases_export_documents(
2312        &self,
2313        request: GoogleFirestoreAdminV1beta1ExportDocumentsRequest,
2314        name: &str,
2315    ) -> ProjectDatabaseExportDocumentCall<'a, C> {
2316        ProjectDatabaseExportDocumentCall {
2317            hub: self.hub,
2318            _request: request,
2319            _name: name.to_string(),
2320            _delegate: Default::default(),
2321            _additional_params: Default::default(),
2322            _scopes: Default::default(),
2323        }
2324    }
2325
2326    /// Create a builder to help you perform the following task:
2327    ///
2328    /// 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.
2329    ///
2330    /// # Arguments
2331    ///
2332    /// * `request` - No description provided.
2333    /// * `name` - Database to import into. Should be of the form: `projects/{project_id}/databases/{database_id}`.
2334    pub fn databases_import_documents(
2335        &self,
2336        request: GoogleFirestoreAdminV1beta1ImportDocumentsRequest,
2337        name: &str,
2338    ) -> ProjectDatabaseImportDocumentCall<'a, C> {
2339        ProjectDatabaseImportDocumentCall {
2340            hub: self.hub,
2341            _request: request,
2342            _name: name.to_string(),
2343            _delegate: Default::default(),
2344            _additional_params: Default::default(),
2345            _scopes: Default::default(),
2346        }
2347    }
2348}
2349
2350// ###################
2351// CallBuilders   ###
2352// #################
2353
2354/// Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
2355///
2356/// A builder for the *databases.documents.batchGet* method supported by a *project* resource.
2357/// It is not used directly, but through a [`ProjectMethods`] instance.
2358///
2359/// # Example
2360///
2361/// Instantiate a resource method builder
2362///
2363/// ```test_harness,no_run
2364/// # extern crate hyper;
2365/// # extern crate hyper_rustls;
2366/// # extern crate google_firestore1_beta1 as firestore1_beta1;
2367/// use firestore1_beta1::api::BatchGetDocumentsRequest;
2368/// # async fn dox() {
2369/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2370///
2371/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2372/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2373/// #     secret,
2374/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2375/// # ).build().await.unwrap();
2376///
2377/// # let client = hyper_util::client::legacy::Client::builder(
2378/// #     hyper_util::rt::TokioExecutor::new()
2379/// # )
2380/// # .build(
2381/// #     hyper_rustls::HttpsConnectorBuilder::new()
2382/// #         .with_native_roots()
2383/// #         .unwrap()
2384/// #         .https_or_http()
2385/// #         .enable_http1()
2386/// #         .build()
2387/// # );
2388/// # let mut hub = Firestore::new(client, auth);
2389/// // As the method needs a request, you would usually fill it with the desired information
2390/// // into the respective structure. Some of the parts shown here might not be applicable !
2391/// // Values shown here are possibly random and not representative !
2392/// let mut req = BatchGetDocumentsRequest::default();
2393///
2394/// // You can configure optional parameters by calling the respective setters at will, and
2395/// // execute the final call using `doit()`.
2396/// // Values shown here are possibly random and not representative !
2397/// let result = hub.projects().databases_documents_batch_get(req, "database")
2398///              .doit().await;
2399/// # }
2400/// ```
2401pub struct ProjectDatabaseDocumentBatchGetCall<'a, C>
2402where
2403    C: 'a,
2404{
2405    hub: &'a Firestore<C>,
2406    _request: BatchGetDocumentsRequest,
2407    _database: String,
2408    _delegate: Option<&'a mut dyn common::Delegate>,
2409    _additional_params: HashMap<String, String>,
2410    _scopes: BTreeSet<String>,
2411}
2412
2413impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBatchGetCall<'a, C> {}
2414
2415impl<'a, C> ProjectDatabaseDocumentBatchGetCall<'a, C>
2416where
2417    C: common::Connector,
2418{
2419    /// Perform the operation you have build so far.
2420    pub async fn doit(mut self) -> common::Result<(common::Response, BatchGetDocumentsResponse)> {
2421        use std::borrow::Cow;
2422        use std::io::{Read, Seek};
2423
2424        use common::{url::Params, ToParts};
2425        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2426
2427        let mut dd = common::DefaultDelegate;
2428        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2429        dlg.begin(common::MethodInfo {
2430            id: "firestore.projects.databases.documents.batchGet",
2431            http_method: hyper::Method::POST,
2432        });
2433
2434        for &field in ["alt", "database"].iter() {
2435            if self._additional_params.contains_key(field) {
2436                dlg.finished(false);
2437                return Err(common::Error::FieldClash(field));
2438            }
2439        }
2440
2441        let mut params = Params::with_capacity(4 + self._additional_params.len());
2442        params.push("database", self._database);
2443
2444        params.extend(self._additional_params.iter());
2445
2446        params.push("alt", "json");
2447        let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:batchGet";
2448        if self._scopes.is_empty() {
2449            self._scopes
2450                .insert(Scope::CloudPlatform.as_ref().to_string());
2451        }
2452
2453        #[allow(clippy::single_element_loop)]
2454        for &(find_this, param_name) in [("{+database}", "database")].iter() {
2455            url = params.uri_replacement(url, param_name, find_this, true);
2456        }
2457        {
2458            let to_remove = ["database"];
2459            params.remove_params(&to_remove);
2460        }
2461
2462        let url = params.parse_with_url(&url);
2463
2464        let mut json_mime_type = mime::APPLICATION_JSON;
2465        let mut request_value_reader = {
2466            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2467            common::remove_json_null_values(&mut value);
2468            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2469            serde_json::to_writer(&mut dst, &value).unwrap();
2470            dst
2471        };
2472        let request_size = request_value_reader
2473            .seek(std::io::SeekFrom::End(0))
2474            .unwrap();
2475        request_value_reader
2476            .seek(std::io::SeekFrom::Start(0))
2477            .unwrap();
2478
2479        loop {
2480            let token = match self
2481                .hub
2482                .auth
2483                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2484                .await
2485            {
2486                Ok(token) => token,
2487                Err(e) => match dlg.token(e) {
2488                    Ok(token) => token,
2489                    Err(e) => {
2490                        dlg.finished(false);
2491                        return Err(common::Error::MissingToken(e));
2492                    }
2493                },
2494            };
2495            request_value_reader
2496                .seek(std::io::SeekFrom::Start(0))
2497                .unwrap();
2498            let mut req_result = {
2499                let client = &self.hub.client;
2500                dlg.pre_request();
2501                let mut req_builder = hyper::Request::builder()
2502                    .method(hyper::Method::POST)
2503                    .uri(url.as_str())
2504                    .header(USER_AGENT, self.hub._user_agent.clone());
2505
2506                if let Some(token) = token.as_ref() {
2507                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2508                }
2509
2510                let request = req_builder
2511                    .header(CONTENT_TYPE, json_mime_type.to_string())
2512                    .header(CONTENT_LENGTH, request_size as u64)
2513                    .body(common::to_body(
2514                        request_value_reader.get_ref().clone().into(),
2515                    ));
2516
2517                client.request(request.unwrap()).await
2518            };
2519
2520            match req_result {
2521                Err(err) => {
2522                    if let common::Retry::After(d) = dlg.http_error(&err) {
2523                        sleep(d).await;
2524                        continue;
2525                    }
2526                    dlg.finished(false);
2527                    return Err(common::Error::HttpError(err));
2528                }
2529                Ok(res) => {
2530                    let (mut parts, body) = res.into_parts();
2531                    let mut body = common::Body::new(body);
2532                    if !parts.status.is_success() {
2533                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2534                        let error = serde_json::from_str(&common::to_string(&bytes));
2535                        let response = common::to_response(parts, bytes.into());
2536
2537                        if let common::Retry::After(d) =
2538                            dlg.http_failure(&response, error.as_ref().ok())
2539                        {
2540                            sleep(d).await;
2541                            continue;
2542                        }
2543
2544                        dlg.finished(false);
2545
2546                        return Err(match error {
2547                            Ok(value) => common::Error::BadRequest(value),
2548                            _ => common::Error::Failure(response),
2549                        });
2550                    }
2551                    let response = {
2552                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2553                        let encoded = common::to_string(&bytes);
2554                        match serde_json::from_str(&encoded) {
2555                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2556                            Err(error) => {
2557                                dlg.response_json_decode_error(&encoded, &error);
2558                                return Err(common::Error::JsonDecodeError(
2559                                    encoded.to_string(),
2560                                    error,
2561                                ));
2562                            }
2563                        }
2564                    };
2565
2566                    dlg.finished(true);
2567                    return Ok(response);
2568                }
2569            }
2570        }
2571    }
2572
2573    ///
2574    /// Sets the *request* property to the given value.
2575    ///
2576    /// Even though the property as already been set when instantiating this call,
2577    /// we provide this method for API completeness.
2578    pub fn request(
2579        mut self,
2580        new_value: BatchGetDocumentsRequest,
2581    ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2582        self._request = new_value;
2583        self
2584    }
2585    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2586    ///
2587    /// Sets the *database* path property to the given value.
2588    ///
2589    /// Even though the property as already been set when instantiating this call,
2590    /// we provide this method for API completeness.
2591    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2592        self._database = new_value.to_string();
2593        self
2594    }
2595    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2596    /// while executing the actual API request.
2597    ///
2598    /// ````text
2599    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2600    /// ````
2601    ///
2602    /// Sets the *delegate* property to the given value.
2603    pub fn delegate(
2604        mut self,
2605        new_value: &'a mut dyn common::Delegate,
2606    ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2607        self._delegate = Some(new_value);
2608        self
2609    }
2610
2611    /// Set any additional parameter of the query string used in the request.
2612    /// It should be used to set parameters which are not yet available through their own
2613    /// setters.
2614    ///
2615    /// Please note that this method must not be used to set any of the known parameters
2616    /// which have their own setter method. If done anyway, the request will fail.
2617    ///
2618    /// # Additional Parameters
2619    ///
2620    /// * *$.xgafv* (query-string) - V1 error format.
2621    /// * *access_token* (query-string) - OAuth access token.
2622    /// * *alt* (query-string) - Data format for response.
2623    /// * *callback* (query-string) - JSONP
2624    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2625    /// * *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.
2626    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2627    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2628    /// * *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.
2629    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2630    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2631    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
2632    where
2633        T: AsRef<str>,
2634    {
2635        self._additional_params
2636            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2637        self
2638    }
2639
2640    /// Identifies the authorization scope for the method you are building.
2641    ///
2642    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2643    /// [`Scope::CloudPlatform`].
2644    ///
2645    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2646    /// tokens for more than one scope.
2647    ///
2648    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2649    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2650    /// sufficient, a read-write scope will do as well.
2651    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
2652    where
2653        St: AsRef<str>,
2654    {
2655        self._scopes.insert(String::from(scope.as_ref()));
2656        self
2657    }
2658    /// Identifies the authorization scope(s) for the method you are building.
2659    ///
2660    /// See [`Self::add_scope()`] for details.
2661    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
2662    where
2663        I: IntoIterator<Item = St>,
2664        St: AsRef<str>,
2665    {
2666        self._scopes
2667            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2668        self
2669    }
2670
2671    /// Removes all scopes, and no default scope will be used either.
2672    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2673    /// for details).
2674    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2675        self._scopes.clear();
2676        self
2677    }
2678}
2679
2680/// 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.
2681///
2682/// A builder for the *databases.documents.batchWrite* method supported by a *project* resource.
2683/// It is not used directly, but through a [`ProjectMethods`] instance.
2684///
2685/// # Example
2686///
2687/// Instantiate a resource method builder
2688///
2689/// ```test_harness,no_run
2690/// # extern crate hyper;
2691/// # extern crate hyper_rustls;
2692/// # extern crate google_firestore1_beta1 as firestore1_beta1;
2693/// use firestore1_beta1::api::BatchWriteRequest;
2694/// # async fn dox() {
2695/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2696///
2697/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2698/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2699/// #     secret,
2700/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2701/// # ).build().await.unwrap();
2702///
2703/// # let client = hyper_util::client::legacy::Client::builder(
2704/// #     hyper_util::rt::TokioExecutor::new()
2705/// # )
2706/// # .build(
2707/// #     hyper_rustls::HttpsConnectorBuilder::new()
2708/// #         .with_native_roots()
2709/// #         .unwrap()
2710/// #         .https_or_http()
2711/// #         .enable_http1()
2712/// #         .build()
2713/// # );
2714/// # let mut hub = Firestore::new(client, auth);
2715/// // As the method needs a request, you would usually fill it with the desired information
2716/// // into the respective structure. Some of the parts shown here might not be applicable !
2717/// // Values shown here are possibly random and not representative !
2718/// let mut req = BatchWriteRequest::default();
2719///
2720/// // You can configure optional parameters by calling the respective setters at will, and
2721/// // execute the final call using `doit()`.
2722/// // Values shown here are possibly random and not representative !
2723/// let result = hub.projects().databases_documents_batch_write(req, "database")
2724///              .doit().await;
2725/// # }
2726/// ```
2727pub struct ProjectDatabaseDocumentBatchWriteCall<'a, C>
2728where
2729    C: 'a,
2730{
2731    hub: &'a Firestore<C>,
2732    _request: BatchWriteRequest,
2733    _database: String,
2734    _delegate: Option<&'a mut dyn common::Delegate>,
2735    _additional_params: HashMap<String, String>,
2736    _scopes: BTreeSet<String>,
2737}
2738
2739impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBatchWriteCall<'a, C> {}
2740
2741impl<'a, C> ProjectDatabaseDocumentBatchWriteCall<'a, C>
2742where
2743    C: common::Connector,
2744{
2745    /// Perform the operation you have build so far.
2746    pub async fn doit(mut self) -> common::Result<(common::Response, BatchWriteResponse)> {
2747        use std::borrow::Cow;
2748        use std::io::{Read, Seek};
2749
2750        use common::{url::Params, ToParts};
2751        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2752
2753        let mut dd = common::DefaultDelegate;
2754        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2755        dlg.begin(common::MethodInfo {
2756            id: "firestore.projects.databases.documents.batchWrite",
2757            http_method: hyper::Method::POST,
2758        });
2759
2760        for &field in ["alt", "database"].iter() {
2761            if self._additional_params.contains_key(field) {
2762                dlg.finished(false);
2763                return Err(common::Error::FieldClash(field));
2764            }
2765        }
2766
2767        let mut params = Params::with_capacity(4 + self._additional_params.len());
2768        params.push("database", self._database);
2769
2770        params.extend(self._additional_params.iter());
2771
2772        params.push("alt", "json");
2773        let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:batchWrite";
2774        if self._scopes.is_empty() {
2775            self._scopes
2776                .insert(Scope::CloudPlatform.as_ref().to_string());
2777        }
2778
2779        #[allow(clippy::single_element_loop)]
2780        for &(find_this, param_name) in [("{+database}", "database")].iter() {
2781            url = params.uri_replacement(url, param_name, find_this, true);
2782        }
2783        {
2784            let to_remove = ["database"];
2785            params.remove_params(&to_remove);
2786        }
2787
2788        let url = params.parse_with_url(&url);
2789
2790        let mut json_mime_type = mime::APPLICATION_JSON;
2791        let mut request_value_reader = {
2792            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2793            common::remove_json_null_values(&mut value);
2794            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2795            serde_json::to_writer(&mut dst, &value).unwrap();
2796            dst
2797        };
2798        let request_size = request_value_reader
2799            .seek(std::io::SeekFrom::End(0))
2800            .unwrap();
2801        request_value_reader
2802            .seek(std::io::SeekFrom::Start(0))
2803            .unwrap();
2804
2805        loop {
2806            let token = match self
2807                .hub
2808                .auth
2809                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2810                .await
2811            {
2812                Ok(token) => token,
2813                Err(e) => match dlg.token(e) {
2814                    Ok(token) => token,
2815                    Err(e) => {
2816                        dlg.finished(false);
2817                        return Err(common::Error::MissingToken(e));
2818                    }
2819                },
2820            };
2821            request_value_reader
2822                .seek(std::io::SeekFrom::Start(0))
2823                .unwrap();
2824            let mut req_result = {
2825                let client = &self.hub.client;
2826                dlg.pre_request();
2827                let mut req_builder = hyper::Request::builder()
2828                    .method(hyper::Method::POST)
2829                    .uri(url.as_str())
2830                    .header(USER_AGENT, self.hub._user_agent.clone());
2831
2832                if let Some(token) = token.as_ref() {
2833                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2834                }
2835
2836                let request = req_builder
2837                    .header(CONTENT_TYPE, json_mime_type.to_string())
2838                    .header(CONTENT_LENGTH, request_size as u64)
2839                    .body(common::to_body(
2840                        request_value_reader.get_ref().clone().into(),
2841                    ));
2842
2843                client.request(request.unwrap()).await
2844            };
2845
2846            match req_result {
2847                Err(err) => {
2848                    if let common::Retry::After(d) = dlg.http_error(&err) {
2849                        sleep(d).await;
2850                        continue;
2851                    }
2852                    dlg.finished(false);
2853                    return Err(common::Error::HttpError(err));
2854                }
2855                Ok(res) => {
2856                    let (mut parts, body) = res.into_parts();
2857                    let mut body = common::Body::new(body);
2858                    if !parts.status.is_success() {
2859                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2860                        let error = serde_json::from_str(&common::to_string(&bytes));
2861                        let response = common::to_response(parts, bytes.into());
2862
2863                        if let common::Retry::After(d) =
2864                            dlg.http_failure(&response, error.as_ref().ok())
2865                        {
2866                            sleep(d).await;
2867                            continue;
2868                        }
2869
2870                        dlg.finished(false);
2871
2872                        return Err(match error {
2873                            Ok(value) => common::Error::BadRequest(value),
2874                            _ => common::Error::Failure(response),
2875                        });
2876                    }
2877                    let response = {
2878                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2879                        let encoded = common::to_string(&bytes);
2880                        match serde_json::from_str(&encoded) {
2881                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2882                            Err(error) => {
2883                                dlg.response_json_decode_error(&encoded, &error);
2884                                return Err(common::Error::JsonDecodeError(
2885                                    encoded.to_string(),
2886                                    error,
2887                                ));
2888                            }
2889                        }
2890                    };
2891
2892                    dlg.finished(true);
2893                    return Ok(response);
2894                }
2895            }
2896        }
2897    }
2898
2899    ///
2900    /// Sets the *request* property to the given value.
2901    ///
2902    /// Even though the property as already been set when instantiating this call,
2903    /// we provide this method for API completeness.
2904    pub fn request(
2905        mut self,
2906        new_value: BatchWriteRequest,
2907    ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
2908        self._request = new_value;
2909        self
2910    }
2911    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2912    ///
2913    /// Sets the *database* path property to the given value.
2914    ///
2915    /// Even though the property as already been set when instantiating this call,
2916    /// we provide this method for API completeness.
2917    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
2918        self._database = new_value.to_string();
2919        self
2920    }
2921    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2922    /// while executing the actual API request.
2923    ///
2924    /// ````text
2925    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2926    /// ````
2927    ///
2928    /// Sets the *delegate* property to the given value.
2929    pub fn delegate(
2930        mut self,
2931        new_value: &'a mut dyn common::Delegate,
2932    ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
2933        self._delegate = Some(new_value);
2934        self
2935    }
2936
2937    /// Set any additional parameter of the query string used in the request.
2938    /// It should be used to set parameters which are not yet available through their own
2939    /// setters.
2940    ///
2941    /// Please note that this method must not be used to set any of the known parameters
2942    /// which have their own setter method. If done anyway, the request will fail.
2943    ///
2944    /// # Additional Parameters
2945    ///
2946    /// * *$.xgafv* (query-string) - V1 error format.
2947    /// * *access_token* (query-string) - OAuth access token.
2948    /// * *alt* (query-string) - Data format for response.
2949    /// * *callback* (query-string) - JSONP
2950    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2951    /// * *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.
2952    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2953    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2954    /// * *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.
2955    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2956    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2957    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
2958    where
2959        T: AsRef<str>,
2960    {
2961        self._additional_params
2962            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2963        self
2964    }
2965
2966    /// Identifies the authorization scope for the method you are building.
2967    ///
2968    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2969    /// [`Scope::CloudPlatform`].
2970    ///
2971    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2972    /// tokens for more than one scope.
2973    ///
2974    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2975    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2976    /// sufficient, a read-write scope will do as well.
2977    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
2978    where
2979        St: AsRef<str>,
2980    {
2981        self._scopes.insert(String::from(scope.as_ref()));
2982        self
2983    }
2984    /// Identifies the authorization scope(s) for the method you are building.
2985    ///
2986    /// See [`Self::add_scope()`] for details.
2987    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
2988    where
2989        I: IntoIterator<Item = St>,
2990        St: AsRef<str>,
2991    {
2992        self._scopes
2993            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2994        self
2995    }
2996
2997    /// Removes all scopes, and no default scope will be used either.
2998    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2999    /// for details).
3000    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
3001        self._scopes.clear();
3002        self
3003    }
3004}
3005
3006/// Starts a new transaction.
3007///
3008/// A builder for the *databases.documents.beginTransaction* method supported by a *project* resource.
3009/// It is not used directly, but through a [`ProjectMethods`] instance.
3010///
3011/// # Example
3012///
3013/// Instantiate a resource method builder
3014///
3015/// ```test_harness,no_run
3016/// # extern crate hyper;
3017/// # extern crate hyper_rustls;
3018/// # extern crate google_firestore1_beta1 as firestore1_beta1;
3019/// use firestore1_beta1::api::BeginTransactionRequest;
3020/// # async fn dox() {
3021/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3022///
3023/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3024/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3025/// #     secret,
3026/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3027/// # ).build().await.unwrap();
3028///
3029/// # let client = hyper_util::client::legacy::Client::builder(
3030/// #     hyper_util::rt::TokioExecutor::new()
3031/// # )
3032/// # .build(
3033/// #     hyper_rustls::HttpsConnectorBuilder::new()
3034/// #         .with_native_roots()
3035/// #         .unwrap()
3036/// #         .https_or_http()
3037/// #         .enable_http1()
3038/// #         .build()
3039/// # );
3040/// # let mut hub = Firestore::new(client, auth);
3041/// // As the method needs a request, you would usually fill it with the desired information
3042/// // into the respective structure. Some of the parts shown here might not be applicable !
3043/// // Values shown here are possibly random and not representative !
3044/// let mut req = BeginTransactionRequest::default();
3045///
3046/// // You can configure optional parameters by calling the respective setters at will, and
3047/// // execute the final call using `doit()`.
3048/// // Values shown here are possibly random and not representative !
3049/// let result = hub.projects().databases_documents_begin_transaction(req, "database")
3050///              .doit().await;
3051/// # }
3052/// ```
3053pub struct ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3054where
3055    C: 'a,
3056{
3057    hub: &'a Firestore<C>,
3058    _request: BeginTransactionRequest,
3059    _database: String,
3060    _delegate: Option<&'a mut dyn common::Delegate>,
3061    _additional_params: HashMap<String, String>,
3062    _scopes: BTreeSet<String>,
3063}
3064
3065impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBeginTransactionCall<'a, C> {}
3066
3067impl<'a, C> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3068where
3069    C: common::Connector,
3070{
3071    /// Perform the operation you have build so far.
3072    pub async fn doit(mut self) -> common::Result<(common::Response, BeginTransactionResponse)> {
3073        use std::borrow::Cow;
3074        use std::io::{Read, Seek};
3075
3076        use common::{url::Params, ToParts};
3077        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3078
3079        let mut dd = common::DefaultDelegate;
3080        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3081        dlg.begin(common::MethodInfo {
3082            id: "firestore.projects.databases.documents.beginTransaction",
3083            http_method: hyper::Method::POST,
3084        });
3085
3086        for &field in ["alt", "database"].iter() {
3087            if self._additional_params.contains_key(field) {
3088                dlg.finished(false);
3089                return Err(common::Error::FieldClash(field));
3090            }
3091        }
3092
3093        let mut params = Params::with_capacity(4 + self._additional_params.len());
3094        params.push("database", self._database);
3095
3096        params.extend(self._additional_params.iter());
3097
3098        params.push("alt", "json");
3099        let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:beginTransaction";
3100        if self._scopes.is_empty() {
3101            self._scopes
3102                .insert(Scope::CloudPlatform.as_ref().to_string());
3103        }
3104
3105        #[allow(clippy::single_element_loop)]
3106        for &(find_this, param_name) in [("{+database}", "database")].iter() {
3107            url = params.uri_replacement(url, param_name, find_this, true);
3108        }
3109        {
3110            let to_remove = ["database"];
3111            params.remove_params(&to_remove);
3112        }
3113
3114        let url = params.parse_with_url(&url);
3115
3116        let mut json_mime_type = mime::APPLICATION_JSON;
3117        let mut request_value_reader = {
3118            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3119            common::remove_json_null_values(&mut value);
3120            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3121            serde_json::to_writer(&mut dst, &value).unwrap();
3122            dst
3123        };
3124        let request_size = request_value_reader
3125            .seek(std::io::SeekFrom::End(0))
3126            .unwrap();
3127        request_value_reader
3128            .seek(std::io::SeekFrom::Start(0))
3129            .unwrap();
3130
3131        loop {
3132            let token = match self
3133                .hub
3134                .auth
3135                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3136                .await
3137            {
3138                Ok(token) => token,
3139                Err(e) => match dlg.token(e) {
3140                    Ok(token) => token,
3141                    Err(e) => {
3142                        dlg.finished(false);
3143                        return Err(common::Error::MissingToken(e));
3144                    }
3145                },
3146            };
3147            request_value_reader
3148                .seek(std::io::SeekFrom::Start(0))
3149                .unwrap();
3150            let mut req_result = {
3151                let client = &self.hub.client;
3152                dlg.pre_request();
3153                let mut req_builder = hyper::Request::builder()
3154                    .method(hyper::Method::POST)
3155                    .uri(url.as_str())
3156                    .header(USER_AGENT, self.hub._user_agent.clone());
3157
3158                if let Some(token) = token.as_ref() {
3159                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3160                }
3161
3162                let request = req_builder
3163                    .header(CONTENT_TYPE, json_mime_type.to_string())
3164                    .header(CONTENT_LENGTH, request_size as u64)
3165                    .body(common::to_body(
3166                        request_value_reader.get_ref().clone().into(),
3167                    ));
3168
3169                client.request(request.unwrap()).await
3170            };
3171
3172            match req_result {
3173                Err(err) => {
3174                    if let common::Retry::After(d) = dlg.http_error(&err) {
3175                        sleep(d).await;
3176                        continue;
3177                    }
3178                    dlg.finished(false);
3179                    return Err(common::Error::HttpError(err));
3180                }
3181                Ok(res) => {
3182                    let (mut parts, body) = res.into_parts();
3183                    let mut body = common::Body::new(body);
3184                    if !parts.status.is_success() {
3185                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3186                        let error = serde_json::from_str(&common::to_string(&bytes));
3187                        let response = common::to_response(parts, bytes.into());
3188
3189                        if let common::Retry::After(d) =
3190                            dlg.http_failure(&response, error.as_ref().ok())
3191                        {
3192                            sleep(d).await;
3193                            continue;
3194                        }
3195
3196                        dlg.finished(false);
3197
3198                        return Err(match error {
3199                            Ok(value) => common::Error::BadRequest(value),
3200                            _ => common::Error::Failure(response),
3201                        });
3202                    }
3203                    let response = {
3204                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3205                        let encoded = common::to_string(&bytes);
3206                        match serde_json::from_str(&encoded) {
3207                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3208                            Err(error) => {
3209                                dlg.response_json_decode_error(&encoded, &error);
3210                                return Err(common::Error::JsonDecodeError(
3211                                    encoded.to_string(),
3212                                    error,
3213                                ));
3214                            }
3215                        }
3216                    };
3217
3218                    dlg.finished(true);
3219                    return Ok(response);
3220                }
3221            }
3222        }
3223    }
3224
3225    ///
3226    /// Sets the *request* property to the given value.
3227    ///
3228    /// Even though the property as already been set when instantiating this call,
3229    /// we provide this method for API completeness.
3230    pub fn request(
3231        mut self,
3232        new_value: BeginTransactionRequest,
3233    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3234        self._request = new_value;
3235        self
3236    }
3237    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3238    ///
3239    /// Sets the *database* path property to the given value.
3240    ///
3241    /// Even though the property as already been set when instantiating this call,
3242    /// we provide this method for API completeness.
3243    pub fn database(
3244        mut self,
3245        new_value: &str,
3246    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3247        self._database = new_value.to_string();
3248        self
3249    }
3250    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3251    /// while executing the actual API request.
3252    ///
3253    /// ````text
3254    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3255    /// ````
3256    ///
3257    /// Sets the *delegate* property to the given value.
3258    pub fn delegate(
3259        mut self,
3260        new_value: &'a mut dyn common::Delegate,
3261    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3262        self._delegate = Some(new_value);
3263        self
3264    }
3265
3266    /// Set any additional parameter of the query string used in the request.
3267    /// It should be used to set parameters which are not yet available through their own
3268    /// setters.
3269    ///
3270    /// Please note that this method must not be used to set any of the known parameters
3271    /// which have their own setter method. If done anyway, the request will fail.
3272    ///
3273    /// # Additional Parameters
3274    ///
3275    /// * *$.xgafv* (query-string) - V1 error format.
3276    /// * *access_token* (query-string) - OAuth access token.
3277    /// * *alt* (query-string) - Data format for response.
3278    /// * *callback* (query-string) - JSONP
3279    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3280    /// * *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.
3281    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3282    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3283    /// * *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.
3284    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3285    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3286    pub fn param<T>(
3287        mut self,
3288        name: T,
3289        value: T,
3290    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3291    where
3292        T: AsRef<str>,
3293    {
3294        self._additional_params
3295            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3296        self
3297    }
3298
3299    /// Identifies the authorization scope for the method you are building.
3300    ///
3301    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3302    /// [`Scope::CloudPlatform`].
3303    ///
3304    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3305    /// tokens for more than one scope.
3306    ///
3307    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3308    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3309    /// sufficient, a read-write scope will do as well.
3310    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3311    where
3312        St: AsRef<str>,
3313    {
3314        self._scopes.insert(String::from(scope.as_ref()));
3315        self
3316    }
3317    /// Identifies the authorization scope(s) for the method you are building.
3318    ///
3319    /// See [`Self::add_scope()`] for details.
3320    pub fn add_scopes<I, St>(
3321        mut self,
3322        scopes: I,
3323    ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3324    where
3325        I: IntoIterator<Item = St>,
3326        St: AsRef<str>,
3327    {
3328        self._scopes
3329            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3330        self
3331    }
3332
3333    /// Removes all scopes, and no default scope will be used either.
3334    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3335    /// for details).
3336    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3337        self._scopes.clear();
3338        self
3339    }
3340}
3341
3342/// Commits a transaction, while optionally updating documents.
3343///
3344/// A builder for the *databases.documents.commit* method supported by a *project* resource.
3345/// It is not used directly, but through a [`ProjectMethods`] instance.
3346///
3347/// # Example
3348///
3349/// Instantiate a resource method builder
3350///
3351/// ```test_harness,no_run
3352/// # extern crate hyper;
3353/// # extern crate hyper_rustls;
3354/// # extern crate google_firestore1_beta1 as firestore1_beta1;
3355/// use firestore1_beta1::api::CommitRequest;
3356/// # async fn dox() {
3357/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3358///
3359/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3360/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3361/// #     secret,
3362/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3363/// # ).build().await.unwrap();
3364///
3365/// # let client = hyper_util::client::legacy::Client::builder(
3366/// #     hyper_util::rt::TokioExecutor::new()
3367/// # )
3368/// # .build(
3369/// #     hyper_rustls::HttpsConnectorBuilder::new()
3370/// #         .with_native_roots()
3371/// #         .unwrap()
3372/// #         .https_or_http()
3373/// #         .enable_http1()
3374/// #         .build()
3375/// # );
3376/// # let mut hub = Firestore::new(client, auth);
3377/// // As the method needs a request, you would usually fill it with the desired information
3378/// // into the respective structure. Some of the parts shown here might not be applicable !
3379/// // Values shown here are possibly random and not representative !
3380/// let mut req = CommitRequest::default();
3381///
3382/// // You can configure optional parameters by calling the respective setters at will, and
3383/// // execute the final call using `doit()`.
3384/// // Values shown here are possibly random and not representative !
3385/// let result = hub.projects().databases_documents_commit(req, "database")
3386///              .doit().await;
3387/// # }
3388/// ```
3389pub struct ProjectDatabaseDocumentCommitCall<'a, C>
3390where
3391    C: 'a,
3392{
3393    hub: &'a Firestore<C>,
3394    _request: CommitRequest,
3395    _database: String,
3396    _delegate: Option<&'a mut dyn common::Delegate>,
3397    _additional_params: HashMap<String, String>,
3398    _scopes: BTreeSet<String>,
3399}
3400
3401impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentCommitCall<'a, C> {}
3402
3403impl<'a, C> ProjectDatabaseDocumentCommitCall<'a, C>
3404where
3405    C: common::Connector,
3406{
3407    /// Perform the operation you have build so far.
3408    pub async fn doit(mut self) -> common::Result<(common::Response, CommitResponse)> {
3409        use std::borrow::Cow;
3410        use std::io::{Read, Seek};
3411
3412        use common::{url::Params, ToParts};
3413        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3414
3415        let mut dd = common::DefaultDelegate;
3416        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3417        dlg.begin(common::MethodInfo {
3418            id: "firestore.projects.databases.documents.commit",
3419            http_method: hyper::Method::POST,
3420        });
3421
3422        for &field in ["alt", "database"].iter() {
3423            if self._additional_params.contains_key(field) {
3424                dlg.finished(false);
3425                return Err(common::Error::FieldClash(field));
3426            }
3427        }
3428
3429        let mut params = Params::with_capacity(4 + self._additional_params.len());
3430        params.push("database", self._database);
3431
3432        params.extend(self._additional_params.iter());
3433
3434        params.push("alt", "json");
3435        let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:commit";
3436        if self._scopes.is_empty() {
3437            self._scopes
3438                .insert(Scope::CloudPlatform.as_ref().to_string());
3439        }
3440
3441        #[allow(clippy::single_element_loop)]
3442        for &(find_this, param_name) in [("{+database}", "database")].iter() {
3443            url = params.uri_replacement(url, param_name, find_this, true);
3444        }
3445        {
3446            let to_remove = ["database"];
3447            params.remove_params(&to_remove);
3448        }
3449
3450        let url = params.parse_with_url(&url);
3451
3452        let mut json_mime_type = mime::APPLICATION_JSON;
3453        let mut request_value_reader = {
3454            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3455            common::remove_json_null_values(&mut value);
3456            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3457            serde_json::to_writer(&mut dst, &value).unwrap();
3458            dst
3459        };
3460        let request_size = request_value_reader
3461            .seek(std::io::SeekFrom::End(0))
3462            .unwrap();
3463        request_value_reader
3464            .seek(std::io::SeekFrom::Start(0))
3465            .unwrap();
3466
3467        loop {
3468            let token = match self
3469                .hub
3470                .auth
3471                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3472                .await
3473            {
3474                Ok(token) => token,
3475                Err(e) => match dlg.token(e) {
3476                    Ok(token) => token,
3477                    Err(e) => {
3478                        dlg.finished(false);
3479                        return Err(common::Error::MissingToken(e));
3480                    }
3481                },
3482            };
3483            request_value_reader
3484                .seek(std::io::SeekFrom::Start(0))
3485                .unwrap();
3486            let mut req_result = {
3487                let client = &self.hub.client;
3488                dlg.pre_request();
3489                let mut req_builder = hyper::Request::builder()
3490                    .method(hyper::Method::POST)
3491                    .uri(url.as_str())
3492                    .header(USER_AGENT, self.hub._user_agent.clone());
3493
3494                if let Some(token) = token.as_ref() {
3495                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3496                }
3497
3498                let request = req_builder
3499                    .header(CONTENT_TYPE, json_mime_type.to_string())
3500                    .header(CONTENT_LENGTH, request_size as u64)
3501                    .body(common::to_body(
3502                        request_value_reader.get_ref().clone().into(),
3503                    ));
3504
3505                client.request(request.unwrap()).await
3506            };
3507
3508            match req_result {
3509                Err(err) => {
3510                    if let common::Retry::After(d) = dlg.http_error(&err) {
3511                        sleep(d).await;
3512                        continue;
3513                    }
3514                    dlg.finished(false);
3515                    return Err(common::Error::HttpError(err));
3516                }
3517                Ok(res) => {
3518                    let (mut parts, body) = res.into_parts();
3519                    let mut body = common::Body::new(body);
3520                    if !parts.status.is_success() {
3521                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3522                        let error = serde_json::from_str(&common::to_string(&bytes));
3523                        let response = common::to_response(parts, bytes.into());
3524
3525                        if let common::Retry::After(d) =
3526                            dlg.http_failure(&response, error.as_ref().ok())
3527                        {
3528                            sleep(d).await;
3529                            continue;
3530                        }
3531
3532                        dlg.finished(false);
3533
3534                        return Err(match error {
3535                            Ok(value) => common::Error::BadRequest(value),
3536                            _ => common::Error::Failure(response),
3537                        });
3538                    }
3539                    let response = {
3540                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3541                        let encoded = common::to_string(&bytes);
3542                        match serde_json::from_str(&encoded) {
3543                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3544                            Err(error) => {
3545                                dlg.response_json_decode_error(&encoded, &error);
3546                                return Err(common::Error::JsonDecodeError(
3547                                    encoded.to_string(),
3548                                    error,
3549                                ));
3550                            }
3551                        }
3552                    };
3553
3554                    dlg.finished(true);
3555                    return Ok(response);
3556                }
3557            }
3558        }
3559    }
3560
3561    ///
3562    /// Sets the *request* property to the given value.
3563    ///
3564    /// Even though the property as already been set when instantiating this call,
3565    /// we provide this method for API completeness.
3566    pub fn request(mut self, new_value: CommitRequest) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3567        self._request = new_value;
3568        self
3569    }
3570    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3571    ///
3572    /// Sets the *database* path property to the given value.
3573    ///
3574    /// Even though the property as already been set when instantiating this call,
3575    /// we provide this method for API completeness.
3576    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3577        self._database = new_value.to_string();
3578        self
3579    }
3580    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3581    /// while executing the actual API request.
3582    ///
3583    /// ````text
3584    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3585    /// ````
3586    ///
3587    /// Sets the *delegate* property to the given value.
3588    pub fn delegate(
3589        mut self,
3590        new_value: &'a mut dyn common::Delegate,
3591    ) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3592        self._delegate = Some(new_value);
3593        self
3594    }
3595
3596    /// Set any additional parameter of the query string used in the request.
3597    /// It should be used to set parameters which are not yet available through their own
3598    /// setters.
3599    ///
3600    /// Please note that this method must not be used to set any of the known parameters
3601    /// which have their own setter method. If done anyway, the request will fail.
3602    ///
3603    /// # Additional Parameters
3604    ///
3605    /// * *$.xgafv* (query-string) - V1 error format.
3606    /// * *access_token* (query-string) - OAuth access token.
3607    /// * *alt* (query-string) - Data format for response.
3608    /// * *callback* (query-string) - JSONP
3609    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3610    /// * *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.
3611    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3612    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3613    /// * *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.
3614    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3615    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3616    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentCommitCall<'a, C>
3617    where
3618        T: AsRef<str>,
3619    {
3620        self._additional_params
3621            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3622        self
3623    }
3624
3625    /// Identifies the authorization scope for the method you are building.
3626    ///
3627    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3628    /// [`Scope::CloudPlatform`].
3629    ///
3630    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3631    /// tokens for more than one scope.
3632    ///
3633    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3634    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3635    /// sufficient, a read-write scope will do as well.
3636    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentCommitCall<'a, C>
3637    where
3638        St: AsRef<str>,
3639    {
3640        self._scopes.insert(String::from(scope.as_ref()));
3641        self
3642    }
3643    /// Identifies the authorization scope(s) for the method you are building.
3644    ///
3645    /// See [`Self::add_scope()`] for details.
3646    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentCommitCall<'a, C>
3647    where
3648        I: IntoIterator<Item = St>,
3649        St: AsRef<str>,
3650    {
3651        self._scopes
3652            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3653        self
3654    }
3655
3656    /// Removes all scopes, and no default scope will be used either.
3657    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3658    /// for details).
3659    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3660        self._scopes.clear();
3661        self
3662    }
3663}
3664
3665/// Creates a new document.
3666///
3667/// A builder for the *databases.documents.createDocument* method supported by a *project* resource.
3668/// It is not used directly, but through a [`ProjectMethods`] instance.
3669///
3670/// # Example
3671///
3672/// Instantiate a resource method builder
3673///
3674/// ```test_harness,no_run
3675/// # extern crate hyper;
3676/// # extern crate hyper_rustls;
3677/// # extern crate google_firestore1_beta1 as firestore1_beta1;
3678/// use firestore1_beta1::api::Document;
3679/// # async fn dox() {
3680/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3681///
3682/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3683/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3684/// #     secret,
3685/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3686/// # ).build().await.unwrap();
3687///
3688/// # let client = hyper_util::client::legacy::Client::builder(
3689/// #     hyper_util::rt::TokioExecutor::new()
3690/// # )
3691/// # .build(
3692/// #     hyper_rustls::HttpsConnectorBuilder::new()
3693/// #         .with_native_roots()
3694/// #         .unwrap()
3695/// #         .https_or_http()
3696/// #         .enable_http1()
3697/// #         .build()
3698/// # );
3699/// # let mut hub = Firestore::new(client, auth);
3700/// // As the method needs a request, you would usually fill it with the desired information
3701/// // into the respective structure. Some of the parts shown here might not be applicable !
3702/// // Values shown here are possibly random and not representative !
3703/// let mut req = Document::default();
3704///
3705/// // You can configure optional parameters by calling the respective setters at will, and
3706/// // execute the final call using `doit()`.
3707/// // Values shown here are possibly random and not representative !
3708/// let result = hub.projects().databases_documents_create_document(req, "parent", "collectionId")
3709///              .add_mask_field_paths("takimata")
3710///              .document_id("amet.")
3711///              .doit().await;
3712/// # }
3713/// ```
3714pub struct ProjectDatabaseDocumentCreateDocumentCall<'a, C>
3715where
3716    C: 'a,
3717{
3718    hub: &'a Firestore<C>,
3719    _request: Document,
3720    _parent: String,
3721    _collection_id: String,
3722    _mask_field_paths: Vec<String>,
3723    _document_id: Option<String>,
3724    _delegate: Option<&'a mut dyn common::Delegate>,
3725    _additional_params: HashMap<String, String>,
3726    _scopes: BTreeSet<String>,
3727}
3728
3729impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentCreateDocumentCall<'a, C> {}
3730
3731impl<'a, C> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
3732where
3733    C: common::Connector,
3734{
3735    /// Perform the operation you have build so far.
3736    pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
3737        use std::borrow::Cow;
3738        use std::io::{Read, Seek};
3739
3740        use common::{url::Params, ToParts};
3741        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3742
3743        let mut dd = common::DefaultDelegate;
3744        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3745        dlg.begin(common::MethodInfo {
3746            id: "firestore.projects.databases.documents.createDocument",
3747            http_method: hyper::Method::POST,
3748        });
3749
3750        for &field in [
3751            "alt",
3752            "parent",
3753            "collectionId",
3754            "mask.fieldPaths",
3755            "documentId",
3756        ]
3757        .iter()
3758        {
3759            if self._additional_params.contains_key(field) {
3760                dlg.finished(false);
3761                return Err(common::Error::FieldClash(field));
3762            }
3763        }
3764
3765        let mut params = Params::with_capacity(7 + self._additional_params.len());
3766        params.push("parent", self._parent);
3767        params.push("collectionId", self._collection_id);
3768        if !self._mask_field_paths.is_empty() {
3769            for f in self._mask_field_paths.iter() {
3770                params.push("mask.fieldPaths", f);
3771            }
3772        }
3773        if let Some(value) = self._document_id.as_ref() {
3774            params.push("documentId", value);
3775        }
3776
3777        params.extend(self._additional_params.iter());
3778
3779        params.push("alt", "json");
3780        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/{collectionId}";
3781        if self._scopes.is_empty() {
3782            self._scopes
3783                .insert(Scope::CloudPlatform.as_ref().to_string());
3784        }
3785
3786        #[allow(clippy::single_element_loop)]
3787        for &(find_this, param_name) in
3788            [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
3789        {
3790            url = params.uri_replacement(url, param_name, find_this, true);
3791        }
3792        {
3793            let to_remove = ["collectionId", "parent"];
3794            params.remove_params(&to_remove);
3795        }
3796
3797        let url = params.parse_with_url(&url);
3798
3799        let mut json_mime_type = mime::APPLICATION_JSON;
3800        let mut request_value_reader = {
3801            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3802            common::remove_json_null_values(&mut value);
3803            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3804            serde_json::to_writer(&mut dst, &value).unwrap();
3805            dst
3806        };
3807        let request_size = request_value_reader
3808            .seek(std::io::SeekFrom::End(0))
3809            .unwrap();
3810        request_value_reader
3811            .seek(std::io::SeekFrom::Start(0))
3812            .unwrap();
3813
3814        loop {
3815            let token = match self
3816                .hub
3817                .auth
3818                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3819                .await
3820            {
3821                Ok(token) => token,
3822                Err(e) => match dlg.token(e) {
3823                    Ok(token) => token,
3824                    Err(e) => {
3825                        dlg.finished(false);
3826                        return Err(common::Error::MissingToken(e));
3827                    }
3828                },
3829            };
3830            request_value_reader
3831                .seek(std::io::SeekFrom::Start(0))
3832                .unwrap();
3833            let mut req_result = {
3834                let client = &self.hub.client;
3835                dlg.pre_request();
3836                let mut req_builder = hyper::Request::builder()
3837                    .method(hyper::Method::POST)
3838                    .uri(url.as_str())
3839                    .header(USER_AGENT, self.hub._user_agent.clone());
3840
3841                if let Some(token) = token.as_ref() {
3842                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3843                }
3844
3845                let request = req_builder
3846                    .header(CONTENT_TYPE, json_mime_type.to_string())
3847                    .header(CONTENT_LENGTH, request_size as u64)
3848                    .body(common::to_body(
3849                        request_value_reader.get_ref().clone().into(),
3850                    ));
3851
3852                client.request(request.unwrap()).await
3853            };
3854
3855            match req_result {
3856                Err(err) => {
3857                    if let common::Retry::After(d) = dlg.http_error(&err) {
3858                        sleep(d).await;
3859                        continue;
3860                    }
3861                    dlg.finished(false);
3862                    return Err(common::Error::HttpError(err));
3863                }
3864                Ok(res) => {
3865                    let (mut parts, body) = res.into_parts();
3866                    let mut body = common::Body::new(body);
3867                    if !parts.status.is_success() {
3868                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3869                        let error = serde_json::from_str(&common::to_string(&bytes));
3870                        let response = common::to_response(parts, bytes.into());
3871
3872                        if let common::Retry::After(d) =
3873                            dlg.http_failure(&response, error.as_ref().ok())
3874                        {
3875                            sleep(d).await;
3876                            continue;
3877                        }
3878
3879                        dlg.finished(false);
3880
3881                        return Err(match error {
3882                            Ok(value) => common::Error::BadRequest(value),
3883                            _ => common::Error::Failure(response),
3884                        });
3885                    }
3886                    let response = {
3887                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3888                        let encoded = common::to_string(&bytes);
3889                        match serde_json::from_str(&encoded) {
3890                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3891                            Err(error) => {
3892                                dlg.response_json_decode_error(&encoded, &error);
3893                                return Err(common::Error::JsonDecodeError(
3894                                    encoded.to_string(),
3895                                    error,
3896                                ));
3897                            }
3898                        }
3899                    };
3900
3901                    dlg.finished(true);
3902                    return Ok(response);
3903                }
3904            }
3905        }
3906    }
3907
3908    ///
3909    /// Sets the *request* property to the given value.
3910    ///
3911    /// Even though the property as already been set when instantiating this call,
3912    /// we provide this method for API completeness.
3913    pub fn request(
3914        mut self,
3915        new_value: Document,
3916    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
3917        self._request = new_value;
3918        self
3919    }
3920    /// Required. The parent resource. For example: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
3921    ///
3922    /// Sets the *parent* path property to the given value.
3923    ///
3924    /// Even though the property as already been set when instantiating this call,
3925    /// we provide this method for API completeness.
3926    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
3927        self._parent = new_value.to_string();
3928        self
3929    }
3930    /// Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
3931    ///
3932    /// Sets the *collection id* path property to the given value.
3933    ///
3934    /// Even though the property as already been set when instantiating this call,
3935    /// we provide this method for API completeness.
3936    pub fn collection_id(
3937        mut self,
3938        new_value: &str,
3939    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
3940        self._collection_id = new_value.to_string();
3941        self
3942    }
3943    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
3944    ///
3945    /// Append the given value to the *mask.field paths* query property.
3946    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3947    pub fn add_mask_field_paths(
3948        mut self,
3949        new_value: &str,
3950    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
3951        self._mask_field_paths.push(new_value.to_string());
3952        self
3953    }
3954    /// The client-assigned document ID to use for this document. Optional. If not specified, an ID will be assigned by the service.
3955    ///
3956    /// Sets the *document id* query property to the given value.
3957    pub fn document_id(
3958        mut self,
3959        new_value: &str,
3960    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
3961        self._document_id = Some(new_value.to_string());
3962        self
3963    }
3964    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3965    /// while executing the actual API request.
3966    ///
3967    /// ````text
3968    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3969    /// ````
3970    ///
3971    /// Sets the *delegate* property to the given value.
3972    pub fn delegate(
3973        mut self,
3974        new_value: &'a mut dyn common::Delegate,
3975    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
3976        self._delegate = Some(new_value);
3977        self
3978    }
3979
3980    /// Set any additional parameter of the query string used in the request.
3981    /// It should be used to set parameters which are not yet available through their own
3982    /// setters.
3983    ///
3984    /// Please note that this method must not be used to set any of the known parameters
3985    /// which have their own setter method. If done anyway, the request will fail.
3986    ///
3987    /// # Additional Parameters
3988    ///
3989    /// * *$.xgafv* (query-string) - V1 error format.
3990    /// * *access_token* (query-string) - OAuth access token.
3991    /// * *alt* (query-string) - Data format for response.
3992    /// * *callback* (query-string) - JSONP
3993    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3994    /// * *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.
3995    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3996    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3997    /// * *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.
3998    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3999    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4000    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
4001    where
4002        T: AsRef<str>,
4003    {
4004        self._additional_params
4005            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4006        self
4007    }
4008
4009    /// Identifies the authorization scope for the method you are building.
4010    ///
4011    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4012    /// [`Scope::CloudPlatform`].
4013    ///
4014    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4015    /// tokens for more than one scope.
4016    ///
4017    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4018    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4019    /// sufficient, a read-write scope will do as well.
4020    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
4021    where
4022        St: AsRef<str>,
4023    {
4024        self._scopes.insert(String::from(scope.as_ref()));
4025        self
4026    }
4027    /// Identifies the authorization scope(s) for the method you are building.
4028    ///
4029    /// See [`Self::add_scope()`] for details.
4030    pub fn add_scopes<I, St>(
4031        mut self,
4032        scopes: I,
4033    ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
4034    where
4035        I: IntoIterator<Item = St>,
4036        St: AsRef<str>,
4037    {
4038        self._scopes
4039            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4040        self
4041    }
4042
4043    /// Removes all scopes, and no default scope will be used either.
4044    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4045    /// for details).
4046    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
4047        self._scopes.clear();
4048        self
4049    }
4050}
4051
4052/// Deletes a document.
4053///
4054/// A builder for the *databases.documents.delete* method supported by a *project* resource.
4055/// It is not used directly, but through a [`ProjectMethods`] instance.
4056///
4057/// # Example
4058///
4059/// Instantiate a resource method builder
4060///
4061/// ```test_harness,no_run
4062/// # extern crate hyper;
4063/// # extern crate hyper_rustls;
4064/// # extern crate google_firestore1_beta1 as firestore1_beta1;
4065/// # async fn dox() {
4066/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4067///
4068/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4069/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4070/// #     secret,
4071/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4072/// # ).build().await.unwrap();
4073///
4074/// # let client = hyper_util::client::legacy::Client::builder(
4075/// #     hyper_util::rt::TokioExecutor::new()
4076/// # )
4077/// # .build(
4078/// #     hyper_rustls::HttpsConnectorBuilder::new()
4079/// #         .with_native_roots()
4080/// #         .unwrap()
4081/// #         .https_or_http()
4082/// #         .enable_http1()
4083/// #         .build()
4084/// # );
4085/// # let mut hub = Firestore::new(client, auth);
4086/// // You can configure optional parameters by calling the respective setters at will, and
4087/// // execute the final call using `doit()`.
4088/// // Values shown here are possibly random and not representative !
4089/// let result = hub.projects().databases_documents_delete("name")
4090///              .current_document_update_time(chrono::Utc::now())
4091///              .current_document_exists(true)
4092///              .doit().await;
4093/// # }
4094/// ```
4095pub struct ProjectDatabaseDocumentDeleteCall<'a, C>
4096where
4097    C: 'a,
4098{
4099    hub: &'a Firestore<C>,
4100    _name: String,
4101    _current_document_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
4102    _current_document_exists: Option<bool>,
4103    _delegate: Option<&'a mut dyn common::Delegate>,
4104    _additional_params: HashMap<String, String>,
4105    _scopes: BTreeSet<String>,
4106}
4107
4108impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentDeleteCall<'a, C> {}
4109
4110impl<'a, C> ProjectDatabaseDocumentDeleteCall<'a, C>
4111where
4112    C: common::Connector,
4113{
4114    /// Perform the operation you have build so far.
4115    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4116        use std::borrow::Cow;
4117        use std::io::{Read, Seek};
4118
4119        use common::{url::Params, ToParts};
4120        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4121
4122        let mut dd = common::DefaultDelegate;
4123        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4124        dlg.begin(common::MethodInfo {
4125            id: "firestore.projects.databases.documents.delete",
4126            http_method: hyper::Method::DELETE,
4127        });
4128
4129        for &field in [
4130            "alt",
4131            "name",
4132            "currentDocument.updateTime",
4133            "currentDocument.exists",
4134        ]
4135        .iter()
4136        {
4137            if self._additional_params.contains_key(field) {
4138                dlg.finished(false);
4139                return Err(common::Error::FieldClash(field));
4140            }
4141        }
4142
4143        let mut params = Params::with_capacity(5 + self._additional_params.len());
4144        params.push("name", self._name);
4145        if let Some(value) = self._current_document_update_time.as_ref() {
4146            params.push(
4147                "currentDocument.updateTime",
4148                common::serde::datetime_to_string(&value),
4149            );
4150        }
4151        if let Some(value) = self._current_document_exists.as_ref() {
4152            params.push("currentDocument.exists", value.to_string());
4153        }
4154
4155        params.extend(self._additional_params.iter());
4156
4157        params.push("alt", "json");
4158        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4159        if self._scopes.is_empty() {
4160            self._scopes
4161                .insert(Scope::CloudPlatform.as_ref().to_string());
4162        }
4163
4164        #[allow(clippy::single_element_loop)]
4165        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4166            url = params.uri_replacement(url, param_name, find_this, true);
4167        }
4168        {
4169            let to_remove = ["name"];
4170            params.remove_params(&to_remove);
4171        }
4172
4173        let url = params.parse_with_url(&url);
4174
4175        loop {
4176            let token = match self
4177                .hub
4178                .auth
4179                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4180                .await
4181            {
4182                Ok(token) => token,
4183                Err(e) => match dlg.token(e) {
4184                    Ok(token) => token,
4185                    Err(e) => {
4186                        dlg.finished(false);
4187                        return Err(common::Error::MissingToken(e));
4188                    }
4189                },
4190            };
4191            let mut req_result = {
4192                let client = &self.hub.client;
4193                dlg.pre_request();
4194                let mut req_builder = hyper::Request::builder()
4195                    .method(hyper::Method::DELETE)
4196                    .uri(url.as_str())
4197                    .header(USER_AGENT, self.hub._user_agent.clone());
4198
4199                if let Some(token) = token.as_ref() {
4200                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4201                }
4202
4203                let request = req_builder
4204                    .header(CONTENT_LENGTH, 0_u64)
4205                    .body(common::to_body::<String>(None));
4206
4207                client.request(request.unwrap()).await
4208            };
4209
4210            match req_result {
4211                Err(err) => {
4212                    if let common::Retry::After(d) = dlg.http_error(&err) {
4213                        sleep(d).await;
4214                        continue;
4215                    }
4216                    dlg.finished(false);
4217                    return Err(common::Error::HttpError(err));
4218                }
4219                Ok(res) => {
4220                    let (mut parts, body) = res.into_parts();
4221                    let mut body = common::Body::new(body);
4222                    if !parts.status.is_success() {
4223                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4224                        let error = serde_json::from_str(&common::to_string(&bytes));
4225                        let response = common::to_response(parts, bytes.into());
4226
4227                        if let common::Retry::After(d) =
4228                            dlg.http_failure(&response, error.as_ref().ok())
4229                        {
4230                            sleep(d).await;
4231                            continue;
4232                        }
4233
4234                        dlg.finished(false);
4235
4236                        return Err(match error {
4237                            Ok(value) => common::Error::BadRequest(value),
4238                            _ => common::Error::Failure(response),
4239                        });
4240                    }
4241                    let response = {
4242                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4243                        let encoded = common::to_string(&bytes);
4244                        match serde_json::from_str(&encoded) {
4245                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4246                            Err(error) => {
4247                                dlg.response_json_decode_error(&encoded, &error);
4248                                return Err(common::Error::JsonDecodeError(
4249                                    encoded.to_string(),
4250                                    error,
4251                                ));
4252                            }
4253                        }
4254                    };
4255
4256                    dlg.finished(true);
4257                    return Ok(response);
4258                }
4259            }
4260        }
4261    }
4262
4263    /// Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
4264    ///
4265    /// Sets the *name* path property to the given value.
4266    ///
4267    /// Even though the property as already been set when instantiating this call,
4268    /// we provide this method for API completeness.
4269    pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4270        self._name = new_value.to_string();
4271        self
4272    }
4273    /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
4274    ///
4275    /// Sets the *current document.update time* query property to the given value.
4276    pub fn current_document_update_time(
4277        mut self,
4278        new_value: chrono::DateTime<chrono::offset::Utc>,
4279    ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4280        self._current_document_update_time = Some(new_value);
4281        self
4282    }
4283    /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
4284    ///
4285    /// Sets the *current document.exists* query property to the given value.
4286    pub fn current_document_exists(
4287        mut self,
4288        new_value: bool,
4289    ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4290        self._current_document_exists = Some(new_value);
4291        self
4292    }
4293    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4294    /// while executing the actual API request.
4295    ///
4296    /// ````text
4297    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4298    /// ````
4299    ///
4300    /// Sets the *delegate* property to the given value.
4301    pub fn delegate(
4302        mut self,
4303        new_value: &'a mut dyn common::Delegate,
4304    ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4305        self._delegate = Some(new_value);
4306        self
4307    }
4308
4309    /// Set any additional parameter of the query string used in the request.
4310    /// It should be used to set parameters which are not yet available through their own
4311    /// setters.
4312    ///
4313    /// Please note that this method must not be used to set any of the known parameters
4314    /// which have their own setter method. If done anyway, the request will fail.
4315    ///
4316    /// # Additional Parameters
4317    ///
4318    /// * *$.xgafv* (query-string) - V1 error format.
4319    /// * *access_token* (query-string) - OAuth access token.
4320    /// * *alt* (query-string) - Data format for response.
4321    /// * *callback* (query-string) - JSONP
4322    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4323    /// * *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.
4324    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4325    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4326    /// * *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.
4327    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4328    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4329    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentDeleteCall<'a, C>
4330    where
4331        T: AsRef<str>,
4332    {
4333        self._additional_params
4334            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4335        self
4336    }
4337
4338    /// Identifies the authorization scope for the method you are building.
4339    ///
4340    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4341    /// [`Scope::CloudPlatform`].
4342    ///
4343    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4344    /// tokens for more than one scope.
4345    ///
4346    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4347    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4348    /// sufficient, a read-write scope will do as well.
4349    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentDeleteCall<'a, C>
4350    where
4351        St: AsRef<str>,
4352    {
4353        self._scopes.insert(String::from(scope.as_ref()));
4354        self
4355    }
4356    /// Identifies the authorization scope(s) for the method you are building.
4357    ///
4358    /// See [`Self::add_scope()`] for details.
4359    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentDeleteCall<'a, C>
4360    where
4361        I: IntoIterator<Item = St>,
4362        St: AsRef<str>,
4363    {
4364        self._scopes
4365            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4366        self
4367    }
4368
4369    /// Removes all scopes, and no default scope will be used either.
4370    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4371    /// for details).
4372    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4373        self._scopes.clear();
4374        self
4375    }
4376}
4377
4378/// Gets a single document.
4379///
4380/// A builder for the *databases.documents.get* method supported by a *project* resource.
4381/// It is not used directly, but through a [`ProjectMethods`] instance.
4382///
4383/// # Example
4384///
4385/// Instantiate a resource method builder
4386///
4387/// ```test_harness,no_run
4388/// # extern crate hyper;
4389/// # extern crate hyper_rustls;
4390/// # extern crate google_firestore1_beta1 as firestore1_beta1;
4391/// # async fn dox() {
4392/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4393///
4394/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4395/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4396/// #     secret,
4397/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4398/// # ).build().await.unwrap();
4399///
4400/// # let client = hyper_util::client::legacy::Client::builder(
4401/// #     hyper_util::rt::TokioExecutor::new()
4402/// # )
4403/// # .build(
4404/// #     hyper_rustls::HttpsConnectorBuilder::new()
4405/// #         .with_native_roots()
4406/// #         .unwrap()
4407/// #         .https_or_http()
4408/// #         .enable_http1()
4409/// #         .build()
4410/// # );
4411/// # let mut hub = Firestore::new(client, auth);
4412/// // You can configure optional parameters by calling the respective setters at will, and
4413/// // execute the final call using `doit()`.
4414/// // Values shown here are possibly random and not representative !
4415/// let result = hub.projects().databases_documents_get("name")
4416///              .transaction(vec![0, 1, 2, 3])
4417///              .read_time(chrono::Utc::now())
4418///              .add_mask_field_paths("Lorem")
4419///              .doit().await;
4420/// # }
4421/// ```
4422pub struct ProjectDatabaseDocumentGetCall<'a, C>
4423where
4424    C: 'a,
4425{
4426    hub: &'a Firestore<C>,
4427    _name: String,
4428    _transaction: Option<Vec<u8>>,
4429    _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
4430    _mask_field_paths: Vec<String>,
4431    _delegate: Option<&'a mut dyn common::Delegate>,
4432    _additional_params: HashMap<String, String>,
4433    _scopes: BTreeSet<String>,
4434}
4435
4436impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentGetCall<'a, C> {}
4437
4438impl<'a, C> ProjectDatabaseDocumentGetCall<'a, C>
4439where
4440    C: common::Connector,
4441{
4442    /// Perform the operation you have build so far.
4443    pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
4444        use std::borrow::Cow;
4445        use std::io::{Read, Seek};
4446
4447        use common::{url::Params, ToParts};
4448        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4449
4450        let mut dd = common::DefaultDelegate;
4451        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4452        dlg.begin(common::MethodInfo {
4453            id: "firestore.projects.databases.documents.get",
4454            http_method: hyper::Method::GET,
4455        });
4456
4457        for &field in ["alt", "name", "transaction", "readTime", "mask.fieldPaths"].iter() {
4458            if self._additional_params.contains_key(field) {
4459                dlg.finished(false);
4460                return Err(common::Error::FieldClash(field));
4461            }
4462        }
4463
4464        let mut params = Params::with_capacity(6 + self._additional_params.len());
4465        params.push("name", self._name);
4466        if let Some(value) = self._transaction.as_ref() {
4467            params.push(
4468                "transaction",
4469                common::serde::standard_base64::to_string(&value),
4470            );
4471        }
4472        if let Some(value) = self._read_time.as_ref() {
4473            params.push("readTime", common::serde::datetime_to_string(&value));
4474        }
4475        if !self._mask_field_paths.is_empty() {
4476            for f in self._mask_field_paths.iter() {
4477                params.push("mask.fieldPaths", f);
4478            }
4479        }
4480
4481        params.extend(self._additional_params.iter());
4482
4483        params.push("alt", "json");
4484        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4485        if self._scopes.is_empty() {
4486            self._scopes
4487                .insert(Scope::CloudPlatform.as_ref().to_string());
4488        }
4489
4490        #[allow(clippy::single_element_loop)]
4491        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4492            url = params.uri_replacement(url, param_name, find_this, true);
4493        }
4494        {
4495            let to_remove = ["name"];
4496            params.remove_params(&to_remove);
4497        }
4498
4499        let url = params.parse_with_url(&url);
4500
4501        loop {
4502            let token = match self
4503                .hub
4504                .auth
4505                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4506                .await
4507            {
4508                Ok(token) => token,
4509                Err(e) => match dlg.token(e) {
4510                    Ok(token) => token,
4511                    Err(e) => {
4512                        dlg.finished(false);
4513                        return Err(common::Error::MissingToken(e));
4514                    }
4515                },
4516            };
4517            let mut req_result = {
4518                let client = &self.hub.client;
4519                dlg.pre_request();
4520                let mut req_builder = hyper::Request::builder()
4521                    .method(hyper::Method::GET)
4522                    .uri(url.as_str())
4523                    .header(USER_AGENT, self.hub._user_agent.clone());
4524
4525                if let Some(token) = token.as_ref() {
4526                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4527                }
4528
4529                let request = req_builder
4530                    .header(CONTENT_LENGTH, 0_u64)
4531                    .body(common::to_body::<String>(None));
4532
4533                client.request(request.unwrap()).await
4534            };
4535
4536            match req_result {
4537                Err(err) => {
4538                    if let common::Retry::After(d) = dlg.http_error(&err) {
4539                        sleep(d).await;
4540                        continue;
4541                    }
4542                    dlg.finished(false);
4543                    return Err(common::Error::HttpError(err));
4544                }
4545                Ok(res) => {
4546                    let (mut parts, body) = res.into_parts();
4547                    let mut body = common::Body::new(body);
4548                    if !parts.status.is_success() {
4549                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4550                        let error = serde_json::from_str(&common::to_string(&bytes));
4551                        let response = common::to_response(parts, bytes.into());
4552
4553                        if let common::Retry::After(d) =
4554                            dlg.http_failure(&response, error.as_ref().ok())
4555                        {
4556                            sleep(d).await;
4557                            continue;
4558                        }
4559
4560                        dlg.finished(false);
4561
4562                        return Err(match error {
4563                            Ok(value) => common::Error::BadRequest(value),
4564                            _ => common::Error::Failure(response),
4565                        });
4566                    }
4567                    let response = {
4568                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4569                        let encoded = common::to_string(&bytes);
4570                        match serde_json::from_str(&encoded) {
4571                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4572                            Err(error) => {
4573                                dlg.response_json_decode_error(&encoded, &error);
4574                                return Err(common::Error::JsonDecodeError(
4575                                    encoded.to_string(),
4576                                    error,
4577                                ));
4578                            }
4579                        }
4580                    };
4581
4582                    dlg.finished(true);
4583                    return Ok(response);
4584                }
4585            }
4586        }
4587    }
4588
4589    /// Required. The resource name of the Document to get. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
4590    ///
4591    /// Sets the *name* path property to the given value.
4592    ///
4593    /// Even though the property as already been set when instantiating this call,
4594    /// we provide this method for API completeness.
4595    pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentGetCall<'a, C> {
4596        self._name = new_value.to_string();
4597        self
4598    }
4599    /// Reads the document in a transaction.
4600    ///
4601    /// Sets the *transaction* query property to the given value.
4602    pub fn transaction(mut self, new_value: Vec<u8>) -> ProjectDatabaseDocumentGetCall<'a, C> {
4603        self._transaction = Some(new_value);
4604        self
4605    }
4606    /// 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.
4607    ///
4608    /// Sets the *read time* query property to the given value.
4609    pub fn read_time(
4610        mut self,
4611        new_value: chrono::DateTime<chrono::offset::Utc>,
4612    ) -> ProjectDatabaseDocumentGetCall<'a, C> {
4613        self._read_time = Some(new_value);
4614        self
4615    }
4616    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
4617    ///
4618    /// Append the given value to the *mask.field paths* query property.
4619    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4620    pub fn add_mask_field_paths(
4621        mut self,
4622        new_value: &str,
4623    ) -> ProjectDatabaseDocumentGetCall<'a, C> {
4624        self._mask_field_paths.push(new_value.to_string());
4625        self
4626    }
4627    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4628    /// while executing the actual API request.
4629    ///
4630    /// ````text
4631    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4632    /// ````
4633    ///
4634    /// Sets the *delegate* property to the given value.
4635    pub fn delegate(
4636        mut self,
4637        new_value: &'a mut dyn common::Delegate,
4638    ) -> ProjectDatabaseDocumentGetCall<'a, C> {
4639        self._delegate = Some(new_value);
4640        self
4641    }
4642
4643    /// Set any additional parameter of the query string used in the request.
4644    /// It should be used to set parameters which are not yet available through their own
4645    /// setters.
4646    ///
4647    /// Please note that this method must not be used to set any of the known parameters
4648    /// which have their own setter method. If done anyway, the request will fail.
4649    ///
4650    /// # Additional Parameters
4651    ///
4652    /// * *$.xgafv* (query-string) - V1 error format.
4653    /// * *access_token* (query-string) - OAuth access token.
4654    /// * *alt* (query-string) - Data format for response.
4655    /// * *callback* (query-string) - JSONP
4656    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4657    /// * *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.
4658    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4659    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4660    /// * *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.
4661    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4662    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4663    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentGetCall<'a, C>
4664    where
4665        T: AsRef<str>,
4666    {
4667        self._additional_params
4668            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4669        self
4670    }
4671
4672    /// Identifies the authorization scope for the method you are building.
4673    ///
4674    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4675    /// [`Scope::CloudPlatform`].
4676    ///
4677    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4678    /// tokens for more than one scope.
4679    ///
4680    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4681    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4682    /// sufficient, a read-write scope will do as well.
4683    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentGetCall<'a, C>
4684    where
4685        St: AsRef<str>,
4686    {
4687        self._scopes.insert(String::from(scope.as_ref()));
4688        self
4689    }
4690    /// Identifies the authorization scope(s) for the method you are building.
4691    ///
4692    /// See [`Self::add_scope()`] for details.
4693    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentGetCall<'a, C>
4694    where
4695        I: IntoIterator<Item = St>,
4696        St: AsRef<str>,
4697    {
4698        self._scopes
4699            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4700        self
4701    }
4702
4703    /// Removes all scopes, and no default scope will be used either.
4704    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4705    /// for details).
4706    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentGetCall<'a, C> {
4707        self._scopes.clear();
4708        self
4709    }
4710}
4711
4712/// Lists documents.
4713///
4714/// A builder for the *databases.documents.list* method supported by a *project* resource.
4715/// It is not used directly, but through a [`ProjectMethods`] instance.
4716///
4717/// # Example
4718///
4719/// Instantiate a resource method builder
4720///
4721/// ```test_harness,no_run
4722/// # extern crate hyper;
4723/// # extern crate hyper_rustls;
4724/// # extern crate google_firestore1_beta1 as firestore1_beta1;
4725/// # async fn dox() {
4726/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4727///
4728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4729/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4730/// #     secret,
4731/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4732/// # ).build().await.unwrap();
4733///
4734/// # let client = hyper_util::client::legacy::Client::builder(
4735/// #     hyper_util::rt::TokioExecutor::new()
4736/// # )
4737/// # .build(
4738/// #     hyper_rustls::HttpsConnectorBuilder::new()
4739/// #         .with_native_roots()
4740/// #         .unwrap()
4741/// #         .https_or_http()
4742/// #         .enable_http1()
4743/// #         .build()
4744/// # );
4745/// # let mut hub = Firestore::new(client, auth);
4746/// // You can configure optional parameters by calling the respective setters at will, and
4747/// // execute the final call using `doit()`.
4748/// // Values shown here are possibly random and not representative !
4749/// let result = hub.projects().databases_documents_list("parent", "collectionId")
4750///              .transaction(vec![0, 1, 2, 3])
4751///              .show_missing(true)
4752///              .read_time(chrono::Utc::now())
4753///              .page_token("invidunt")
4754///              .page_size(-47)
4755///              .order_by("duo")
4756///              .add_mask_field_paths("ipsum")
4757///              .doit().await;
4758/// # }
4759/// ```
4760pub struct ProjectDatabaseDocumentListCall<'a, C>
4761where
4762    C: 'a,
4763{
4764    hub: &'a Firestore<C>,
4765    _parent: String,
4766    _collection_id: String,
4767    _transaction: Option<Vec<u8>>,
4768    _show_missing: Option<bool>,
4769    _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
4770    _page_token: Option<String>,
4771    _page_size: Option<i32>,
4772    _order_by: Option<String>,
4773    _mask_field_paths: Vec<String>,
4774    _delegate: Option<&'a mut dyn common::Delegate>,
4775    _additional_params: HashMap<String, String>,
4776    _scopes: BTreeSet<String>,
4777}
4778
4779impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListCall<'a, C> {}
4780
4781impl<'a, C> ProjectDatabaseDocumentListCall<'a, C>
4782where
4783    C: common::Connector,
4784{
4785    /// Perform the operation you have build so far.
4786    pub async fn doit(mut self) -> common::Result<(common::Response, ListDocumentsResponse)> {
4787        use std::borrow::Cow;
4788        use std::io::{Read, Seek};
4789
4790        use common::{url::Params, ToParts};
4791        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4792
4793        let mut dd = common::DefaultDelegate;
4794        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4795        dlg.begin(common::MethodInfo {
4796            id: "firestore.projects.databases.documents.list",
4797            http_method: hyper::Method::GET,
4798        });
4799
4800        for &field in [
4801            "alt",
4802            "parent",
4803            "collectionId",
4804            "transaction",
4805            "showMissing",
4806            "readTime",
4807            "pageToken",
4808            "pageSize",
4809            "orderBy",
4810            "mask.fieldPaths",
4811        ]
4812        .iter()
4813        {
4814            if self._additional_params.contains_key(field) {
4815                dlg.finished(false);
4816                return Err(common::Error::FieldClash(field));
4817            }
4818        }
4819
4820        let mut params = Params::with_capacity(11 + self._additional_params.len());
4821        params.push("parent", self._parent);
4822        params.push("collectionId", self._collection_id);
4823        if let Some(value) = self._transaction.as_ref() {
4824            params.push(
4825                "transaction",
4826                common::serde::standard_base64::to_string(&value),
4827            );
4828        }
4829        if let Some(value) = self._show_missing.as_ref() {
4830            params.push("showMissing", value.to_string());
4831        }
4832        if let Some(value) = self._read_time.as_ref() {
4833            params.push("readTime", common::serde::datetime_to_string(&value));
4834        }
4835        if let Some(value) = self._page_token.as_ref() {
4836            params.push("pageToken", value);
4837        }
4838        if let Some(value) = self._page_size.as_ref() {
4839            params.push("pageSize", value.to_string());
4840        }
4841        if let Some(value) = self._order_by.as_ref() {
4842            params.push("orderBy", value);
4843        }
4844        if !self._mask_field_paths.is_empty() {
4845            for f in self._mask_field_paths.iter() {
4846                params.push("mask.fieldPaths", f);
4847            }
4848        }
4849
4850        params.extend(self._additional_params.iter());
4851
4852        params.push("alt", "json");
4853        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/{collectionId}";
4854        if self._scopes.is_empty() {
4855            self._scopes
4856                .insert(Scope::CloudPlatform.as_ref().to_string());
4857        }
4858
4859        #[allow(clippy::single_element_loop)]
4860        for &(find_this, param_name) in
4861            [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
4862        {
4863            url = params.uri_replacement(url, param_name, find_this, true);
4864        }
4865        {
4866            let to_remove = ["collectionId", "parent"];
4867            params.remove_params(&to_remove);
4868        }
4869
4870        let url = params.parse_with_url(&url);
4871
4872        loop {
4873            let token = match self
4874                .hub
4875                .auth
4876                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4877                .await
4878            {
4879                Ok(token) => token,
4880                Err(e) => match dlg.token(e) {
4881                    Ok(token) => token,
4882                    Err(e) => {
4883                        dlg.finished(false);
4884                        return Err(common::Error::MissingToken(e));
4885                    }
4886                },
4887            };
4888            let mut req_result = {
4889                let client = &self.hub.client;
4890                dlg.pre_request();
4891                let mut req_builder = hyper::Request::builder()
4892                    .method(hyper::Method::GET)
4893                    .uri(url.as_str())
4894                    .header(USER_AGENT, self.hub._user_agent.clone());
4895
4896                if let Some(token) = token.as_ref() {
4897                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4898                }
4899
4900                let request = req_builder
4901                    .header(CONTENT_LENGTH, 0_u64)
4902                    .body(common::to_body::<String>(None));
4903
4904                client.request(request.unwrap()).await
4905            };
4906
4907            match req_result {
4908                Err(err) => {
4909                    if let common::Retry::After(d) = dlg.http_error(&err) {
4910                        sleep(d).await;
4911                        continue;
4912                    }
4913                    dlg.finished(false);
4914                    return Err(common::Error::HttpError(err));
4915                }
4916                Ok(res) => {
4917                    let (mut parts, body) = res.into_parts();
4918                    let mut body = common::Body::new(body);
4919                    if !parts.status.is_success() {
4920                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4921                        let error = serde_json::from_str(&common::to_string(&bytes));
4922                        let response = common::to_response(parts, bytes.into());
4923
4924                        if let common::Retry::After(d) =
4925                            dlg.http_failure(&response, error.as_ref().ok())
4926                        {
4927                            sleep(d).await;
4928                            continue;
4929                        }
4930
4931                        dlg.finished(false);
4932
4933                        return Err(match error {
4934                            Ok(value) => common::Error::BadRequest(value),
4935                            _ => common::Error::Failure(response),
4936                        });
4937                    }
4938                    let response = {
4939                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4940                        let encoded = common::to_string(&bytes);
4941                        match serde_json::from_str(&encoded) {
4942                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4943                            Err(error) => {
4944                                dlg.response_json_decode_error(&encoded, &error);
4945                                return Err(common::Error::JsonDecodeError(
4946                                    encoded.to_string(),
4947                                    error,
4948                                ));
4949                            }
4950                        }
4951                    };
4952
4953                    dlg.finished(true);
4954                    return Ok(response);
4955                }
4956            }
4957        }
4958    }
4959
4960    /// 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`
4961    ///
4962    /// Sets the *parent* path property to the given value.
4963    ///
4964    /// Even though the property as already been set when instantiating this call,
4965    /// we provide this method for API completeness.
4966    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
4967        self._parent = new_value.to_string();
4968        self
4969    }
4970    /// 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`.
4971    ///
4972    /// Sets the *collection id* path property to the given value.
4973    ///
4974    /// Even though the property as already been set when instantiating this call,
4975    /// we provide this method for API completeness.
4976    pub fn collection_id(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
4977        self._collection_id = new_value.to_string();
4978        self
4979    }
4980    /// Perform the read as part of an already active transaction.
4981    ///
4982    /// Sets the *transaction* query property to the given value.
4983    pub fn transaction(mut self, new_value: Vec<u8>) -> ProjectDatabaseDocumentListCall<'a, C> {
4984        self._transaction = Some(new_value);
4985        self
4986    }
4987    /// 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`.
4988    ///
4989    /// Sets the *show missing* query property to the given value.
4990    pub fn show_missing(mut self, new_value: bool) -> ProjectDatabaseDocumentListCall<'a, C> {
4991        self._show_missing = Some(new_value);
4992        self
4993    }
4994    /// 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.
4995    ///
4996    /// Sets the *read time* query property to the given value.
4997    pub fn read_time(
4998        mut self,
4999        new_value: chrono::DateTime<chrono::offset::Utc>,
5000    ) -> ProjectDatabaseDocumentListCall<'a, C> {
5001        self._read_time = Some(new_value);
5002        self
5003    }
5004    /// 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.
5005    ///
5006    /// Sets the *page token* query property to the given value.
5007    pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
5008        self._page_token = Some(new_value.to_string());
5009        self
5010    }
5011    /// Optional. The maximum number of documents to return in a single response. Firestore may return fewer than this value.
5012    ///
5013    /// Sets the *page size* query property to the given value.
5014    pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseDocumentListCall<'a, C> {
5015        self._page_size = Some(new_value);
5016        self
5017    }
5018    /// 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`.
5019    ///
5020    /// Sets the *order by* query property to the given value.
5021    pub fn order_by(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
5022        self._order_by = Some(new_value.to_string());
5023        self
5024    }
5025    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
5026    ///
5027    /// Append the given value to the *mask.field paths* query property.
5028    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5029    pub fn add_mask_field_paths(
5030        mut self,
5031        new_value: &str,
5032    ) -> ProjectDatabaseDocumentListCall<'a, C> {
5033        self._mask_field_paths.push(new_value.to_string());
5034        self
5035    }
5036    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5037    /// while executing the actual API request.
5038    ///
5039    /// ````text
5040    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5041    /// ````
5042    ///
5043    /// Sets the *delegate* property to the given value.
5044    pub fn delegate(
5045        mut self,
5046        new_value: &'a mut dyn common::Delegate,
5047    ) -> ProjectDatabaseDocumentListCall<'a, C> {
5048        self._delegate = Some(new_value);
5049        self
5050    }
5051
5052    /// Set any additional parameter of the query string used in the request.
5053    /// It should be used to set parameters which are not yet available through their own
5054    /// setters.
5055    ///
5056    /// Please note that this method must not be used to set any of the known parameters
5057    /// which have their own setter method. If done anyway, the request will fail.
5058    ///
5059    /// # Additional Parameters
5060    ///
5061    /// * *$.xgafv* (query-string) - V1 error format.
5062    /// * *access_token* (query-string) - OAuth access token.
5063    /// * *alt* (query-string) - Data format for response.
5064    /// * *callback* (query-string) - JSONP
5065    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5066    /// * *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.
5067    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5068    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5069    /// * *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.
5070    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5071    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5072    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListCall<'a, C>
5073    where
5074        T: AsRef<str>,
5075    {
5076        self._additional_params
5077            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5078        self
5079    }
5080
5081    /// Identifies the authorization scope for the method you are building.
5082    ///
5083    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5084    /// [`Scope::CloudPlatform`].
5085    ///
5086    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5087    /// tokens for more than one scope.
5088    ///
5089    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5090    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5091    /// sufficient, a read-write scope will do as well.
5092    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListCall<'a, C>
5093    where
5094        St: AsRef<str>,
5095    {
5096        self._scopes.insert(String::from(scope.as_ref()));
5097        self
5098    }
5099    /// Identifies the authorization scope(s) for the method you are building.
5100    ///
5101    /// See [`Self::add_scope()`] for details.
5102    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListCall<'a, C>
5103    where
5104        I: IntoIterator<Item = St>,
5105        St: AsRef<str>,
5106    {
5107        self._scopes
5108            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5109        self
5110    }
5111
5112    /// Removes all scopes, and no default scope will be used either.
5113    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5114    /// for details).
5115    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListCall<'a, C> {
5116        self._scopes.clear();
5117        self
5118    }
5119}
5120
5121/// Lists all the collection IDs underneath a document.
5122///
5123/// A builder for the *databases.documents.listCollectionIds* method supported by a *project* resource.
5124/// It is not used directly, but through a [`ProjectMethods`] instance.
5125///
5126/// # Example
5127///
5128/// Instantiate a resource method builder
5129///
5130/// ```test_harness,no_run
5131/// # extern crate hyper;
5132/// # extern crate hyper_rustls;
5133/// # extern crate google_firestore1_beta1 as firestore1_beta1;
5134/// use firestore1_beta1::api::ListCollectionIdsRequest;
5135/// # async fn dox() {
5136/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5137///
5138/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5139/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5140/// #     secret,
5141/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5142/// # ).build().await.unwrap();
5143///
5144/// # let client = hyper_util::client::legacy::Client::builder(
5145/// #     hyper_util::rt::TokioExecutor::new()
5146/// # )
5147/// # .build(
5148/// #     hyper_rustls::HttpsConnectorBuilder::new()
5149/// #         .with_native_roots()
5150/// #         .unwrap()
5151/// #         .https_or_http()
5152/// #         .enable_http1()
5153/// #         .build()
5154/// # );
5155/// # let mut hub = Firestore::new(client, auth);
5156/// // As the method needs a request, you would usually fill it with the desired information
5157/// // into the respective structure. Some of the parts shown here might not be applicable !
5158/// // Values shown here are possibly random and not representative !
5159/// let mut req = ListCollectionIdsRequest::default();
5160///
5161/// // You can configure optional parameters by calling the respective setters at will, and
5162/// // execute the final call using `doit()`.
5163/// // Values shown here are possibly random and not representative !
5164/// let result = hub.projects().databases_documents_list_collection_ids(req, "parent")
5165///              .doit().await;
5166/// # }
5167/// ```
5168pub struct ProjectDatabaseDocumentListCollectionIdCall<'a, C>
5169where
5170    C: 'a,
5171{
5172    hub: &'a Firestore<C>,
5173    _request: ListCollectionIdsRequest,
5174    _parent: String,
5175    _delegate: Option<&'a mut dyn common::Delegate>,
5176    _additional_params: HashMap<String, String>,
5177    _scopes: BTreeSet<String>,
5178}
5179
5180impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListCollectionIdCall<'a, C> {}
5181
5182impl<'a, C> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
5183where
5184    C: common::Connector,
5185{
5186    /// Perform the operation you have build so far.
5187    pub async fn doit(mut self) -> common::Result<(common::Response, ListCollectionIdsResponse)> {
5188        use std::borrow::Cow;
5189        use std::io::{Read, Seek};
5190
5191        use common::{url::Params, ToParts};
5192        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5193
5194        let mut dd = common::DefaultDelegate;
5195        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5196        dlg.begin(common::MethodInfo {
5197            id: "firestore.projects.databases.documents.listCollectionIds",
5198            http_method: hyper::Method::POST,
5199        });
5200
5201        for &field in ["alt", "parent"].iter() {
5202            if self._additional_params.contains_key(field) {
5203                dlg.finished(false);
5204                return Err(common::Error::FieldClash(field));
5205            }
5206        }
5207
5208        let mut params = Params::with_capacity(4 + self._additional_params.len());
5209        params.push("parent", self._parent);
5210
5211        params.extend(self._additional_params.iter());
5212
5213        params.push("alt", "json");
5214        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}:listCollectionIds";
5215        if self._scopes.is_empty() {
5216            self._scopes
5217                .insert(Scope::CloudPlatform.as_ref().to_string());
5218        }
5219
5220        #[allow(clippy::single_element_loop)]
5221        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5222            url = params.uri_replacement(url, param_name, find_this, true);
5223        }
5224        {
5225            let to_remove = ["parent"];
5226            params.remove_params(&to_remove);
5227        }
5228
5229        let url = params.parse_with_url(&url);
5230
5231        let mut json_mime_type = mime::APPLICATION_JSON;
5232        let mut request_value_reader = {
5233            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5234            common::remove_json_null_values(&mut value);
5235            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5236            serde_json::to_writer(&mut dst, &value).unwrap();
5237            dst
5238        };
5239        let request_size = request_value_reader
5240            .seek(std::io::SeekFrom::End(0))
5241            .unwrap();
5242        request_value_reader
5243            .seek(std::io::SeekFrom::Start(0))
5244            .unwrap();
5245
5246        loop {
5247            let token = match self
5248                .hub
5249                .auth
5250                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5251                .await
5252            {
5253                Ok(token) => token,
5254                Err(e) => match dlg.token(e) {
5255                    Ok(token) => token,
5256                    Err(e) => {
5257                        dlg.finished(false);
5258                        return Err(common::Error::MissingToken(e));
5259                    }
5260                },
5261            };
5262            request_value_reader
5263                .seek(std::io::SeekFrom::Start(0))
5264                .unwrap();
5265            let mut req_result = {
5266                let client = &self.hub.client;
5267                dlg.pre_request();
5268                let mut req_builder = hyper::Request::builder()
5269                    .method(hyper::Method::POST)
5270                    .uri(url.as_str())
5271                    .header(USER_AGENT, self.hub._user_agent.clone());
5272
5273                if let Some(token) = token.as_ref() {
5274                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5275                }
5276
5277                let request = req_builder
5278                    .header(CONTENT_TYPE, json_mime_type.to_string())
5279                    .header(CONTENT_LENGTH, request_size as u64)
5280                    .body(common::to_body(
5281                        request_value_reader.get_ref().clone().into(),
5282                    ));
5283
5284                client.request(request.unwrap()).await
5285            };
5286
5287            match req_result {
5288                Err(err) => {
5289                    if let common::Retry::After(d) = dlg.http_error(&err) {
5290                        sleep(d).await;
5291                        continue;
5292                    }
5293                    dlg.finished(false);
5294                    return Err(common::Error::HttpError(err));
5295                }
5296                Ok(res) => {
5297                    let (mut parts, body) = res.into_parts();
5298                    let mut body = common::Body::new(body);
5299                    if !parts.status.is_success() {
5300                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5301                        let error = serde_json::from_str(&common::to_string(&bytes));
5302                        let response = common::to_response(parts, bytes.into());
5303
5304                        if let common::Retry::After(d) =
5305                            dlg.http_failure(&response, error.as_ref().ok())
5306                        {
5307                            sleep(d).await;
5308                            continue;
5309                        }
5310
5311                        dlg.finished(false);
5312
5313                        return Err(match error {
5314                            Ok(value) => common::Error::BadRequest(value),
5315                            _ => common::Error::Failure(response),
5316                        });
5317                    }
5318                    let response = {
5319                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5320                        let encoded = common::to_string(&bytes);
5321                        match serde_json::from_str(&encoded) {
5322                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5323                            Err(error) => {
5324                                dlg.response_json_decode_error(&encoded, &error);
5325                                return Err(common::Error::JsonDecodeError(
5326                                    encoded.to_string(),
5327                                    error,
5328                                ));
5329                            }
5330                        }
5331                    };
5332
5333                    dlg.finished(true);
5334                    return Ok(response);
5335                }
5336            }
5337        }
5338    }
5339
5340    ///
5341    /// Sets the *request* property to the given value.
5342    ///
5343    /// Even though the property as already been set when instantiating this call,
5344    /// we provide this method for API completeness.
5345    pub fn request(
5346        mut self,
5347        new_value: ListCollectionIdsRequest,
5348    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
5349        self._request = new_value;
5350        self
5351    }
5352    /// 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`
5353    ///
5354    /// Sets the *parent* path property to the given value.
5355    ///
5356    /// Even though the property as already been set when instantiating this call,
5357    /// we provide this method for API completeness.
5358    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
5359        self._parent = new_value.to_string();
5360        self
5361    }
5362    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5363    /// while executing the actual API request.
5364    ///
5365    /// ````text
5366    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5367    /// ````
5368    ///
5369    /// Sets the *delegate* property to the given value.
5370    pub fn delegate(
5371        mut self,
5372        new_value: &'a mut dyn common::Delegate,
5373    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
5374        self._delegate = Some(new_value);
5375        self
5376    }
5377
5378    /// Set any additional parameter of the query string used in the request.
5379    /// It should be used to set parameters which are not yet available through their own
5380    /// setters.
5381    ///
5382    /// Please note that this method must not be used to set any of the known parameters
5383    /// which have their own setter method. If done anyway, the request will fail.
5384    ///
5385    /// # Additional Parameters
5386    ///
5387    /// * *$.xgafv* (query-string) - V1 error format.
5388    /// * *access_token* (query-string) - OAuth access token.
5389    /// * *alt* (query-string) - Data format for response.
5390    /// * *callback* (query-string) - JSONP
5391    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5392    /// * *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.
5393    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5394    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5395    /// * *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.
5396    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5397    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5398    pub fn param<T>(
5399        mut self,
5400        name: T,
5401        value: T,
5402    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
5403    where
5404        T: AsRef<str>,
5405    {
5406        self._additional_params
5407            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5408        self
5409    }
5410
5411    /// Identifies the authorization scope for the method you are building.
5412    ///
5413    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5414    /// [`Scope::CloudPlatform`].
5415    ///
5416    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5417    /// tokens for more than one scope.
5418    ///
5419    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5420    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5421    /// sufficient, a read-write scope will do as well.
5422    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
5423    where
5424        St: AsRef<str>,
5425    {
5426        self._scopes.insert(String::from(scope.as_ref()));
5427        self
5428    }
5429    /// Identifies the authorization scope(s) for the method you are building.
5430    ///
5431    /// See [`Self::add_scope()`] for details.
5432    pub fn add_scopes<I, St>(
5433        mut self,
5434        scopes: I,
5435    ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
5436    where
5437        I: IntoIterator<Item = St>,
5438        St: AsRef<str>,
5439    {
5440        self._scopes
5441            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5442        self
5443    }
5444
5445    /// Removes all scopes, and no default scope will be used either.
5446    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5447    /// for details).
5448    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
5449        self._scopes.clear();
5450        self
5451    }
5452}
5453
5454/// Lists documents.
5455///
5456/// A builder for the *databases.documents.listDocuments* method supported by a *project* resource.
5457/// It is not used directly, but through a [`ProjectMethods`] instance.
5458///
5459/// # Example
5460///
5461/// Instantiate a resource method builder
5462///
5463/// ```test_harness,no_run
5464/// # extern crate hyper;
5465/// # extern crate hyper_rustls;
5466/// # extern crate google_firestore1_beta1 as firestore1_beta1;
5467/// # async fn dox() {
5468/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5469///
5470/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5471/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5472/// #     secret,
5473/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5474/// # ).build().await.unwrap();
5475///
5476/// # let client = hyper_util::client::legacy::Client::builder(
5477/// #     hyper_util::rt::TokioExecutor::new()
5478/// # )
5479/// # .build(
5480/// #     hyper_rustls::HttpsConnectorBuilder::new()
5481/// #         .with_native_roots()
5482/// #         .unwrap()
5483/// #         .https_or_http()
5484/// #         .enable_http1()
5485/// #         .build()
5486/// # );
5487/// # let mut hub = Firestore::new(client, auth);
5488/// // You can configure optional parameters by calling the respective setters at will, and
5489/// // execute the final call using `doit()`.
5490/// // Values shown here are possibly random and not representative !
5491/// let result = hub.projects().databases_documents_list_documents("parent", "collectionId")
5492///              .transaction(vec![0, 1, 2, 3])
5493///              .show_missing(true)
5494///              .read_time(chrono::Utc::now())
5495///              .page_token("ipsum")
5496///              .page_size(-50)
5497///              .order_by("est")
5498///              .add_mask_field_paths("gubergren")
5499///              .doit().await;
5500/// # }
5501/// ```
5502pub struct ProjectDatabaseDocumentListDocumentCall<'a, C>
5503where
5504    C: 'a,
5505{
5506    hub: &'a Firestore<C>,
5507    _parent: String,
5508    _collection_id: String,
5509    _transaction: Option<Vec<u8>>,
5510    _show_missing: Option<bool>,
5511    _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
5512    _page_token: Option<String>,
5513    _page_size: Option<i32>,
5514    _order_by: Option<String>,
5515    _mask_field_paths: Vec<String>,
5516    _delegate: Option<&'a mut dyn common::Delegate>,
5517    _additional_params: HashMap<String, String>,
5518    _scopes: BTreeSet<String>,
5519}
5520
5521impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListDocumentCall<'a, C> {}
5522
5523impl<'a, C> ProjectDatabaseDocumentListDocumentCall<'a, C>
5524where
5525    C: common::Connector,
5526{
5527    /// Perform the operation you have build so far.
5528    pub async fn doit(mut self) -> common::Result<(common::Response, ListDocumentsResponse)> {
5529        use std::borrow::Cow;
5530        use std::io::{Read, Seek};
5531
5532        use common::{url::Params, ToParts};
5533        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5534
5535        let mut dd = common::DefaultDelegate;
5536        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5537        dlg.begin(common::MethodInfo {
5538            id: "firestore.projects.databases.documents.listDocuments",
5539            http_method: hyper::Method::GET,
5540        });
5541
5542        for &field in [
5543            "alt",
5544            "parent",
5545            "collectionId",
5546            "transaction",
5547            "showMissing",
5548            "readTime",
5549            "pageToken",
5550            "pageSize",
5551            "orderBy",
5552            "mask.fieldPaths",
5553        ]
5554        .iter()
5555        {
5556            if self._additional_params.contains_key(field) {
5557                dlg.finished(false);
5558                return Err(common::Error::FieldClash(field));
5559            }
5560        }
5561
5562        let mut params = Params::with_capacity(11 + self._additional_params.len());
5563        params.push("parent", self._parent);
5564        params.push("collectionId", self._collection_id);
5565        if let Some(value) = self._transaction.as_ref() {
5566            params.push(
5567                "transaction",
5568                common::serde::standard_base64::to_string(&value),
5569            );
5570        }
5571        if let Some(value) = self._show_missing.as_ref() {
5572            params.push("showMissing", value.to_string());
5573        }
5574        if let Some(value) = self._read_time.as_ref() {
5575            params.push("readTime", common::serde::datetime_to_string(&value));
5576        }
5577        if let Some(value) = self._page_token.as_ref() {
5578            params.push("pageToken", value);
5579        }
5580        if let Some(value) = self._page_size.as_ref() {
5581            params.push("pageSize", value.to_string());
5582        }
5583        if let Some(value) = self._order_by.as_ref() {
5584            params.push("orderBy", value);
5585        }
5586        if !self._mask_field_paths.is_empty() {
5587            for f in self._mask_field_paths.iter() {
5588                params.push("mask.fieldPaths", f);
5589            }
5590        }
5591
5592        params.extend(self._additional_params.iter());
5593
5594        params.push("alt", "json");
5595        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/{collectionId}";
5596        if self._scopes.is_empty() {
5597            self._scopes
5598                .insert(Scope::CloudPlatform.as_ref().to_string());
5599        }
5600
5601        #[allow(clippy::single_element_loop)]
5602        for &(find_this, param_name) in
5603            [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
5604        {
5605            url = params.uri_replacement(url, param_name, find_this, true);
5606        }
5607        {
5608            let to_remove = ["collectionId", "parent"];
5609            params.remove_params(&to_remove);
5610        }
5611
5612        let url = params.parse_with_url(&url);
5613
5614        loop {
5615            let token = match self
5616                .hub
5617                .auth
5618                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5619                .await
5620            {
5621                Ok(token) => token,
5622                Err(e) => match dlg.token(e) {
5623                    Ok(token) => token,
5624                    Err(e) => {
5625                        dlg.finished(false);
5626                        return Err(common::Error::MissingToken(e));
5627                    }
5628                },
5629            };
5630            let mut req_result = {
5631                let client = &self.hub.client;
5632                dlg.pre_request();
5633                let mut req_builder = hyper::Request::builder()
5634                    .method(hyper::Method::GET)
5635                    .uri(url.as_str())
5636                    .header(USER_AGENT, self.hub._user_agent.clone());
5637
5638                if let Some(token) = token.as_ref() {
5639                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5640                }
5641
5642                let request = req_builder
5643                    .header(CONTENT_LENGTH, 0_u64)
5644                    .body(common::to_body::<String>(None));
5645
5646                client.request(request.unwrap()).await
5647            };
5648
5649            match req_result {
5650                Err(err) => {
5651                    if let common::Retry::After(d) = dlg.http_error(&err) {
5652                        sleep(d).await;
5653                        continue;
5654                    }
5655                    dlg.finished(false);
5656                    return Err(common::Error::HttpError(err));
5657                }
5658                Ok(res) => {
5659                    let (mut parts, body) = res.into_parts();
5660                    let mut body = common::Body::new(body);
5661                    if !parts.status.is_success() {
5662                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5663                        let error = serde_json::from_str(&common::to_string(&bytes));
5664                        let response = common::to_response(parts, bytes.into());
5665
5666                        if let common::Retry::After(d) =
5667                            dlg.http_failure(&response, error.as_ref().ok())
5668                        {
5669                            sleep(d).await;
5670                            continue;
5671                        }
5672
5673                        dlg.finished(false);
5674
5675                        return Err(match error {
5676                            Ok(value) => common::Error::BadRequest(value),
5677                            _ => common::Error::Failure(response),
5678                        });
5679                    }
5680                    let response = {
5681                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5682                        let encoded = common::to_string(&bytes);
5683                        match serde_json::from_str(&encoded) {
5684                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5685                            Err(error) => {
5686                                dlg.response_json_decode_error(&encoded, &error);
5687                                return Err(common::Error::JsonDecodeError(
5688                                    encoded.to_string(),
5689                                    error,
5690                                ));
5691                            }
5692                        }
5693                    };
5694
5695                    dlg.finished(true);
5696                    return Ok(response);
5697                }
5698            }
5699        }
5700    }
5701
5702    /// 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`
5703    ///
5704    /// Sets the *parent* path property to the given value.
5705    ///
5706    /// Even though the property as already been set when instantiating this call,
5707    /// we provide this method for API completeness.
5708    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5709        self._parent = new_value.to_string();
5710        self
5711    }
5712    /// 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`.
5713    ///
5714    /// Sets the *collection id* path property to the given value.
5715    ///
5716    /// Even though the property as already been set when instantiating this call,
5717    /// we provide this method for API completeness.
5718    pub fn collection_id(
5719        mut self,
5720        new_value: &str,
5721    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5722        self._collection_id = new_value.to_string();
5723        self
5724    }
5725    /// Perform the read as part of an already active transaction.
5726    ///
5727    /// Sets the *transaction* query property to the given value.
5728    pub fn transaction(
5729        mut self,
5730        new_value: Vec<u8>,
5731    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5732        self._transaction = Some(new_value);
5733        self
5734    }
5735    /// 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`.
5736    ///
5737    /// Sets the *show missing* query property to the given value.
5738    pub fn show_missing(
5739        mut self,
5740        new_value: bool,
5741    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5742        self._show_missing = Some(new_value);
5743        self
5744    }
5745    /// 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.
5746    ///
5747    /// Sets the *read time* query property to the given value.
5748    pub fn read_time(
5749        mut self,
5750        new_value: chrono::DateTime<chrono::offset::Utc>,
5751    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5752        self._read_time = Some(new_value);
5753        self
5754    }
5755    /// 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.
5756    ///
5757    /// Sets the *page token* query property to the given value.
5758    pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5759        self._page_token = Some(new_value.to_string());
5760        self
5761    }
5762    /// Optional. The maximum number of documents to return in a single response. Firestore may return fewer than this value.
5763    ///
5764    /// Sets the *page size* query property to the given value.
5765    pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5766        self._page_size = Some(new_value);
5767        self
5768    }
5769    /// 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`.
5770    ///
5771    /// Sets the *order by* query property to the given value.
5772    pub fn order_by(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5773        self._order_by = Some(new_value.to_string());
5774        self
5775    }
5776    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
5777    ///
5778    /// Append the given value to the *mask.field paths* query property.
5779    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5780    pub fn add_mask_field_paths(
5781        mut self,
5782        new_value: &str,
5783    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5784        self._mask_field_paths.push(new_value.to_string());
5785        self
5786    }
5787    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5788    /// while executing the actual API request.
5789    ///
5790    /// ````text
5791    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5792    /// ````
5793    ///
5794    /// Sets the *delegate* property to the given value.
5795    pub fn delegate(
5796        mut self,
5797        new_value: &'a mut dyn common::Delegate,
5798    ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5799        self._delegate = Some(new_value);
5800        self
5801    }
5802
5803    /// Set any additional parameter of the query string used in the request.
5804    /// It should be used to set parameters which are not yet available through their own
5805    /// setters.
5806    ///
5807    /// Please note that this method must not be used to set any of the known parameters
5808    /// which have their own setter method. If done anyway, the request will fail.
5809    ///
5810    /// # Additional Parameters
5811    ///
5812    /// * *$.xgafv* (query-string) - V1 error format.
5813    /// * *access_token* (query-string) - OAuth access token.
5814    /// * *alt* (query-string) - Data format for response.
5815    /// * *callback* (query-string) - JSONP
5816    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5817    /// * *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.
5818    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5819    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5820    /// * *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.
5821    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5822    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5823    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListDocumentCall<'a, C>
5824    where
5825        T: AsRef<str>,
5826    {
5827        self._additional_params
5828            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5829        self
5830    }
5831
5832    /// Identifies the authorization scope for the method you are building.
5833    ///
5834    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5835    /// [`Scope::CloudPlatform`].
5836    ///
5837    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5838    /// tokens for more than one scope.
5839    ///
5840    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5841    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5842    /// sufficient, a read-write scope will do as well.
5843    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListDocumentCall<'a, C>
5844    where
5845        St: AsRef<str>,
5846    {
5847        self._scopes.insert(String::from(scope.as_ref()));
5848        self
5849    }
5850    /// Identifies the authorization scope(s) for the method you are building.
5851    ///
5852    /// See [`Self::add_scope()`] for details.
5853    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListDocumentCall<'a, C>
5854    where
5855        I: IntoIterator<Item = St>,
5856        St: AsRef<str>,
5857    {
5858        self._scopes
5859            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5860        self
5861    }
5862
5863    /// Removes all scopes, and no default scope will be used either.
5864    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5865    /// for details).
5866    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
5867        self._scopes.clear();
5868        self
5869    }
5870}
5871
5872/// Listens to changes. This method is only available via gRPC or WebChannel (not REST).
5873///
5874/// A builder for the *databases.documents.listen* method supported by a *project* resource.
5875/// It is not used directly, but through a [`ProjectMethods`] instance.
5876///
5877/// # Example
5878///
5879/// Instantiate a resource method builder
5880///
5881/// ```test_harness,no_run
5882/// # extern crate hyper;
5883/// # extern crate hyper_rustls;
5884/// # extern crate google_firestore1_beta1 as firestore1_beta1;
5885/// use firestore1_beta1::api::ListenRequest;
5886/// # async fn dox() {
5887/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5888///
5889/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5890/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5891/// #     secret,
5892/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5893/// # ).build().await.unwrap();
5894///
5895/// # let client = hyper_util::client::legacy::Client::builder(
5896/// #     hyper_util::rt::TokioExecutor::new()
5897/// # )
5898/// # .build(
5899/// #     hyper_rustls::HttpsConnectorBuilder::new()
5900/// #         .with_native_roots()
5901/// #         .unwrap()
5902/// #         .https_or_http()
5903/// #         .enable_http1()
5904/// #         .build()
5905/// # );
5906/// # let mut hub = Firestore::new(client, auth);
5907/// // As the method needs a request, you would usually fill it with the desired information
5908/// // into the respective structure. Some of the parts shown here might not be applicable !
5909/// // Values shown here are possibly random and not representative !
5910/// let mut req = ListenRequest::default();
5911///
5912/// // You can configure optional parameters by calling the respective setters at will, and
5913/// // execute the final call using `doit()`.
5914/// // Values shown here are possibly random and not representative !
5915/// let result = hub.projects().databases_documents_listen(req, "database")
5916///              .doit().await;
5917/// # }
5918/// ```
5919pub struct ProjectDatabaseDocumentListenCall<'a, C>
5920where
5921    C: 'a,
5922{
5923    hub: &'a Firestore<C>,
5924    _request: ListenRequest,
5925    _database: String,
5926    _delegate: Option<&'a mut dyn common::Delegate>,
5927    _additional_params: HashMap<String, String>,
5928    _scopes: BTreeSet<String>,
5929}
5930
5931impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListenCall<'a, C> {}
5932
5933impl<'a, C> ProjectDatabaseDocumentListenCall<'a, C>
5934where
5935    C: common::Connector,
5936{
5937    /// Perform the operation you have build so far.
5938    pub async fn doit(mut self) -> common::Result<(common::Response, ListenResponse)> {
5939        use std::borrow::Cow;
5940        use std::io::{Read, Seek};
5941
5942        use common::{url::Params, ToParts};
5943        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5944
5945        let mut dd = common::DefaultDelegate;
5946        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5947        dlg.begin(common::MethodInfo {
5948            id: "firestore.projects.databases.documents.listen",
5949            http_method: hyper::Method::POST,
5950        });
5951
5952        for &field in ["alt", "database"].iter() {
5953            if self._additional_params.contains_key(field) {
5954                dlg.finished(false);
5955                return Err(common::Error::FieldClash(field));
5956            }
5957        }
5958
5959        let mut params = Params::with_capacity(4 + self._additional_params.len());
5960        params.push("database", self._database);
5961
5962        params.extend(self._additional_params.iter());
5963
5964        params.push("alt", "json");
5965        let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:listen";
5966        if self._scopes.is_empty() {
5967            self._scopes
5968                .insert(Scope::CloudPlatform.as_ref().to_string());
5969        }
5970
5971        #[allow(clippy::single_element_loop)]
5972        for &(find_this, param_name) in [("{+database}", "database")].iter() {
5973            url = params.uri_replacement(url, param_name, find_this, true);
5974        }
5975        {
5976            let to_remove = ["database"];
5977            params.remove_params(&to_remove);
5978        }
5979
5980        let url = params.parse_with_url(&url);
5981
5982        let mut json_mime_type = mime::APPLICATION_JSON;
5983        let mut request_value_reader = {
5984            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5985            common::remove_json_null_values(&mut value);
5986            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5987            serde_json::to_writer(&mut dst, &value).unwrap();
5988            dst
5989        };
5990        let request_size = request_value_reader
5991            .seek(std::io::SeekFrom::End(0))
5992            .unwrap();
5993        request_value_reader
5994            .seek(std::io::SeekFrom::Start(0))
5995            .unwrap();
5996
5997        loop {
5998            let token = match self
5999                .hub
6000                .auth
6001                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6002                .await
6003            {
6004                Ok(token) => token,
6005                Err(e) => match dlg.token(e) {
6006                    Ok(token) => token,
6007                    Err(e) => {
6008                        dlg.finished(false);
6009                        return Err(common::Error::MissingToken(e));
6010                    }
6011                },
6012            };
6013            request_value_reader
6014                .seek(std::io::SeekFrom::Start(0))
6015                .unwrap();
6016            let mut req_result = {
6017                let client = &self.hub.client;
6018                dlg.pre_request();
6019                let mut req_builder = hyper::Request::builder()
6020                    .method(hyper::Method::POST)
6021                    .uri(url.as_str())
6022                    .header(USER_AGENT, self.hub._user_agent.clone());
6023
6024                if let Some(token) = token.as_ref() {
6025                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6026                }
6027
6028                let request = req_builder
6029                    .header(CONTENT_TYPE, json_mime_type.to_string())
6030                    .header(CONTENT_LENGTH, request_size as u64)
6031                    .body(common::to_body(
6032                        request_value_reader.get_ref().clone().into(),
6033                    ));
6034
6035                client.request(request.unwrap()).await
6036            };
6037
6038            match req_result {
6039                Err(err) => {
6040                    if let common::Retry::After(d) = dlg.http_error(&err) {
6041                        sleep(d).await;
6042                        continue;
6043                    }
6044                    dlg.finished(false);
6045                    return Err(common::Error::HttpError(err));
6046                }
6047                Ok(res) => {
6048                    let (mut parts, body) = res.into_parts();
6049                    let mut body = common::Body::new(body);
6050                    if !parts.status.is_success() {
6051                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6052                        let error = serde_json::from_str(&common::to_string(&bytes));
6053                        let response = common::to_response(parts, bytes.into());
6054
6055                        if let common::Retry::After(d) =
6056                            dlg.http_failure(&response, error.as_ref().ok())
6057                        {
6058                            sleep(d).await;
6059                            continue;
6060                        }
6061
6062                        dlg.finished(false);
6063
6064                        return Err(match error {
6065                            Ok(value) => common::Error::BadRequest(value),
6066                            _ => common::Error::Failure(response),
6067                        });
6068                    }
6069                    let response = {
6070                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6071                        let encoded = common::to_string(&bytes);
6072                        match serde_json::from_str(&encoded) {
6073                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6074                            Err(error) => {
6075                                dlg.response_json_decode_error(&encoded, &error);
6076                                return Err(common::Error::JsonDecodeError(
6077                                    encoded.to_string(),
6078                                    error,
6079                                ));
6080                            }
6081                        }
6082                    };
6083
6084                    dlg.finished(true);
6085                    return Ok(response);
6086                }
6087            }
6088        }
6089    }
6090
6091    ///
6092    /// Sets the *request* property to the given value.
6093    ///
6094    /// Even though the property as already been set when instantiating this call,
6095    /// we provide this method for API completeness.
6096    pub fn request(mut self, new_value: ListenRequest) -> ProjectDatabaseDocumentListenCall<'a, C> {
6097        self._request = new_value;
6098        self
6099    }
6100    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
6101    ///
6102    /// Sets the *database* path property to the given value.
6103    ///
6104    /// Even though the property as already been set when instantiating this call,
6105    /// we provide this method for API completeness.
6106    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentListenCall<'a, C> {
6107        self._database = new_value.to_string();
6108        self
6109    }
6110    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6111    /// while executing the actual API request.
6112    ///
6113    /// ````text
6114    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6115    /// ````
6116    ///
6117    /// Sets the *delegate* property to the given value.
6118    pub fn delegate(
6119        mut self,
6120        new_value: &'a mut dyn common::Delegate,
6121    ) -> ProjectDatabaseDocumentListenCall<'a, C> {
6122        self._delegate = Some(new_value);
6123        self
6124    }
6125
6126    /// Set any additional parameter of the query string used in the request.
6127    /// It should be used to set parameters which are not yet available through their own
6128    /// setters.
6129    ///
6130    /// Please note that this method must not be used to set any of the known parameters
6131    /// which have their own setter method. If done anyway, the request will fail.
6132    ///
6133    /// # Additional Parameters
6134    ///
6135    /// * *$.xgafv* (query-string) - V1 error format.
6136    /// * *access_token* (query-string) - OAuth access token.
6137    /// * *alt* (query-string) - Data format for response.
6138    /// * *callback* (query-string) - JSONP
6139    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6140    /// * *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.
6141    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6142    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6143    /// * *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.
6144    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6145    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6146    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListenCall<'a, C>
6147    where
6148        T: AsRef<str>,
6149    {
6150        self._additional_params
6151            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6152        self
6153    }
6154
6155    /// Identifies the authorization scope for the method you are building.
6156    ///
6157    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6158    /// [`Scope::CloudPlatform`].
6159    ///
6160    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6161    /// tokens for more than one scope.
6162    ///
6163    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6164    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6165    /// sufficient, a read-write scope will do as well.
6166    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListenCall<'a, C>
6167    where
6168        St: AsRef<str>,
6169    {
6170        self._scopes.insert(String::from(scope.as_ref()));
6171        self
6172    }
6173    /// Identifies the authorization scope(s) for the method you are building.
6174    ///
6175    /// See [`Self::add_scope()`] for details.
6176    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListenCall<'a, C>
6177    where
6178        I: IntoIterator<Item = St>,
6179        St: AsRef<str>,
6180    {
6181        self._scopes
6182            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6183        self
6184    }
6185
6186    /// Removes all scopes, and no default scope will be used either.
6187    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6188    /// for details).
6189    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListenCall<'a, C> {
6190        self._scopes.clear();
6191        self
6192    }
6193}
6194
6195/// 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.
6196///
6197/// A builder for the *databases.documents.partitionQuery* method supported by a *project* resource.
6198/// It is not used directly, but through a [`ProjectMethods`] instance.
6199///
6200/// # Example
6201///
6202/// Instantiate a resource method builder
6203///
6204/// ```test_harness,no_run
6205/// # extern crate hyper;
6206/// # extern crate hyper_rustls;
6207/// # extern crate google_firestore1_beta1 as firestore1_beta1;
6208/// use firestore1_beta1::api::PartitionQueryRequest;
6209/// # async fn dox() {
6210/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6211///
6212/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6213/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6214/// #     secret,
6215/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6216/// # ).build().await.unwrap();
6217///
6218/// # let client = hyper_util::client::legacy::Client::builder(
6219/// #     hyper_util::rt::TokioExecutor::new()
6220/// # )
6221/// # .build(
6222/// #     hyper_rustls::HttpsConnectorBuilder::new()
6223/// #         .with_native_roots()
6224/// #         .unwrap()
6225/// #         .https_or_http()
6226/// #         .enable_http1()
6227/// #         .build()
6228/// # );
6229/// # let mut hub = Firestore::new(client, auth);
6230/// // As the method needs a request, you would usually fill it with the desired information
6231/// // into the respective structure. Some of the parts shown here might not be applicable !
6232/// // Values shown here are possibly random and not representative !
6233/// let mut req = PartitionQueryRequest::default();
6234///
6235/// // You can configure optional parameters by calling the respective setters at will, and
6236/// // execute the final call using `doit()`.
6237/// // Values shown here are possibly random and not representative !
6238/// let result = hub.projects().databases_documents_partition_query(req, "parent")
6239///              .doit().await;
6240/// # }
6241/// ```
6242pub struct ProjectDatabaseDocumentPartitionQueryCall<'a, C>
6243where
6244    C: 'a,
6245{
6246    hub: &'a Firestore<C>,
6247    _request: PartitionQueryRequest,
6248    _parent: String,
6249    _delegate: Option<&'a mut dyn common::Delegate>,
6250    _additional_params: HashMap<String, String>,
6251    _scopes: BTreeSet<String>,
6252}
6253
6254impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentPartitionQueryCall<'a, C> {}
6255
6256impl<'a, C> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
6257where
6258    C: common::Connector,
6259{
6260    /// Perform the operation you have build so far.
6261    pub async fn doit(mut self) -> common::Result<(common::Response, PartitionQueryResponse)> {
6262        use std::borrow::Cow;
6263        use std::io::{Read, Seek};
6264
6265        use common::{url::Params, ToParts};
6266        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6267
6268        let mut dd = common::DefaultDelegate;
6269        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6270        dlg.begin(common::MethodInfo {
6271            id: "firestore.projects.databases.documents.partitionQuery",
6272            http_method: hyper::Method::POST,
6273        });
6274
6275        for &field in ["alt", "parent"].iter() {
6276            if self._additional_params.contains_key(field) {
6277                dlg.finished(false);
6278                return Err(common::Error::FieldClash(field));
6279            }
6280        }
6281
6282        let mut params = Params::with_capacity(4 + self._additional_params.len());
6283        params.push("parent", self._parent);
6284
6285        params.extend(self._additional_params.iter());
6286
6287        params.push("alt", "json");
6288        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}:partitionQuery";
6289        if self._scopes.is_empty() {
6290            self._scopes
6291                .insert(Scope::CloudPlatform.as_ref().to_string());
6292        }
6293
6294        #[allow(clippy::single_element_loop)]
6295        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6296            url = params.uri_replacement(url, param_name, find_this, true);
6297        }
6298        {
6299            let to_remove = ["parent"];
6300            params.remove_params(&to_remove);
6301        }
6302
6303        let url = params.parse_with_url(&url);
6304
6305        let mut json_mime_type = mime::APPLICATION_JSON;
6306        let mut request_value_reader = {
6307            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6308            common::remove_json_null_values(&mut value);
6309            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6310            serde_json::to_writer(&mut dst, &value).unwrap();
6311            dst
6312        };
6313        let request_size = request_value_reader
6314            .seek(std::io::SeekFrom::End(0))
6315            .unwrap();
6316        request_value_reader
6317            .seek(std::io::SeekFrom::Start(0))
6318            .unwrap();
6319
6320        loop {
6321            let token = match self
6322                .hub
6323                .auth
6324                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6325                .await
6326            {
6327                Ok(token) => token,
6328                Err(e) => match dlg.token(e) {
6329                    Ok(token) => token,
6330                    Err(e) => {
6331                        dlg.finished(false);
6332                        return Err(common::Error::MissingToken(e));
6333                    }
6334                },
6335            };
6336            request_value_reader
6337                .seek(std::io::SeekFrom::Start(0))
6338                .unwrap();
6339            let mut req_result = {
6340                let client = &self.hub.client;
6341                dlg.pre_request();
6342                let mut req_builder = hyper::Request::builder()
6343                    .method(hyper::Method::POST)
6344                    .uri(url.as_str())
6345                    .header(USER_AGENT, self.hub._user_agent.clone());
6346
6347                if let Some(token) = token.as_ref() {
6348                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6349                }
6350
6351                let request = req_builder
6352                    .header(CONTENT_TYPE, json_mime_type.to_string())
6353                    .header(CONTENT_LENGTH, request_size as u64)
6354                    .body(common::to_body(
6355                        request_value_reader.get_ref().clone().into(),
6356                    ));
6357
6358                client.request(request.unwrap()).await
6359            };
6360
6361            match req_result {
6362                Err(err) => {
6363                    if let common::Retry::After(d) = dlg.http_error(&err) {
6364                        sleep(d).await;
6365                        continue;
6366                    }
6367                    dlg.finished(false);
6368                    return Err(common::Error::HttpError(err));
6369                }
6370                Ok(res) => {
6371                    let (mut parts, body) = res.into_parts();
6372                    let mut body = common::Body::new(body);
6373                    if !parts.status.is_success() {
6374                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6375                        let error = serde_json::from_str(&common::to_string(&bytes));
6376                        let response = common::to_response(parts, bytes.into());
6377
6378                        if let common::Retry::After(d) =
6379                            dlg.http_failure(&response, error.as_ref().ok())
6380                        {
6381                            sleep(d).await;
6382                            continue;
6383                        }
6384
6385                        dlg.finished(false);
6386
6387                        return Err(match error {
6388                            Ok(value) => common::Error::BadRequest(value),
6389                            _ => common::Error::Failure(response),
6390                        });
6391                    }
6392                    let response = {
6393                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6394                        let encoded = common::to_string(&bytes);
6395                        match serde_json::from_str(&encoded) {
6396                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6397                            Err(error) => {
6398                                dlg.response_json_decode_error(&encoded, &error);
6399                                return Err(common::Error::JsonDecodeError(
6400                                    encoded.to_string(),
6401                                    error,
6402                                ));
6403                            }
6404                        }
6405                    };
6406
6407                    dlg.finished(true);
6408                    return Ok(response);
6409                }
6410            }
6411        }
6412    }
6413
6414    ///
6415    /// Sets the *request* property to the given value.
6416    ///
6417    /// Even though the property as already been set when instantiating this call,
6418    /// we provide this method for API completeness.
6419    pub fn request(
6420        mut self,
6421        new_value: PartitionQueryRequest,
6422    ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
6423        self._request = new_value;
6424        self
6425    }
6426    /// 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.
6427    ///
6428    /// Sets the *parent* path property to the given value.
6429    ///
6430    /// Even though the property as already been set when instantiating this call,
6431    /// we provide this method for API completeness.
6432    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
6433        self._parent = new_value.to_string();
6434        self
6435    }
6436    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6437    /// while executing the actual API request.
6438    ///
6439    /// ````text
6440    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6441    /// ````
6442    ///
6443    /// Sets the *delegate* property to the given value.
6444    pub fn delegate(
6445        mut self,
6446        new_value: &'a mut dyn common::Delegate,
6447    ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
6448        self._delegate = Some(new_value);
6449        self
6450    }
6451
6452    /// Set any additional parameter of the query string used in the request.
6453    /// It should be used to set parameters which are not yet available through their own
6454    /// setters.
6455    ///
6456    /// Please note that this method must not be used to set any of the known parameters
6457    /// which have their own setter method. If done anyway, the request will fail.
6458    ///
6459    /// # Additional Parameters
6460    ///
6461    /// * *$.xgafv* (query-string) - V1 error format.
6462    /// * *access_token* (query-string) - OAuth access token.
6463    /// * *alt* (query-string) - Data format for response.
6464    /// * *callback* (query-string) - JSONP
6465    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6466    /// * *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.
6467    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6468    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6469    /// * *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.
6470    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6471    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6472    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
6473    where
6474        T: AsRef<str>,
6475    {
6476        self._additional_params
6477            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6478        self
6479    }
6480
6481    /// Identifies the authorization scope for the method you are building.
6482    ///
6483    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6484    /// [`Scope::CloudPlatform`].
6485    ///
6486    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6487    /// tokens for more than one scope.
6488    ///
6489    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6490    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6491    /// sufficient, a read-write scope will do as well.
6492    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
6493    where
6494        St: AsRef<str>,
6495    {
6496        self._scopes.insert(String::from(scope.as_ref()));
6497        self
6498    }
6499    /// Identifies the authorization scope(s) for the method you are building.
6500    ///
6501    /// See [`Self::add_scope()`] for details.
6502    pub fn add_scopes<I, St>(
6503        mut self,
6504        scopes: I,
6505    ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
6506    where
6507        I: IntoIterator<Item = St>,
6508        St: AsRef<str>,
6509    {
6510        self._scopes
6511            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6512        self
6513    }
6514
6515    /// Removes all scopes, and no default scope will be used either.
6516    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6517    /// for details).
6518    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
6519        self._scopes.clear();
6520        self
6521    }
6522}
6523
6524/// Updates or inserts a document.
6525///
6526/// A builder for the *databases.documents.patch* method supported by a *project* resource.
6527/// It is not used directly, but through a [`ProjectMethods`] instance.
6528///
6529/// # Example
6530///
6531/// Instantiate a resource method builder
6532///
6533/// ```test_harness,no_run
6534/// # extern crate hyper;
6535/// # extern crate hyper_rustls;
6536/// # extern crate google_firestore1_beta1 as firestore1_beta1;
6537/// use firestore1_beta1::api::Document;
6538/// # async fn dox() {
6539/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6540///
6541/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6542/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6543/// #     secret,
6544/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6545/// # ).build().await.unwrap();
6546///
6547/// # let client = hyper_util::client::legacy::Client::builder(
6548/// #     hyper_util::rt::TokioExecutor::new()
6549/// # )
6550/// # .build(
6551/// #     hyper_rustls::HttpsConnectorBuilder::new()
6552/// #         .with_native_roots()
6553/// #         .unwrap()
6554/// #         .https_or_http()
6555/// #         .enable_http1()
6556/// #         .build()
6557/// # );
6558/// # let mut hub = Firestore::new(client, auth);
6559/// // As the method needs a request, you would usually fill it with the desired information
6560/// // into the respective structure. Some of the parts shown here might not be applicable !
6561/// // Values shown here are possibly random and not representative !
6562/// let mut req = Document::default();
6563///
6564/// // You can configure optional parameters by calling the respective setters at will, and
6565/// // execute the final call using `doit()`.
6566/// // Values shown here are possibly random and not representative !
6567/// let result = hub.projects().databases_documents_patch(req, "name")
6568///              .add_update_mask_field_paths("eos")
6569///              .add_mask_field_paths("labore")
6570///              .current_document_update_time(chrono::Utc::now())
6571///              .current_document_exists(true)
6572///              .doit().await;
6573/// # }
6574/// ```
6575pub struct ProjectDatabaseDocumentPatchCall<'a, C>
6576where
6577    C: 'a,
6578{
6579    hub: &'a Firestore<C>,
6580    _request: Document,
6581    _name: String,
6582    _update_mask_field_paths: Vec<String>,
6583    _mask_field_paths: Vec<String>,
6584    _current_document_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
6585    _current_document_exists: Option<bool>,
6586    _delegate: Option<&'a mut dyn common::Delegate>,
6587    _additional_params: HashMap<String, String>,
6588    _scopes: BTreeSet<String>,
6589}
6590
6591impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentPatchCall<'a, C> {}
6592
6593impl<'a, C> ProjectDatabaseDocumentPatchCall<'a, C>
6594where
6595    C: common::Connector,
6596{
6597    /// Perform the operation you have build so far.
6598    pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
6599        use std::borrow::Cow;
6600        use std::io::{Read, Seek};
6601
6602        use common::{url::Params, ToParts};
6603        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6604
6605        let mut dd = common::DefaultDelegate;
6606        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6607        dlg.begin(common::MethodInfo {
6608            id: "firestore.projects.databases.documents.patch",
6609            http_method: hyper::Method::PATCH,
6610        });
6611
6612        for &field in [
6613            "alt",
6614            "name",
6615            "updateMask.fieldPaths",
6616            "mask.fieldPaths",
6617            "currentDocument.updateTime",
6618            "currentDocument.exists",
6619        ]
6620        .iter()
6621        {
6622            if self._additional_params.contains_key(field) {
6623                dlg.finished(false);
6624                return Err(common::Error::FieldClash(field));
6625            }
6626        }
6627
6628        let mut params = Params::with_capacity(8 + self._additional_params.len());
6629        params.push("name", self._name);
6630        if !self._update_mask_field_paths.is_empty() {
6631            for f in self._update_mask_field_paths.iter() {
6632                params.push("updateMask.fieldPaths", f);
6633            }
6634        }
6635        if !self._mask_field_paths.is_empty() {
6636            for f in self._mask_field_paths.iter() {
6637                params.push("mask.fieldPaths", f);
6638            }
6639        }
6640        if let Some(value) = self._current_document_update_time.as_ref() {
6641            params.push(
6642                "currentDocument.updateTime",
6643                common::serde::datetime_to_string(&value),
6644            );
6645        }
6646        if let Some(value) = self._current_document_exists.as_ref() {
6647            params.push("currentDocument.exists", value.to_string());
6648        }
6649
6650        params.extend(self._additional_params.iter());
6651
6652        params.push("alt", "json");
6653        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
6654        if self._scopes.is_empty() {
6655            self._scopes
6656                .insert(Scope::CloudPlatform.as_ref().to_string());
6657        }
6658
6659        #[allow(clippy::single_element_loop)]
6660        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6661            url = params.uri_replacement(url, param_name, find_this, true);
6662        }
6663        {
6664            let to_remove = ["name"];
6665            params.remove_params(&to_remove);
6666        }
6667
6668        let url = params.parse_with_url(&url);
6669
6670        let mut json_mime_type = mime::APPLICATION_JSON;
6671        let mut request_value_reader = {
6672            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6673            common::remove_json_null_values(&mut value);
6674            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6675            serde_json::to_writer(&mut dst, &value).unwrap();
6676            dst
6677        };
6678        let request_size = request_value_reader
6679            .seek(std::io::SeekFrom::End(0))
6680            .unwrap();
6681        request_value_reader
6682            .seek(std::io::SeekFrom::Start(0))
6683            .unwrap();
6684
6685        loop {
6686            let token = match self
6687                .hub
6688                .auth
6689                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6690                .await
6691            {
6692                Ok(token) => token,
6693                Err(e) => match dlg.token(e) {
6694                    Ok(token) => token,
6695                    Err(e) => {
6696                        dlg.finished(false);
6697                        return Err(common::Error::MissingToken(e));
6698                    }
6699                },
6700            };
6701            request_value_reader
6702                .seek(std::io::SeekFrom::Start(0))
6703                .unwrap();
6704            let mut req_result = {
6705                let client = &self.hub.client;
6706                dlg.pre_request();
6707                let mut req_builder = hyper::Request::builder()
6708                    .method(hyper::Method::PATCH)
6709                    .uri(url.as_str())
6710                    .header(USER_AGENT, self.hub._user_agent.clone());
6711
6712                if let Some(token) = token.as_ref() {
6713                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6714                }
6715
6716                let request = req_builder
6717                    .header(CONTENT_TYPE, json_mime_type.to_string())
6718                    .header(CONTENT_LENGTH, request_size as u64)
6719                    .body(common::to_body(
6720                        request_value_reader.get_ref().clone().into(),
6721                    ));
6722
6723                client.request(request.unwrap()).await
6724            };
6725
6726            match req_result {
6727                Err(err) => {
6728                    if let common::Retry::After(d) = dlg.http_error(&err) {
6729                        sleep(d).await;
6730                        continue;
6731                    }
6732                    dlg.finished(false);
6733                    return Err(common::Error::HttpError(err));
6734                }
6735                Ok(res) => {
6736                    let (mut parts, body) = res.into_parts();
6737                    let mut body = common::Body::new(body);
6738                    if !parts.status.is_success() {
6739                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6740                        let error = serde_json::from_str(&common::to_string(&bytes));
6741                        let response = common::to_response(parts, bytes.into());
6742
6743                        if let common::Retry::After(d) =
6744                            dlg.http_failure(&response, error.as_ref().ok())
6745                        {
6746                            sleep(d).await;
6747                            continue;
6748                        }
6749
6750                        dlg.finished(false);
6751
6752                        return Err(match error {
6753                            Ok(value) => common::Error::BadRequest(value),
6754                            _ => common::Error::Failure(response),
6755                        });
6756                    }
6757                    let response = {
6758                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6759                        let encoded = common::to_string(&bytes);
6760                        match serde_json::from_str(&encoded) {
6761                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6762                            Err(error) => {
6763                                dlg.response_json_decode_error(&encoded, &error);
6764                                return Err(common::Error::JsonDecodeError(
6765                                    encoded.to_string(),
6766                                    error,
6767                                ));
6768                            }
6769                        }
6770                    };
6771
6772                    dlg.finished(true);
6773                    return Ok(response);
6774                }
6775            }
6776        }
6777    }
6778
6779    ///
6780    /// Sets the *request* property to the given value.
6781    ///
6782    /// Even though the property as already been set when instantiating this call,
6783    /// we provide this method for API completeness.
6784    pub fn request(mut self, new_value: Document) -> ProjectDatabaseDocumentPatchCall<'a, C> {
6785        self._request = new_value;
6786        self
6787    }
6788    /// The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
6789    ///
6790    /// Sets the *name* path property to the given value.
6791    ///
6792    /// Even though the property as already been set when instantiating this call,
6793    /// we provide this method for API completeness.
6794    pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentPatchCall<'a, C> {
6795        self._name = new_value.to_string();
6796        self
6797    }
6798    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
6799    ///
6800    /// Append the given value to the *update mask.field paths* query property.
6801    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
6802    pub fn add_update_mask_field_paths(
6803        mut self,
6804        new_value: &str,
6805    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
6806        self._update_mask_field_paths.push(new_value.to_string());
6807        self
6808    }
6809    /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
6810    ///
6811    /// Append the given value to the *mask.field paths* query property.
6812    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
6813    pub fn add_mask_field_paths(
6814        mut self,
6815        new_value: &str,
6816    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
6817        self._mask_field_paths.push(new_value.to_string());
6818        self
6819    }
6820    /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
6821    ///
6822    /// Sets the *current document.update time* query property to the given value.
6823    pub fn current_document_update_time(
6824        mut self,
6825        new_value: chrono::DateTime<chrono::offset::Utc>,
6826    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
6827        self._current_document_update_time = Some(new_value);
6828        self
6829    }
6830    /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
6831    ///
6832    /// Sets the *current document.exists* query property to the given value.
6833    pub fn current_document_exists(
6834        mut self,
6835        new_value: bool,
6836    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
6837        self._current_document_exists = Some(new_value);
6838        self
6839    }
6840    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6841    /// while executing the actual API request.
6842    ///
6843    /// ````text
6844    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6845    /// ````
6846    ///
6847    /// Sets the *delegate* property to the given value.
6848    pub fn delegate(
6849        mut self,
6850        new_value: &'a mut dyn common::Delegate,
6851    ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
6852        self._delegate = Some(new_value);
6853        self
6854    }
6855
6856    /// Set any additional parameter of the query string used in the request.
6857    /// It should be used to set parameters which are not yet available through their own
6858    /// setters.
6859    ///
6860    /// Please note that this method must not be used to set any of the known parameters
6861    /// which have their own setter method. If done anyway, the request will fail.
6862    ///
6863    /// # Additional Parameters
6864    ///
6865    /// * *$.xgafv* (query-string) - V1 error format.
6866    /// * *access_token* (query-string) - OAuth access token.
6867    /// * *alt* (query-string) - Data format for response.
6868    /// * *callback* (query-string) - JSONP
6869    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6870    /// * *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.
6871    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6872    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6873    /// * *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.
6874    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6875    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6876    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentPatchCall<'a, C>
6877    where
6878        T: AsRef<str>,
6879    {
6880        self._additional_params
6881            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6882        self
6883    }
6884
6885    /// Identifies the authorization scope for the method you are building.
6886    ///
6887    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6888    /// [`Scope::CloudPlatform`].
6889    ///
6890    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6891    /// tokens for more than one scope.
6892    ///
6893    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6894    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6895    /// sufficient, a read-write scope will do as well.
6896    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentPatchCall<'a, C>
6897    where
6898        St: AsRef<str>,
6899    {
6900        self._scopes.insert(String::from(scope.as_ref()));
6901        self
6902    }
6903    /// Identifies the authorization scope(s) for the method you are building.
6904    ///
6905    /// See [`Self::add_scope()`] for details.
6906    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentPatchCall<'a, C>
6907    where
6908        I: IntoIterator<Item = St>,
6909        St: AsRef<str>,
6910    {
6911        self._scopes
6912            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6913        self
6914    }
6915
6916    /// Removes all scopes, and no default scope will be used either.
6917    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6918    /// for details).
6919    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentPatchCall<'a, C> {
6920        self._scopes.clear();
6921        self
6922    }
6923}
6924
6925/// Rolls back a transaction.
6926///
6927/// A builder for the *databases.documents.rollback* method supported by a *project* resource.
6928/// It is not used directly, but through a [`ProjectMethods`] instance.
6929///
6930/// # Example
6931///
6932/// Instantiate a resource method builder
6933///
6934/// ```test_harness,no_run
6935/// # extern crate hyper;
6936/// # extern crate hyper_rustls;
6937/// # extern crate google_firestore1_beta1 as firestore1_beta1;
6938/// use firestore1_beta1::api::RollbackRequest;
6939/// # async fn dox() {
6940/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6941///
6942/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6943/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6944/// #     secret,
6945/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6946/// # ).build().await.unwrap();
6947///
6948/// # let client = hyper_util::client::legacy::Client::builder(
6949/// #     hyper_util::rt::TokioExecutor::new()
6950/// # )
6951/// # .build(
6952/// #     hyper_rustls::HttpsConnectorBuilder::new()
6953/// #         .with_native_roots()
6954/// #         .unwrap()
6955/// #         .https_or_http()
6956/// #         .enable_http1()
6957/// #         .build()
6958/// # );
6959/// # let mut hub = Firestore::new(client, auth);
6960/// // As the method needs a request, you would usually fill it with the desired information
6961/// // into the respective structure. Some of the parts shown here might not be applicable !
6962/// // Values shown here are possibly random and not representative !
6963/// let mut req = RollbackRequest::default();
6964///
6965/// // You can configure optional parameters by calling the respective setters at will, and
6966/// // execute the final call using `doit()`.
6967/// // Values shown here are possibly random and not representative !
6968/// let result = hub.projects().databases_documents_rollback(req, "database")
6969///              .doit().await;
6970/// # }
6971/// ```
6972pub struct ProjectDatabaseDocumentRollbackCall<'a, C>
6973where
6974    C: 'a,
6975{
6976    hub: &'a Firestore<C>,
6977    _request: RollbackRequest,
6978    _database: String,
6979    _delegate: Option<&'a mut dyn common::Delegate>,
6980    _additional_params: HashMap<String, String>,
6981    _scopes: BTreeSet<String>,
6982}
6983
6984impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRollbackCall<'a, C> {}
6985
6986impl<'a, C> ProjectDatabaseDocumentRollbackCall<'a, C>
6987where
6988    C: common::Connector,
6989{
6990    /// Perform the operation you have build so far.
6991    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6992        use std::borrow::Cow;
6993        use std::io::{Read, Seek};
6994
6995        use common::{url::Params, ToParts};
6996        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6997
6998        let mut dd = common::DefaultDelegate;
6999        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7000        dlg.begin(common::MethodInfo {
7001            id: "firestore.projects.databases.documents.rollback",
7002            http_method: hyper::Method::POST,
7003        });
7004
7005        for &field in ["alt", "database"].iter() {
7006            if self._additional_params.contains_key(field) {
7007                dlg.finished(false);
7008                return Err(common::Error::FieldClash(field));
7009            }
7010        }
7011
7012        let mut params = Params::with_capacity(4 + self._additional_params.len());
7013        params.push("database", self._database);
7014
7015        params.extend(self._additional_params.iter());
7016
7017        params.push("alt", "json");
7018        let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:rollback";
7019        if self._scopes.is_empty() {
7020            self._scopes
7021                .insert(Scope::CloudPlatform.as_ref().to_string());
7022        }
7023
7024        #[allow(clippy::single_element_loop)]
7025        for &(find_this, param_name) in [("{+database}", "database")].iter() {
7026            url = params.uri_replacement(url, param_name, find_this, true);
7027        }
7028        {
7029            let to_remove = ["database"];
7030            params.remove_params(&to_remove);
7031        }
7032
7033        let url = params.parse_with_url(&url);
7034
7035        let mut json_mime_type = mime::APPLICATION_JSON;
7036        let mut request_value_reader = {
7037            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7038            common::remove_json_null_values(&mut value);
7039            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7040            serde_json::to_writer(&mut dst, &value).unwrap();
7041            dst
7042        };
7043        let request_size = request_value_reader
7044            .seek(std::io::SeekFrom::End(0))
7045            .unwrap();
7046        request_value_reader
7047            .seek(std::io::SeekFrom::Start(0))
7048            .unwrap();
7049
7050        loop {
7051            let token = match self
7052                .hub
7053                .auth
7054                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7055                .await
7056            {
7057                Ok(token) => token,
7058                Err(e) => match dlg.token(e) {
7059                    Ok(token) => token,
7060                    Err(e) => {
7061                        dlg.finished(false);
7062                        return Err(common::Error::MissingToken(e));
7063                    }
7064                },
7065            };
7066            request_value_reader
7067                .seek(std::io::SeekFrom::Start(0))
7068                .unwrap();
7069            let mut req_result = {
7070                let client = &self.hub.client;
7071                dlg.pre_request();
7072                let mut req_builder = hyper::Request::builder()
7073                    .method(hyper::Method::POST)
7074                    .uri(url.as_str())
7075                    .header(USER_AGENT, self.hub._user_agent.clone());
7076
7077                if let Some(token) = token.as_ref() {
7078                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7079                }
7080
7081                let request = req_builder
7082                    .header(CONTENT_TYPE, json_mime_type.to_string())
7083                    .header(CONTENT_LENGTH, request_size as u64)
7084                    .body(common::to_body(
7085                        request_value_reader.get_ref().clone().into(),
7086                    ));
7087
7088                client.request(request.unwrap()).await
7089            };
7090
7091            match req_result {
7092                Err(err) => {
7093                    if let common::Retry::After(d) = dlg.http_error(&err) {
7094                        sleep(d).await;
7095                        continue;
7096                    }
7097                    dlg.finished(false);
7098                    return Err(common::Error::HttpError(err));
7099                }
7100                Ok(res) => {
7101                    let (mut parts, body) = res.into_parts();
7102                    let mut body = common::Body::new(body);
7103                    if !parts.status.is_success() {
7104                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7105                        let error = serde_json::from_str(&common::to_string(&bytes));
7106                        let response = common::to_response(parts, bytes.into());
7107
7108                        if let common::Retry::After(d) =
7109                            dlg.http_failure(&response, error.as_ref().ok())
7110                        {
7111                            sleep(d).await;
7112                            continue;
7113                        }
7114
7115                        dlg.finished(false);
7116
7117                        return Err(match error {
7118                            Ok(value) => common::Error::BadRequest(value),
7119                            _ => common::Error::Failure(response),
7120                        });
7121                    }
7122                    let response = {
7123                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7124                        let encoded = common::to_string(&bytes);
7125                        match serde_json::from_str(&encoded) {
7126                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7127                            Err(error) => {
7128                                dlg.response_json_decode_error(&encoded, &error);
7129                                return Err(common::Error::JsonDecodeError(
7130                                    encoded.to_string(),
7131                                    error,
7132                                ));
7133                            }
7134                        }
7135                    };
7136
7137                    dlg.finished(true);
7138                    return Ok(response);
7139                }
7140            }
7141        }
7142    }
7143
7144    ///
7145    /// Sets the *request* property to the given value.
7146    ///
7147    /// Even though the property as already been set when instantiating this call,
7148    /// we provide this method for API completeness.
7149    pub fn request(
7150        mut self,
7151        new_value: RollbackRequest,
7152    ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
7153        self._request = new_value;
7154        self
7155    }
7156    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
7157    ///
7158    /// Sets the *database* path property to the given value.
7159    ///
7160    /// Even though the property as already been set when instantiating this call,
7161    /// we provide this method for API completeness.
7162    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
7163        self._database = new_value.to_string();
7164        self
7165    }
7166    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7167    /// while executing the actual API request.
7168    ///
7169    /// ````text
7170    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7171    /// ````
7172    ///
7173    /// Sets the *delegate* property to the given value.
7174    pub fn delegate(
7175        mut self,
7176        new_value: &'a mut dyn common::Delegate,
7177    ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
7178        self._delegate = Some(new_value);
7179        self
7180    }
7181
7182    /// Set any additional parameter of the query string used in the request.
7183    /// It should be used to set parameters which are not yet available through their own
7184    /// setters.
7185    ///
7186    /// Please note that this method must not be used to set any of the known parameters
7187    /// which have their own setter method. If done anyway, the request will fail.
7188    ///
7189    /// # Additional Parameters
7190    ///
7191    /// * *$.xgafv* (query-string) - V1 error format.
7192    /// * *access_token* (query-string) - OAuth access token.
7193    /// * *alt* (query-string) - Data format for response.
7194    /// * *callback* (query-string) - JSONP
7195    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7196    /// * *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.
7197    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7198    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7199    /// * *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.
7200    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7201    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7202    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentRollbackCall<'a, C>
7203    where
7204        T: AsRef<str>,
7205    {
7206        self._additional_params
7207            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7208        self
7209    }
7210
7211    /// Identifies the authorization scope for the method you are building.
7212    ///
7213    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7214    /// [`Scope::CloudPlatform`].
7215    ///
7216    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7217    /// tokens for more than one scope.
7218    ///
7219    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7220    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7221    /// sufficient, a read-write scope will do as well.
7222    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentRollbackCall<'a, C>
7223    where
7224        St: AsRef<str>,
7225    {
7226        self._scopes.insert(String::from(scope.as_ref()));
7227        self
7228    }
7229    /// Identifies the authorization scope(s) for the method you are building.
7230    ///
7231    /// See [`Self::add_scope()`] for details.
7232    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentRollbackCall<'a, C>
7233    where
7234        I: IntoIterator<Item = St>,
7235        St: AsRef<str>,
7236    {
7237        self._scopes
7238            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7239        self
7240    }
7241
7242    /// Removes all scopes, and no default scope will be used either.
7243    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7244    /// for details).
7245    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
7246        self._scopes.clear();
7247        self
7248    }
7249}
7250
7251/// 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 ); ```
7252///
7253/// A builder for the *databases.documents.runAggregationQuery* method supported by a *project* resource.
7254/// It is not used directly, but through a [`ProjectMethods`] instance.
7255///
7256/// # Example
7257///
7258/// Instantiate a resource method builder
7259///
7260/// ```test_harness,no_run
7261/// # extern crate hyper;
7262/// # extern crate hyper_rustls;
7263/// # extern crate google_firestore1_beta1 as firestore1_beta1;
7264/// use firestore1_beta1::api::RunAggregationQueryRequest;
7265/// # async fn dox() {
7266/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7267///
7268/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7269/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7270/// #     secret,
7271/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7272/// # ).build().await.unwrap();
7273///
7274/// # let client = hyper_util::client::legacy::Client::builder(
7275/// #     hyper_util::rt::TokioExecutor::new()
7276/// # )
7277/// # .build(
7278/// #     hyper_rustls::HttpsConnectorBuilder::new()
7279/// #         .with_native_roots()
7280/// #         .unwrap()
7281/// #         .https_or_http()
7282/// #         .enable_http1()
7283/// #         .build()
7284/// # );
7285/// # let mut hub = Firestore::new(client, auth);
7286/// // As the method needs a request, you would usually fill it with the desired information
7287/// // into the respective structure. Some of the parts shown here might not be applicable !
7288/// // Values shown here are possibly random and not representative !
7289/// let mut req = RunAggregationQueryRequest::default();
7290///
7291/// // You can configure optional parameters by calling the respective setters at will, and
7292/// // execute the final call using `doit()`.
7293/// // Values shown here are possibly random and not representative !
7294/// let result = hub.projects().databases_documents_run_aggregation_query(req, "parent")
7295///              .doit().await;
7296/// # }
7297/// ```
7298pub struct ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
7299where
7300    C: 'a,
7301{
7302    hub: &'a Firestore<C>,
7303    _request: RunAggregationQueryRequest,
7304    _parent: String,
7305    _delegate: Option<&'a mut dyn common::Delegate>,
7306    _additional_params: HashMap<String, String>,
7307    _scopes: BTreeSet<String>,
7308}
7309
7310impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {}
7311
7312impl<'a, C> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
7313where
7314    C: common::Connector,
7315{
7316    /// Perform the operation you have build so far.
7317    pub async fn doit(mut self) -> common::Result<(common::Response, RunAggregationQueryResponse)> {
7318        use std::borrow::Cow;
7319        use std::io::{Read, Seek};
7320
7321        use common::{url::Params, ToParts};
7322        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7323
7324        let mut dd = common::DefaultDelegate;
7325        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7326        dlg.begin(common::MethodInfo {
7327            id: "firestore.projects.databases.documents.runAggregationQuery",
7328            http_method: hyper::Method::POST,
7329        });
7330
7331        for &field in ["alt", "parent"].iter() {
7332            if self._additional_params.contains_key(field) {
7333                dlg.finished(false);
7334                return Err(common::Error::FieldClash(field));
7335            }
7336        }
7337
7338        let mut params = Params::with_capacity(4 + self._additional_params.len());
7339        params.push("parent", self._parent);
7340
7341        params.extend(self._additional_params.iter());
7342
7343        params.push("alt", "json");
7344        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}:runAggregationQuery";
7345        if self._scopes.is_empty() {
7346            self._scopes
7347                .insert(Scope::CloudPlatform.as_ref().to_string());
7348        }
7349
7350        #[allow(clippy::single_element_loop)]
7351        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7352            url = params.uri_replacement(url, param_name, find_this, true);
7353        }
7354        {
7355            let to_remove = ["parent"];
7356            params.remove_params(&to_remove);
7357        }
7358
7359        let url = params.parse_with_url(&url);
7360
7361        let mut json_mime_type = mime::APPLICATION_JSON;
7362        let mut request_value_reader = {
7363            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7364            common::remove_json_null_values(&mut value);
7365            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7366            serde_json::to_writer(&mut dst, &value).unwrap();
7367            dst
7368        };
7369        let request_size = request_value_reader
7370            .seek(std::io::SeekFrom::End(0))
7371            .unwrap();
7372        request_value_reader
7373            .seek(std::io::SeekFrom::Start(0))
7374            .unwrap();
7375
7376        loop {
7377            let token = match self
7378                .hub
7379                .auth
7380                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7381                .await
7382            {
7383                Ok(token) => token,
7384                Err(e) => match dlg.token(e) {
7385                    Ok(token) => token,
7386                    Err(e) => {
7387                        dlg.finished(false);
7388                        return Err(common::Error::MissingToken(e));
7389                    }
7390                },
7391            };
7392            request_value_reader
7393                .seek(std::io::SeekFrom::Start(0))
7394                .unwrap();
7395            let mut req_result = {
7396                let client = &self.hub.client;
7397                dlg.pre_request();
7398                let mut req_builder = hyper::Request::builder()
7399                    .method(hyper::Method::POST)
7400                    .uri(url.as_str())
7401                    .header(USER_AGENT, self.hub._user_agent.clone());
7402
7403                if let Some(token) = token.as_ref() {
7404                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7405                }
7406
7407                let request = req_builder
7408                    .header(CONTENT_TYPE, json_mime_type.to_string())
7409                    .header(CONTENT_LENGTH, request_size as u64)
7410                    .body(common::to_body(
7411                        request_value_reader.get_ref().clone().into(),
7412                    ));
7413
7414                client.request(request.unwrap()).await
7415            };
7416
7417            match req_result {
7418                Err(err) => {
7419                    if let common::Retry::After(d) = dlg.http_error(&err) {
7420                        sleep(d).await;
7421                        continue;
7422                    }
7423                    dlg.finished(false);
7424                    return Err(common::Error::HttpError(err));
7425                }
7426                Ok(res) => {
7427                    let (mut parts, body) = res.into_parts();
7428                    let mut body = common::Body::new(body);
7429                    if !parts.status.is_success() {
7430                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7431                        let error = serde_json::from_str(&common::to_string(&bytes));
7432                        let response = common::to_response(parts, bytes.into());
7433
7434                        if let common::Retry::After(d) =
7435                            dlg.http_failure(&response, error.as_ref().ok())
7436                        {
7437                            sleep(d).await;
7438                            continue;
7439                        }
7440
7441                        dlg.finished(false);
7442
7443                        return Err(match error {
7444                            Ok(value) => common::Error::BadRequest(value),
7445                            _ => common::Error::Failure(response),
7446                        });
7447                    }
7448                    let response = {
7449                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7450                        let encoded = common::to_string(&bytes);
7451                        match serde_json::from_str(&encoded) {
7452                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7453                            Err(error) => {
7454                                dlg.response_json_decode_error(&encoded, &error);
7455                                return Err(common::Error::JsonDecodeError(
7456                                    encoded.to_string(),
7457                                    error,
7458                                ));
7459                            }
7460                        }
7461                    };
7462
7463                    dlg.finished(true);
7464                    return Ok(response);
7465                }
7466            }
7467        }
7468    }
7469
7470    ///
7471    /// Sets the *request* property to the given value.
7472    ///
7473    /// Even though the property as already been set when instantiating this call,
7474    /// we provide this method for API completeness.
7475    pub fn request(
7476        mut self,
7477        new_value: RunAggregationQueryRequest,
7478    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
7479        self._request = new_value;
7480        self
7481    }
7482    /// 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`
7483    ///
7484    /// Sets the *parent* path property to the given value.
7485    ///
7486    /// Even though the property as already been set when instantiating this call,
7487    /// we provide this method for API completeness.
7488    pub fn parent(
7489        mut self,
7490        new_value: &str,
7491    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
7492        self._parent = new_value.to_string();
7493        self
7494    }
7495    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7496    /// while executing the actual API request.
7497    ///
7498    /// ````text
7499    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7500    /// ````
7501    ///
7502    /// Sets the *delegate* property to the given value.
7503    pub fn delegate(
7504        mut self,
7505        new_value: &'a mut dyn common::Delegate,
7506    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
7507        self._delegate = Some(new_value);
7508        self
7509    }
7510
7511    /// Set any additional parameter of the query string used in the request.
7512    /// It should be used to set parameters which are not yet available through their own
7513    /// setters.
7514    ///
7515    /// Please note that this method must not be used to set any of the known parameters
7516    /// which have their own setter method. If done anyway, the request will fail.
7517    ///
7518    /// # Additional Parameters
7519    ///
7520    /// * *$.xgafv* (query-string) - V1 error format.
7521    /// * *access_token* (query-string) - OAuth access token.
7522    /// * *alt* (query-string) - Data format for response.
7523    /// * *callback* (query-string) - JSONP
7524    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7525    /// * *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.
7526    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7527    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7528    /// * *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.
7529    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7530    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7531    pub fn param<T>(
7532        mut self,
7533        name: T,
7534        value: T,
7535    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
7536    where
7537        T: AsRef<str>,
7538    {
7539        self._additional_params
7540            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7541        self
7542    }
7543
7544    /// Identifies the authorization scope for the method you are building.
7545    ///
7546    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7547    /// [`Scope::CloudPlatform`].
7548    ///
7549    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7550    /// tokens for more than one scope.
7551    ///
7552    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7553    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7554    /// sufficient, a read-write scope will do as well.
7555    pub fn add_scope<St>(
7556        mut self,
7557        scope: St,
7558    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
7559    where
7560        St: AsRef<str>,
7561    {
7562        self._scopes.insert(String::from(scope.as_ref()));
7563        self
7564    }
7565    /// Identifies the authorization scope(s) for the method you are building.
7566    ///
7567    /// See [`Self::add_scope()`] for details.
7568    pub fn add_scopes<I, St>(
7569        mut self,
7570        scopes: I,
7571    ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
7572    where
7573        I: IntoIterator<Item = St>,
7574        St: AsRef<str>,
7575    {
7576        self._scopes
7577            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7578        self
7579    }
7580
7581    /// Removes all scopes, and no default scope will be used either.
7582    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7583    /// for details).
7584    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
7585        self._scopes.clear();
7586        self
7587    }
7588}
7589
7590/// Runs a query.
7591///
7592/// A builder for the *databases.documents.runQuery* method supported by a *project* resource.
7593/// It is not used directly, but through a [`ProjectMethods`] instance.
7594///
7595/// # Example
7596///
7597/// Instantiate a resource method builder
7598///
7599/// ```test_harness,no_run
7600/// # extern crate hyper;
7601/// # extern crate hyper_rustls;
7602/// # extern crate google_firestore1_beta1 as firestore1_beta1;
7603/// use firestore1_beta1::api::RunQueryRequest;
7604/// # async fn dox() {
7605/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7606///
7607/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7608/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7609/// #     secret,
7610/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7611/// # ).build().await.unwrap();
7612///
7613/// # let client = hyper_util::client::legacy::Client::builder(
7614/// #     hyper_util::rt::TokioExecutor::new()
7615/// # )
7616/// # .build(
7617/// #     hyper_rustls::HttpsConnectorBuilder::new()
7618/// #         .with_native_roots()
7619/// #         .unwrap()
7620/// #         .https_or_http()
7621/// #         .enable_http1()
7622/// #         .build()
7623/// # );
7624/// # let mut hub = Firestore::new(client, auth);
7625/// // As the method needs a request, you would usually fill it with the desired information
7626/// // into the respective structure. Some of the parts shown here might not be applicable !
7627/// // Values shown here are possibly random and not representative !
7628/// let mut req = RunQueryRequest::default();
7629///
7630/// // You can configure optional parameters by calling the respective setters at will, and
7631/// // execute the final call using `doit()`.
7632/// // Values shown here are possibly random and not representative !
7633/// let result = hub.projects().databases_documents_run_query(req, "parent")
7634///              .doit().await;
7635/// # }
7636/// ```
7637pub struct ProjectDatabaseDocumentRunQueryCall<'a, C>
7638where
7639    C: 'a,
7640{
7641    hub: &'a Firestore<C>,
7642    _request: RunQueryRequest,
7643    _parent: String,
7644    _delegate: Option<&'a mut dyn common::Delegate>,
7645    _additional_params: HashMap<String, String>,
7646    _scopes: BTreeSet<String>,
7647}
7648
7649impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRunQueryCall<'a, C> {}
7650
7651impl<'a, C> ProjectDatabaseDocumentRunQueryCall<'a, C>
7652where
7653    C: common::Connector,
7654{
7655    /// Perform the operation you have build so far.
7656    pub async fn doit(mut self) -> common::Result<(common::Response, RunQueryResponse)> {
7657        use std::borrow::Cow;
7658        use std::io::{Read, Seek};
7659
7660        use common::{url::Params, ToParts};
7661        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7662
7663        let mut dd = common::DefaultDelegate;
7664        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7665        dlg.begin(common::MethodInfo {
7666            id: "firestore.projects.databases.documents.runQuery",
7667            http_method: hyper::Method::POST,
7668        });
7669
7670        for &field in ["alt", "parent"].iter() {
7671            if self._additional_params.contains_key(field) {
7672                dlg.finished(false);
7673                return Err(common::Error::FieldClash(field));
7674            }
7675        }
7676
7677        let mut params = Params::with_capacity(4 + self._additional_params.len());
7678        params.push("parent", self._parent);
7679
7680        params.extend(self._additional_params.iter());
7681
7682        params.push("alt", "json");
7683        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}:runQuery";
7684        if self._scopes.is_empty() {
7685            self._scopes
7686                .insert(Scope::CloudPlatform.as_ref().to_string());
7687        }
7688
7689        #[allow(clippy::single_element_loop)]
7690        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7691            url = params.uri_replacement(url, param_name, find_this, true);
7692        }
7693        {
7694            let to_remove = ["parent"];
7695            params.remove_params(&to_remove);
7696        }
7697
7698        let url = params.parse_with_url(&url);
7699
7700        let mut json_mime_type = mime::APPLICATION_JSON;
7701        let mut request_value_reader = {
7702            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7703            common::remove_json_null_values(&mut value);
7704            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7705            serde_json::to_writer(&mut dst, &value).unwrap();
7706            dst
7707        };
7708        let request_size = request_value_reader
7709            .seek(std::io::SeekFrom::End(0))
7710            .unwrap();
7711        request_value_reader
7712            .seek(std::io::SeekFrom::Start(0))
7713            .unwrap();
7714
7715        loop {
7716            let token = match self
7717                .hub
7718                .auth
7719                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7720                .await
7721            {
7722                Ok(token) => token,
7723                Err(e) => match dlg.token(e) {
7724                    Ok(token) => token,
7725                    Err(e) => {
7726                        dlg.finished(false);
7727                        return Err(common::Error::MissingToken(e));
7728                    }
7729                },
7730            };
7731            request_value_reader
7732                .seek(std::io::SeekFrom::Start(0))
7733                .unwrap();
7734            let mut req_result = {
7735                let client = &self.hub.client;
7736                dlg.pre_request();
7737                let mut req_builder = hyper::Request::builder()
7738                    .method(hyper::Method::POST)
7739                    .uri(url.as_str())
7740                    .header(USER_AGENT, self.hub._user_agent.clone());
7741
7742                if let Some(token) = token.as_ref() {
7743                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7744                }
7745
7746                let request = req_builder
7747                    .header(CONTENT_TYPE, json_mime_type.to_string())
7748                    .header(CONTENT_LENGTH, request_size as u64)
7749                    .body(common::to_body(
7750                        request_value_reader.get_ref().clone().into(),
7751                    ));
7752
7753                client.request(request.unwrap()).await
7754            };
7755
7756            match req_result {
7757                Err(err) => {
7758                    if let common::Retry::After(d) = dlg.http_error(&err) {
7759                        sleep(d).await;
7760                        continue;
7761                    }
7762                    dlg.finished(false);
7763                    return Err(common::Error::HttpError(err));
7764                }
7765                Ok(res) => {
7766                    let (mut parts, body) = res.into_parts();
7767                    let mut body = common::Body::new(body);
7768                    if !parts.status.is_success() {
7769                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7770                        let error = serde_json::from_str(&common::to_string(&bytes));
7771                        let response = common::to_response(parts, bytes.into());
7772
7773                        if let common::Retry::After(d) =
7774                            dlg.http_failure(&response, error.as_ref().ok())
7775                        {
7776                            sleep(d).await;
7777                            continue;
7778                        }
7779
7780                        dlg.finished(false);
7781
7782                        return Err(match error {
7783                            Ok(value) => common::Error::BadRequest(value),
7784                            _ => common::Error::Failure(response),
7785                        });
7786                    }
7787                    let response = {
7788                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7789                        let encoded = common::to_string(&bytes);
7790                        match serde_json::from_str(&encoded) {
7791                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7792                            Err(error) => {
7793                                dlg.response_json_decode_error(&encoded, &error);
7794                                return Err(common::Error::JsonDecodeError(
7795                                    encoded.to_string(),
7796                                    error,
7797                                ));
7798                            }
7799                        }
7800                    };
7801
7802                    dlg.finished(true);
7803                    return Ok(response);
7804                }
7805            }
7806        }
7807    }
7808
7809    ///
7810    /// Sets the *request* property to the given value.
7811    ///
7812    /// Even though the property as already been set when instantiating this call,
7813    /// we provide this method for API completeness.
7814    pub fn request(
7815        mut self,
7816        new_value: RunQueryRequest,
7817    ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
7818        self._request = new_value;
7819        self
7820    }
7821    /// 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`
7822    ///
7823    /// Sets the *parent* path property to the given value.
7824    ///
7825    /// Even though the property as already been set when instantiating this call,
7826    /// we provide this method for API completeness.
7827    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
7828        self._parent = new_value.to_string();
7829        self
7830    }
7831    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7832    /// while executing the actual API request.
7833    ///
7834    /// ````text
7835    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7836    /// ````
7837    ///
7838    /// Sets the *delegate* property to the given value.
7839    pub fn delegate(
7840        mut self,
7841        new_value: &'a mut dyn common::Delegate,
7842    ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
7843        self._delegate = Some(new_value);
7844        self
7845    }
7846
7847    /// Set any additional parameter of the query string used in the request.
7848    /// It should be used to set parameters which are not yet available through their own
7849    /// setters.
7850    ///
7851    /// Please note that this method must not be used to set any of the known parameters
7852    /// which have their own setter method. If done anyway, the request will fail.
7853    ///
7854    /// # Additional Parameters
7855    ///
7856    /// * *$.xgafv* (query-string) - V1 error format.
7857    /// * *access_token* (query-string) - OAuth access token.
7858    /// * *alt* (query-string) - Data format for response.
7859    /// * *callback* (query-string) - JSONP
7860    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7861    /// * *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.
7862    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7863    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7864    /// * *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.
7865    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7866    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7867    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
7868    where
7869        T: AsRef<str>,
7870    {
7871        self._additional_params
7872            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7873        self
7874    }
7875
7876    /// Identifies the authorization scope for the method you are building.
7877    ///
7878    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7879    /// [`Scope::CloudPlatform`].
7880    ///
7881    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7882    /// tokens for more than one scope.
7883    ///
7884    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7885    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7886    /// sufficient, a read-write scope will do as well.
7887    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
7888    where
7889        St: AsRef<str>,
7890    {
7891        self._scopes.insert(String::from(scope.as_ref()));
7892        self
7893    }
7894    /// Identifies the authorization scope(s) for the method you are building.
7895    ///
7896    /// See [`Self::add_scope()`] for details.
7897    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
7898    where
7899        I: IntoIterator<Item = St>,
7900        St: AsRef<str>,
7901    {
7902        self._scopes
7903            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7904        self
7905    }
7906
7907    /// Removes all scopes, and no default scope will be used either.
7908    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7909    /// for details).
7910    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
7911        self._scopes.clear();
7912        self
7913    }
7914}
7915
7916/// Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).
7917///
7918/// A builder for the *databases.documents.write* method supported by a *project* resource.
7919/// It is not used directly, but through a [`ProjectMethods`] instance.
7920///
7921/// # Example
7922///
7923/// Instantiate a resource method builder
7924///
7925/// ```test_harness,no_run
7926/// # extern crate hyper;
7927/// # extern crate hyper_rustls;
7928/// # extern crate google_firestore1_beta1 as firestore1_beta1;
7929/// use firestore1_beta1::api::WriteRequest;
7930/// # async fn dox() {
7931/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7932///
7933/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7934/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7935/// #     secret,
7936/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7937/// # ).build().await.unwrap();
7938///
7939/// # let client = hyper_util::client::legacy::Client::builder(
7940/// #     hyper_util::rt::TokioExecutor::new()
7941/// # )
7942/// # .build(
7943/// #     hyper_rustls::HttpsConnectorBuilder::new()
7944/// #         .with_native_roots()
7945/// #         .unwrap()
7946/// #         .https_or_http()
7947/// #         .enable_http1()
7948/// #         .build()
7949/// # );
7950/// # let mut hub = Firestore::new(client, auth);
7951/// // As the method needs a request, you would usually fill it with the desired information
7952/// // into the respective structure. Some of the parts shown here might not be applicable !
7953/// // Values shown here are possibly random and not representative !
7954/// let mut req = WriteRequest::default();
7955///
7956/// // You can configure optional parameters by calling the respective setters at will, and
7957/// // execute the final call using `doit()`.
7958/// // Values shown here are possibly random and not representative !
7959/// let result = hub.projects().databases_documents_write(req, "database")
7960///              .doit().await;
7961/// # }
7962/// ```
7963pub struct ProjectDatabaseDocumentWriteCall<'a, C>
7964where
7965    C: 'a,
7966{
7967    hub: &'a Firestore<C>,
7968    _request: WriteRequest,
7969    _database: String,
7970    _delegate: Option<&'a mut dyn common::Delegate>,
7971    _additional_params: HashMap<String, String>,
7972    _scopes: BTreeSet<String>,
7973}
7974
7975impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentWriteCall<'a, C> {}
7976
7977impl<'a, C> ProjectDatabaseDocumentWriteCall<'a, C>
7978where
7979    C: common::Connector,
7980{
7981    /// Perform the operation you have build so far.
7982    pub async fn doit(mut self) -> common::Result<(common::Response, WriteResponse)> {
7983        use std::borrow::Cow;
7984        use std::io::{Read, Seek};
7985
7986        use common::{url::Params, ToParts};
7987        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7988
7989        let mut dd = common::DefaultDelegate;
7990        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7991        dlg.begin(common::MethodInfo {
7992            id: "firestore.projects.databases.documents.write",
7993            http_method: hyper::Method::POST,
7994        });
7995
7996        for &field in ["alt", "database"].iter() {
7997            if self._additional_params.contains_key(field) {
7998                dlg.finished(false);
7999                return Err(common::Error::FieldClash(field));
8000            }
8001        }
8002
8003        let mut params = Params::with_capacity(4 + self._additional_params.len());
8004        params.push("database", self._database);
8005
8006        params.extend(self._additional_params.iter());
8007
8008        params.push("alt", "json");
8009        let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:write";
8010        if self._scopes.is_empty() {
8011            self._scopes
8012                .insert(Scope::CloudPlatform.as_ref().to_string());
8013        }
8014
8015        #[allow(clippy::single_element_loop)]
8016        for &(find_this, param_name) in [("{+database}", "database")].iter() {
8017            url = params.uri_replacement(url, param_name, find_this, true);
8018        }
8019        {
8020            let to_remove = ["database"];
8021            params.remove_params(&to_remove);
8022        }
8023
8024        let url = params.parse_with_url(&url);
8025
8026        let mut json_mime_type = mime::APPLICATION_JSON;
8027        let mut request_value_reader = {
8028            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8029            common::remove_json_null_values(&mut value);
8030            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8031            serde_json::to_writer(&mut dst, &value).unwrap();
8032            dst
8033        };
8034        let request_size = request_value_reader
8035            .seek(std::io::SeekFrom::End(0))
8036            .unwrap();
8037        request_value_reader
8038            .seek(std::io::SeekFrom::Start(0))
8039            .unwrap();
8040
8041        loop {
8042            let token = match self
8043                .hub
8044                .auth
8045                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8046                .await
8047            {
8048                Ok(token) => token,
8049                Err(e) => match dlg.token(e) {
8050                    Ok(token) => token,
8051                    Err(e) => {
8052                        dlg.finished(false);
8053                        return Err(common::Error::MissingToken(e));
8054                    }
8055                },
8056            };
8057            request_value_reader
8058                .seek(std::io::SeekFrom::Start(0))
8059                .unwrap();
8060            let mut req_result = {
8061                let client = &self.hub.client;
8062                dlg.pre_request();
8063                let mut req_builder = hyper::Request::builder()
8064                    .method(hyper::Method::POST)
8065                    .uri(url.as_str())
8066                    .header(USER_AGENT, self.hub._user_agent.clone());
8067
8068                if let Some(token) = token.as_ref() {
8069                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8070                }
8071
8072                let request = req_builder
8073                    .header(CONTENT_TYPE, json_mime_type.to_string())
8074                    .header(CONTENT_LENGTH, request_size as u64)
8075                    .body(common::to_body(
8076                        request_value_reader.get_ref().clone().into(),
8077                    ));
8078
8079                client.request(request.unwrap()).await
8080            };
8081
8082            match req_result {
8083                Err(err) => {
8084                    if let common::Retry::After(d) = dlg.http_error(&err) {
8085                        sleep(d).await;
8086                        continue;
8087                    }
8088                    dlg.finished(false);
8089                    return Err(common::Error::HttpError(err));
8090                }
8091                Ok(res) => {
8092                    let (mut parts, body) = res.into_parts();
8093                    let mut body = common::Body::new(body);
8094                    if !parts.status.is_success() {
8095                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8096                        let error = serde_json::from_str(&common::to_string(&bytes));
8097                        let response = common::to_response(parts, bytes.into());
8098
8099                        if let common::Retry::After(d) =
8100                            dlg.http_failure(&response, error.as_ref().ok())
8101                        {
8102                            sleep(d).await;
8103                            continue;
8104                        }
8105
8106                        dlg.finished(false);
8107
8108                        return Err(match error {
8109                            Ok(value) => common::Error::BadRequest(value),
8110                            _ => common::Error::Failure(response),
8111                        });
8112                    }
8113                    let response = {
8114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8115                        let encoded = common::to_string(&bytes);
8116                        match serde_json::from_str(&encoded) {
8117                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8118                            Err(error) => {
8119                                dlg.response_json_decode_error(&encoded, &error);
8120                                return Err(common::Error::JsonDecodeError(
8121                                    encoded.to_string(),
8122                                    error,
8123                                ));
8124                            }
8125                        }
8126                    };
8127
8128                    dlg.finished(true);
8129                    return Ok(response);
8130                }
8131            }
8132        }
8133    }
8134
8135    ///
8136    /// Sets the *request* property to the given value.
8137    ///
8138    /// Even though the property as already been set when instantiating this call,
8139    /// we provide this method for API completeness.
8140    pub fn request(mut self, new_value: WriteRequest) -> ProjectDatabaseDocumentWriteCall<'a, C> {
8141        self._request = new_value;
8142        self
8143    }
8144    /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. This is only required in the first message.
8145    ///
8146    /// Sets the *database* path property to the given value.
8147    ///
8148    /// Even though the property as already been set when instantiating this call,
8149    /// we provide this method for API completeness.
8150    pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentWriteCall<'a, C> {
8151        self._database = new_value.to_string();
8152        self
8153    }
8154    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8155    /// while executing the actual API request.
8156    ///
8157    /// ````text
8158    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8159    /// ````
8160    ///
8161    /// Sets the *delegate* property to the given value.
8162    pub fn delegate(
8163        mut self,
8164        new_value: &'a mut dyn common::Delegate,
8165    ) -> ProjectDatabaseDocumentWriteCall<'a, C> {
8166        self._delegate = Some(new_value);
8167        self
8168    }
8169
8170    /// Set any additional parameter of the query string used in the request.
8171    /// It should be used to set parameters which are not yet available through their own
8172    /// setters.
8173    ///
8174    /// Please note that this method must not be used to set any of the known parameters
8175    /// which have their own setter method. If done anyway, the request will fail.
8176    ///
8177    /// # Additional Parameters
8178    ///
8179    /// * *$.xgafv* (query-string) - V1 error format.
8180    /// * *access_token* (query-string) - OAuth access token.
8181    /// * *alt* (query-string) - Data format for response.
8182    /// * *callback* (query-string) - JSONP
8183    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8184    /// * *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.
8185    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8186    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8187    /// * *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.
8188    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8189    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8190    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentWriteCall<'a, C>
8191    where
8192        T: AsRef<str>,
8193    {
8194        self._additional_params
8195            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8196        self
8197    }
8198
8199    /// Identifies the authorization scope for the method you are building.
8200    ///
8201    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8202    /// [`Scope::CloudPlatform`].
8203    ///
8204    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8205    /// tokens for more than one scope.
8206    ///
8207    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8208    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8209    /// sufficient, a read-write scope will do as well.
8210    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentWriteCall<'a, C>
8211    where
8212        St: AsRef<str>,
8213    {
8214        self._scopes.insert(String::from(scope.as_ref()));
8215        self
8216    }
8217    /// Identifies the authorization scope(s) for the method you are building.
8218    ///
8219    /// See [`Self::add_scope()`] for details.
8220    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentWriteCall<'a, C>
8221    where
8222        I: IntoIterator<Item = St>,
8223        St: AsRef<str>,
8224    {
8225        self._scopes
8226            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8227        self
8228    }
8229
8230    /// Removes all scopes, and no default scope will be used either.
8231    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8232    /// for details).
8233    pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentWriteCall<'a, C> {
8234        self._scopes.clear();
8235        self
8236    }
8237}
8238
8239/// Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned google.longrunning.Operation, the state will be `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. During creation, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, removing the index with delete, then re-creating the index with create. Indexes with a single field cannot be created.
8240///
8241/// A builder for the *databases.indexes.create* method supported by a *project* resource.
8242/// It is not used directly, but through a [`ProjectMethods`] instance.
8243///
8244/// # Example
8245///
8246/// Instantiate a resource method builder
8247///
8248/// ```test_harness,no_run
8249/// # extern crate hyper;
8250/// # extern crate hyper_rustls;
8251/// # extern crate google_firestore1_beta1 as firestore1_beta1;
8252/// use firestore1_beta1::api::GoogleFirestoreAdminV1beta1Index;
8253/// # async fn dox() {
8254/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8255///
8256/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8257/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8258/// #     secret,
8259/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8260/// # ).build().await.unwrap();
8261///
8262/// # let client = hyper_util::client::legacy::Client::builder(
8263/// #     hyper_util::rt::TokioExecutor::new()
8264/// # )
8265/// # .build(
8266/// #     hyper_rustls::HttpsConnectorBuilder::new()
8267/// #         .with_native_roots()
8268/// #         .unwrap()
8269/// #         .https_or_http()
8270/// #         .enable_http1()
8271/// #         .build()
8272/// # );
8273/// # let mut hub = Firestore::new(client, auth);
8274/// // As the method needs a request, you would usually fill it with the desired information
8275/// // into the respective structure. Some of the parts shown here might not be applicable !
8276/// // Values shown here are possibly random and not representative !
8277/// let mut req = GoogleFirestoreAdminV1beta1Index::default();
8278///
8279/// // You can configure optional parameters by calling the respective setters at will, and
8280/// // execute the final call using `doit()`.
8281/// // Values shown here are possibly random and not representative !
8282/// let result = hub.projects().databases_indexes_create(req, "parent")
8283///              .doit().await;
8284/// # }
8285/// ```
8286pub struct ProjectDatabaseIndexCreateCall<'a, C>
8287where
8288    C: 'a,
8289{
8290    hub: &'a Firestore<C>,
8291    _request: GoogleFirestoreAdminV1beta1Index,
8292    _parent: String,
8293    _delegate: Option<&'a mut dyn common::Delegate>,
8294    _additional_params: HashMap<String, String>,
8295    _scopes: BTreeSet<String>,
8296}
8297
8298impl<'a, C> common::CallBuilder for ProjectDatabaseIndexCreateCall<'a, C> {}
8299
8300impl<'a, C> ProjectDatabaseIndexCreateCall<'a, C>
8301where
8302    C: common::Connector,
8303{
8304    /// Perform the operation you have build so far.
8305    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
8306        use std::borrow::Cow;
8307        use std::io::{Read, Seek};
8308
8309        use common::{url::Params, ToParts};
8310        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8311
8312        let mut dd = common::DefaultDelegate;
8313        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8314        dlg.begin(common::MethodInfo {
8315            id: "firestore.projects.databases.indexes.create",
8316            http_method: hyper::Method::POST,
8317        });
8318
8319        for &field in ["alt", "parent"].iter() {
8320            if self._additional_params.contains_key(field) {
8321                dlg.finished(false);
8322                return Err(common::Error::FieldClash(field));
8323            }
8324        }
8325
8326        let mut params = Params::with_capacity(4 + self._additional_params.len());
8327        params.push("parent", self._parent);
8328
8329        params.extend(self._additional_params.iter());
8330
8331        params.push("alt", "json");
8332        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/indexes";
8333        if self._scopes.is_empty() {
8334            self._scopes
8335                .insert(Scope::CloudPlatform.as_ref().to_string());
8336        }
8337
8338        #[allow(clippy::single_element_loop)]
8339        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8340            url = params.uri_replacement(url, param_name, find_this, true);
8341        }
8342        {
8343            let to_remove = ["parent"];
8344            params.remove_params(&to_remove);
8345        }
8346
8347        let url = params.parse_with_url(&url);
8348
8349        let mut json_mime_type = mime::APPLICATION_JSON;
8350        let mut request_value_reader = {
8351            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8352            common::remove_json_null_values(&mut value);
8353            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8354            serde_json::to_writer(&mut dst, &value).unwrap();
8355            dst
8356        };
8357        let request_size = request_value_reader
8358            .seek(std::io::SeekFrom::End(0))
8359            .unwrap();
8360        request_value_reader
8361            .seek(std::io::SeekFrom::Start(0))
8362            .unwrap();
8363
8364        loop {
8365            let token = match self
8366                .hub
8367                .auth
8368                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8369                .await
8370            {
8371                Ok(token) => token,
8372                Err(e) => match dlg.token(e) {
8373                    Ok(token) => token,
8374                    Err(e) => {
8375                        dlg.finished(false);
8376                        return Err(common::Error::MissingToken(e));
8377                    }
8378                },
8379            };
8380            request_value_reader
8381                .seek(std::io::SeekFrom::Start(0))
8382                .unwrap();
8383            let mut req_result = {
8384                let client = &self.hub.client;
8385                dlg.pre_request();
8386                let mut req_builder = hyper::Request::builder()
8387                    .method(hyper::Method::POST)
8388                    .uri(url.as_str())
8389                    .header(USER_AGENT, self.hub._user_agent.clone());
8390
8391                if let Some(token) = token.as_ref() {
8392                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8393                }
8394
8395                let request = req_builder
8396                    .header(CONTENT_TYPE, json_mime_type.to_string())
8397                    .header(CONTENT_LENGTH, request_size as u64)
8398                    .body(common::to_body(
8399                        request_value_reader.get_ref().clone().into(),
8400                    ));
8401
8402                client.request(request.unwrap()).await
8403            };
8404
8405            match req_result {
8406                Err(err) => {
8407                    if let common::Retry::After(d) = dlg.http_error(&err) {
8408                        sleep(d).await;
8409                        continue;
8410                    }
8411                    dlg.finished(false);
8412                    return Err(common::Error::HttpError(err));
8413                }
8414                Ok(res) => {
8415                    let (mut parts, body) = res.into_parts();
8416                    let mut body = common::Body::new(body);
8417                    if !parts.status.is_success() {
8418                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8419                        let error = serde_json::from_str(&common::to_string(&bytes));
8420                        let response = common::to_response(parts, bytes.into());
8421
8422                        if let common::Retry::After(d) =
8423                            dlg.http_failure(&response, error.as_ref().ok())
8424                        {
8425                            sleep(d).await;
8426                            continue;
8427                        }
8428
8429                        dlg.finished(false);
8430
8431                        return Err(match error {
8432                            Ok(value) => common::Error::BadRequest(value),
8433                            _ => common::Error::Failure(response),
8434                        });
8435                    }
8436                    let response = {
8437                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8438                        let encoded = common::to_string(&bytes);
8439                        match serde_json::from_str(&encoded) {
8440                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8441                            Err(error) => {
8442                                dlg.response_json_decode_error(&encoded, &error);
8443                                return Err(common::Error::JsonDecodeError(
8444                                    encoded.to_string(),
8445                                    error,
8446                                ));
8447                            }
8448                        }
8449                    };
8450
8451                    dlg.finished(true);
8452                    return Ok(response);
8453                }
8454            }
8455        }
8456    }
8457
8458    ///
8459    /// Sets the *request* property to the given value.
8460    ///
8461    /// Even though the property as already been set when instantiating this call,
8462    /// we provide this method for API completeness.
8463    pub fn request(
8464        mut self,
8465        new_value: GoogleFirestoreAdminV1beta1Index,
8466    ) -> ProjectDatabaseIndexCreateCall<'a, C> {
8467        self._request = new_value;
8468        self
8469    }
8470    /// The name of the database this index will apply to. For example: `projects/{project_id}/databases/{database_id}`
8471    ///
8472    /// Sets the *parent* path property to the given value.
8473    ///
8474    /// Even though the property as already been set when instantiating this call,
8475    /// we provide this method for API completeness.
8476    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseIndexCreateCall<'a, C> {
8477        self._parent = new_value.to_string();
8478        self
8479    }
8480    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8481    /// while executing the actual API request.
8482    ///
8483    /// ````text
8484    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8485    /// ````
8486    ///
8487    /// Sets the *delegate* property to the given value.
8488    pub fn delegate(
8489        mut self,
8490        new_value: &'a mut dyn common::Delegate,
8491    ) -> ProjectDatabaseIndexCreateCall<'a, C> {
8492        self._delegate = Some(new_value);
8493        self
8494    }
8495
8496    /// Set any additional parameter of the query string used in the request.
8497    /// It should be used to set parameters which are not yet available through their own
8498    /// setters.
8499    ///
8500    /// Please note that this method must not be used to set any of the known parameters
8501    /// which have their own setter method. If done anyway, the request will fail.
8502    ///
8503    /// # Additional Parameters
8504    ///
8505    /// * *$.xgafv* (query-string) - V1 error format.
8506    /// * *access_token* (query-string) - OAuth access token.
8507    /// * *alt* (query-string) - Data format for response.
8508    /// * *callback* (query-string) - JSONP
8509    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8510    /// * *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.
8511    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8512    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8513    /// * *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.
8514    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8515    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8516    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseIndexCreateCall<'a, C>
8517    where
8518        T: AsRef<str>,
8519    {
8520        self._additional_params
8521            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8522        self
8523    }
8524
8525    /// Identifies the authorization scope for the method you are building.
8526    ///
8527    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8528    /// [`Scope::CloudPlatform`].
8529    ///
8530    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8531    /// tokens for more than one scope.
8532    ///
8533    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8534    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8535    /// sufficient, a read-write scope will do as well.
8536    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseIndexCreateCall<'a, C>
8537    where
8538        St: AsRef<str>,
8539    {
8540        self._scopes.insert(String::from(scope.as_ref()));
8541        self
8542    }
8543    /// Identifies the authorization scope(s) for the method you are building.
8544    ///
8545    /// See [`Self::add_scope()`] for details.
8546    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseIndexCreateCall<'a, C>
8547    where
8548        I: IntoIterator<Item = St>,
8549        St: AsRef<str>,
8550    {
8551        self._scopes
8552            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8553        self
8554    }
8555
8556    /// Removes all scopes, and no default scope will be used either.
8557    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8558    /// for details).
8559    pub fn clear_scopes(mut self) -> ProjectDatabaseIndexCreateCall<'a, C> {
8560        self._scopes.clear();
8561        self
8562    }
8563}
8564
8565/// Deletes an index.
8566///
8567/// A builder for the *databases.indexes.delete* method supported by a *project* resource.
8568/// It is not used directly, but through a [`ProjectMethods`] instance.
8569///
8570/// # Example
8571///
8572/// Instantiate a resource method builder
8573///
8574/// ```test_harness,no_run
8575/// # extern crate hyper;
8576/// # extern crate hyper_rustls;
8577/// # extern crate google_firestore1_beta1 as firestore1_beta1;
8578/// # async fn dox() {
8579/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8580///
8581/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8582/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8583/// #     secret,
8584/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8585/// # ).build().await.unwrap();
8586///
8587/// # let client = hyper_util::client::legacy::Client::builder(
8588/// #     hyper_util::rt::TokioExecutor::new()
8589/// # )
8590/// # .build(
8591/// #     hyper_rustls::HttpsConnectorBuilder::new()
8592/// #         .with_native_roots()
8593/// #         .unwrap()
8594/// #         .https_or_http()
8595/// #         .enable_http1()
8596/// #         .build()
8597/// # );
8598/// # let mut hub = Firestore::new(client, auth);
8599/// // You can configure optional parameters by calling the respective setters at will, and
8600/// // execute the final call using `doit()`.
8601/// // Values shown here are possibly random and not representative !
8602/// let result = hub.projects().databases_indexes_delete("name")
8603///              .doit().await;
8604/// # }
8605/// ```
8606pub struct ProjectDatabaseIndexDeleteCall<'a, C>
8607where
8608    C: 'a,
8609{
8610    hub: &'a Firestore<C>,
8611    _name: String,
8612    _delegate: Option<&'a mut dyn common::Delegate>,
8613    _additional_params: HashMap<String, String>,
8614    _scopes: BTreeSet<String>,
8615}
8616
8617impl<'a, C> common::CallBuilder for ProjectDatabaseIndexDeleteCall<'a, C> {}
8618
8619impl<'a, C> ProjectDatabaseIndexDeleteCall<'a, C>
8620where
8621    C: common::Connector,
8622{
8623    /// Perform the operation you have build so far.
8624    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8625        use std::borrow::Cow;
8626        use std::io::{Read, Seek};
8627
8628        use common::{url::Params, ToParts};
8629        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8630
8631        let mut dd = common::DefaultDelegate;
8632        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8633        dlg.begin(common::MethodInfo {
8634            id: "firestore.projects.databases.indexes.delete",
8635            http_method: hyper::Method::DELETE,
8636        });
8637
8638        for &field in ["alt", "name"].iter() {
8639            if self._additional_params.contains_key(field) {
8640                dlg.finished(false);
8641                return Err(common::Error::FieldClash(field));
8642            }
8643        }
8644
8645        let mut params = Params::with_capacity(3 + self._additional_params.len());
8646        params.push("name", self._name);
8647
8648        params.extend(self._additional_params.iter());
8649
8650        params.push("alt", "json");
8651        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
8652        if self._scopes.is_empty() {
8653            self._scopes
8654                .insert(Scope::CloudPlatform.as_ref().to_string());
8655        }
8656
8657        #[allow(clippy::single_element_loop)]
8658        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8659            url = params.uri_replacement(url, param_name, find_this, true);
8660        }
8661        {
8662            let to_remove = ["name"];
8663            params.remove_params(&to_remove);
8664        }
8665
8666        let url = params.parse_with_url(&url);
8667
8668        loop {
8669            let token = match self
8670                .hub
8671                .auth
8672                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8673                .await
8674            {
8675                Ok(token) => token,
8676                Err(e) => match dlg.token(e) {
8677                    Ok(token) => token,
8678                    Err(e) => {
8679                        dlg.finished(false);
8680                        return Err(common::Error::MissingToken(e));
8681                    }
8682                },
8683            };
8684            let mut req_result = {
8685                let client = &self.hub.client;
8686                dlg.pre_request();
8687                let mut req_builder = hyper::Request::builder()
8688                    .method(hyper::Method::DELETE)
8689                    .uri(url.as_str())
8690                    .header(USER_AGENT, self.hub._user_agent.clone());
8691
8692                if let Some(token) = token.as_ref() {
8693                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8694                }
8695
8696                let request = req_builder
8697                    .header(CONTENT_LENGTH, 0_u64)
8698                    .body(common::to_body::<String>(None));
8699
8700                client.request(request.unwrap()).await
8701            };
8702
8703            match req_result {
8704                Err(err) => {
8705                    if let common::Retry::After(d) = dlg.http_error(&err) {
8706                        sleep(d).await;
8707                        continue;
8708                    }
8709                    dlg.finished(false);
8710                    return Err(common::Error::HttpError(err));
8711                }
8712                Ok(res) => {
8713                    let (mut parts, body) = res.into_parts();
8714                    let mut body = common::Body::new(body);
8715                    if !parts.status.is_success() {
8716                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8717                        let error = serde_json::from_str(&common::to_string(&bytes));
8718                        let response = common::to_response(parts, bytes.into());
8719
8720                        if let common::Retry::After(d) =
8721                            dlg.http_failure(&response, error.as_ref().ok())
8722                        {
8723                            sleep(d).await;
8724                            continue;
8725                        }
8726
8727                        dlg.finished(false);
8728
8729                        return Err(match error {
8730                            Ok(value) => common::Error::BadRequest(value),
8731                            _ => common::Error::Failure(response),
8732                        });
8733                    }
8734                    let response = {
8735                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8736                        let encoded = common::to_string(&bytes);
8737                        match serde_json::from_str(&encoded) {
8738                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8739                            Err(error) => {
8740                                dlg.response_json_decode_error(&encoded, &error);
8741                                return Err(common::Error::JsonDecodeError(
8742                                    encoded.to_string(),
8743                                    error,
8744                                ));
8745                            }
8746                        }
8747                    };
8748
8749                    dlg.finished(true);
8750                    return Ok(response);
8751                }
8752            }
8753        }
8754    }
8755
8756    /// The index name. For example: `projects/{project_id}/databases/{database_id}/indexes/{index_id}`
8757    ///
8758    /// Sets the *name* path property to the given value.
8759    ///
8760    /// Even though the property as already been set when instantiating this call,
8761    /// we provide this method for API completeness.
8762    pub fn name(mut self, new_value: &str) -> ProjectDatabaseIndexDeleteCall<'a, C> {
8763        self._name = new_value.to_string();
8764        self
8765    }
8766    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8767    /// while executing the actual API request.
8768    ///
8769    /// ````text
8770    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8771    /// ````
8772    ///
8773    /// Sets the *delegate* property to the given value.
8774    pub fn delegate(
8775        mut self,
8776        new_value: &'a mut dyn common::Delegate,
8777    ) -> ProjectDatabaseIndexDeleteCall<'a, C> {
8778        self._delegate = Some(new_value);
8779        self
8780    }
8781
8782    /// Set any additional parameter of the query string used in the request.
8783    /// It should be used to set parameters which are not yet available through their own
8784    /// setters.
8785    ///
8786    /// Please note that this method must not be used to set any of the known parameters
8787    /// which have their own setter method. If done anyway, the request will fail.
8788    ///
8789    /// # Additional Parameters
8790    ///
8791    /// * *$.xgafv* (query-string) - V1 error format.
8792    /// * *access_token* (query-string) - OAuth access token.
8793    /// * *alt* (query-string) - Data format for response.
8794    /// * *callback* (query-string) - JSONP
8795    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8796    /// * *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.
8797    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8798    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8799    /// * *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.
8800    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8801    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8802    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseIndexDeleteCall<'a, C>
8803    where
8804        T: AsRef<str>,
8805    {
8806        self._additional_params
8807            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8808        self
8809    }
8810
8811    /// Identifies the authorization scope for the method you are building.
8812    ///
8813    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8814    /// [`Scope::CloudPlatform`].
8815    ///
8816    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8817    /// tokens for more than one scope.
8818    ///
8819    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8820    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8821    /// sufficient, a read-write scope will do as well.
8822    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseIndexDeleteCall<'a, C>
8823    where
8824        St: AsRef<str>,
8825    {
8826        self._scopes.insert(String::from(scope.as_ref()));
8827        self
8828    }
8829    /// Identifies the authorization scope(s) for the method you are building.
8830    ///
8831    /// See [`Self::add_scope()`] for details.
8832    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseIndexDeleteCall<'a, C>
8833    where
8834        I: IntoIterator<Item = St>,
8835        St: AsRef<str>,
8836    {
8837        self._scopes
8838            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8839        self
8840    }
8841
8842    /// Removes all scopes, and no default scope will be used either.
8843    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8844    /// for details).
8845    pub fn clear_scopes(mut self) -> ProjectDatabaseIndexDeleteCall<'a, C> {
8846        self._scopes.clear();
8847        self
8848    }
8849}
8850
8851/// Gets an index.
8852///
8853/// A builder for the *databases.indexes.get* method supported by a *project* resource.
8854/// It is not used directly, but through a [`ProjectMethods`] instance.
8855///
8856/// # Example
8857///
8858/// Instantiate a resource method builder
8859///
8860/// ```test_harness,no_run
8861/// # extern crate hyper;
8862/// # extern crate hyper_rustls;
8863/// # extern crate google_firestore1_beta1 as firestore1_beta1;
8864/// # async fn dox() {
8865/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8866///
8867/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8868/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8869/// #     secret,
8870/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8871/// # ).build().await.unwrap();
8872///
8873/// # let client = hyper_util::client::legacy::Client::builder(
8874/// #     hyper_util::rt::TokioExecutor::new()
8875/// # )
8876/// # .build(
8877/// #     hyper_rustls::HttpsConnectorBuilder::new()
8878/// #         .with_native_roots()
8879/// #         .unwrap()
8880/// #         .https_or_http()
8881/// #         .enable_http1()
8882/// #         .build()
8883/// # );
8884/// # let mut hub = Firestore::new(client, auth);
8885/// // You can configure optional parameters by calling the respective setters at will, and
8886/// // execute the final call using `doit()`.
8887/// // Values shown here are possibly random and not representative !
8888/// let result = hub.projects().databases_indexes_get("name")
8889///              .doit().await;
8890/// # }
8891/// ```
8892pub struct ProjectDatabaseIndexGetCall<'a, C>
8893where
8894    C: 'a,
8895{
8896    hub: &'a Firestore<C>,
8897    _name: String,
8898    _delegate: Option<&'a mut dyn common::Delegate>,
8899    _additional_params: HashMap<String, String>,
8900    _scopes: BTreeSet<String>,
8901}
8902
8903impl<'a, C> common::CallBuilder for ProjectDatabaseIndexGetCall<'a, C> {}
8904
8905impl<'a, C> ProjectDatabaseIndexGetCall<'a, C>
8906where
8907    C: common::Connector,
8908{
8909    /// Perform the operation you have build so far.
8910    pub async fn doit(
8911        mut self,
8912    ) -> common::Result<(common::Response, GoogleFirestoreAdminV1beta1Index)> {
8913        use std::borrow::Cow;
8914        use std::io::{Read, Seek};
8915
8916        use common::{url::Params, ToParts};
8917        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8918
8919        let mut dd = common::DefaultDelegate;
8920        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8921        dlg.begin(common::MethodInfo {
8922            id: "firestore.projects.databases.indexes.get",
8923            http_method: hyper::Method::GET,
8924        });
8925
8926        for &field in ["alt", "name"].iter() {
8927            if self._additional_params.contains_key(field) {
8928                dlg.finished(false);
8929                return Err(common::Error::FieldClash(field));
8930            }
8931        }
8932
8933        let mut params = Params::with_capacity(3 + self._additional_params.len());
8934        params.push("name", self._name);
8935
8936        params.extend(self._additional_params.iter());
8937
8938        params.push("alt", "json");
8939        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
8940        if self._scopes.is_empty() {
8941            self._scopes
8942                .insert(Scope::CloudPlatform.as_ref().to_string());
8943        }
8944
8945        #[allow(clippy::single_element_loop)]
8946        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8947            url = params.uri_replacement(url, param_name, find_this, true);
8948        }
8949        {
8950            let to_remove = ["name"];
8951            params.remove_params(&to_remove);
8952        }
8953
8954        let url = params.parse_with_url(&url);
8955
8956        loop {
8957            let token = match self
8958                .hub
8959                .auth
8960                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8961                .await
8962            {
8963                Ok(token) => token,
8964                Err(e) => match dlg.token(e) {
8965                    Ok(token) => token,
8966                    Err(e) => {
8967                        dlg.finished(false);
8968                        return Err(common::Error::MissingToken(e));
8969                    }
8970                },
8971            };
8972            let mut req_result = {
8973                let client = &self.hub.client;
8974                dlg.pre_request();
8975                let mut req_builder = hyper::Request::builder()
8976                    .method(hyper::Method::GET)
8977                    .uri(url.as_str())
8978                    .header(USER_AGENT, self.hub._user_agent.clone());
8979
8980                if let Some(token) = token.as_ref() {
8981                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8982                }
8983
8984                let request = req_builder
8985                    .header(CONTENT_LENGTH, 0_u64)
8986                    .body(common::to_body::<String>(None));
8987
8988                client.request(request.unwrap()).await
8989            };
8990
8991            match req_result {
8992                Err(err) => {
8993                    if let common::Retry::After(d) = dlg.http_error(&err) {
8994                        sleep(d).await;
8995                        continue;
8996                    }
8997                    dlg.finished(false);
8998                    return Err(common::Error::HttpError(err));
8999                }
9000                Ok(res) => {
9001                    let (mut parts, body) = res.into_parts();
9002                    let mut body = common::Body::new(body);
9003                    if !parts.status.is_success() {
9004                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9005                        let error = serde_json::from_str(&common::to_string(&bytes));
9006                        let response = common::to_response(parts, bytes.into());
9007
9008                        if let common::Retry::After(d) =
9009                            dlg.http_failure(&response, error.as_ref().ok())
9010                        {
9011                            sleep(d).await;
9012                            continue;
9013                        }
9014
9015                        dlg.finished(false);
9016
9017                        return Err(match error {
9018                            Ok(value) => common::Error::BadRequest(value),
9019                            _ => common::Error::Failure(response),
9020                        });
9021                    }
9022                    let response = {
9023                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9024                        let encoded = common::to_string(&bytes);
9025                        match serde_json::from_str(&encoded) {
9026                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9027                            Err(error) => {
9028                                dlg.response_json_decode_error(&encoded, &error);
9029                                return Err(common::Error::JsonDecodeError(
9030                                    encoded.to_string(),
9031                                    error,
9032                                ));
9033                            }
9034                        }
9035                    };
9036
9037                    dlg.finished(true);
9038                    return Ok(response);
9039                }
9040            }
9041        }
9042    }
9043
9044    /// The name of the index. For example: `projects/{project_id}/databases/{database_id}/indexes/{index_id}`
9045    ///
9046    /// Sets the *name* path property to the given value.
9047    ///
9048    /// Even though the property as already been set when instantiating this call,
9049    /// we provide this method for API completeness.
9050    pub fn name(mut self, new_value: &str) -> ProjectDatabaseIndexGetCall<'a, C> {
9051        self._name = new_value.to_string();
9052        self
9053    }
9054    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9055    /// while executing the actual API request.
9056    ///
9057    /// ````text
9058    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9059    /// ````
9060    ///
9061    /// Sets the *delegate* property to the given value.
9062    pub fn delegate(
9063        mut self,
9064        new_value: &'a mut dyn common::Delegate,
9065    ) -> ProjectDatabaseIndexGetCall<'a, C> {
9066        self._delegate = Some(new_value);
9067        self
9068    }
9069
9070    /// Set any additional parameter of the query string used in the request.
9071    /// It should be used to set parameters which are not yet available through their own
9072    /// setters.
9073    ///
9074    /// Please note that this method must not be used to set any of the known parameters
9075    /// which have their own setter method. If done anyway, the request will fail.
9076    ///
9077    /// # Additional Parameters
9078    ///
9079    /// * *$.xgafv* (query-string) - V1 error format.
9080    /// * *access_token* (query-string) - OAuth access token.
9081    /// * *alt* (query-string) - Data format for response.
9082    /// * *callback* (query-string) - JSONP
9083    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9084    /// * *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.
9085    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9086    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9087    /// * *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.
9088    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9089    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9090    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseIndexGetCall<'a, C>
9091    where
9092        T: AsRef<str>,
9093    {
9094        self._additional_params
9095            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9096        self
9097    }
9098
9099    /// Identifies the authorization scope for the method you are building.
9100    ///
9101    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9102    /// [`Scope::CloudPlatform`].
9103    ///
9104    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9105    /// tokens for more than one scope.
9106    ///
9107    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9108    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9109    /// sufficient, a read-write scope will do as well.
9110    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseIndexGetCall<'a, C>
9111    where
9112        St: AsRef<str>,
9113    {
9114        self._scopes.insert(String::from(scope.as_ref()));
9115        self
9116    }
9117    /// Identifies the authorization scope(s) for the method you are building.
9118    ///
9119    /// See [`Self::add_scope()`] for details.
9120    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseIndexGetCall<'a, C>
9121    where
9122        I: IntoIterator<Item = St>,
9123        St: AsRef<str>,
9124    {
9125        self._scopes
9126            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9127        self
9128    }
9129
9130    /// Removes all scopes, and no default scope will be used either.
9131    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9132    /// for details).
9133    pub fn clear_scopes(mut self) -> ProjectDatabaseIndexGetCall<'a, C> {
9134        self._scopes.clear();
9135        self
9136    }
9137}
9138
9139/// Lists the indexes that match the specified filters.
9140///
9141/// A builder for the *databases.indexes.list* method supported by a *project* resource.
9142/// It is not used directly, but through a [`ProjectMethods`] instance.
9143///
9144/// # Example
9145///
9146/// Instantiate a resource method builder
9147///
9148/// ```test_harness,no_run
9149/// # extern crate hyper;
9150/// # extern crate hyper_rustls;
9151/// # extern crate google_firestore1_beta1 as firestore1_beta1;
9152/// # async fn dox() {
9153/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9154///
9155/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9156/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9157/// #     secret,
9158/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9159/// # ).build().await.unwrap();
9160///
9161/// # let client = hyper_util::client::legacy::Client::builder(
9162/// #     hyper_util::rt::TokioExecutor::new()
9163/// # )
9164/// # .build(
9165/// #     hyper_rustls::HttpsConnectorBuilder::new()
9166/// #         .with_native_roots()
9167/// #         .unwrap()
9168/// #         .https_or_http()
9169/// #         .enable_http1()
9170/// #         .build()
9171/// # );
9172/// # let mut hub = Firestore::new(client, auth);
9173/// // You can configure optional parameters by calling the respective setters at will, and
9174/// // execute the final call using `doit()`.
9175/// // Values shown here are possibly random and not representative !
9176/// let result = hub.projects().databases_indexes_list("parent")
9177///              .page_token("et")
9178///              .page_size(-76)
9179///              .filter("erat")
9180///              .doit().await;
9181/// # }
9182/// ```
9183pub struct ProjectDatabaseIndexListCall<'a, C>
9184where
9185    C: 'a,
9186{
9187    hub: &'a Firestore<C>,
9188    _parent: String,
9189    _page_token: Option<String>,
9190    _page_size: Option<i32>,
9191    _filter: Option<String>,
9192    _delegate: Option<&'a mut dyn common::Delegate>,
9193    _additional_params: HashMap<String, String>,
9194    _scopes: BTreeSet<String>,
9195}
9196
9197impl<'a, C> common::CallBuilder for ProjectDatabaseIndexListCall<'a, C> {}
9198
9199impl<'a, C> ProjectDatabaseIndexListCall<'a, C>
9200where
9201    C: common::Connector,
9202{
9203    /// Perform the operation you have build so far.
9204    pub async fn doit(
9205        mut self,
9206    ) -> common::Result<(
9207        common::Response,
9208        GoogleFirestoreAdminV1beta1ListIndexesResponse,
9209    )> {
9210        use std::borrow::Cow;
9211        use std::io::{Read, Seek};
9212
9213        use common::{url::Params, ToParts};
9214        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9215
9216        let mut dd = common::DefaultDelegate;
9217        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9218        dlg.begin(common::MethodInfo {
9219            id: "firestore.projects.databases.indexes.list",
9220            http_method: hyper::Method::GET,
9221        });
9222
9223        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
9224            if self._additional_params.contains_key(field) {
9225                dlg.finished(false);
9226                return Err(common::Error::FieldClash(field));
9227            }
9228        }
9229
9230        let mut params = Params::with_capacity(6 + self._additional_params.len());
9231        params.push("parent", self._parent);
9232        if let Some(value) = self._page_token.as_ref() {
9233            params.push("pageToken", value);
9234        }
9235        if let Some(value) = self._page_size.as_ref() {
9236            params.push("pageSize", value.to_string());
9237        }
9238        if let Some(value) = self._filter.as_ref() {
9239            params.push("filter", value);
9240        }
9241
9242        params.extend(self._additional_params.iter());
9243
9244        params.push("alt", "json");
9245        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/indexes";
9246        if self._scopes.is_empty() {
9247            self._scopes
9248                .insert(Scope::CloudPlatform.as_ref().to_string());
9249        }
9250
9251        #[allow(clippy::single_element_loop)]
9252        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9253            url = params.uri_replacement(url, param_name, find_this, true);
9254        }
9255        {
9256            let to_remove = ["parent"];
9257            params.remove_params(&to_remove);
9258        }
9259
9260        let url = params.parse_with_url(&url);
9261
9262        loop {
9263            let token = match self
9264                .hub
9265                .auth
9266                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9267                .await
9268            {
9269                Ok(token) => token,
9270                Err(e) => match dlg.token(e) {
9271                    Ok(token) => token,
9272                    Err(e) => {
9273                        dlg.finished(false);
9274                        return Err(common::Error::MissingToken(e));
9275                    }
9276                },
9277            };
9278            let mut req_result = {
9279                let client = &self.hub.client;
9280                dlg.pre_request();
9281                let mut req_builder = hyper::Request::builder()
9282                    .method(hyper::Method::GET)
9283                    .uri(url.as_str())
9284                    .header(USER_AGENT, self.hub._user_agent.clone());
9285
9286                if let Some(token) = token.as_ref() {
9287                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9288                }
9289
9290                let request = req_builder
9291                    .header(CONTENT_LENGTH, 0_u64)
9292                    .body(common::to_body::<String>(None));
9293
9294                client.request(request.unwrap()).await
9295            };
9296
9297            match req_result {
9298                Err(err) => {
9299                    if let common::Retry::After(d) = dlg.http_error(&err) {
9300                        sleep(d).await;
9301                        continue;
9302                    }
9303                    dlg.finished(false);
9304                    return Err(common::Error::HttpError(err));
9305                }
9306                Ok(res) => {
9307                    let (mut parts, body) = res.into_parts();
9308                    let mut body = common::Body::new(body);
9309                    if !parts.status.is_success() {
9310                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9311                        let error = serde_json::from_str(&common::to_string(&bytes));
9312                        let response = common::to_response(parts, bytes.into());
9313
9314                        if let common::Retry::After(d) =
9315                            dlg.http_failure(&response, error.as_ref().ok())
9316                        {
9317                            sleep(d).await;
9318                            continue;
9319                        }
9320
9321                        dlg.finished(false);
9322
9323                        return Err(match error {
9324                            Ok(value) => common::Error::BadRequest(value),
9325                            _ => common::Error::Failure(response),
9326                        });
9327                    }
9328                    let response = {
9329                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9330                        let encoded = common::to_string(&bytes);
9331                        match serde_json::from_str(&encoded) {
9332                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9333                            Err(error) => {
9334                                dlg.response_json_decode_error(&encoded, &error);
9335                                return Err(common::Error::JsonDecodeError(
9336                                    encoded.to_string(),
9337                                    error,
9338                                ));
9339                            }
9340                        }
9341                    };
9342
9343                    dlg.finished(true);
9344                    return Ok(response);
9345                }
9346            }
9347        }
9348    }
9349
9350    /// The database name. For example: `projects/{project_id}/databases/{database_id}`
9351    ///
9352    /// Sets the *parent* path property to the given value.
9353    ///
9354    /// Even though the property as already been set when instantiating this call,
9355    /// we provide this method for API completeness.
9356    pub fn parent(mut self, new_value: &str) -> ProjectDatabaseIndexListCall<'a, C> {
9357        self._parent = new_value.to_string();
9358        self
9359    }
9360    /// The standard List page token.
9361    ///
9362    /// Sets the *page token* query property to the given value.
9363    pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseIndexListCall<'a, C> {
9364        self._page_token = Some(new_value.to_string());
9365        self
9366    }
9367    /// The standard List page size.
9368    ///
9369    /// Sets the *page size* query property to the given value.
9370    pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseIndexListCall<'a, C> {
9371        self._page_size = Some(new_value);
9372        self
9373    }
9374    ///
9375    /// Sets the *filter* query property to the given value.
9376    pub fn filter(mut self, new_value: &str) -> ProjectDatabaseIndexListCall<'a, C> {
9377        self._filter = Some(new_value.to_string());
9378        self
9379    }
9380    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9381    /// while executing the actual API request.
9382    ///
9383    /// ````text
9384    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9385    /// ````
9386    ///
9387    /// Sets the *delegate* property to the given value.
9388    pub fn delegate(
9389        mut self,
9390        new_value: &'a mut dyn common::Delegate,
9391    ) -> ProjectDatabaseIndexListCall<'a, C> {
9392        self._delegate = Some(new_value);
9393        self
9394    }
9395
9396    /// Set any additional parameter of the query string used in the request.
9397    /// It should be used to set parameters which are not yet available through their own
9398    /// setters.
9399    ///
9400    /// Please note that this method must not be used to set any of the known parameters
9401    /// which have their own setter method. If done anyway, the request will fail.
9402    ///
9403    /// # Additional Parameters
9404    ///
9405    /// * *$.xgafv* (query-string) - V1 error format.
9406    /// * *access_token* (query-string) - OAuth access token.
9407    /// * *alt* (query-string) - Data format for response.
9408    /// * *callback* (query-string) - JSONP
9409    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9410    /// * *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.
9411    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9412    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9413    /// * *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.
9414    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9415    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9416    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseIndexListCall<'a, C>
9417    where
9418        T: AsRef<str>,
9419    {
9420        self._additional_params
9421            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9422        self
9423    }
9424
9425    /// Identifies the authorization scope for the method you are building.
9426    ///
9427    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9428    /// [`Scope::CloudPlatform`].
9429    ///
9430    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9431    /// tokens for more than one scope.
9432    ///
9433    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9434    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9435    /// sufficient, a read-write scope will do as well.
9436    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseIndexListCall<'a, C>
9437    where
9438        St: AsRef<str>,
9439    {
9440        self._scopes.insert(String::from(scope.as_ref()));
9441        self
9442    }
9443    /// Identifies the authorization scope(s) for the method you are building.
9444    ///
9445    /// See [`Self::add_scope()`] for details.
9446    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseIndexListCall<'a, C>
9447    where
9448        I: IntoIterator<Item = St>,
9449        St: AsRef<str>,
9450    {
9451        self._scopes
9452            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9453        self
9454    }
9455
9456    /// Removes all scopes, and no default scope will be used either.
9457    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9458    /// for details).
9459    pub fn clear_scopes(mut self) -> ProjectDatabaseIndexListCall<'a, C> {
9460        self._scopes.clear();
9461        self
9462    }
9463}
9464
9465/// 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.
9466///
9467/// A builder for the *databases.exportDocuments* method supported by a *project* resource.
9468/// It is not used directly, but through a [`ProjectMethods`] instance.
9469///
9470/// # Example
9471///
9472/// Instantiate a resource method builder
9473///
9474/// ```test_harness,no_run
9475/// # extern crate hyper;
9476/// # extern crate hyper_rustls;
9477/// # extern crate google_firestore1_beta1 as firestore1_beta1;
9478/// use firestore1_beta1::api::GoogleFirestoreAdminV1beta1ExportDocumentsRequest;
9479/// # async fn dox() {
9480/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9481///
9482/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9483/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9484/// #     secret,
9485/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9486/// # ).build().await.unwrap();
9487///
9488/// # let client = hyper_util::client::legacy::Client::builder(
9489/// #     hyper_util::rt::TokioExecutor::new()
9490/// # )
9491/// # .build(
9492/// #     hyper_rustls::HttpsConnectorBuilder::new()
9493/// #         .with_native_roots()
9494/// #         .unwrap()
9495/// #         .https_or_http()
9496/// #         .enable_http1()
9497/// #         .build()
9498/// # );
9499/// # let mut hub = Firestore::new(client, auth);
9500/// // As the method needs a request, you would usually fill it with the desired information
9501/// // into the respective structure. Some of the parts shown here might not be applicable !
9502/// // Values shown here are possibly random and not representative !
9503/// let mut req = GoogleFirestoreAdminV1beta1ExportDocumentsRequest::default();
9504///
9505/// // You can configure optional parameters by calling the respective setters at will, and
9506/// // execute the final call using `doit()`.
9507/// // Values shown here are possibly random and not representative !
9508/// let result = hub.projects().databases_export_documents(req, "name")
9509///              .doit().await;
9510/// # }
9511/// ```
9512pub struct ProjectDatabaseExportDocumentCall<'a, C>
9513where
9514    C: 'a,
9515{
9516    hub: &'a Firestore<C>,
9517    _request: GoogleFirestoreAdminV1beta1ExportDocumentsRequest,
9518    _name: String,
9519    _delegate: Option<&'a mut dyn common::Delegate>,
9520    _additional_params: HashMap<String, String>,
9521    _scopes: BTreeSet<String>,
9522}
9523
9524impl<'a, C> common::CallBuilder for ProjectDatabaseExportDocumentCall<'a, C> {}
9525
9526impl<'a, C> ProjectDatabaseExportDocumentCall<'a, C>
9527where
9528    C: common::Connector,
9529{
9530    /// Perform the operation you have build so far.
9531    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
9532        use std::borrow::Cow;
9533        use std::io::{Read, Seek};
9534
9535        use common::{url::Params, ToParts};
9536        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9537
9538        let mut dd = common::DefaultDelegate;
9539        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9540        dlg.begin(common::MethodInfo {
9541            id: "firestore.projects.databases.exportDocuments",
9542            http_method: hyper::Method::POST,
9543        });
9544
9545        for &field in ["alt", "name"].iter() {
9546            if self._additional_params.contains_key(field) {
9547                dlg.finished(false);
9548                return Err(common::Error::FieldClash(field));
9549            }
9550        }
9551
9552        let mut params = Params::with_capacity(4 + self._additional_params.len());
9553        params.push("name", self._name);
9554
9555        params.extend(self._additional_params.iter());
9556
9557        params.push("alt", "json");
9558        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:exportDocuments";
9559        if self._scopes.is_empty() {
9560            self._scopes
9561                .insert(Scope::CloudPlatform.as_ref().to_string());
9562        }
9563
9564        #[allow(clippy::single_element_loop)]
9565        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9566            url = params.uri_replacement(url, param_name, find_this, true);
9567        }
9568        {
9569            let to_remove = ["name"];
9570            params.remove_params(&to_remove);
9571        }
9572
9573        let url = params.parse_with_url(&url);
9574
9575        let mut json_mime_type = mime::APPLICATION_JSON;
9576        let mut request_value_reader = {
9577            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9578            common::remove_json_null_values(&mut value);
9579            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9580            serde_json::to_writer(&mut dst, &value).unwrap();
9581            dst
9582        };
9583        let request_size = request_value_reader
9584            .seek(std::io::SeekFrom::End(0))
9585            .unwrap();
9586        request_value_reader
9587            .seek(std::io::SeekFrom::Start(0))
9588            .unwrap();
9589
9590        loop {
9591            let token = match self
9592                .hub
9593                .auth
9594                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9595                .await
9596            {
9597                Ok(token) => token,
9598                Err(e) => match dlg.token(e) {
9599                    Ok(token) => token,
9600                    Err(e) => {
9601                        dlg.finished(false);
9602                        return Err(common::Error::MissingToken(e));
9603                    }
9604                },
9605            };
9606            request_value_reader
9607                .seek(std::io::SeekFrom::Start(0))
9608                .unwrap();
9609            let mut req_result = {
9610                let client = &self.hub.client;
9611                dlg.pre_request();
9612                let mut req_builder = hyper::Request::builder()
9613                    .method(hyper::Method::POST)
9614                    .uri(url.as_str())
9615                    .header(USER_AGENT, self.hub._user_agent.clone());
9616
9617                if let Some(token) = token.as_ref() {
9618                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9619                }
9620
9621                let request = req_builder
9622                    .header(CONTENT_TYPE, json_mime_type.to_string())
9623                    .header(CONTENT_LENGTH, request_size as u64)
9624                    .body(common::to_body(
9625                        request_value_reader.get_ref().clone().into(),
9626                    ));
9627
9628                client.request(request.unwrap()).await
9629            };
9630
9631            match req_result {
9632                Err(err) => {
9633                    if let common::Retry::After(d) = dlg.http_error(&err) {
9634                        sleep(d).await;
9635                        continue;
9636                    }
9637                    dlg.finished(false);
9638                    return Err(common::Error::HttpError(err));
9639                }
9640                Ok(res) => {
9641                    let (mut parts, body) = res.into_parts();
9642                    let mut body = common::Body::new(body);
9643                    if !parts.status.is_success() {
9644                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9645                        let error = serde_json::from_str(&common::to_string(&bytes));
9646                        let response = common::to_response(parts, bytes.into());
9647
9648                        if let common::Retry::After(d) =
9649                            dlg.http_failure(&response, error.as_ref().ok())
9650                        {
9651                            sleep(d).await;
9652                            continue;
9653                        }
9654
9655                        dlg.finished(false);
9656
9657                        return Err(match error {
9658                            Ok(value) => common::Error::BadRequest(value),
9659                            _ => common::Error::Failure(response),
9660                        });
9661                    }
9662                    let response = {
9663                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9664                        let encoded = common::to_string(&bytes);
9665                        match serde_json::from_str(&encoded) {
9666                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9667                            Err(error) => {
9668                                dlg.response_json_decode_error(&encoded, &error);
9669                                return Err(common::Error::JsonDecodeError(
9670                                    encoded.to_string(),
9671                                    error,
9672                                ));
9673                            }
9674                        }
9675                    };
9676
9677                    dlg.finished(true);
9678                    return Ok(response);
9679                }
9680            }
9681        }
9682    }
9683
9684    ///
9685    /// Sets the *request* property to the given value.
9686    ///
9687    /// Even though the property as already been set when instantiating this call,
9688    /// we provide this method for API completeness.
9689    pub fn request(
9690        mut self,
9691        new_value: GoogleFirestoreAdminV1beta1ExportDocumentsRequest,
9692    ) -> ProjectDatabaseExportDocumentCall<'a, C> {
9693        self._request = new_value;
9694        self
9695    }
9696    /// Database to export. Should be of the form: `projects/{project_id}/databases/{database_id}`.
9697    ///
9698    /// Sets the *name* path property to the given value.
9699    ///
9700    /// Even though the property as already been set when instantiating this call,
9701    /// we provide this method for API completeness.
9702    pub fn name(mut self, new_value: &str) -> ProjectDatabaseExportDocumentCall<'a, C> {
9703        self._name = new_value.to_string();
9704        self
9705    }
9706    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9707    /// while executing the actual API request.
9708    ///
9709    /// ````text
9710    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9711    /// ````
9712    ///
9713    /// Sets the *delegate* property to the given value.
9714    pub fn delegate(
9715        mut self,
9716        new_value: &'a mut dyn common::Delegate,
9717    ) -> ProjectDatabaseExportDocumentCall<'a, C> {
9718        self._delegate = Some(new_value);
9719        self
9720    }
9721
9722    /// Set any additional parameter of the query string used in the request.
9723    /// It should be used to set parameters which are not yet available through their own
9724    /// setters.
9725    ///
9726    /// Please note that this method must not be used to set any of the known parameters
9727    /// which have their own setter method. If done anyway, the request will fail.
9728    ///
9729    /// # Additional Parameters
9730    ///
9731    /// * *$.xgafv* (query-string) - V1 error format.
9732    /// * *access_token* (query-string) - OAuth access token.
9733    /// * *alt* (query-string) - Data format for response.
9734    /// * *callback* (query-string) - JSONP
9735    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9736    /// * *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.
9737    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9738    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9739    /// * *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.
9740    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9741    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9742    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseExportDocumentCall<'a, C>
9743    where
9744        T: AsRef<str>,
9745    {
9746        self._additional_params
9747            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9748        self
9749    }
9750
9751    /// Identifies the authorization scope for the method you are building.
9752    ///
9753    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9754    /// [`Scope::CloudPlatform`].
9755    ///
9756    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9757    /// tokens for more than one scope.
9758    ///
9759    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9760    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9761    /// sufficient, a read-write scope will do as well.
9762    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseExportDocumentCall<'a, C>
9763    where
9764        St: AsRef<str>,
9765    {
9766        self._scopes.insert(String::from(scope.as_ref()));
9767        self
9768    }
9769    /// Identifies the authorization scope(s) for the method you are building.
9770    ///
9771    /// See [`Self::add_scope()`] for details.
9772    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseExportDocumentCall<'a, C>
9773    where
9774        I: IntoIterator<Item = St>,
9775        St: AsRef<str>,
9776    {
9777        self._scopes
9778            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9779        self
9780    }
9781
9782    /// Removes all scopes, and no default scope will be used either.
9783    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9784    /// for details).
9785    pub fn clear_scopes(mut self) -> ProjectDatabaseExportDocumentCall<'a, C> {
9786        self._scopes.clear();
9787        self
9788    }
9789}
9790
9791/// 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.
9792///
9793/// A builder for the *databases.importDocuments* method supported by a *project* resource.
9794/// It is not used directly, but through a [`ProjectMethods`] instance.
9795///
9796/// # Example
9797///
9798/// Instantiate a resource method builder
9799///
9800/// ```test_harness,no_run
9801/// # extern crate hyper;
9802/// # extern crate hyper_rustls;
9803/// # extern crate google_firestore1_beta1 as firestore1_beta1;
9804/// use firestore1_beta1::api::GoogleFirestoreAdminV1beta1ImportDocumentsRequest;
9805/// # async fn dox() {
9806/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9807///
9808/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9809/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9810/// #     secret,
9811/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9812/// # ).build().await.unwrap();
9813///
9814/// # let client = hyper_util::client::legacy::Client::builder(
9815/// #     hyper_util::rt::TokioExecutor::new()
9816/// # )
9817/// # .build(
9818/// #     hyper_rustls::HttpsConnectorBuilder::new()
9819/// #         .with_native_roots()
9820/// #         .unwrap()
9821/// #         .https_or_http()
9822/// #         .enable_http1()
9823/// #         .build()
9824/// # );
9825/// # let mut hub = Firestore::new(client, auth);
9826/// // As the method needs a request, you would usually fill it with the desired information
9827/// // into the respective structure. Some of the parts shown here might not be applicable !
9828/// // Values shown here are possibly random and not representative !
9829/// let mut req = GoogleFirestoreAdminV1beta1ImportDocumentsRequest::default();
9830///
9831/// // You can configure optional parameters by calling the respective setters at will, and
9832/// // execute the final call using `doit()`.
9833/// // Values shown here are possibly random and not representative !
9834/// let result = hub.projects().databases_import_documents(req, "name")
9835///              .doit().await;
9836/// # }
9837/// ```
9838pub struct ProjectDatabaseImportDocumentCall<'a, C>
9839where
9840    C: 'a,
9841{
9842    hub: &'a Firestore<C>,
9843    _request: GoogleFirestoreAdminV1beta1ImportDocumentsRequest,
9844    _name: String,
9845    _delegate: Option<&'a mut dyn common::Delegate>,
9846    _additional_params: HashMap<String, String>,
9847    _scopes: BTreeSet<String>,
9848}
9849
9850impl<'a, C> common::CallBuilder for ProjectDatabaseImportDocumentCall<'a, C> {}
9851
9852impl<'a, C> ProjectDatabaseImportDocumentCall<'a, C>
9853where
9854    C: common::Connector,
9855{
9856    /// Perform the operation you have build so far.
9857    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
9858        use std::borrow::Cow;
9859        use std::io::{Read, Seek};
9860
9861        use common::{url::Params, ToParts};
9862        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9863
9864        let mut dd = common::DefaultDelegate;
9865        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9866        dlg.begin(common::MethodInfo {
9867            id: "firestore.projects.databases.importDocuments",
9868            http_method: hyper::Method::POST,
9869        });
9870
9871        for &field in ["alt", "name"].iter() {
9872            if self._additional_params.contains_key(field) {
9873                dlg.finished(false);
9874                return Err(common::Error::FieldClash(field));
9875            }
9876        }
9877
9878        let mut params = Params::with_capacity(4 + self._additional_params.len());
9879        params.push("name", self._name);
9880
9881        params.extend(self._additional_params.iter());
9882
9883        params.push("alt", "json");
9884        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:importDocuments";
9885        if self._scopes.is_empty() {
9886            self._scopes
9887                .insert(Scope::CloudPlatform.as_ref().to_string());
9888        }
9889
9890        #[allow(clippy::single_element_loop)]
9891        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9892            url = params.uri_replacement(url, param_name, find_this, true);
9893        }
9894        {
9895            let to_remove = ["name"];
9896            params.remove_params(&to_remove);
9897        }
9898
9899        let url = params.parse_with_url(&url);
9900
9901        let mut json_mime_type = mime::APPLICATION_JSON;
9902        let mut request_value_reader = {
9903            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9904            common::remove_json_null_values(&mut value);
9905            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9906            serde_json::to_writer(&mut dst, &value).unwrap();
9907            dst
9908        };
9909        let request_size = request_value_reader
9910            .seek(std::io::SeekFrom::End(0))
9911            .unwrap();
9912        request_value_reader
9913            .seek(std::io::SeekFrom::Start(0))
9914            .unwrap();
9915
9916        loop {
9917            let token = match self
9918                .hub
9919                .auth
9920                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9921                .await
9922            {
9923                Ok(token) => token,
9924                Err(e) => match dlg.token(e) {
9925                    Ok(token) => token,
9926                    Err(e) => {
9927                        dlg.finished(false);
9928                        return Err(common::Error::MissingToken(e));
9929                    }
9930                },
9931            };
9932            request_value_reader
9933                .seek(std::io::SeekFrom::Start(0))
9934                .unwrap();
9935            let mut req_result = {
9936                let client = &self.hub.client;
9937                dlg.pre_request();
9938                let mut req_builder = hyper::Request::builder()
9939                    .method(hyper::Method::POST)
9940                    .uri(url.as_str())
9941                    .header(USER_AGENT, self.hub._user_agent.clone());
9942
9943                if let Some(token) = token.as_ref() {
9944                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9945                }
9946
9947                let request = req_builder
9948                    .header(CONTENT_TYPE, json_mime_type.to_string())
9949                    .header(CONTENT_LENGTH, request_size as u64)
9950                    .body(common::to_body(
9951                        request_value_reader.get_ref().clone().into(),
9952                    ));
9953
9954                client.request(request.unwrap()).await
9955            };
9956
9957            match req_result {
9958                Err(err) => {
9959                    if let common::Retry::After(d) = dlg.http_error(&err) {
9960                        sleep(d).await;
9961                        continue;
9962                    }
9963                    dlg.finished(false);
9964                    return Err(common::Error::HttpError(err));
9965                }
9966                Ok(res) => {
9967                    let (mut parts, body) = res.into_parts();
9968                    let mut body = common::Body::new(body);
9969                    if !parts.status.is_success() {
9970                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9971                        let error = serde_json::from_str(&common::to_string(&bytes));
9972                        let response = common::to_response(parts, bytes.into());
9973
9974                        if let common::Retry::After(d) =
9975                            dlg.http_failure(&response, error.as_ref().ok())
9976                        {
9977                            sleep(d).await;
9978                            continue;
9979                        }
9980
9981                        dlg.finished(false);
9982
9983                        return Err(match error {
9984                            Ok(value) => common::Error::BadRequest(value),
9985                            _ => common::Error::Failure(response),
9986                        });
9987                    }
9988                    let response = {
9989                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9990                        let encoded = common::to_string(&bytes);
9991                        match serde_json::from_str(&encoded) {
9992                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9993                            Err(error) => {
9994                                dlg.response_json_decode_error(&encoded, &error);
9995                                return Err(common::Error::JsonDecodeError(
9996                                    encoded.to_string(),
9997                                    error,
9998                                ));
9999                            }
10000                        }
10001                    };
10002
10003                    dlg.finished(true);
10004                    return Ok(response);
10005                }
10006            }
10007        }
10008    }
10009
10010    ///
10011    /// Sets the *request* property to the given value.
10012    ///
10013    /// Even though the property as already been set when instantiating this call,
10014    /// we provide this method for API completeness.
10015    pub fn request(
10016        mut self,
10017        new_value: GoogleFirestoreAdminV1beta1ImportDocumentsRequest,
10018    ) -> ProjectDatabaseImportDocumentCall<'a, C> {
10019        self._request = new_value;
10020        self
10021    }
10022    /// Database to import into. Should be of the form: `projects/{project_id}/databases/{database_id}`.
10023    ///
10024    /// Sets the *name* path property to the given value.
10025    ///
10026    /// Even though the property as already been set when instantiating this call,
10027    /// we provide this method for API completeness.
10028    pub fn name(mut self, new_value: &str) -> ProjectDatabaseImportDocumentCall<'a, C> {
10029        self._name = new_value.to_string();
10030        self
10031    }
10032    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10033    /// while executing the actual API request.
10034    ///
10035    /// ````text
10036    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10037    /// ````
10038    ///
10039    /// Sets the *delegate* property to the given value.
10040    pub fn delegate(
10041        mut self,
10042        new_value: &'a mut dyn common::Delegate,
10043    ) -> ProjectDatabaseImportDocumentCall<'a, C> {
10044        self._delegate = Some(new_value);
10045        self
10046    }
10047
10048    /// Set any additional parameter of the query string used in the request.
10049    /// It should be used to set parameters which are not yet available through their own
10050    /// setters.
10051    ///
10052    /// Please note that this method must not be used to set any of the known parameters
10053    /// which have their own setter method. If done anyway, the request will fail.
10054    ///
10055    /// # Additional Parameters
10056    ///
10057    /// * *$.xgafv* (query-string) - V1 error format.
10058    /// * *access_token* (query-string) - OAuth access token.
10059    /// * *alt* (query-string) - Data format for response.
10060    /// * *callback* (query-string) - JSONP
10061    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10062    /// * *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.
10063    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10064    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10065    /// * *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.
10066    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10067    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10068    pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseImportDocumentCall<'a, C>
10069    where
10070        T: AsRef<str>,
10071    {
10072        self._additional_params
10073            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10074        self
10075    }
10076
10077    /// Identifies the authorization scope for the method you are building.
10078    ///
10079    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10080    /// [`Scope::CloudPlatform`].
10081    ///
10082    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10083    /// tokens for more than one scope.
10084    ///
10085    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10086    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10087    /// sufficient, a read-write scope will do as well.
10088    pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseImportDocumentCall<'a, C>
10089    where
10090        St: AsRef<str>,
10091    {
10092        self._scopes.insert(String::from(scope.as_ref()));
10093        self
10094    }
10095    /// Identifies the authorization scope(s) for the method you are building.
10096    ///
10097    /// See [`Self::add_scope()`] for details.
10098    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseImportDocumentCall<'a, C>
10099    where
10100        I: IntoIterator<Item = St>,
10101        St: AsRef<str>,
10102    {
10103        self._scopes
10104            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10105        self
10106    }
10107
10108    /// Removes all scopes, and no default scope will be used either.
10109    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10110    /// for details).
10111    pub fn clear_scopes(mut self) -> ProjectDatabaseImportDocumentCall<'a, C> {
10112        self._scopes.clear();
10113        self
10114    }
10115}