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 connector = hyper_rustls::HttpsConnectorBuilder::new()
67/// .with_native_roots()
68/// .unwrap()
69/// .https_only()
70/// .enable_http2()
71/// .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75/// secret,
76/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77/// yup_oauth2::client::CustomHyperClientBuilder::from(
78/// hyper_util::client::legacy::Client::builder(executor).build(connector),
79/// ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83/// hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86/// hyper_rustls::HttpsConnectorBuilder::new()
87/// .with_native_roots()
88/// .unwrap()
89/// .https_or_http()
90/// .enable_http2()
91/// .build()
92/// );
93/// let mut hub = Firestore::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = GoogleFirestoreAdminV1beta1Index::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.projects().databases_indexes_create(req, "parent")
103/// .doit().await;
104///
105/// match result {
106/// Err(e) => match e {
107/// // The Error enum provides details about what exactly happened.
108/// // You can also just use its `Debug`, `Display` or `Error` traits
109/// Error::HttpError(_)
110/// |Error::Io(_)
111/// |Error::MissingAPIKey
112/// |Error::MissingToken(_)
113/// |Error::Cancelled
114/// |Error::UploadSizeLimitExceeded(_, _)
115/// |Error::Failure(_)
116/// |Error::BadRequest(_)
117/// |Error::FieldClash(_)
118/// |Error::JsonDecodeError(_, _) => println!("{}", e),
119/// },
120/// Ok(res) => println!("Success: {:?}", res),
121/// }
122/// # }
123/// ```
124#[derive(Clone)]
125pub struct Firestore<C> {
126 pub client: common::Client<C>,
127 pub auth: Box<dyn common::GetToken>,
128 _user_agent: String,
129 _base_url: String,
130 _root_url: String,
131}
132
133impl<C> common::Hub for Firestore<C> {}
134
135impl<'a, C> Firestore<C> {
136 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Firestore<C> {
137 Firestore {
138 client,
139 auth: Box::new(auth),
140 _user_agent: "google-api-rust-client/7.0.0".to_string(),
141 _base_url: "https://firestore.googleapis.com/".to_string(),
142 _root_url: "https://firestore.googleapis.com/".to_string(),
143 }
144 }
145
146 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147 ProjectMethods { hub: self }
148 }
149
150 /// Set the user-agent header field to use in all requests to the server.
151 /// It defaults to `google-api-rust-client/7.0.0`.
152 ///
153 /// Returns the previously set user-agent.
154 pub fn user_agent(&mut self, agent_name: String) -> String {
155 std::mem::replace(&mut self._user_agent, agent_name)
156 }
157
158 /// Set the base url to use in all requests to the server.
159 /// It defaults to `https://firestore.googleapis.com/`.
160 ///
161 /// Returns the previously set base url.
162 pub fn base_url(&mut self, new_base_url: String) -> String {
163 std::mem::replace(&mut self._base_url, new_base_url)
164 }
165
166 /// Set the root url to use in all requests to the server.
167 /// It defaults to `https://firestore.googleapis.com/`.
168 ///
169 /// Returns the previously set root url.
170 pub fn root_url(&mut self, new_root_url: String) -> String {
171 std::mem::replace(&mut self._root_url, new_root_url)
172 }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// Defines an aggregation that produces a single result.
179///
180/// This type is not used in any activity, and only used as *part* of another schema.
181///
182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
183#[serde_with::serde_as]
184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
185pub struct Aggregation {
186 /// 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.
187 pub alias: Option<String>,
188 /// Average aggregator.
189 pub avg: Option<Avg>,
190 /// Count aggregator.
191 pub count: Option<Count>,
192 /// Sum aggregator.
193 pub sum: Option<Sum>,
194}
195
196impl common::Part for Aggregation {}
197
198/// 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.
199///
200/// This type is not used in any activity, and only used as *part* of another schema.
201///
202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
203#[serde_with::serde_as]
204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
205pub struct AggregationResult {
206 /// 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.
207 #[serde(rename = "aggregateFields")]
208 pub aggregate_fields: Option<HashMap<String, Value>>,
209}
210
211impl common::Part for AggregationResult {}
212
213/// An array value.
214///
215/// This type is not used in any activity, and only used as *part* of another schema.
216///
217#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
218#[serde_with::serde_as]
219#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
220pub struct ArrayValue {
221 /// Values in the array.
222 pub values: Option<Vec<Value>>,
223}
224
225impl common::Part for ArrayValue {}
226
227/// 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.
228///
229/// This type is not used in any activity, and only used as *part* of another schema.
230///
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct Avg {
235 /// The field to aggregate on.
236 pub field: Option<FieldReference>,
237}
238
239impl common::Part for Avg {}
240
241/// The request for Firestore.BatchGetDocuments.
242///
243/// # Activities
244///
245/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
246/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
247///
248/// * [databases documents batch get projects](ProjectDatabaseDocumentBatchGetCall) (request)
249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
250#[serde_with::serde_as]
251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
252pub struct BatchGetDocumentsRequest {
253 /// 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.
254 pub documents: Option<Vec<String>>,
255 /// 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.
256 pub mask: Option<DocumentMask>,
257 /// 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.
258 #[serde(rename = "newTransaction")]
259 pub new_transaction: Option<TransactionOptions>,
260 /// 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.
261 #[serde(rename = "readTime")]
262 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
263 /// Reads documents in a transaction.
264 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
265 pub transaction: Option<Vec<u8>>,
266}
267
268impl common::RequestValue for BatchGetDocumentsRequest {}
269
270/// The streamed response for Firestore.BatchGetDocuments.
271///
272/// # Activities
273///
274/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
275/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
276///
277/// * [databases documents batch get projects](ProjectDatabaseDocumentBatchGetCall) (response)
278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
279#[serde_with::serde_as]
280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
281pub struct BatchGetDocumentsResponse {
282 /// A document that was requested.
283 pub found: Option<Document>,
284 /// A document name that was requested but does not exist. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
285 pub missing: Option<String>,
286 /// 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.
287 #[serde(rename = "readTime")]
288 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
289 /// 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.
290 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
291 pub transaction: Option<Vec<u8>>,
292}
293
294impl common::ResponseResult for BatchGetDocumentsResponse {}
295
296/// The request for Firestore.BatchWrite.
297///
298/// # Activities
299///
300/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
301/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
302///
303/// * [databases documents batch write projects](ProjectDatabaseDocumentBatchWriteCall) (request)
304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
305#[serde_with::serde_as]
306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
307pub struct BatchWriteRequest {
308 /// Labels associated with this batch write.
309 pub labels: Option<HashMap<String, String>>,
310 /// 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.
311 pub writes: Option<Vec<Write>>,
312}
313
314impl common::RequestValue for BatchWriteRequest {}
315
316/// The response from Firestore.BatchWrite.
317///
318/// # Activities
319///
320/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
321/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
322///
323/// * [databases documents batch write projects](ProjectDatabaseDocumentBatchWriteCall) (response)
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct BatchWriteResponse {
328 /// The status of applying the writes. This i-th write status corresponds to the i-th write in the request.
329 pub status: Option<Vec<Status>>,
330 /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
331 #[serde(rename = "writeResults")]
332 pub write_results: Option<Vec<WriteResult>>,
333}
334
335impl common::ResponseResult for BatchWriteResponse {}
336
337/// The request for Firestore.BeginTransaction.
338///
339/// # Activities
340///
341/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
342/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
343///
344/// * [databases documents begin transaction projects](ProjectDatabaseDocumentBeginTransactionCall) (request)
345#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
346#[serde_with::serde_as]
347#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
348pub struct BeginTransactionRequest {
349 /// The options for the transaction. Defaults to a read-write transaction.
350 pub options: Option<TransactionOptions>,
351}
352
353impl common::RequestValue for BeginTransactionRequest {}
354
355/// The response for Firestore.BeginTransaction.
356///
357/// # Activities
358///
359/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
360/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
361///
362/// * [databases documents begin transaction projects](ProjectDatabaseDocumentBeginTransactionCall) (response)
363#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
364#[serde_with::serde_as]
365#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
366pub struct BeginTransactionResponse {
367 /// The transaction that was started.
368 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
369 pub transaction: Option<Vec<u8>>,
370}
371
372impl common::ResponseResult for BeginTransactionResponse {}
373
374/// 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`.
375///
376/// This type is not used in any activity, and only used as *part* of another schema.
377///
378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
379#[serde_with::serde_as]
380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
381pub struct BitSequence {
382 /// The bytes that encode the bit sequence. May have a length of zero.
383 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
384 pub bitmap: Option<Vec<u8>>,
385 /// 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.
386 pub padding: Option<i32>,
387}
388
389impl common::Part for BitSequence {}
390
391/// 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.
392///
393/// This type is not used in any activity, and only used as *part* of another schema.
394///
395#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
396#[serde_with::serde_as]
397#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
398pub struct BloomFilter {
399 /// The bloom filter data.
400 pub bits: Option<BitSequence>,
401 /// The number of hashes used by the algorithm.
402 #[serde(rename = "hashCount")]
403 pub hash_count: Option<i32>,
404}
405
406impl common::Part for BloomFilter {}
407
408/// A selection of a collection, such as `messages as m1`.
409///
410/// This type is not used in any activity, and only used as *part* of another schema.
411///
412#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
413#[serde_with::serde_as]
414#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
415pub struct CollectionSelector {
416 /// When false, selects only collections that are immediate children of the `parent` specified in the containing `RunQueryRequest`. When true, selects all descendant collections.
417 #[serde(rename = "allDescendants")]
418 pub all_descendants: Option<bool>,
419 /// The collection ID. When set, selects only collections with this ID.
420 #[serde(rename = "collectionId")]
421 pub collection_id: Option<String>,
422}
423
424impl common::Part for CollectionSelector {}
425
426/// The request for Firestore.Commit.
427///
428/// # Activities
429///
430/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
431/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
432///
433/// * [databases documents commit projects](ProjectDatabaseDocumentCommitCall) (request)
434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
435#[serde_with::serde_as]
436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
437pub struct CommitRequest {
438 /// If set, applies all writes in this transaction, and commits it.
439 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
440 pub transaction: Option<Vec<u8>>,
441 /// The writes to apply. Always executed atomically and in order.
442 pub writes: Option<Vec<Write>>,
443}
444
445impl common::RequestValue for CommitRequest {}
446
447/// The response for Firestore.Commit.
448///
449/// # Activities
450///
451/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
452/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
453///
454/// * [databases documents commit projects](ProjectDatabaseDocumentCommitCall) (response)
455#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
456#[serde_with::serde_as]
457#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
458pub struct CommitResponse {
459 /// 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.
460 #[serde(rename = "commitTime")]
461 pub commit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
462 /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
463 #[serde(rename = "writeResults")]
464 pub write_results: Option<Vec<WriteResult>>,
465}
466
467impl common::ResponseResult for CommitResponse {}
468
469/// A filter that merges multiple other filters using the given operator.
470///
471/// This type is not used in any activity, and only used as *part* of another schema.
472///
473#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
474#[serde_with::serde_as]
475#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
476pub struct CompositeFilter {
477 /// The list of filters to combine. Requires: * At least one filter is present.
478 pub filters: Option<Vec<Filter>>,
479 /// The operator for combining multiple filters.
480 pub op: Option<String>,
481}
482
483impl common::Part for CompositeFilter {}
484
485/// Count of documents that match the query. The `COUNT(*)` aggregation function operates on the entire document so it does not require a field reference.
486///
487/// This type is not used in any activity, and only used as *part* of another schema.
488///
489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
490#[serde_with::serde_as]
491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
492pub struct Count {
493 /// 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.
494 #[serde(rename = "upTo")]
495 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
496 pub up_to: Option<i64>,
497}
498
499impl common::Part for Count {}
500
501/// A position in a query result set.
502///
503/// This type is not used in any activity, and only used as *part* of another schema.
504///
505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
506#[serde_with::serde_as]
507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
508pub struct Cursor {
509 /// If the position is just before or just after the given values, relative to the sort order defined by the query.
510 pub before: Option<bool>,
511 /// 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.
512 pub values: Option<Vec<Value>>,
513}
514
515impl common::Part for Cursor {}
516
517/// A Firestore document. Must not exceed 1 MiB - 4 bytes.
518///
519/// # Activities
520///
521/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
522/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
523///
524/// * [databases documents create document projects](ProjectDatabaseDocumentCreateDocumentCall) (request|response)
525/// * [databases documents get projects](ProjectDatabaseDocumentGetCall) (response)
526/// * [databases documents patch projects](ProjectDatabaseDocumentPatchCall) (request|response)
527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
528#[serde_with::serde_as]
529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
530pub struct Document {
531 /// 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.
532 #[serde(rename = "createTime")]
533 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
534 /// 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 ``.
535 pub fields: Option<HashMap<String, Value>>,
536 /// The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
537 pub name: Option<String>,
538 /// 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.
539 #[serde(rename = "updateTime")]
540 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
541}
542
543impl common::RequestValue for Document {}
544impl common::ResponseResult for Document {}
545
546/// 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.
547///
548/// This type is not used in any activity, and only used as *part* of another schema.
549///
550#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
551#[serde_with::serde_as]
552#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
553pub struct DocumentChange {
554 /// The new state of the Document. If `mask` is set, contains only fields that were updated or added.
555 pub document: Option<Document>,
556 /// A set of target IDs for targets that no longer match this document.
557 #[serde(rename = "removedTargetIds")]
558 pub removed_target_ids: Option<Vec<i32>>,
559 /// A set of target IDs of targets that match this document.
560 #[serde(rename = "targetIds")]
561 pub target_ids: Option<Vec<i32>>,
562}
563
564impl common::Part for DocumentChange {}
565
566/// 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.
567///
568/// This type is not used in any activity, and only used as *part* of another schema.
569///
570#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
571#[serde_with::serde_as]
572#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
573pub struct DocumentDelete {
574 /// The resource name of the Document that was deleted.
575 pub document: Option<String>,
576 /// The read timestamp at which the delete was observed. Greater or equal to the `commit_time` of the delete.
577 #[serde(rename = "readTime")]
578 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
579 /// A set of target IDs for targets that previously matched this entity.
580 #[serde(rename = "removedTargetIds")]
581 pub removed_target_ids: Option<Vec<i32>>,
582}
583
584impl common::Part for DocumentDelete {}
585
586/// 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.
587///
588/// This type is not used in any activity, and only used as *part* of another schema.
589///
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct DocumentMask {
594 /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
595 #[serde(rename = "fieldPaths")]
596 pub field_paths: Option<Vec<String>>,
597}
598
599impl common::Part for DocumentMask {}
600
601/// 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.
602///
603/// This type is not used in any activity, and only used as *part* of another schema.
604///
605#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
606#[serde_with::serde_as]
607#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
608pub struct DocumentRemove {
609 /// The resource name of the Document that has gone out of view.
610 pub document: Option<String>,
611 /// The read timestamp at which the remove was observed. Greater or equal to the `commit_time` of the change/delete/remove.
612 #[serde(rename = "readTime")]
613 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
614 /// A set of target IDs for targets that previously matched this document.
615 #[serde(rename = "removedTargetIds")]
616 pub removed_target_ids: Option<Vec<i32>>,
617}
618
619impl common::Part for DocumentRemove {}
620
621/// A transformation of a document.
622///
623/// This type is not used in any activity, and only used as *part* of another schema.
624///
625#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
626#[serde_with::serde_as]
627#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
628pub struct DocumentTransform {
629 /// The name of the document to transform.
630 pub document: Option<String>,
631 /// The list of transformations to apply to the fields of the document, in order. This must not be empty.
632 #[serde(rename = "fieldTransforms")]
633 pub field_transforms: Option<Vec<FieldTransform>>,
634}
635
636impl common::Part for DocumentTransform {}
637
638/// A target specified by a set of documents names.
639///
640/// This type is not used in any activity, and only used as *part* of another schema.
641///
642#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
643#[serde_with::serde_as]
644#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
645pub struct DocumentsTarget {
646 /// 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.
647 pub documents: Option<Vec<String>>,
648}
649
650impl common::Part for DocumentsTarget {}
651
652/// 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); }
653///
654/// # Activities
655///
656/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
657/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
658///
659/// * [databases documents delete projects](ProjectDatabaseDocumentDeleteCall) (response)
660/// * [databases documents rollback projects](ProjectDatabaseDocumentRollbackCall) (response)
661/// * [databases indexes delete projects](ProjectDatabaseIndexDeleteCall) (response)
662#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
663#[serde_with::serde_as]
664#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
665pub struct Empty {
666 _never_set: Option<bool>,
667}
668
669impl common::ResponseResult for Empty {}
670
671/// The request for Firestore.ExecutePipeline.
672///
673/// # Activities
674///
675/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
676/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
677///
678/// * [databases documents execute pipeline projects](ProjectDatabaseDocumentExecutePipelineCall) (request)
679#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
680#[serde_with::serde_as]
681#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
682pub struct ExecutePipelineRequest {
683 /// Execute the pipeline in a new transaction. The identifier of the newly created transaction will be returned in the first response on the stream. This defaults to a read-only transaction.
684 #[serde(rename = "newTransaction")]
685 pub new_transaction: Option<TransactionOptions>,
686 /// Execute the pipeline in a snapshot transaction at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days.
687 #[serde(rename = "readTime")]
688 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
689 /// A pipelined operation.
690 #[serde(rename = "structuredPipeline")]
691 pub structured_pipeline: Option<StructuredPipeline>,
692 /// Run the query within an already active transaction. The value here is the opaque transaction ID to execute the query in.
693 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
694 pub transaction: Option<Vec<u8>>,
695}
696
697impl common::RequestValue for ExecutePipelineRequest {}
698
699/// The response for Firestore.Execute.
700///
701/// # Activities
702///
703/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
704/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
705///
706/// * [databases documents execute pipeline projects](ProjectDatabaseDocumentExecutePipelineCall) (response)
707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
708#[serde_with::serde_as]
709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
710pub struct ExecutePipelineResponse {
711 /// The time at which the results are valid. This is a (not strictly) monotonically increasing value across multiple responses in the same stream. The API guarantees that all previously returned results are still valid at the latest `execution_time`. This allows the API consumer to treat the query if it ran at the latest `execution_time` returned. If the query returns no results, a response with `execution_time` and no `results` will be sent, and this represents the time at which the operation was run.
712 #[serde(rename = "executionTime")]
713 pub execution_time: Option<chrono::DateTime<chrono::offset::Utc>>,
714 /// Query explain stats. This is present on the **last** response if the request configured explain to run in 'analyze' or 'explain' mode in the pipeline options. If the query does not return any results, a response with `explain_stats` and no `results` will still be sent.
715 #[serde(rename = "explainStats")]
716 pub explain_stats: Option<ExplainStats>,
717 /// An ordered batch of results returned executing a pipeline. The batch size is variable, and can even be zero for when only a partial progress message is returned. The fields present in the returned documents are only those that were explicitly requested in the pipeline, this includes those like `__name__` and `__update_time__`. This is explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument` RPCs which always return such fields even when they are not specified in the `mask`.
718 pub results: Option<Vec<Document>>,
719 /// Newly created transaction identifier. This field is only specified as part of the first response from the server, alongside the `results` field when the original request specified ExecuteRequest.new_transaction.
720 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
721 pub transaction: Option<Vec<u8>>,
722}
723
724impl common::ResponseResult for ExecutePipelineResponse {}
725
726/// Execution statistics for the query.
727///
728/// This type is not used in any activity, and only used as *part* of another schema.
729///
730#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
731#[serde_with::serde_as]
732#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
733pub struct ExecutionStats {
734 /// 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" } }
735 #[serde(rename = "debugStats")]
736 pub debug_stats: Option<HashMap<String, serde_json::Value>>,
737 /// Total time to execute the query in the backend.
738 #[serde(rename = "executionDuration")]
739 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
740 pub execution_duration: Option<chrono::Duration>,
741 /// Total billable read operations.
742 #[serde(rename = "readOperations")]
743 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
744 pub read_operations: Option<i64>,
745 /// Total number of results returned, including documents, projections, aggregation results, keys.
746 #[serde(rename = "resultsReturned")]
747 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
748 pub results_returned: Option<i64>,
749}
750
751impl common::Part for ExecutionStats {}
752
753/// A digest of all the documents that match a given target.
754///
755/// This type is not used in any activity, and only used as *part* of another schema.
756///
757#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
758#[serde_with::serde_as]
759#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
760pub struct ExistenceFilter {
761 /// 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.
762 pub count: Option<i32>,
763 /// The target ID to which this filter applies.
764 #[serde(rename = "targetId")]
765 pub target_id: Option<i32>,
766 /// 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.
767 #[serde(rename = "unchangedNames")]
768 pub unchanged_names: Option<BloomFilter>,
769}
770
771impl common::Part for ExistenceFilter {}
772
773/// Explain metrics for the query.
774///
775/// This type is not used in any activity, and only used as *part* of another schema.
776///
777#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
778#[serde_with::serde_as]
779#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
780pub struct ExplainMetrics {
781 /// Aggregated stats from the execution of the query. Only present when ExplainOptions.analyze is set to true.
782 #[serde(rename = "executionStats")]
783 pub execution_stats: Option<ExecutionStats>,
784 /// Planning phase information for the query.
785 #[serde(rename = "planSummary")]
786 pub plan_summary: Option<PlanSummary>,
787}
788
789impl common::Part for ExplainMetrics {}
790
791/// Explain options for the query.
792///
793/// This type is not used in any activity, and only used as *part* of another schema.
794///
795#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
796#[serde_with::serde_as]
797#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
798pub struct ExplainOptions {
799 /// 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.
800 pub analyze: Option<bool>,
801}
802
803impl common::Part for ExplainOptions {}
804
805/// Pipeline explain stats. Depending on the explain options in the original request, this can contain the optimized plan and / or execution stats.
806///
807/// This type is not used in any activity, and only used as *part* of another schema.
808///
809#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
810#[serde_with::serde_as]
811#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
812pub struct ExplainStats {
813 /// The format depends on the `output_format` options in the request. Currently there are two supported options: `TEXT` and `JSON`. Both supply a `google.protobuf.StringValue`.
814 pub data: Option<HashMap<String, serde_json::Value>>,
815}
816
817impl common::Part for ExplainStats {}
818
819/// A filter on a specific field.
820///
821/// This type is not used in any activity, and only used as *part* of another schema.
822///
823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
824#[serde_with::serde_as]
825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
826pub struct FieldFilter {
827 /// The field to filter by.
828 pub field: Option<FieldReference>,
829 /// The operator to filter by.
830 pub op: Option<String>,
831 /// The value to compare to.
832 pub value: Option<Value>,
833}
834
835impl common::Part for FieldFilter {}
836
837/// A reference to a field in a document, ex: `stats.operations`.
838///
839/// This type is not used in any activity, and only used as *part* of another schema.
840///
841#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
842#[serde_with::serde_as]
843#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
844pub struct FieldReference {
845 /// 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.
846 #[serde(rename = "fieldPath")]
847 pub field_path: Option<String>,
848}
849
850impl common::Part for FieldReference {}
851
852/// A transformation of a field of the document.
853///
854/// This type is not used in any activity, and only used as *part* of another schema.
855///
856#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
857#[serde_with::serde_as]
858#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
859pub struct FieldTransform {
860 /// 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.
861 #[serde(rename = "appendMissingElements")]
862 pub append_missing_elements: Option<ArrayValue>,
863 /// The path of the field. See Document.fields for the field path syntax reference.
864 #[serde(rename = "fieldPath")]
865 pub field_path: Option<String>,
866 /// 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.
867 pub increment: Option<Value>,
868 /// 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.
869 pub maximum: Option<Value>,
870 /// 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.
871 pub minimum: Option<Value>,
872 /// 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.
873 #[serde(rename = "removeAllFromArray")]
874 pub remove_all_from_array: Option<ArrayValue>,
875 /// Sets the field to the given server value.
876 #[serde(rename = "setToServerValue")]
877 pub set_to_server_value: Option<String>,
878}
879
880impl common::Part for FieldTransform {}
881
882/// A filter.
883///
884/// This type is not used in any activity, and only used as *part* of another schema.
885///
886#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
887#[serde_with::serde_as]
888#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
889pub struct Filter {
890 /// A composite filter.
891 #[serde(rename = "compositeFilter")]
892 pub composite_filter: Option<CompositeFilter>,
893 /// A filter on a document field.
894 #[serde(rename = "fieldFilter")]
895 pub field_filter: Option<FieldFilter>,
896 /// A filter that takes exactly one argument.
897 #[serde(rename = "unaryFilter")]
898 pub unary_filter: Option<UnaryFilter>,
899}
900
901impl common::Part for Filter {}
902
903/// Nearest Neighbors search config. The ordering provided by FindNearest supersedes the order_by stage. If multiple documents have the same vector distance, the returned document order is not guaranteed to be stable between queries.
904///
905/// This type is not used in any activity, and only used as *part* of another schema.
906///
907#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
908#[serde_with::serde_as]
909#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
910pub struct FindNearest {
911 /// Required. The distance measure to use, required.
912 #[serde(rename = "distanceMeasure")]
913 pub distance_measure: Option<String>,
914 /// Optional. Optional name of the field to output the result of the vector distance calculation. Must conform to document field name limitations.
915 #[serde(rename = "distanceResultField")]
916 pub distance_result_field: Option<String>,
917 /// Optional. Option to specify a threshold for which no less similar documents will be returned. The behavior of the specified `distance_measure` will affect the meaning of the distance threshold. Since DOT_PRODUCT distances increase when the vectors are more similar, the comparison is inverted. * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold` * For DOT_PRODUCT: `WHERE distance >= distance_threshold`
918 #[serde(rename = "distanceThreshold")]
919 pub distance_threshold: Option<f64>,
920 /// Required. The number of nearest neighbors to return. Must be a positive integer of no more than 1000.
921 pub limit: Option<i32>,
922 /// Required. The query vector that we are searching on. Must be a vector of no more than 2048 dimensions.
923 #[serde(rename = "queryVector")]
924 pub query_vector: Option<Value>,
925 /// Required. An indexed vector field to search upon. Only documents which contain vectors whose dimensionality match the query_vector can be returned.
926 #[serde(rename = "vectorField")]
927 pub vector_field: Option<FieldReference>,
928}
929
930impl common::Part for FindNearest {}
931
932/// Represents an unevaluated scalar expression. For example, the expression `like(user_name, "%alice%")` is represented as: ``` name: "like" args { field_reference: "user_name" } args { string_value: "%alice%" } ```
933///
934/// This type is not used in any activity, and only used as *part* of another schema.
935///
936#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
937#[serde_with::serde_as]
938#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
939pub struct Function {
940 /// Optional. Ordered list of arguments the given function expects.
941 pub args: Option<Vec<Value>>,
942 /// Required. The name of the function to evaluate. **Requires:** * must be in snake case (lower case with underscore separator).
943 pub name: Option<String>,
944 /// Optional. Optional named arguments that certain functions may support.
945 pub options: Option<HashMap<String, Value>>,
946}
947
948impl common::Part for Function {}
949
950/// The request for FirestoreAdmin.ExportDocuments.
951///
952/// # Activities
953///
954/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
955/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
956///
957/// * [databases export documents projects](ProjectDatabaseExportDocumentCall) (request)
958#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
959#[serde_with::serde_as]
960#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
961pub struct GoogleFirestoreAdminV1beta1ExportDocumentsRequest {
962 /// Which collection ids to export. Unspecified means all collections.
963 #[serde(rename = "collectionIds")]
964 pub collection_ids: Option<Vec<String>>,
965 /// 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.
966 #[serde(rename = "outputUriPrefix")]
967 pub output_uri_prefix: Option<String>,
968}
969
970impl common::RequestValue for GoogleFirestoreAdminV1beta1ExportDocumentsRequest {}
971
972/// The request for FirestoreAdmin.ImportDocuments.
973///
974/// # Activities
975///
976/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
977/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
978///
979/// * [databases import documents projects](ProjectDatabaseImportDocumentCall) (request)
980#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
981#[serde_with::serde_as]
982#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
983pub struct GoogleFirestoreAdminV1beta1ImportDocumentsRequest {
984 /// Which collection ids to import. Unspecified means all collections included in the import.
985 #[serde(rename = "collectionIds")]
986 pub collection_ids: Option<Vec<String>>,
987 /// 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.
988 #[serde(rename = "inputUriPrefix")]
989 pub input_uri_prefix: Option<String>,
990}
991
992impl common::RequestValue for GoogleFirestoreAdminV1beta1ImportDocumentsRequest {}
993
994/// An index definition.
995///
996/// # Activities
997///
998/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
999/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1000///
1001/// * [databases indexes create projects](ProjectDatabaseIndexCreateCall) (request)
1002/// * [databases indexes get projects](ProjectDatabaseIndexGetCall) (response)
1003#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1004#[serde_with::serde_as]
1005#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1006pub struct GoogleFirestoreAdminV1beta1Index {
1007 /// The collection ID to which this index applies. Required.
1008 #[serde(rename = "collectionId")]
1009 pub collection_id: Option<String>,
1010 /// The fields to index.
1011 pub fields: Option<Vec<GoogleFirestoreAdminV1beta1IndexField>>,
1012 /// The resource name of the index. Output only.
1013 pub name: Option<String>,
1014 /// The state of the index. Output only.
1015 pub state: Option<String>,
1016}
1017
1018impl common::RequestValue for GoogleFirestoreAdminV1beta1Index {}
1019impl common::ResponseResult for GoogleFirestoreAdminV1beta1Index {}
1020
1021/// A field of an index.
1022///
1023/// This type is not used in any activity, and only used as *part* of another schema.
1024///
1025#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1026#[serde_with::serde_as]
1027#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1028pub struct GoogleFirestoreAdminV1beta1IndexField {
1029 /// 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.
1030 #[serde(rename = "fieldPath")]
1031 pub field_path: Option<String>,
1032 /// The field's mode.
1033 pub mode: Option<String>,
1034}
1035
1036impl common::Part for GoogleFirestoreAdminV1beta1IndexField {}
1037
1038/// The response for FirestoreAdmin.ListIndexes.
1039///
1040/// # Activities
1041///
1042/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1043/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1044///
1045/// * [databases indexes list projects](ProjectDatabaseIndexListCall) (response)
1046#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1047#[serde_with::serde_as]
1048#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1049pub struct GoogleFirestoreAdminV1beta1ListIndexesResponse {
1050 /// The indexes.
1051 pub indexes: Option<Vec<GoogleFirestoreAdminV1beta1Index>>,
1052 /// The standard List next-page token.
1053 #[serde(rename = "nextPageToken")]
1054 pub next_page_token: Option<String>,
1055}
1056
1057impl common::ResponseResult for GoogleFirestoreAdminV1beta1ListIndexesResponse {}
1058
1059/// This resource represents a long-running operation that is the result of a network API call.
1060///
1061/// # Activities
1062///
1063/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1064/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1065///
1066/// * [databases indexes create projects](ProjectDatabaseIndexCreateCall) (response)
1067/// * [databases export documents projects](ProjectDatabaseExportDocumentCall) (response)
1068/// * [databases import documents projects](ProjectDatabaseImportDocumentCall) (response)
1069#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1070#[serde_with::serde_as]
1071#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1072pub struct GoogleLongrunningOperation {
1073 /// 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.
1074 pub done: Option<bool>,
1075 /// The error result of the operation in case of failure or cancellation.
1076 pub error: Option<Status>,
1077 /// 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.
1078 pub metadata: Option<HashMap<String, serde_json::Value>>,
1079 /// 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}`.
1080 pub name: Option<String>,
1081 /// 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`.
1082 pub response: Option<HashMap<String, serde_json::Value>>,
1083}
1084
1085impl common::ResponseResult for GoogleLongrunningOperation {}
1086
1087/// 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.
1088///
1089/// This type is not used in any activity, and only used as *part* of another schema.
1090///
1091#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1092#[serde_with::serde_as]
1093#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1094pub struct LatLng {
1095 /// The latitude in degrees. It must be in the range [-90.0, +90.0].
1096 pub latitude: Option<f64>,
1097 /// The longitude in degrees. It must be in the range [-180.0, +180.0].
1098 pub longitude: Option<f64>,
1099}
1100
1101impl common::Part for LatLng {}
1102
1103/// The request for Firestore.ListCollectionIds.
1104///
1105/// # Activities
1106///
1107/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1108/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1109///
1110/// * [databases documents list collection ids projects](ProjectDatabaseDocumentListCollectionIdCall) (request)
1111#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1112#[serde_with::serde_as]
1113#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1114pub struct ListCollectionIdsRequest {
1115 /// The maximum number of results to return.
1116 #[serde(rename = "pageSize")]
1117 pub page_size: Option<i32>,
1118 /// A page token. Must be a value from ListCollectionIdsResponse.
1119 #[serde(rename = "pageToken")]
1120 pub page_token: Option<String>,
1121 /// 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.
1122 #[serde(rename = "readTime")]
1123 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1124}
1125
1126impl common::RequestValue for ListCollectionIdsRequest {}
1127
1128/// The response from Firestore.ListCollectionIds.
1129///
1130/// # Activities
1131///
1132/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1133/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1134///
1135/// * [databases documents list collection ids projects](ProjectDatabaseDocumentListCollectionIdCall) (response)
1136#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1137#[serde_with::serde_as]
1138#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1139pub struct ListCollectionIdsResponse {
1140 /// The collection ids.
1141 #[serde(rename = "collectionIds")]
1142 pub collection_ids: Option<Vec<String>>,
1143 /// A page token that may be used to continue the list.
1144 #[serde(rename = "nextPageToken")]
1145 pub next_page_token: Option<String>,
1146}
1147
1148impl common::ResponseResult for ListCollectionIdsResponse {}
1149
1150/// The response for Firestore.ListDocuments.
1151///
1152/// # Activities
1153///
1154/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1155/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1156///
1157/// * [databases documents list projects](ProjectDatabaseDocumentListCall) (response)
1158/// * [databases documents list documents projects](ProjectDatabaseDocumentListDocumentCall) (response)
1159#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1160#[serde_with::serde_as]
1161#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1162pub struct ListDocumentsResponse {
1163 /// The Documents found.
1164 pub documents: Option<Vec<Document>>,
1165 /// A token to retrieve the next page of documents. If this field is omitted, there are no subsequent pages.
1166 #[serde(rename = "nextPageToken")]
1167 pub next_page_token: Option<String>,
1168}
1169
1170impl common::ResponseResult for ListDocumentsResponse {}
1171
1172/// A request for Firestore.Listen
1173///
1174/// # Activities
1175///
1176/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1177/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1178///
1179/// * [databases documents listen projects](ProjectDatabaseDocumentListenCall) (request)
1180#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1181#[serde_with::serde_as]
1182#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1183pub struct ListenRequest {
1184 /// A target to add to this stream.
1185 #[serde(rename = "addTarget")]
1186 pub add_target: Option<Target>,
1187 /// Labels associated with this target change.
1188 pub labels: Option<HashMap<String, String>>,
1189 /// The ID of a target to remove from this stream.
1190 #[serde(rename = "removeTarget")]
1191 pub remove_target: Option<i32>,
1192}
1193
1194impl common::RequestValue for ListenRequest {}
1195
1196/// The response for Firestore.Listen.
1197///
1198/// # Activities
1199///
1200/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1201/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1202///
1203/// * [databases documents listen projects](ProjectDatabaseDocumentListenCall) (response)
1204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1205#[serde_with::serde_as]
1206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1207pub struct ListenResponse {
1208 /// A Document has changed.
1209 #[serde(rename = "documentChange")]
1210 pub document_change: Option<DocumentChange>,
1211 /// A Document has been deleted.
1212 #[serde(rename = "documentDelete")]
1213 pub document_delete: Option<DocumentDelete>,
1214 /// A Document has been removed from a target (because it is no longer relevant to that target).
1215 #[serde(rename = "documentRemove")]
1216 pub document_remove: Option<DocumentRemove>,
1217 /// 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.
1218 pub filter: Option<ExistenceFilter>,
1219 /// Targets have changed.
1220 #[serde(rename = "targetChange")]
1221 pub target_change: Option<TargetChange>,
1222}
1223
1224impl common::ResponseResult for ListenResponse {}
1225
1226/// A map value.
1227///
1228/// This type is not used in any activity, and only used as *part* of another schema.
1229///
1230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1231#[serde_with::serde_as]
1232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1233pub struct MapValue {
1234 /// 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.
1235 pub fields: Option<HashMap<String, Value>>,
1236}
1237
1238impl common::Part for MapValue {}
1239
1240/// An order on a field.
1241///
1242/// This type is not used in any activity, and only used as *part* of another schema.
1243///
1244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1245#[serde_with::serde_as]
1246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1247pub struct Order {
1248 /// The direction to order by. Defaults to `ASCENDING`.
1249 pub direction: Option<String>,
1250 /// The field to order by.
1251 pub field: Option<FieldReference>,
1252}
1253
1254impl common::Part for Order {}
1255
1256/// The request for Firestore.PartitionQuery.
1257///
1258/// # Activities
1259///
1260/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1261/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1262///
1263/// * [databases documents partition query projects](ProjectDatabaseDocumentPartitionQueryCall) (request)
1264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1265#[serde_with::serde_as]
1266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1267pub struct PartitionQueryRequest {
1268 /// 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`.
1269 #[serde(rename = "pageSize")]
1270 pub page_size: Option<i32>,
1271 /// 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
1272 #[serde(rename = "pageToken")]
1273 pub page_token: Option<String>,
1274 /// 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.
1275 #[serde(rename = "partitionCount")]
1276 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1277 pub partition_count: Option<i64>,
1278 /// 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.
1279 #[serde(rename = "readTime")]
1280 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1281 /// 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.
1282 #[serde(rename = "structuredQuery")]
1283 pub structured_query: Option<StructuredQuery>,
1284}
1285
1286impl common::RequestValue for PartitionQueryRequest {}
1287
1288/// The response for Firestore.PartitionQuery.
1289///
1290/// # Activities
1291///
1292/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1293/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1294///
1295/// * [databases documents partition query projects](ProjectDatabaseDocumentPartitionQueryCall) (response)
1296#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1297#[serde_with::serde_as]
1298#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1299pub struct PartitionQueryResponse {
1300 /// 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.
1301 #[serde(rename = "nextPageToken")]
1302 pub next_page_token: Option<String>,
1303 /// 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.
1304 pub partitions: Option<Vec<Cursor>>,
1305}
1306
1307impl common::ResponseResult for PartitionQueryResponse {}
1308
1309/// A Firestore query represented as an ordered list of operations / stages.
1310///
1311/// This type is not used in any activity, and only used as *part* of another schema.
1312///
1313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1314#[serde_with::serde_as]
1315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1316pub struct Pipeline {
1317 /// Required. Ordered list of stages to evaluate.
1318 pub stages: Option<Vec<Stage>>,
1319}
1320
1321impl common::Part for Pipeline {}
1322
1323/// Planning phase information for the query.
1324///
1325/// This type is not used in any activity, and only used as *part* of another schema.
1326///
1327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1328#[serde_with::serde_as]
1329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1330pub struct PlanSummary {
1331 /// The indexes selected for the query. For example: [ {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} ]
1332 #[serde(rename = "indexesUsed")]
1333 pub indexes_used: Option<Vec<HashMap<String, serde_json::Value>>>,
1334}
1335
1336impl common::Part for PlanSummary {}
1337
1338/// A precondition on a document, used for conditional operations.
1339///
1340/// This type is not used in any activity, and only used as *part* of another schema.
1341///
1342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1343#[serde_with::serde_as]
1344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1345pub struct Precondition {
1346 /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
1347 pub exists: Option<bool>,
1348 /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
1349 #[serde(rename = "updateTime")]
1350 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1351}
1352
1353impl common::Part for Precondition {}
1354
1355/// The projection of document's fields to return.
1356///
1357/// This type is not used in any activity, and only used as *part* of another schema.
1358///
1359#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1360#[serde_with::serde_as]
1361#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1362pub struct Projection {
1363 /// The fields to return. If empty, all fields are returned. To only return the name of the document, use `['__name__']`.
1364 pub fields: Option<Vec<FieldReference>>,
1365}
1366
1367impl common::Part for Projection {}
1368
1369/// A target specified by a query.
1370///
1371/// This type is not used in any activity, and only used as *part* of another schema.
1372///
1373#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1374#[serde_with::serde_as]
1375#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1376pub struct QueryTarget {
1377 /// 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`
1378 pub parent: Option<String>,
1379 /// A structured query.
1380 #[serde(rename = "structuredQuery")]
1381 pub structured_query: Option<StructuredQuery>,
1382}
1383
1384impl common::Part for QueryTarget {}
1385
1386/// Options for a transaction that can only be used to read documents.
1387///
1388/// This type is not used in any activity, and only used as *part* of another schema.
1389///
1390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1391#[serde_with::serde_as]
1392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1393pub struct ReadOnly {
1394 /// 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.
1395 #[serde(rename = "readTime")]
1396 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1397}
1398
1399impl common::Part for ReadOnly {}
1400
1401/// 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.
1402///
1403/// This type is not used in any activity, and only used as *part* of another schema.
1404///
1405#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1406#[serde_with::serde_as]
1407#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1408pub struct ReadWrite {
1409 /// An optional transaction to retry.
1410 #[serde(rename = "retryTransaction")]
1411 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1412 pub retry_transaction: Option<Vec<u8>>,
1413}
1414
1415impl common::Part for ReadWrite {}
1416
1417/// The request for Firestore.Rollback.
1418///
1419/// # Activities
1420///
1421/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1422/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1423///
1424/// * [databases documents rollback projects](ProjectDatabaseDocumentRollbackCall) (request)
1425#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1426#[serde_with::serde_as]
1427#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1428pub struct RollbackRequest {
1429 /// Required. The transaction to roll back.
1430 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1431 pub transaction: Option<Vec<u8>>,
1432}
1433
1434impl common::RequestValue for RollbackRequest {}
1435
1436/// The request for Firestore.RunAggregationQuery.
1437///
1438/// # Activities
1439///
1440/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1441/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1442///
1443/// * [databases documents run aggregation query projects](ProjectDatabaseDocumentRunAggregationQueryCall) (request)
1444#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1445#[serde_with::serde_as]
1446#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1447pub struct RunAggregationQueryRequest {
1448 /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
1449 #[serde(rename = "explainOptions")]
1450 pub explain_options: Option<ExplainOptions>,
1451 /// 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.
1452 #[serde(rename = "newTransaction")]
1453 pub new_transaction: Option<TransactionOptions>,
1454 /// 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.
1455 #[serde(rename = "readTime")]
1456 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1457 /// An aggregation query.
1458 #[serde(rename = "structuredAggregationQuery")]
1459 pub structured_aggregation_query: Option<StructuredAggregationQuery>,
1460 /// Run the aggregation within an already active transaction. The value here is the opaque transaction ID to execute the query in.
1461 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1462 pub transaction: Option<Vec<u8>>,
1463}
1464
1465impl common::RequestValue for RunAggregationQueryRequest {}
1466
1467/// The response for Firestore.RunAggregationQuery.
1468///
1469/// # Activities
1470///
1471/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1472/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1473///
1474/// * [databases documents run aggregation query projects](ProjectDatabaseDocumentRunAggregationQueryCall) (response)
1475#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1476#[serde_with::serde_as]
1477#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1478pub struct RunAggregationQueryResponse {
1479 /// 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.
1480 #[serde(rename = "explainMetrics")]
1481 pub explain_metrics: Option<ExplainMetrics>,
1482 /// 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.
1483 #[serde(rename = "readTime")]
1484 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1485 /// A single aggregation result. Not present when reporting partial progress.
1486 pub result: Option<AggregationResult>,
1487 /// 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.
1488 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1489 pub transaction: Option<Vec<u8>>,
1490}
1491
1492impl common::ResponseResult for RunAggregationQueryResponse {}
1493
1494/// The request for Firestore.RunQuery.
1495///
1496/// # Activities
1497///
1498/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1499/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1500///
1501/// * [databases documents run query projects](ProjectDatabaseDocumentRunQueryCall) (request)
1502#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1503#[serde_with::serde_as]
1504#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1505pub struct RunQueryRequest {
1506 /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
1507 #[serde(rename = "explainOptions")]
1508 pub explain_options: Option<ExplainOptions>,
1509 /// 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.
1510 #[serde(rename = "newTransaction")]
1511 pub new_transaction: Option<TransactionOptions>,
1512 /// 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.
1513 #[serde(rename = "readTime")]
1514 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1515 /// A structured query.
1516 #[serde(rename = "structuredQuery")]
1517 pub structured_query: Option<StructuredQuery>,
1518 /// Run the query within an already active transaction. The value here is the opaque transaction ID to execute the query in.
1519 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1520 pub transaction: Option<Vec<u8>>,
1521}
1522
1523impl common::RequestValue for RunQueryRequest {}
1524
1525/// The response for Firestore.RunQuery.
1526///
1527/// # Activities
1528///
1529/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1530/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1531///
1532/// * [databases documents run query projects](ProjectDatabaseDocumentRunQueryCall) (response)
1533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1534#[serde_with::serde_as]
1535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1536pub struct RunQueryResponse {
1537 /// A query result, not set when reporting partial progress.
1538 pub document: Option<Document>,
1539 /// If present, Firestore has completely finished the request and no more documents will be returned.
1540 pub done: Option<bool>,
1541 /// 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.
1542 #[serde(rename = "explainMetrics")]
1543 pub explain_metrics: Option<ExplainMetrics>,
1544 /// 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.
1545 #[serde(rename = "readTime")]
1546 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1547 /// The number of results that have been skipped due to an offset between the last response and the current response.
1548 #[serde(rename = "skippedResults")]
1549 pub skipped_results: Option<i32>,
1550 /// 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.
1551 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1552 pub transaction: Option<Vec<u8>>,
1553}
1554
1555impl common::ResponseResult for RunQueryResponse {}
1556
1557/// A single operation within a pipeline. A stage is made up of a unique name, and a list of arguments. The exact number of arguments & types is dependent on the stage type. To give an example, the stage `filter(state = "MD")` would be encoded as: ``` name: "filter" args { function_value { name: "eq" args { field_reference_value: "state" } args { string_value: "MD" } } } ``` See public documentation for the full list.
1558///
1559/// This type is not used in any activity, and only used as *part* of another schema.
1560///
1561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1562#[serde_with::serde_as]
1563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1564pub struct Stage {
1565 /// Optional. Ordered list of arguments the given stage expects.
1566 pub args: Option<Vec<Value>>,
1567 /// Required. The name of the stage to evaluate. **Requires:** * must be in snake case (lower case with underscore separator).
1568 pub name: Option<String>,
1569 /// Optional. Optional named arguments that certain functions may support.
1570 pub options: Option<HashMap<String, Value>>,
1571}
1572
1573impl common::Part for Stage {}
1574
1575/// 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).
1576///
1577/// This type is not used in any activity, and only used as *part* of another schema.
1578///
1579#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1580#[serde_with::serde_as]
1581#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1582pub struct Status {
1583 /// The status code, which should be an enum value of google.rpc.Code.
1584 pub code: Option<i32>,
1585 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1586 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1587 /// 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.
1588 pub message: Option<String>,
1589}
1590
1591impl common::Part for Status {}
1592
1593/// Firestore query for running an aggregation over a StructuredQuery.
1594///
1595/// This type is not used in any activity, and only used as *part* of another schema.
1596///
1597#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1598#[serde_with::serde_as]
1599#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1600pub struct StructuredAggregationQuery {
1601 /// 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.
1602 pub aggregations: Option<Vec<Aggregation>>,
1603 /// Nested structured query.
1604 #[serde(rename = "structuredQuery")]
1605 pub structured_query: Option<StructuredQuery>,
1606}
1607
1608impl common::Part for StructuredAggregationQuery {}
1609
1610/// A Firestore query represented as an ordered list of operations / stages. This is considered the top-level function which plans and executes a query. It is logically equivalent to `query(stages, options)`, but prevents the client from having to build a function wrapper.
1611///
1612/// This type is not used in any activity, and only used as *part* of another schema.
1613///
1614#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1615#[serde_with::serde_as]
1616#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1617pub struct StructuredPipeline {
1618 /// Optional. Optional query-level arguments.
1619 pub options: Option<HashMap<String, Value>>,
1620 /// Required. The pipeline query to execute.
1621 pub pipeline: Option<Pipeline>,
1622}
1623
1624impl common::Part for StructuredPipeline {}
1625
1626/// A Firestore query. The query stages are executed in the following order: 1. from 2. where 3. select 4. order_by + start_at + end_at 5. offset 6. limit 7. find_nearest
1627///
1628/// This type is not used in any activity, and only used as *part* of another schema.
1629///
1630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1631#[serde_with::serde_as]
1632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1633pub struct StructuredQuery {
1634 /// 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.
1635 #[serde(rename = "endAt")]
1636 pub end_at: Option<Cursor>,
1637 /// Optional. A potential nearest neighbors search. Applies after all other filters and ordering. Finds the closest vector embeddings to the given query vector.
1638 #[serde(rename = "findNearest")]
1639 pub find_nearest: Option<FindNearest>,
1640 /// The collections to query.
1641 pub from: Option<Vec<CollectionSelector>>,
1642 /// 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.
1643 pub limit: Option<i32>,
1644 /// 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.
1645 pub offset: Option<i32>,
1646 /// 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`
1647 #[serde(rename = "orderBy")]
1648 pub order_by: Option<Vec<Order>>,
1649 /// 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.
1650 pub select: Option<Projection>,
1651 /// 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.
1652 #[serde(rename = "startAt")]
1653 pub start_at: Option<Cursor>,
1654 /// The filter to apply.
1655 #[serde(rename = "where")]
1656 pub where_: Option<Filter>,
1657}
1658
1659impl common::Part for StructuredQuery {}
1660
1661/// 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.
1662///
1663/// This type is not used in any activity, and only used as *part* of another schema.
1664///
1665#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1666#[serde_with::serde_as]
1667#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1668pub struct Sum {
1669 /// The field to aggregate on.
1670 pub field: Option<FieldReference>,
1671}
1672
1673impl common::Part for Sum {}
1674
1675/// A specification of a set of documents to listen to.
1676///
1677/// This type is not used in any activity, and only used as *part* of another schema.
1678///
1679#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1680#[serde_with::serde_as]
1681#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1682pub struct Target {
1683 /// A target specified by a set of document names.
1684 pub documents: Option<DocumentsTarget>,
1685 /// 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.
1686 #[serde(rename = "expectedCount")]
1687 pub expected_count: Option<i32>,
1688 /// If the target should be removed once it is current and consistent.
1689 pub once: Option<bool>,
1690 /// A target specified by a query.
1691 pub query: Option<QueryTarget>,
1692 /// Start listening after a specific `read_time`. The client must know the state of matching documents at this time.
1693 #[serde(rename = "readTime")]
1694 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1695 /// A resume token from a prior TargetChange for an identical target. Using a resume token with a different target is unsupported and may fail.
1696 #[serde(rename = "resumeToken")]
1697 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1698 pub resume_token: Option<Vec<u8>>,
1699 /// The target ID that identifies the target on the stream. Must be a positive number and non-zero. If `target_id` is 0 (or unspecified), the server will assign an ID for this target and return that in a `TargetChange::ADD` event. Once a target with `target_id=0` is added, all subsequent targets must also have `target_id=0`. If an `AddTarget` request with `target_id != 0` is sent to the server after a target with `target_id=0` is added, the server will immediately send a response with a `TargetChange::Remove` event. Note that if the client sends multiple `AddTarget` requests without an ID, the order of IDs returned in `TargetChange.target_ids` are undefined. Therefore, clients should provide a target ID instead of relying on the server to assign one. If `target_id` is non-zero, there must not be an existing active target on this stream with the same ID.
1700 #[serde(rename = "targetId")]
1701 pub target_id: Option<i32>,
1702}
1703
1704impl common::Part for Target {}
1705
1706/// Targets being watched have changed.
1707///
1708/// This type is not used in any activity, and only used as *part* of another schema.
1709///
1710#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1711#[serde_with::serde_as]
1712#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1713pub struct TargetChange {
1714 /// The error that resulted in this change, if applicable.
1715 pub cause: Option<Status>,
1716 /// 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.
1717 #[serde(rename = "readTime")]
1718 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1719 /// 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.
1720 #[serde(rename = "resumeToken")]
1721 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1722 pub resume_token: Option<Vec<u8>>,
1723 /// The type of change that occurred.
1724 #[serde(rename = "targetChangeType")]
1725 pub target_change_type: Option<String>,
1726 /// 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.
1727 #[serde(rename = "targetIds")]
1728 pub target_ids: Option<Vec<i32>>,
1729}
1730
1731impl common::Part for TargetChange {}
1732
1733/// Options for creating a new transaction.
1734///
1735/// This type is not used in any activity, and only used as *part* of another schema.
1736///
1737#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1738#[serde_with::serde_as]
1739#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1740pub struct TransactionOptions {
1741 /// The transaction can only be used for read operations.
1742 #[serde(rename = "readOnly")]
1743 pub read_only: Option<ReadOnly>,
1744 /// The transaction can be used for both read and write operations.
1745 #[serde(rename = "readWrite")]
1746 pub read_write: Option<ReadWrite>,
1747}
1748
1749impl common::Part for TransactionOptions {}
1750
1751/// A filter with a single operand.
1752///
1753/// This type is not used in any activity, and only used as *part* of another schema.
1754///
1755#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1756#[serde_with::serde_as]
1757#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1758pub struct UnaryFilter {
1759 /// The field to which to apply the operator.
1760 pub field: Option<FieldReference>,
1761 /// The unary operator to apply.
1762 pub op: Option<String>,
1763}
1764
1765impl common::Part for UnaryFilter {}
1766
1767/// A message that can hold any of the supported value types.
1768///
1769/// This type is not used in any activity, and only used as *part* of another schema.
1770///
1771#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1772#[serde_with::serde_as]
1773#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1774pub struct Value {
1775 /// An array value. Cannot directly contain another array value, though can contain a map which contains another array.
1776 #[serde(rename = "arrayValue")]
1777 pub array_value: Option<ArrayValue>,
1778 /// A boolean value.
1779 #[serde(rename = "booleanValue")]
1780 pub boolean_value: Option<bool>,
1781 /// A bytes value. Must not exceed 1 MiB - 89 bytes. Only the first 1,500 bytes are considered by queries.
1782 #[serde(rename = "bytesValue")]
1783 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1784 pub bytes_value: Option<Vec<u8>>,
1785 /// A double value.
1786 #[serde(rename = "doubleValue")]
1787 pub double_value: Option<f64>,
1788 /// Value which references a field. This is considered relative (vs absolute) since it only refers to a field and not a field within a particular document. **Requires:** * Must follow field reference limitations. * Not allowed to be used when writing documents.
1789 #[serde(rename = "fieldReferenceValue")]
1790 pub field_reference_value: Option<String>,
1791 /// A value that represents an unevaluated expression. **Requires:** * Not allowed to be used when writing documents.
1792 #[serde(rename = "functionValue")]
1793 pub function_value: Option<Function>,
1794 /// A geo point value representing a point on the surface of Earth.
1795 #[serde(rename = "geoPointValue")]
1796 pub geo_point_value: Option<LatLng>,
1797 /// An integer value.
1798 #[serde(rename = "integerValue")]
1799 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1800 pub integer_value: Option<i64>,
1801 /// A map value.
1802 #[serde(rename = "mapValue")]
1803 pub map_value: Option<MapValue>,
1804 /// A null value.
1805 #[serde(rename = "nullValue")]
1806 pub null_value: Option<String>,
1807 /// A value that represents an unevaluated pipeline. **Requires:** * Not allowed to be used when writing documents.
1808 #[serde(rename = "pipelineValue")]
1809 pub pipeline_value: Option<Pipeline>,
1810 /// A reference to a document. For example: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1811 #[serde(rename = "referenceValue")]
1812 pub reference_value: Option<String>,
1813 /// 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.
1814 #[serde(rename = "stringValue")]
1815 pub string_value: Option<String>,
1816 /// A timestamp value. Precise only to microseconds. When stored, any additional precision is rounded down.
1817 #[serde(rename = "timestampValue")]
1818 pub timestamp_value: Option<chrono::DateTime<chrono::offset::Utc>>,
1819}
1820
1821impl common::Part for Value {}
1822
1823/// A write on a document.
1824///
1825/// This type is not used in any activity, and only used as *part* of another schema.
1826///
1827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1828#[serde_with::serde_as]
1829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1830pub struct Write {
1831 /// An optional precondition on the document. The write will fail if this is set and not met by the target document.
1832 #[serde(rename = "currentDocument")]
1833 pub current_document: Option<Precondition>,
1834 /// A document name to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
1835 pub delete: Option<String>,
1836 /// Applies a transformation to a document.
1837 pub transform: Option<DocumentTransform>,
1838 /// A document to write.
1839 pub update: Option<Document>,
1840 /// 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.
1841 #[serde(rename = "updateMask")]
1842 pub update_mask: Option<DocumentMask>,
1843 /// 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.
1844 #[serde(rename = "updateTransforms")]
1845 pub update_transforms: Option<Vec<FieldTransform>>,
1846}
1847
1848impl common::Part for Write {}
1849
1850/// 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.
1851///
1852/// # Activities
1853///
1854/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1855/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1856///
1857/// * [databases documents write projects](ProjectDatabaseDocumentWriteCall) (request)
1858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1859#[serde_with::serde_as]
1860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1861pub struct WriteRequest {
1862 /// Labels associated with this write request.
1863 pub labels: Option<HashMap<String, String>>,
1864 /// 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.
1865 #[serde(rename = "streamId")]
1866 pub stream_id: Option<String>,
1867 /// 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.
1868 #[serde(rename = "streamToken")]
1869 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1870 pub stream_token: Option<Vec<u8>>,
1871 /// 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.
1872 pub writes: Option<Vec<Write>>,
1873}
1874
1875impl common::RequestValue for WriteRequest {}
1876
1877/// The response for Firestore.Write.
1878///
1879/// # Activities
1880///
1881/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1882/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1883///
1884/// * [databases documents write projects](ProjectDatabaseDocumentWriteCall) (response)
1885#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1886#[serde_with::serde_as]
1887#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1888pub struct WriteResponse {
1889 /// 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.
1890 #[serde(rename = "commitTime")]
1891 pub commit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1892 /// The ID of the stream. Only set on the first message, when a new stream was created.
1893 #[serde(rename = "streamId")]
1894 pub stream_id: Option<String>,
1895 /// 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.
1896 #[serde(rename = "streamToken")]
1897 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1898 pub stream_token: Option<Vec<u8>>,
1899 /// The result of applying the writes. This i-th write result corresponds to the i-th write in the request.
1900 #[serde(rename = "writeResults")]
1901 pub write_results: Option<Vec<WriteResult>>,
1902}
1903
1904impl common::ResponseResult for WriteResponse {}
1905
1906/// The result of applying a write.
1907///
1908/// This type is not used in any activity, and only used as *part* of another schema.
1909///
1910#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1911#[serde_with::serde_as]
1912#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1913pub struct WriteResult {
1914 /// The results of applying each DocumentTransform.FieldTransform, in the same order.
1915 #[serde(rename = "transformResults")]
1916 pub transform_results: Option<Vec<Value>>,
1917 /// 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.
1918 #[serde(rename = "updateTime")]
1919 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1920}
1921
1922impl common::Part for WriteResult {}
1923
1924// ###################
1925// MethodBuilders ###
1926// #################
1927
1928/// A builder providing access to all methods supported on *project* resources.
1929/// It is not used directly, but through the [`Firestore`] hub.
1930///
1931/// # Example
1932///
1933/// Instantiate a resource builder
1934///
1935/// ```test_harness,no_run
1936/// extern crate hyper;
1937/// extern crate hyper_rustls;
1938/// extern crate google_firestore1_beta1 as firestore1_beta1;
1939///
1940/// # async fn dox() {
1941/// use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1942///
1943/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1944/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1945/// .with_native_roots()
1946/// .unwrap()
1947/// .https_only()
1948/// .enable_http2()
1949/// .build();
1950///
1951/// let executor = hyper_util::rt::TokioExecutor::new();
1952/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1953/// secret,
1954/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1955/// yup_oauth2::client::CustomHyperClientBuilder::from(
1956/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1957/// ),
1958/// ).build().await.unwrap();
1959///
1960/// let client = hyper_util::client::legacy::Client::builder(
1961/// hyper_util::rt::TokioExecutor::new()
1962/// )
1963/// .build(
1964/// hyper_rustls::HttpsConnectorBuilder::new()
1965/// .with_native_roots()
1966/// .unwrap()
1967/// .https_or_http()
1968/// .enable_http2()
1969/// .build()
1970/// );
1971/// let mut hub = Firestore::new(client, auth);
1972/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1973/// // 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_execute_pipeline(...)`, `databases_documents_get(...)`, `databases_documents_list(...)`, `databases_documents_list_collection_ids(...)`, `databases_documents_list_documents(...)`, `databases_documents_listen(...)`, `databases_documents_partition_query(...)`, `databases_documents_patch(...)`, `databases_documents_rollback(...)`, `databases_documents_run_aggregation_query(...)`, `databases_documents_run_query(...)`, `databases_documents_write(...)`, `databases_export_documents(...)`, `databases_import_documents(...)`, `databases_indexes_create(...)`, `databases_indexes_delete(...)`, `databases_indexes_get(...)` and `databases_indexes_list(...)`
1974/// // to build up your call.
1975/// let rb = hub.projects();
1976/// # }
1977/// ```
1978pub struct ProjectMethods<'a, C>
1979where
1980 C: 'a,
1981{
1982 hub: &'a Firestore<C>,
1983}
1984
1985impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1986
1987impl<'a, C> ProjectMethods<'a, C> {
1988 /// Create a builder to help you perform the following task:
1989 ///
1990 /// Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
1991 ///
1992 /// # Arguments
1993 ///
1994 /// * `request` - No description provided.
1995 /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
1996 pub fn databases_documents_batch_get(
1997 &self,
1998 request: BatchGetDocumentsRequest,
1999 database: &str,
2000 ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2001 ProjectDatabaseDocumentBatchGetCall {
2002 hub: self.hub,
2003 _request: request,
2004 _database: database.to_string(),
2005 _delegate: Default::default(),
2006 _additional_params: Default::default(),
2007 _scopes: Default::default(),
2008 }
2009 }
2010
2011 /// Create a builder to help you perform the following task:
2012 ///
2013 /// 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.
2014 ///
2015 /// # Arguments
2016 ///
2017 /// * `request` - No description provided.
2018 /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2019 pub fn databases_documents_batch_write(
2020 &self,
2021 request: BatchWriteRequest,
2022 database: &str,
2023 ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
2024 ProjectDatabaseDocumentBatchWriteCall {
2025 hub: self.hub,
2026 _request: request,
2027 _database: database.to_string(),
2028 _delegate: Default::default(),
2029 _additional_params: Default::default(),
2030 _scopes: Default::default(),
2031 }
2032 }
2033
2034 /// Create a builder to help you perform the following task:
2035 ///
2036 /// Starts a new transaction.
2037 ///
2038 /// # Arguments
2039 ///
2040 /// * `request` - No description provided.
2041 /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2042 pub fn databases_documents_begin_transaction(
2043 &self,
2044 request: BeginTransactionRequest,
2045 database: &str,
2046 ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
2047 ProjectDatabaseDocumentBeginTransactionCall {
2048 hub: self.hub,
2049 _request: request,
2050 _database: database.to_string(),
2051 _delegate: Default::default(),
2052 _additional_params: Default::default(),
2053 _scopes: Default::default(),
2054 }
2055 }
2056
2057 /// Create a builder to help you perform the following task:
2058 ///
2059 /// Commits a transaction, while optionally updating documents.
2060 ///
2061 /// # Arguments
2062 ///
2063 /// * `request` - No description provided.
2064 /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2065 pub fn databases_documents_commit(
2066 &self,
2067 request: CommitRequest,
2068 database: &str,
2069 ) -> ProjectDatabaseDocumentCommitCall<'a, C> {
2070 ProjectDatabaseDocumentCommitCall {
2071 hub: self.hub,
2072 _request: request,
2073 _database: database.to_string(),
2074 _delegate: Default::default(),
2075 _additional_params: Default::default(),
2076 _scopes: Default::default(),
2077 }
2078 }
2079
2080 /// Create a builder to help you perform the following task:
2081 ///
2082 /// Creates a new document.
2083 ///
2084 /// # Arguments
2085 ///
2086 /// * `request` - No description provided.
2087 /// * `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}`
2088 /// * `collectionId` - Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
2089 pub fn databases_documents_create_document(
2090 &self,
2091 request: Document,
2092 parent: &str,
2093 collection_id: &str,
2094 ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
2095 ProjectDatabaseDocumentCreateDocumentCall {
2096 hub: self.hub,
2097 _request: request,
2098 _parent: parent.to_string(),
2099 _collection_id: collection_id.to_string(),
2100 _mask_field_paths: Default::default(),
2101 _document_id: Default::default(),
2102 _delegate: Default::default(),
2103 _additional_params: Default::default(),
2104 _scopes: Default::default(),
2105 }
2106 }
2107
2108 /// Create a builder to help you perform the following task:
2109 ///
2110 /// Deletes a document.
2111 ///
2112 /// # Arguments
2113 ///
2114 /// * `name` - Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
2115 pub fn databases_documents_delete(
2116 &self,
2117 name: &str,
2118 ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
2119 ProjectDatabaseDocumentDeleteCall {
2120 hub: self.hub,
2121 _name: name.to_string(),
2122 _current_document_update_time: Default::default(),
2123 _current_document_exists: Default::default(),
2124 _delegate: Default::default(),
2125 _additional_params: Default::default(),
2126 _scopes: Default::default(),
2127 }
2128 }
2129
2130 /// Create a builder to help you perform the following task:
2131 ///
2132 /// Executes a pipeline query.
2133 ///
2134 /// # Arguments
2135 ///
2136 /// * `request` - No description provided.
2137 /// * `database` - Required. Database identifier, in the form `projects/{project}/databases/{database}`.
2138 pub fn databases_documents_execute_pipeline(
2139 &self,
2140 request: ExecutePipelineRequest,
2141 database: &str,
2142 ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
2143 ProjectDatabaseDocumentExecutePipelineCall {
2144 hub: self.hub,
2145 _request: request,
2146 _database: database.to_string(),
2147 _delegate: Default::default(),
2148 _additional_params: Default::default(),
2149 _scopes: Default::default(),
2150 }
2151 }
2152
2153 /// Create a builder to help you perform the following task:
2154 ///
2155 /// Gets a single document.
2156 ///
2157 /// # Arguments
2158 ///
2159 /// * `name` - Required. The resource name of the Document to get. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
2160 pub fn databases_documents_get(&self, name: &str) -> ProjectDatabaseDocumentGetCall<'a, C> {
2161 ProjectDatabaseDocumentGetCall {
2162 hub: self.hub,
2163 _name: name.to_string(),
2164 _transaction: Default::default(),
2165 _read_time: Default::default(),
2166 _mask_field_paths: Default::default(),
2167 _delegate: Default::default(),
2168 _additional_params: Default::default(),
2169 _scopes: Default::default(),
2170 }
2171 }
2172
2173 /// Create a builder to help you perform the following task:
2174 ///
2175 /// Lists documents.
2176 ///
2177 /// # Arguments
2178 ///
2179 /// * `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`
2180 /// * `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`.
2181 pub fn databases_documents_list(
2182 &self,
2183 parent: &str,
2184 collection_id: &str,
2185 ) -> ProjectDatabaseDocumentListCall<'a, C> {
2186 ProjectDatabaseDocumentListCall {
2187 hub: self.hub,
2188 _parent: parent.to_string(),
2189 _collection_id: collection_id.to_string(),
2190 _transaction: Default::default(),
2191 _show_missing: Default::default(),
2192 _read_time: Default::default(),
2193 _page_token: Default::default(),
2194 _page_size: Default::default(),
2195 _order_by: Default::default(),
2196 _mask_field_paths: Default::default(),
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 /// Lists all the collection IDs underneath a document.
2206 ///
2207 /// # Arguments
2208 ///
2209 /// * `request` - No description provided.
2210 /// * `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`
2211 pub fn databases_documents_list_collection_ids(
2212 &self,
2213 request: ListCollectionIdsRequest,
2214 parent: &str,
2215 ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
2216 ProjectDatabaseDocumentListCollectionIdCall {
2217 hub: self.hub,
2218 _request: request,
2219 _parent: parent.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 /// Lists documents.
2229 ///
2230 /// # Arguments
2231 ///
2232 /// * `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`
2233 /// * `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`.
2234 pub fn databases_documents_list_documents(
2235 &self,
2236 parent: &str,
2237 collection_id: &str,
2238 ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
2239 ProjectDatabaseDocumentListDocumentCall {
2240 hub: self.hub,
2241 _parent: parent.to_string(),
2242 _collection_id: collection_id.to_string(),
2243 _transaction: Default::default(),
2244 _show_missing: Default::default(),
2245 _read_time: Default::default(),
2246 _page_token: Default::default(),
2247 _page_size: Default::default(),
2248 _order_by: Default::default(),
2249 _mask_field_paths: Default::default(),
2250 _delegate: Default::default(),
2251 _additional_params: Default::default(),
2252 _scopes: Default::default(),
2253 }
2254 }
2255
2256 /// Create a builder to help you perform the following task:
2257 ///
2258 /// Listens to changes. This method is only available via gRPC or WebChannel (not REST).
2259 ///
2260 /// # Arguments
2261 ///
2262 /// * `request` - No description provided.
2263 /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2264 pub fn databases_documents_listen(
2265 &self,
2266 request: ListenRequest,
2267 database: &str,
2268 ) -> ProjectDatabaseDocumentListenCall<'a, C> {
2269 ProjectDatabaseDocumentListenCall {
2270 hub: self.hub,
2271 _request: request,
2272 _database: database.to_string(),
2273 _delegate: Default::default(),
2274 _additional_params: Default::default(),
2275 _scopes: Default::default(),
2276 }
2277 }
2278
2279 /// Create a builder to help you perform the following task:
2280 ///
2281 /// 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.
2282 ///
2283 /// # Arguments
2284 ///
2285 /// * `request` - No description provided.
2286 /// * `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.
2287 pub fn databases_documents_partition_query(
2288 &self,
2289 request: PartitionQueryRequest,
2290 parent: &str,
2291 ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
2292 ProjectDatabaseDocumentPartitionQueryCall {
2293 hub: self.hub,
2294 _request: request,
2295 _parent: parent.to_string(),
2296 _delegate: Default::default(),
2297 _additional_params: Default::default(),
2298 _scopes: Default::default(),
2299 }
2300 }
2301
2302 /// Create a builder to help you perform the following task:
2303 ///
2304 /// Updates or inserts a document.
2305 ///
2306 /// # Arguments
2307 ///
2308 /// * `request` - No description provided.
2309 /// * `name` - The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
2310 pub fn databases_documents_patch(
2311 &self,
2312 request: Document,
2313 name: &str,
2314 ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
2315 ProjectDatabaseDocumentPatchCall {
2316 hub: self.hub,
2317 _request: request,
2318 _name: name.to_string(),
2319 _update_mask_field_paths: Default::default(),
2320 _mask_field_paths: Default::default(),
2321 _current_document_update_time: Default::default(),
2322 _current_document_exists: Default::default(),
2323 _delegate: Default::default(),
2324 _additional_params: Default::default(),
2325 _scopes: Default::default(),
2326 }
2327 }
2328
2329 /// Create a builder to help you perform the following task:
2330 ///
2331 /// Rolls back a transaction.
2332 ///
2333 /// # Arguments
2334 ///
2335 /// * `request` - No description provided.
2336 /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2337 pub fn databases_documents_rollback(
2338 &self,
2339 request: RollbackRequest,
2340 database: &str,
2341 ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
2342 ProjectDatabaseDocumentRollbackCall {
2343 hub: self.hub,
2344 _request: request,
2345 _database: database.to_string(),
2346 _delegate: Default::default(),
2347 _additional_params: Default::default(),
2348 _scopes: Default::default(),
2349 }
2350 }
2351
2352 /// Create a builder to help you perform the following task:
2353 ///
2354 /// 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 ); ```
2355 ///
2356 /// # Arguments
2357 ///
2358 /// * `request` - No description provided.
2359 /// * `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`
2360 pub fn databases_documents_run_aggregation_query(
2361 &self,
2362 request: RunAggregationQueryRequest,
2363 parent: &str,
2364 ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
2365 ProjectDatabaseDocumentRunAggregationQueryCall {
2366 hub: self.hub,
2367 _request: request,
2368 _parent: parent.to_string(),
2369 _delegate: Default::default(),
2370 _additional_params: Default::default(),
2371 _scopes: Default::default(),
2372 }
2373 }
2374
2375 /// Create a builder to help you perform the following task:
2376 ///
2377 /// Runs a query.
2378 ///
2379 /// # Arguments
2380 ///
2381 /// * `request` - No description provided.
2382 /// * `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`
2383 pub fn databases_documents_run_query(
2384 &self,
2385 request: RunQueryRequest,
2386 parent: &str,
2387 ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
2388 ProjectDatabaseDocumentRunQueryCall {
2389 hub: self.hub,
2390 _request: request,
2391 _parent: parent.to_string(),
2392 _delegate: Default::default(),
2393 _additional_params: Default::default(),
2394 _scopes: Default::default(),
2395 }
2396 }
2397
2398 /// Create a builder to help you perform the following task:
2399 ///
2400 /// Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).
2401 ///
2402 /// # Arguments
2403 ///
2404 /// * `request` - No description provided.
2405 /// * `database` - Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. This is only required in the first message.
2406 pub fn databases_documents_write(
2407 &self,
2408 request: WriteRequest,
2409 database: &str,
2410 ) -> ProjectDatabaseDocumentWriteCall<'a, C> {
2411 ProjectDatabaseDocumentWriteCall {
2412 hub: self.hub,
2413 _request: request,
2414 _database: database.to_string(),
2415 _delegate: Default::default(),
2416 _additional_params: Default::default(),
2417 _scopes: Default::default(),
2418 }
2419 }
2420
2421 /// Create a builder to help you perform the following task:
2422 ///
2423 /// 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.
2424 ///
2425 /// # Arguments
2426 ///
2427 /// * `request` - No description provided.
2428 /// * `parent` - The name of the database this index will apply to. For example: `projects/{project_id}/databases/{database_id}`
2429 pub fn databases_indexes_create(
2430 &self,
2431 request: GoogleFirestoreAdminV1beta1Index,
2432 parent: &str,
2433 ) -> ProjectDatabaseIndexCreateCall<'a, C> {
2434 ProjectDatabaseIndexCreateCall {
2435 hub: self.hub,
2436 _request: request,
2437 _parent: parent.to_string(),
2438 _delegate: Default::default(),
2439 _additional_params: Default::default(),
2440 _scopes: Default::default(),
2441 }
2442 }
2443
2444 /// Create a builder to help you perform the following task:
2445 ///
2446 /// Deletes an index.
2447 ///
2448 /// # Arguments
2449 ///
2450 /// * `name` - The index name. For example: `projects/{project_id}/databases/{database_id}/indexes/{index_id}`
2451 pub fn databases_indexes_delete(&self, name: &str) -> ProjectDatabaseIndexDeleteCall<'a, C> {
2452 ProjectDatabaseIndexDeleteCall {
2453 hub: self.hub,
2454 _name: name.to_string(),
2455 _delegate: Default::default(),
2456 _additional_params: Default::default(),
2457 _scopes: Default::default(),
2458 }
2459 }
2460
2461 /// Create a builder to help you perform the following task:
2462 ///
2463 /// Gets an index.
2464 ///
2465 /// # Arguments
2466 ///
2467 /// * `name` - The name of the index. For example: `projects/{project_id}/databases/{database_id}/indexes/{index_id}`
2468 pub fn databases_indexes_get(&self, name: &str) -> ProjectDatabaseIndexGetCall<'a, C> {
2469 ProjectDatabaseIndexGetCall {
2470 hub: self.hub,
2471 _name: name.to_string(),
2472 _delegate: Default::default(),
2473 _additional_params: Default::default(),
2474 _scopes: Default::default(),
2475 }
2476 }
2477
2478 /// Create a builder to help you perform the following task:
2479 ///
2480 /// Lists the indexes that match the specified filters.
2481 ///
2482 /// # Arguments
2483 ///
2484 /// * `parent` - The database name. For example: `projects/{project_id}/databases/{database_id}`
2485 pub fn databases_indexes_list(&self, parent: &str) -> ProjectDatabaseIndexListCall<'a, C> {
2486 ProjectDatabaseIndexListCall {
2487 hub: self.hub,
2488 _parent: parent.to_string(),
2489 _page_token: Default::default(),
2490 _page_size: Default::default(),
2491 _filter: Default::default(),
2492 _delegate: Default::default(),
2493 _additional_params: Default::default(),
2494 _scopes: Default::default(),
2495 }
2496 }
2497
2498 /// Create a builder to help you perform the following task:
2499 ///
2500 /// 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.
2501 ///
2502 /// # Arguments
2503 ///
2504 /// * `request` - No description provided.
2505 /// * `name` - Database to export. Should be of the form: `projects/{project_id}/databases/{database_id}`.
2506 pub fn databases_export_documents(
2507 &self,
2508 request: GoogleFirestoreAdminV1beta1ExportDocumentsRequest,
2509 name: &str,
2510 ) -> ProjectDatabaseExportDocumentCall<'a, C> {
2511 ProjectDatabaseExportDocumentCall {
2512 hub: self.hub,
2513 _request: request,
2514 _name: name.to_string(),
2515 _delegate: Default::default(),
2516 _additional_params: Default::default(),
2517 _scopes: Default::default(),
2518 }
2519 }
2520
2521 /// Create a builder to help you perform the following task:
2522 ///
2523 /// 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.
2524 ///
2525 /// # Arguments
2526 ///
2527 /// * `request` - No description provided.
2528 /// * `name` - Database to import into. Should be of the form: `projects/{project_id}/databases/{database_id}`.
2529 pub fn databases_import_documents(
2530 &self,
2531 request: GoogleFirestoreAdminV1beta1ImportDocumentsRequest,
2532 name: &str,
2533 ) -> ProjectDatabaseImportDocumentCall<'a, C> {
2534 ProjectDatabaseImportDocumentCall {
2535 hub: self.hub,
2536 _request: request,
2537 _name: name.to_string(),
2538 _delegate: Default::default(),
2539 _additional_params: Default::default(),
2540 _scopes: Default::default(),
2541 }
2542 }
2543}
2544
2545// ###################
2546// CallBuilders ###
2547// #################
2548
2549/// Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
2550///
2551/// A builder for the *databases.documents.batchGet* method supported by a *project* resource.
2552/// It is not used directly, but through a [`ProjectMethods`] instance.
2553///
2554/// # Example
2555///
2556/// Instantiate a resource method builder
2557///
2558/// ```test_harness,no_run
2559/// # extern crate hyper;
2560/// # extern crate hyper_rustls;
2561/// # extern crate google_firestore1_beta1 as firestore1_beta1;
2562/// use firestore1_beta1::api::BatchGetDocumentsRequest;
2563/// # async fn dox() {
2564/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2565///
2566/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2567/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2568/// # .with_native_roots()
2569/// # .unwrap()
2570/// # .https_only()
2571/// # .enable_http2()
2572/// # .build();
2573///
2574/// # let executor = hyper_util::rt::TokioExecutor::new();
2575/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2576/// # secret,
2577/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2578/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2579/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2580/// # ),
2581/// # ).build().await.unwrap();
2582///
2583/// # let client = hyper_util::client::legacy::Client::builder(
2584/// # hyper_util::rt::TokioExecutor::new()
2585/// # )
2586/// # .build(
2587/// # hyper_rustls::HttpsConnectorBuilder::new()
2588/// # .with_native_roots()
2589/// # .unwrap()
2590/// # .https_or_http()
2591/// # .enable_http2()
2592/// # .build()
2593/// # );
2594/// # let mut hub = Firestore::new(client, auth);
2595/// // As the method needs a request, you would usually fill it with the desired information
2596/// // into the respective structure. Some of the parts shown here might not be applicable !
2597/// // Values shown here are possibly random and not representative !
2598/// let mut req = BatchGetDocumentsRequest::default();
2599///
2600/// // You can configure optional parameters by calling the respective setters at will, and
2601/// // execute the final call using `doit()`.
2602/// // Values shown here are possibly random and not representative !
2603/// let result = hub.projects().databases_documents_batch_get(req, "database")
2604/// .doit().await;
2605/// # }
2606/// ```
2607pub struct ProjectDatabaseDocumentBatchGetCall<'a, C>
2608where
2609 C: 'a,
2610{
2611 hub: &'a Firestore<C>,
2612 _request: BatchGetDocumentsRequest,
2613 _database: String,
2614 _delegate: Option<&'a mut dyn common::Delegate>,
2615 _additional_params: HashMap<String, String>,
2616 _scopes: BTreeSet<String>,
2617}
2618
2619impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBatchGetCall<'a, C> {}
2620
2621impl<'a, C> ProjectDatabaseDocumentBatchGetCall<'a, C>
2622where
2623 C: common::Connector,
2624{
2625 /// Perform the operation you have build so far.
2626 pub async fn doit(mut self) -> common::Result<(common::Response, BatchGetDocumentsResponse)> {
2627 use std::borrow::Cow;
2628 use std::io::{Read, Seek};
2629
2630 use common::{url::Params, ToParts};
2631 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2632
2633 let mut dd = common::DefaultDelegate;
2634 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2635 dlg.begin(common::MethodInfo {
2636 id: "firestore.projects.databases.documents.batchGet",
2637 http_method: hyper::Method::POST,
2638 });
2639
2640 for &field in ["alt", "database"].iter() {
2641 if self._additional_params.contains_key(field) {
2642 dlg.finished(false);
2643 return Err(common::Error::FieldClash(field));
2644 }
2645 }
2646
2647 let mut params = Params::with_capacity(4 + self._additional_params.len());
2648 params.push("database", self._database);
2649
2650 params.extend(self._additional_params.iter());
2651
2652 params.push("alt", "json");
2653 let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:batchGet";
2654 if self._scopes.is_empty() {
2655 self._scopes
2656 .insert(Scope::CloudPlatform.as_ref().to_string());
2657 }
2658
2659 #[allow(clippy::single_element_loop)]
2660 for &(find_this, param_name) in [("{+database}", "database")].iter() {
2661 url = params.uri_replacement(url, param_name, find_this, true);
2662 }
2663 {
2664 let to_remove = ["database"];
2665 params.remove_params(&to_remove);
2666 }
2667
2668 let url = params.parse_with_url(&url);
2669
2670 let mut json_mime_type = mime::APPLICATION_JSON;
2671 let mut request_value_reader = {
2672 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2673 common::remove_json_null_values(&mut value);
2674 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2675 serde_json::to_writer(&mut dst, &value).unwrap();
2676 dst
2677 };
2678 let request_size = request_value_reader
2679 .seek(std::io::SeekFrom::End(0))
2680 .unwrap();
2681 request_value_reader
2682 .seek(std::io::SeekFrom::Start(0))
2683 .unwrap();
2684
2685 loop {
2686 let token = match self
2687 .hub
2688 .auth
2689 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2690 .await
2691 {
2692 Ok(token) => token,
2693 Err(e) => match dlg.token(e) {
2694 Ok(token) => token,
2695 Err(e) => {
2696 dlg.finished(false);
2697 return Err(common::Error::MissingToken(e));
2698 }
2699 },
2700 };
2701 request_value_reader
2702 .seek(std::io::SeekFrom::Start(0))
2703 .unwrap();
2704 let mut req_result = {
2705 let client = &self.hub.client;
2706 dlg.pre_request();
2707 let mut req_builder = hyper::Request::builder()
2708 .method(hyper::Method::POST)
2709 .uri(url.as_str())
2710 .header(USER_AGENT, self.hub._user_agent.clone());
2711
2712 if let Some(token) = token.as_ref() {
2713 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2714 }
2715
2716 let request = req_builder
2717 .header(CONTENT_TYPE, json_mime_type.to_string())
2718 .header(CONTENT_LENGTH, request_size as u64)
2719 .body(common::to_body(
2720 request_value_reader.get_ref().clone().into(),
2721 ));
2722
2723 client.request(request.unwrap()).await
2724 };
2725
2726 match req_result {
2727 Err(err) => {
2728 if let common::Retry::After(d) = dlg.http_error(&err) {
2729 sleep(d).await;
2730 continue;
2731 }
2732 dlg.finished(false);
2733 return Err(common::Error::HttpError(err));
2734 }
2735 Ok(res) => {
2736 let (mut parts, body) = res.into_parts();
2737 let mut body = common::Body::new(body);
2738 if !parts.status.is_success() {
2739 let bytes = common::to_bytes(body).await.unwrap_or_default();
2740 let error = serde_json::from_str(&common::to_string(&bytes));
2741 let response = common::to_response(parts, bytes.into());
2742
2743 if let common::Retry::After(d) =
2744 dlg.http_failure(&response, error.as_ref().ok())
2745 {
2746 sleep(d).await;
2747 continue;
2748 }
2749
2750 dlg.finished(false);
2751
2752 return Err(match error {
2753 Ok(value) => common::Error::BadRequest(value),
2754 _ => common::Error::Failure(response),
2755 });
2756 }
2757 let response = {
2758 let bytes = common::to_bytes(body).await.unwrap_or_default();
2759 let encoded = common::to_string(&bytes);
2760 match serde_json::from_str(&encoded) {
2761 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2762 Err(error) => {
2763 dlg.response_json_decode_error(&encoded, &error);
2764 return Err(common::Error::JsonDecodeError(
2765 encoded.to_string(),
2766 error,
2767 ));
2768 }
2769 }
2770 };
2771
2772 dlg.finished(true);
2773 return Ok(response);
2774 }
2775 }
2776 }
2777 }
2778
2779 ///
2780 /// Sets the *request* property to the given value.
2781 ///
2782 /// Even though the property as already been set when instantiating this call,
2783 /// we provide this method for API completeness.
2784 pub fn request(
2785 mut self,
2786 new_value: BatchGetDocumentsRequest,
2787 ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2788 self._request = new_value;
2789 self
2790 }
2791 /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
2792 ///
2793 /// Sets the *database* path property to the given value.
2794 ///
2795 /// Even though the property as already been set when instantiating this call,
2796 /// we provide this method for API completeness.
2797 pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2798 self._database = new_value.to_string();
2799 self
2800 }
2801 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2802 /// while executing the actual API request.
2803 ///
2804 /// ````text
2805 /// It should be used to handle progress information, and to implement a certain level of resilience.
2806 /// ````
2807 ///
2808 /// Sets the *delegate* property to the given value.
2809 pub fn delegate(
2810 mut self,
2811 new_value: &'a mut dyn common::Delegate,
2812 ) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2813 self._delegate = Some(new_value);
2814 self
2815 }
2816
2817 /// Set any additional parameter of the query string used in the request.
2818 /// It should be used to set parameters which are not yet available through their own
2819 /// setters.
2820 ///
2821 /// Please note that this method must not be used to set any of the known parameters
2822 /// which have their own setter method. If done anyway, the request will fail.
2823 ///
2824 /// # Additional Parameters
2825 ///
2826 /// * *$.xgafv* (query-string) - V1 error format.
2827 /// * *access_token* (query-string) - OAuth access token.
2828 /// * *alt* (query-string) - Data format for response.
2829 /// * *callback* (query-string) - JSONP
2830 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2831 /// * *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.
2832 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2833 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2834 /// * *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.
2835 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2836 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2837 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
2838 where
2839 T: AsRef<str>,
2840 {
2841 self._additional_params
2842 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2843 self
2844 }
2845
2846 /// Identifies the authorization scope for the method you are building.
2847 ///
2848 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2849 /// [`Scope::CloudPlatform`].
2850 ///
2851 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2852 /// tokens for more than one scope.
2853 ///
2854 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2855 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2856 /// sufficient, a read-write scope will do as well.
2857 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
2858 where
2859 St: AsRef<str>,
2860 {
2861 self._scopes.insert(String::from(scope.as_ref()));
2862 self
2863 }
2864 /// Identifies the authorization scope(s) for the method you are building.
2865 ///
2866 /// See [`Self::add_scope()`] for details.
2867 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentBatchGetCall<'a, C>
2868 where
2869 I: IntoIterator<Item = St>,
2870 St: AsRef<str>,
2871 {
2872 self._scopes
2873 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2874 self
2875 }
2876
2877 /// Removes all scopes, and no default scope will be used either.
2878 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2879 /// for details).
2880 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBatchGetCall<'a, C> {
2881 self._scopes.clear();
2882 self
2883 }
2884}
2885
2886/// 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.
2887///
2888/// A builder for the *databases.documents.batchWrite* method supported by a *project* resource.
2889/// It is not used directly, but through a [`ProjectMethods`] instance.
2890///
2891/// # Example
2892///
2893/// Instantiate a resource method builder
2894///
2895/// ```test_harness,no_run
2896/// # extern crate hyper;
2897/// # extern crate hyper_rustls;
2898/// # extern crate google_firestore1_beta1 as firestore1_beta1;
2899/// use firestore1_beta1::api::BatchWriteRequest;
2900/// # async fn dox() {
2901/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2902///
2903/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2904/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2905/// # .with_native_roots()
2906/// # .unwrap()
2907/// # .https_only()
2908/// # .enable_http2()
2909/// # .build();
2910///
2911/// # let executor = hyper_util::rt::TokioExecutor::new();
2912/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2913/// # secret,
2914/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2915/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2916/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2917/// # ),
2918/// # ).build().await.unwrap();
2919///
2920/// # let client = hyper_util::client::legacy::Client::builder(
2921/// # hyper_util::rt::TokioExecutor::new()
2922/// # )
2923/// # .build(
2924/// # hyper_rustls::HttpsConnectorBuilder::new()
2925/// # .with_native_roots()
2926/// # .unwrap()
2927/// # .https_or_http()
2928/// # .enable_http2()
2929/// # .build()
2930/// # );
2931/// # let mut hub = Firestore::new(client, auth);
2932/// // As the method needs a request, you would usually fill it with the desired information
2933/// // into the respective structure. Some of the parts shown here might not be applicable !
2934/// // Values shown here are possibly random and not representative !
2935/// let mut req = BatchWriteRequest::default();
2936///
2937/// // You can configure optional parameters by calling the respective setters at will, and
2938/// // execute the final call using `doit()`.
2939/// // Values shown here are possibly random and not representative !
2940/// let result = hub.projects().databases_documents_batch_write(req, "database")
2941/// .doit().await;
2942/// # }
2943/// ```
2944pub struct ProjectDatabaseDocumentBatchWriteCall<'a, C>
2945where
2946 C: 'a,
2947{
2948 hub: &'a Firestore<C>,
2949 _request: BatchWriteRequest,
2950 _database: String,
2951 _delegate: Option<&'a mut dyn common::Delegate>,
2952 _additional_params: HashMap<String, String>,
2953 _scopes: BTreeSet<String>,
2954}
2955
2956impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBatchWriteCall<'a, C> {}
2957
2958impl<'a, C> ProjectDatabaseDocumentBatchWriteCall<'a, C>
2959where
2960 C: common::Connector,
2961{
2962 /// Perform the operation you have build so far.
2963 pub async fn doit(mut self) -> common::Result<(common::Response, BatchWriteResponse)> {
2964 use std::borrow::Cow;
2965 use std::io::{Read, Seek};
2966
2967 use common::{url::Params, ToParts};
2968 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2969
2970 let mut dd = common::DefaultDelegate;
2971 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2972 dlg.begin(common::MethodInfo {
2973 id: "firestore.projects.databases.documents.batchWrite",
2974 http_method: hyper::Method::POST,
2975 });
2976
2977 for &field in ["alt", "database"].iter() {
2978 if self._additional_params.contains_key(field) {
2979 dlg.finished(false);
2980 return Err(common::Error::FieldClash(field));
2981 }
2982 }
2983
2984 let mut params = Params::with_capacity(4 + self._additional_params.len());
2985 params.push("database", self._database);
2986
2987 params.extend(self._additional_params.iter());
2988
2989 params.push("alt", "json");
2990 let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:batchWrite";
2991 if self._scopes.is_empty() {
2992 self._scopes
2993 .insert(Scope::CloudPlatform.as_ref().to_string());
2994 }
2995
2996 #[allow(clippy::single_element_loop)]
2997 for &(find_this, param_name) in [("{+database}", "database")].iter() {
2998 url = params.uri_replacement(url, param_name, find_this, true);
2999 }
3000 {
3001 let to_remove = ["database"];
3002 params.remove_params(&to_remove);
3003 }
3004
3005 let url = params.parse_with_url(&url);
3006
3007 let mut json_mime_type = mime::APPLICATION_JSON;
3008 let mut request_value_reader = {
3009 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3010 common::remove_json_null_values(&mut value);
3011 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3012 serde_json::to_writer(&mut dst, &value).unwrap();
3013 dst
3014 };
3015 let request_size = request_value_reader
3016 .seek(std::io::SeekFrom::End(0))
3017 .unwrap();
3018 request_value_reader
3019 .seek(std::io::SeekFrom::Start(0))
3020 .unwrap();
3021
3022 loop {
3023 let token = match self
3024 .hub
3025 .auth
3026 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3027 .await
3028 {
3029 Ok(token) => token,
3030 Err(e) => match dlg.token(e) {
3031 Ok(token) => token,
3032 Err(e) => {
3033 dlg.finished(false);
3034 return Err(common::Error::MissingToken(e));
3035 }
3036 },
3037 };
3038 request_value_reader
3039 .seek(std::io::SeekFrom::Start(0))
3040 .unwrap();
3041 let mut req_result = {
3042 let client = &self.hub.client;
3043 dlg.pre_request();
3044 let mut req_builder = hyper::Request::builder()
3045 .method(hyper::Method::POST)
3046 .uri(url.as_str())
3047 .header(USER_AGENT, self.hub._user_agent.clone());
3048
3049 if let Some(token) = token.as_ref() {
3050 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3051 }
3052
3053 let request = req_builder
3054 .header(CONTENT_TYPE, json_mime_type.to_string())
3055 .header(CONTENT_LENGTH, request_size as u64)
3056 .body(common::to_body(
3057 request_value_reader.get_ref().clone().into(),
3058 ));
3059
3060 client.request(request.unwrap()).await
3061 };
3062
3063 match req_result {
3064 Err(err) => {
3065 if let common::Retry::After(d) = dlg.http_error(&err) {
3066 sleep(d).await;
3067 continue;
3068 }
3069 dlg.finished(false);
3070 return Err(common::Error::HttpError(err));
3071 }
3072 Ok(res) => {
3073 let (mut parts, body) = res.into_parts();
3074 let mut body = common::Body::new(body);
3075 if !parts.status.is_success() {
3076 let bytes = common::to_bytes(body).await.unwrap_or_default();
3077 let error = serde_json::from_str(&common::to_string(&bytes));
3078 let response = common::to_response(parts, bytes.into());
3079
3080 if let common::Retry::After(d) =
3081 dlg.http_failure(&response, error.as_ref().ok())
3082 {
3083 sleep(d).await;
3084 continue;
3085 }
3086
3087 dlg.finished(false);
3088
3089 return Err(match error {
3090 Ok(value) => common::Error::BadRequest(value),
3091 _ => common::Error::Failure(response),
3092 });
3093 }
3094 let response = {
3095 let bytes = common::to_bytes(body).await.unwrap_or_default();
3096 let encoded = common::to_string(&bytes);
3097 match serde_json::from_str(&encoded) {
3098 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3099 Err(error) => {
3100 dlg.response_json_decode_error(&encoded, &error);
3101 return Err(common::Error::JsonDecodeError(
3102 encoded.to_string(),
3103 error,
3104 ));
3105 }
3106 }
3107 };
3108
3109 dlg.finished(true);
3110 return Ok(response);
3111 }
3112 }
3113 }
3114 }
3115
3116 ///
3117 /// Sets the *request* property to the given value.
3118 ///
3119 /// Even though the property as already been set when instantiating this call,
3120 /// we provide this method for API completeness.
3121 pub fn request(
3122 mut self,
3123 new_value: BatchWriteRequest,
3124 ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
3125 self._request = new_value;
3126 self
3127 }
3128 /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3129 ///
3130 /// Sets the *database* path property to the given value.
3131 ///
3132 /// Even though the property as already been set when instantiating this call,
3133 /// we provide this method for API completeness.
3134 pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
3135 self._database = new_value.to_string();
3136 self
3137 }
3138 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3139 /// while executing the actual API request.
3140 ///
3141 /// ````text
3142 /// It should be used to handle progress information, and to implement a certain level of resilience.
3143 /// ````
3144 ///
3145 /// Sets the *delegate* property to the given value.
3146 pub fn delegate(
3147 mut self,
3148 new_value: &'a mut dyn common::Delegate,
3149 ) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
3150 self._delegate = Some(new_value);
3151 self
3152 }
3153
3154 /// Set any additional parameter of the query string used in the request.
3155 /// It should be used to set parameters which are not yet available through their own
3156 /// setters.
3157 ///
3158 /// Please note that this method must not be used to set any of the known parameters
3159 /// which have their own setter method. If done anyway, the request will fail.
3160 ///
3161 /// # Additional Parameters
3162 ///
3163 /// * *$.xgafv* (query-string) - V1 error format.
3164 /// * *access_token* (query-string) - OAuth access token.
3165 /// * *alt* (query-string) - Data format for response.
3166 /// * *callback* (query-string) - JSONP
3167 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3168 /// * *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.
3169 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3170 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3171 /// * *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.
3172 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3173 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3174 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
3175 where
3176 T: AsRef<str>,
3177 {
3178 self._additional_params
3179 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3180 self
3181 }
3182
3183 /// Identifies the authorization scope for the method you are building.
3184 ///
3185 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3186 /// [`Scope::CloudPlatform`].
3187 ///
3188 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3189 /// tokens for more than one scope.
3190 ///
3191 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3192 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3193 /// sufficient, a read-write scope will do as well.
3194 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
3195 where
3196 St: AsRef<str>,
3197 {
3198 self._scopes.insert(String::from(scope.as_ref()));
3199 self
3200 }
3201 /// Identifies the authorization scope(s) for the method you are building.
3202 ///
3203 /// See [`Self::add_scope()`] for details.
3204 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentBatchWriteCall<'a, C>
3205 where
3206 I: IntoIterator<Item = St>,
3207 St: AsRef<str>,
3208 {
3209 self._scopes
3210 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3211 self
3212 }
3213
3214 /// Removes all scopes, and no default scope will be used either.
3215 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3216 /// for details).
3217 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBatchWriteCall<'a, C> {
3218 self._scopes.clear();
3219 self
3220 }
3221}
3222
3223/// Starts a new transaction.
3224///
3225/// A builder for the *databases.documents.beginTransaction* method supported by a *project* resource.
3226/// It is not used directly, but through a [`ProjectMethods`] instance.
3227///
3228/// # Example
3229///
3230/// Instantiate a resource method builder
3231///
3232/// ```test_harness,no_run
3233/// # extern crate hyper;
3234/// # extern crate hyper_rustls;
3235/// # extern crate google_firestore1_beta1 as firestore1_beta1;
3236/// use firestore1_beta1::api::BeginTransactionRequest;
3237/// # async fn dox() {
3238/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3239///
3240/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3241/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3242/// # .with_native_roots()
3243/// # .unwrap()
3244/// # .https_only()
3245/// # .enable_http2()
3246/// # .build();
3247///
3248/// # let executor = hyper_util::rt::TokioExecutor::new();
3249/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3250/// # secret,
3251/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3252/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3253/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3254/// # ),
3255/// # ).build().await.unwrap();
3256///
3257/// # let client = hyper_util::client::legacy::Client::builder(
3258/// # hyper_util::rt::TokioExecutor::new()
3259/// # )
3260/// # .build(
3261/// # hyper_rustls::HttpsConnectorBuilder::new()
3262/// # .with_native_roots()
3263/// # .unwrap()
3264/// # .https_or_http()
3265/// # .enable_http2()
3266/// # .build()
3267/// # );
3268/// # let mut hub = Firestore::new(client, auth);
3269/// // As the method needs a request, you would usually fill it with the desired information
3270/// // into the respective structure. Some of the parts shown here might not be applicable !
3271/// // Values shown here are possibly random and not representative !
3272/// let mut req = BeginTransactionRequest::default();
3273///
3274/// // You can configure optional parameters by calling the respective setters at will, and
3275/// // execute the final call using `doit()`.
3276/// // Values shown here are possibly random and not representative !
3277/// let result = hub.projects().databases_documents_begin_transaction(req, "database")
3278/// .doit().await;
3279/// # }
3280/// ```
3281pub struct ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3282where
3283 C: 'a,
3284{
3285 hub: &'a Firestore<C>,
3286 _request: BeginTransactionRequest,
3287 _database: String,
3288 _delegate: Option<&'a mut dyn common::Delegate>,
3289 _additional_params: HashMap<String, String>,
3290 _scopes: BTreeSet<String>,
3291}
3292
3293impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentBeginTransactionCall<'a, C> {}
3294
3295impl<'a, C> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3296where
3297 C: common::Connector,
3298{
3299 /// Perform the operation you have build so far.
3300 pub async fn doit(mut self) -> common::Result<(common::Response, BeginTransactionResponse)> {
3301 use std::borrow::Cow;
3302 use std::io::{Read, Seek};
3303
3304 use common::{url::Params, ToParts};
3305 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3306
3307 let mut dd = common::DefaultDelegate;
3308 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3309 dlg.begin(common::MethodInfo {
3310 id: "firestore.projects.databases.documents.beginTransaction",
3311 http_method: hyper::Method::POST,
3312 });
3313
3314 for &field in ["alt", "database"].iter() {
3315 if self._additional_params.contains_key(field) {
3316 dlg.finished(false);
3317 return Err(common::Error::FieldClash(field));
3318 }
3319 }
3320
3321 let mut params = Params::with_capacity(4 + self._additional_params.len());
3322 params.push("database", self._database);
3323
3324 params.extend(self._additional_params.iter());
3325
3326 params.push("alt", "json");
3327 let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:beginTransaction";
3328 if self._scopes.is_empty() {
3329 self._scopes
3330 .insert(Scope::CloudPlatform.as_ref().to_string());
3331 }
3332
3333 #[allow(clippy::single_element_loop)]
3334 for &(find_this, param_name) in [("{+database}", "database")].iter() {
3335 url = params.uri_replacement(url, param_name, find_this, true);
3336 }
3337 {
3338 let to_remove = ["database"];
3339 params.remove_params(&to_remove);
3340 }
3341
3342 let url = params.parse_with_url(&url);
3343
3344 let mut json_mime_type = mime::APPLICATION_JSON;
3345 let mut request_value_reader = {
3346 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3347 common::remove_json_null_values(&mut value);
3348 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3349 serde_json::to_writer(&mut dst, &value).unwrap();
3350 dst
3351 };
3352 let request_size = request_value_reader
3353 .seek(std::io::SeekFrom::End(0))
3354 .unwrap();
3355 request_value_reader
3356 .seek(std::io::SeekFrom::Start(0))
3357 .unwrap();
3358
3359 loop {
3360 let token = match self
3361 .hub
3362 .auth
3363 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3364 .await
3365 {
3366 Ok(token) => token,
3367 Err(e) => match dlg.token(e) {
3368 Ok(token) => token,
3369 Err(e) => {
3370 dlg.finished(false);
3371 return Err(common::Error::MissingToken(e));
3372 }
3373 },
3374 };
3375 request_value_reader
3376 .seek(std::io::SeekFrom::Start(0))
3377 .unwrap();
3378 let mut req_result = {
3379 let client = &self.hub.client;
3380 dlg.pre_request();
3381 let mut req_builder = hyper::Request::builder()
3382 .method(hyper::Method::POST)
3383 .uri(url.as_str())
3384 .header(USER_AGENT, self.hub._user_agent.clone());
3385
3386 if let Some(token) = token.as_ref() {
3387 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3388 }
3389
3390 let request = req_builder
3391 .header(CONTENT_TYPE, json_mime_type.to_string())
3392 .header(CONTENT_LENGTH, request_size as u64)
3393 .body(common::to_body(
3394 request_value_reader.get_ref().clone().into(),
3395 ));
3396
3397 client.request(request.unwrap()).await
3398 };
3399
3400 match req_result {
3401 Err(err) => {
3402 if let common::Retry::After(d) = dlg.http_error(&err) {
3403 sleep(d).await;
3404 continue;
3405 }
3406 dlg.finished(false);
3407 return Err(common::Error::HttpError(err));
3408 }
3409 Ok(res) => {
3410 let (mut parts, body) = res.into_parts();
3411 let mut body = common::Body::new(body);
3412 if !parts.status.is_success() {
3413 let bytes = common::to_bytes(body).await.unwrap_or_default();
3414 let error = serde_json::from_str(&common::to_string(&bytes));
3415 let response = common::to_response(parts, bytes.into());
3416
3417 if let common::Retry::After(d) =
3418 dlg.http_failure(&response, error.as_ref().ok())
3419 {
3420 sleep(d).await;
3421 continue;
3422 }
3423
3424 dlg.finished(false);
3425
3426 return Err(match error {
3427 Ok(value) => common::Error::BadRequest(value),
3428 _ => common::Error::Failure(response),
3429 });
3430 }
3431 let response = {
3432 let bytes = common::to_bytes(body).await.unwrap_or_default();
3433 let encoded = common::to_string(&bytes);
3434 match serde_json::from_str(&encoded) {
3435 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3436 Err(error) => {
3437 dlg.response_json_decode_error(&encoded, &error);
3438 return Err(common::Error::JsonDecodeError(
3439 encoded.to_string(),
3440 error,
3441 ));
3442 }
3443 }
3444 };
3445
3446 dlg.finished(true);
3447 return Ok(response);
3448 }
3449 }
3450 }
3451 }
3452
3453 ///
3454 /// Sets the *request* property to the given value.
3455 ///
3456 /// Even though the property as already been set when instantiating this call,
3457 /// we provide this method for API completeness.
3458 pub fn request(
3459 mut self,
3460 new_value: BeginTransactionRequest,
3461 ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3462 self._request = new_value;
3463 self
3464 }
3465 /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3466 ///
3467 /// Sets the *database* path property to the given value.
3468 ///
3469 /// Even though the property as already been set when instantiating this call,
3470 /// we provide this method for API completeness.
3471 pub fn database(
3472 mut self,
3473 new_value: &str,
3474 ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3475 self._database = new_value.to_string();
3476 self
3477 }
3478 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3479 /// while executing the actual API request.
3480 ///
3481 /// ````text
3482 /// It should be used to handle progress information, and to implement a certain level of resilience.
3483 /// ````
3484 ///
3485 /// Sets the *delegate* property to the given value.
3486 pub fn delegate(
3487 mut self,
3488 new_value: &'a mut dyn common::Delegate,
3489 ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3490 self._delegate = Some(new_value);
3491 self
3492 }
3493
3494 /// Set any additional parameter of the query string used in the request.
3495 /// It should be used to set parameters which are not yet available through their own
3496 /// setters.
3497 ///
3498 /// Please note that this method must not be used to set any of the known parameters
3499 /// which have their own setter method. If done anyway, the request will fail.
3500 ///
3501 /// # Additional Parameters
3502 ///
3503 /// * *$.xgafv* (query-string) - V1 error format.
3504 /// * *access_token* (query-string) - OAuth access token.
3505 /// * *alt* (query-string) - Data format for response.
3506 /// * *callback* (query-string) - JSONP
3507 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3508 /// * *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.
3509 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3510 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3511 /// * *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.
3512 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3513 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3514 pub fn param<T>(
3515 mut self,
3516 name: T,
3517 value: T,
3518 ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3519 where
3520 T: AsRef<str>,
3521 {
3522 self._additional_params
3523 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3524 self
3525 }
3526
3527 /// Identifies the authorization scope for the method you are building.
3528 ///
3529 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3530 /// [`Scope::CloudPlatform`].
3531 ///
3532 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3533 /// tokens for more than one scope.
3534 ///
3535 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3536 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3537 /// sufficient, a read-write scope will do as well.
3538 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3539 where
3540 St: AsRef<str>,
3541 {
3542 self._scopes.insert(String::from(scope.as_ref()));
3543 self
3544 }
3545 /// Identifies the authorization scope(s) for the method you are building.
3546 ///
3547 /// See [`Self::add_scope()`] for details.
3548 pub fn add_scopes<I, St>(
3549 mut self,
3550 scopes: I,
3551 ) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C>
3552 where
3553 I: IntoIterator<Item = St>,
3554 St: AsRef<str>,
3555 {
3556 self._scopes
3557 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3558 self
3559 }
3560
3561 /// Removes all scopes, and no default scope will be used either.
3562 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3563 /// for details).
3564 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentBeginTransactionCall<'a, C> {
3565 self._scopes.clear();
3566 self
3567 }
3568}
3569
3570/// Commits a transaction, while optionally updating documents.
3571///
3572/// A builder for the *databases.documents.commit* method supported by a *project* resource.
3573/// It is not used directly, but through a [`ProjectMethods`] instance.
3574///
3575/// # Example
3576///
3577/// Instantiate a resource method builder
3578///
3579/// ```test_harness,no_run
3580/// # extern crate hyper;
3581/// # extern crate hyper_rustls;
3582/// # extern crate google_firestore1_beta1 as firestore1_beta1;
3583/// use firestore1_beta1::api::CommitRequest;
3584/// # async fn dox() {
3585/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3586///
3587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3588/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3589/// # .with_native_roots()
3590/// # .unwrap()
3591/// # .https_only()
3592/// # .enable_http2()
3593/// # .build();
3594///
3595/// # let executor = hyper_util::rt::TokioExecutor::new();
3596/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3597/// # secret,
3598/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3599/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3600/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3601/// # ),
3602/// # ).build().await.unwrap();
3603///
3604/// # let client = hyper_util::client::legacy::Client::builder(
3605/// # hyper_util::rt::TokioExecutor::new()
3606/// # )
3607/// # .build(
3608/// # hyper_rustls::HttpsConnectorBuilder::new()
3609/// # .with_native_roots()
3610/// # .unwrap()
3611/// # .https_or_http()
3612/// # .enable_http2()
3613/// # .build()
3614/// # );
3615/// # let mut hub = Firestore::new(client, auth);
3616/// // As the method needs a request, you would usually fill it with the desired information
3617/// // into the respective structure. Some of the parts shown here might not be applicable !
3618/// // Values shown here are possibly random and not representative !
3619/// let mut req = CommitRequest::default();
3620///
3621/// // You can configure optional parameters by calling the respective setters at will, and
3622/// // execute the final call using `doit()`.
3623/// // Values shown here are possibly random and not representative !
3624/// let result = hub.projects().databases_documents_commit(req, "database")
3625/// .doit().await;
3626/// # }
3627/// ```
3628pub struct ProjectDatabaseDocumentCommitCall<'a, C>
3629where
3630 C: 'a,
3631{
3632 hub: &'a Firestore<C>,
3633 _request: CommitRequest,
3634 _database: String,
3635 _delegate: Option<&'a mut dyn common::Delegate>,
3636 _additional_params: HashMap<String, String>,
3637 _scopes: BTreeSet<String>,
3638}
3639
3640impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentCommitCall<'a, C> {}
3641
3642impl<'a, C> ProjectDatabaseDocumentCommitCall<'a, C>
3643where
3644 C: common::Connector,
3645{
3646 /// Perform the operation you have build so far.
3647 pub async fn doit(mut self) -> common::Result<(common::Response, CommitResponse)> {
3648 use std::borrow::Cow;
3649 use std::io::{Read, Seek};
3650
3651 use common::{url::Params, ToParts};
3652 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3653
3654 let mut dd = common::DefaultDelegate;
3655 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3656 dlg.begin(common::MethodInfo {
3657 id: "firestore.projects.databases.documents.commit",
3658 http_method: hyper::Method::POST,
3659 });
3660
3661 for &field in ["alt", "database"].iter() {
3662 if self._additional_params.contains_key(field) {
3663 dlg.finished(false);
3664 return Err(common::Error::FieldClash(field));
3665 }
3666 }
3667
3668 let mut params = Params::with_capacity(4 + self._additional_params.len());
3669 params.push("database", self._database);
3670
3671 params.extend(self._additional_params.iter());
3672
3673 params.push("alt", "json");
3674 let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:commit";
3675 if self._scopes.is_empty() {
3676 self._scopes
3677 .insert(Scope::CloudPlatform.as_ref().to_string());
3678 }
3679
3680 #[allow(clippy::single_element_loop)]
3681 for &(find_this, param_name) in [("{+database}", "database")].iter() {
3682 url = params.uri_replacement(url, param_name, find_this, true);
3683 }
3684 {
3685 let to_remove = ["database"];
3686 params.remove_params(&to_remove);
3687 }
3688
3689 let url = params.parse_with_url(&url);
3690
3691 let mut json_mime_type = mime::APPLICATION_JSON;
3692 let mut request_value_reader = {
3693 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3694 common::remove_json_null_values(&mut value);
3695 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3696 serde_json::to_writer(&mut dst, &value).unwrap();
3697 dst
3698 };
3699 let request_size = request_value_reader
3700 .seek(std::io::SeekFrom::End(0))
3701 .unwrap();
3702 request_value_reader
3703 .seek(std::io::SeekFrom::Start(0))
3704 .unwrap();
3705
3706 loop {
3707 let token = match self
3708 .hub
3709 .auth
3710 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3711 .await
3712 {
3713 Ok(token) => token,
3714 Err(e) => match dlg.token(e) {
3715 Ok(token) => token,
3716 Err(e) => {
3717 dlg.finished(false);
3718 return Err(common::Error::MissingToken(e));
3719 }
3720 },
3721 };
3722 request_value_reader
3723 .seek(std::io::SeekFrom::Start(0))
3724 .unwrap();
3725 let mut req_result = {
3726 let client = &self.hub.client;
3727 dlg.pre_request();
3728 let mut req_builder = hyper::Request::builder()
3729 .method(hyper::Method::POST)
3730 .uri(url.as_str())
3731 .header(USER_AGENT, self.hub._user_agent.clone());
3732
3733 if let Some(token) = token.as_ref() {
3734 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3735 }
3736
3737 let request = req_builder
3738 .header(CONTENT_TYPE, json_mime_type.to_string())
3739 .header(CONTENT_LENGTH, request_size as u64)
3740 .body(common::to_body(
3741 request_value_reader.get_ref().clone().into(),
3742 ));
3743
3744 client.request(request.unwrap()).await
3745 };
3746
3747 match req_result {
3748 Err(err) => {
3749 if let common::Retry::After(d) = dlg.http_error(&err) {
3750 sleep(d).await;
3751 continue;
3752 }
3753 dlg.finished(false);
3754 return Err(common::Error::HttpError(err));
3755 }
3756 Ok(res) => {
3757 let (mut parts, body) = res.into_parts();
3758 let mut body = common::Body::new(body);
3759 if !parts.status.is_success() {
3760 let bytes = common::to_bytes(body).await.unwrap_or_default();
3761 let error = serde_json::from_str(&common::to_string(&bytes));
3762 let response = common::to_response(parts, bytes.into());
3763
3764 if let common::Retry::After(d) =
3765 dlg.http_failure(&response, error.as_ref().ok())
3766 {
3767 sleep(d).await;
3768 continue;
3769 }
3770
3771 dlg.finished(false);
3772
3773 return Err(match error {
3774 Ok(value) => common::Error::BadRequest(value),
3775 _ => common::Error::Failure(response),
3776 });
3777 }
3778 let response = {
3779 let bytes = common::to_bytes(body).await.unwrap_or_default();
3780 let encoded = common::to_string(&bytes);
3781 match serde_json::from_str(&encoded) {
3782 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3783 Err(error) => {
3784 dlg.response_json_decode_error(&encoded, &error);
3785 return Err(common::Error::JsonDecodeError(
3786 encoded.to_string(),
3787 error,
3788 ));
3789 }
3790 }
3791 };
3792
3793 dlg.finished(true);
3794 return Ok(response);
3795 }
3796 }
3797 }
3798 }
3799
3800 ///
3801 /// Sets the *request* property to the given value.
3802 ///
3803 /// Even though the property as already been set when instantiating this call,
3804 /// we provide this method for API completeness.
3805 pub fn request(mut self, new_value: CommitRequest) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3806 self._request = new_value;
3807 self
3808 }
3809 /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
3810 ///
3811 /// Sets the *database* path property to the given value.
3812 ///
3813 /// Even though the property as already been set when instantiating this call,
3814 /// we provide this method for API completeness.
3815 pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3816 self._database = new_value.to_string();
3817 self
3818 }
3819 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3820 /// while executing the actual API request.
3821 ///
3822 /// ````text
3823 /// It should be used to handle progress information, and to implement a certain level of resilience.
3824 /// ````
3825 ///
3826 /// Sets the *delegate* property to the given value.
3827 pub fn delegate(
3828 mut self,
3829 new_value: &'a mut dyn common::Delegate,
3830 ) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3831 self._delegate = Some(new_value);
3832 self
3833 }
3834
3835 /// Set any additional parameter of the query string used in the request.
3836 /// It should be used to set parameters which are not yet available through their own
3837 /// setters.
3838 ///
3839 /// Please note that this method must not be used to set any of the known parameters
3840 /// which have their own setter method. If done anyway, the request will fail.
3841 ///
3842 /// # Additional Parameters
3843 ///
3844 /// * *$.xgafv* (query-string) - V1 error format.
3845 /// * *access_token* (query-string) - OAuth access token.
3846 /// * *alt* (query-string) - Data format for response.
3847 /// * *callback* (query-string) - JSONP
3848 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3849 /// * *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.
3850 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3851 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3852 /// * *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.
3853 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3854 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3855 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentCommitCall<'a, C>
3856 where
3857 T: AsRef<str>,
3858 {
3859 self._additional_params
3860 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3861 self
3862 }
3863
3864 /// Identifies the authorization scope for the method you are building.
3865 ///
3866 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3867 /// [`Scope::CloudPlatform`].
3868 ///
3869 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3870 /// tokens for more than one scope.
3871 ///
3872 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3873 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3874 /// sufficient, a read-write scope will do as well.
3875 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentCommitCall<'a, C>
3876 where
3877 St: AsRef<str>,
3878 {
3879 self._scopes.insert(String::from(scope.as_ref()));
3880 self
3881 }
3882 /// Identifies the authorization scope(s) for the method you are building.
3883 ///
3884 /// See [`Self::add_scope()`] for details.
3885 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentCommitCall<'a, C>
3886 where
3887 I: IntoIterator<Item = St>,
3888 St: AsRef<str>,
3889 {
3890 self._scopes
3891 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3892 self
3893 }
3894
3895 /// Removes all scopes, and no default scope will be used either.
3896 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3897 /// for details).
3898 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentCommitCall<'a, C> {
3899 self._scopes.clear();
3900 self
3901 }
3902}
3903
3904/// Creates a new document.
3905///
3906/// A builder for the *databases.documents.createDocument* method supported by a *project* resource.
3907/// It is not used directly, but through a [`ProjectMethods`] instance.
3908///
3909/// # Example
3910///
3911/// Instantiate a resource method builder
3912///
3913/// ```test_harness,no_run
3914/// # extern crate hyper;
3915/// # extern crate hyper_rustls;
3916/// # extern crate google_firestore1_beta1 as firestore1_beta1;
3917/// use firestore1_beta1::api::Document;
3918/// # async fn dox() {
3919/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3920///
3921/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3922/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3923/// # .with_native_roots()
3924/// # .unwrap()
3925/// # .https_only()
3926/// # .enable_http2()
3927/// # .build();
3928///
3929/// # let executor = hyper_util::rt::TokioExecutor::new();
3930/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3931/// # secret,
3932/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3933/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3934/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3935/// # ),
3936/// # ).build().await.unwrap();
3937///
3938/// # let client = hyper_util::client::legacy::Client::builder(
3939/// # hyper_util::rt::TokioExecutor::new()
3940/// # )
3941/// # .build(
3942/// # hyper_rustls::HttpsConnectorBuilder::new()
3943/// # .with_native_roots()
3944/// # .unwrap()
3945/// # .https_or_http()
3946/// # .enable_http2()
3947/// # .build()
3948/// # );
3949/// # let mut hub = Firestore::new(client, auth);
3950/// // As the method needs a request, you would usually fill it with the desired information
3951/// // into the respective structure. Some of the parts shown here might not be applicable !
3952/// // Values shown here are possibly random and not representative !
3953/// let mut req = Document::default();
3954///
3955/// // You can configure optional parameters by calling the respective setters at will, and
3956/// // execute the final call using `doit()`.
3957/// // Values shown here are possibly random and not representative !
3958/// let result = hub.projects().databases_documents_create_document(req, "parent", "collectionId")
3959/// .add_mask_field_paths("takimata")
3960/// .document_id("amet.")
3961/// .doit().await;
3962/// # }
3963/// ```
3964pub struct ProjectDatabaseDocumentCreateDocumentCall<'a, C>
3965where
3966 C: 'a,
3967{
3968 hub: &'a Firestore<C>,
3969 _request: Document,
3970 _parent: String,
3971 _collection_id: String,
3972 _mask_field_paths: Vec<String>,
3973 _document_id: Option<String>,
3974 _delegate: Option<&'a mut dyn common::Delegate>,
3975 _additional_params: HashMap<String, String>,
3976 _scopes: BTreeSet<String>,
3977}
3978
3979impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentCreateDocumentCall<'a, C> {}
3980
3981impl<'a, C> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
3982where
3983 C: common::Connector,
3984{
3985 /// Perform the operation you have build so far.
3986 pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
3987 use std::borrow::Cow;
3988 use std::io::{Read, Seek};
3989
3990 use common::{url::Params, ToParts};
3991 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3992
3993 let mut dd = common::DefaultDelegate;
3994 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3995 dlg.begin(common::MethodInfo {
3996 id: "firestore.projects.databases.documents.createDocument",
3997 http_method: hyper::Method::POST,
3998 });
3999
4000 for &field in [
4001 "alt",
4002 "parent",
4003 "collectionId",
4004 "mask.fieldPaths",
4005 "documentId",
4006 ]
4007 .iter()
4008 {
4009 if self._additional_params.contains_key(field) {
4010 dlg.finished(false);
4011 return Err(common::Error::FieldClash(field));
4012 }
4013 }
4014
4015 let mut params = Params::with_capacity(7 + self._additional_params.len());
4016 params.push("parent", self._parent);
4017 params.push("collectionId", self._collection_id);
4018 if !self._mask_field_paths.is_empty() {
4019 for f in self._mask_field_paths.iter() {
4020 params.push("mask.fieldPaths", f);
4021 }
4022 }
4023 if let Some(value) = self._document_id.as_ref() {
4024 params.push("documentId", value);
4025 }
4026
4027 params.extend(self._additional_params.iter());
4028
4029 params.push("alt", "json");
4030 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/{collectionId}";
4031 if self._scopes.is_empty() {
4032 self._scopes
4033 .insert(Scope::CloudPlatform.as_ref().to_string());
4034 }
4035
4036 #[allow(clippy::single_element_loop)]
4037 for &(find_this, param_name) in
4038 [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
4039 {
4040 url = params.uri_replacement(url, param_name, find_this, true);
4041 }
4042 {
4043 let to_remove = ["collectionId", "parent"];
4044 params.remove_params(&to_remove);
4045 }
4046
4047 let url = params.parse_with_url(&url);
4048
4049 let mut json_mime_type = mime::APPLICATION_JSON;
4050 let mut request_value_reader = {
4051 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4052 common::remove_json_null_values(&mut value);
4053 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4054 serde_json::to_writer(&mut dst, &value).unwrap();
4055 dst
4056 };
4057 let request_size = request_value_reader
4058 .seek(std::io::SeekFrom::End(0))
4059 .unwrap();
4060 request_value_reader
4061 .seek(std::io::SeekFrom::Start(0))
4062 .unwrap();
4063
4064 loop {
4065 let token = match self
4066 .hub
4067 .auth
4068 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4069 .await
4070 {
4071 Ok(token) => token,
4072 Err(e) => match dlg.token(e) {
4073 Ok(token) => token,
4074 Err(e) => {
4075 dlg.finished(false);
4076 return Err(common::Error::MissingToken(e));
4077 }
4078 },
4079 };
4080 request_value_reader
4081 .seek(std::io::SeekFrom::Start(0))
4082 .unwrap();
4083 let mut req_result = {
4084 let client = &self.hub.client;
4085 dlg.pre_request();
4086 let mut req_builder = hyper::Request::builder()
4087 .method(hyper::Method::POST)
4088 .uri(url.as_str())
4089 .header(USER_AGENT, self.hub._user_agent.clone());
4090
4091 if let Some(token) = token.as_ref() {
4092 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4093 }
4094
4095 let request = req_builder
4096 .header(CONTENT_TYPE, json_mime_type.to_string())
4097 .header(CONTENT_LENGTH, request_size as u64)
4098 .body(common::to_body(
4099 request_value_reader.get_ref().clone().into(),
4100 ));
4101
4102 client.request(request.unwrap()).await
4103 };
4104
4105 match req_result {
4106 Err(err) => {
4107 if let common::Retry::After(d) = dlg.http_error(&err) {
4108 sleep(d).await;
4109 continue;
4110 }
4111 dlg.finished(false);
4112 return Err(common::Error::HttpError(err));
4113 }
4114 Ok(res) => {
4115 let (mut parts, body) = res.into_parts();
4116 let mut body = common::Body::new(body);
4117 if !parts.status.is_success() {
4118 let bytes = common::to_bytes(body).await.unwrap_or_default();
4119 let error = serde_json::from_str(&common::to_string(&bytes));
4120 let response = common::to_response(parts, bytes.into());
4121
4122 if let common::Retry::After(d) =
4123 dlg.http_failure(&response, error.as_ref().ok())
4124 {
4125 sleep(d).await;
4126 continue;
4127 }
4128
4129 dlg.finished(false);
4130
4131 return Err(match error {
4132 Ok(value) => common::Error::BadRequest(value),
4133 _ => common::Error::Failure(response),
4134 });
4135 }
4136 let response = {
4137 let bytes = common::to_bytes(body).await.unwrap_or_default();
4138 let encoded = common::to_string(&bytes);
4139 match serde_json::from_str(&encoded) {
4140 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4141 Err(error) => {
4142 dlg.response_json_decode_error(&encoded, &error);
4143 return Err(common::Error::JsonDecodeError(
4144 encoded.to_string(),
4145 error,
4146 ));
4147 }
4148 }
4149 };
4150
4151 dlg.finished(true);
4152 return Ok(response);
4153 }
4154 }
4155 }
4156 }
4157
4158 ///
4159 /// Sets the *request* property to the given value.
4160 ///
4161 /// Even though the property as already been set when instantiating this call,
4162 /// we provide this method for API completeness.
4163 pub fn request(
4164 mut self,
4165 new_value: Document,
4166 ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
4167 self._request = new_value;
4168 self
4169 }
4170 /// Required. The parent resource. For example: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
4171 ///
4172 /// Sets the *parent* path property to the given value.
4173 ///
4174 /// Even though the property as already been set when instantiating this call,
4175 /// we provide this method for API completeness.
4176 pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
4177 self._parent = new_value.to_string();
4178 self
4179 }
4180 /// Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`.
4181 ///
4182 /// Sets the *collection id* path property to the given value.
4183 ///
4184 /// Even though the property as already been set when instantiating this call,
4185 /// we provide this method for API completeness.
4186 pub fn collection_id(
4187 mut self,
4188 new_value: &str,
4189 ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
4190 self._collection_id = new_value.to_string();
4191 self
4192 }
4193 /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
4194 ///
4195 /// Append the given value to the *mask.field paths* query property.
4196 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4197 pub fn add_mask_field_paths(
4198 mut self,
4199 new_value: &str,
4200 ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
4201 self._mask_field_paths.push(new_value.to_string());
4202 self
4203 }
4204 /// The client-assigned document ID to use for this document. Optional. If not specified, an ID will be assigned by the service.
4205 ///
4206 /// Sets the *document id* query property to the given value.
4207 pub fn document_id(
4208 mut self,
4209 new_value: &str,
4210 ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
4211 self._document_id = Some(new_value.to_string());
4212 self
4213 }
4214 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4215 /// while executing the actual API request.
4216 ///
4217 /// ````text
4218 /// It should be used to handle progress information, and to implement a certain level of resilience.
4219 /// ````
4220 ///
4221 /// Sets the *delegate* property to the given value.
4222 pub fn delegate(
4223 mut self,
4224 new_value: &'a mut dyn common::Delegate,
4225 ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
4226 self._delegate = Some(new_value);
4227 self
4228 }
4229
4230 /// Set any additional parameter of the query string used in the request.
4231 /// It should be used to set parameters which are not yet available through their own
4232 /// setters.
4233 ///
4234 /// Please note that this method must not be used to set any of the known parameters
4235 /// which have their own setter method. If done anyway, the request will fail.
4236 ///
4237 /// # Additional Parameters
4238 ///
4239 /// * *$.xgafv* (query-string) - V1 error format.
4240 /// * *access_token* (query-string) - OAuth access token.
4241 /// * *alt* (query-string) - Data format for response.
4242 /// * *callback* (query-string) - JSONP
4243 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4244 /// * *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.
4245 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4246 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4247 /// * *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.
4248 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4249 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4250 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
4251 where
4252 T: AsRef<str>,
4253 {
4254 self._additional_params
4255 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4256 self
4257 }
4258
4259 /// Identifies the authorization scope for the method you are building.
4260 ///
4261 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4262 /// [`Scope::CloudPlatform`].
4263 ///
4264 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4265 /// tokens for more than one scope.
4266 ///
4267 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4268 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4269 /// sufficient, a read-write scope will do as well.
4270 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
4271 where
4272 St: AsRef<str>,
4273 {
4274 self._scopes.insert(String::from(scope.as_ref()));
4275 self
4276 }
4277 /// Identifies the authorization scope(s) for the method you are building.
4278 ///
4279 /// See [`Self::add_scope()`] for details.
4280 pub fn add_scopes<I, St>(
4281 mut self,
4282 scopes: I,
4283 ) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C>
4284 where
4285 I: IntoIterator<Item = St>,
4286 St: AsRef<str>,
4287 {
4288 self._scopes
4289 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4290 self
4291 }
4292
4293 /// Removes all scopes, and no default scope will be used either.
4294 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4295 /// for details).
4296 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentCreateDocumentCall<'a, C> {
4297 self._scopes.clear();
4298 self
4299 }
4300}
4301
4302/// Deletes a document.
4303///
4304/// A builder for the *databases.documents.delete* method supported by a *project* resource.
4305/// It is not used directly, but through a [`ProjectMethods`] instance.
4306///
4307/// # Example
4308///
4309/// Instantiate a resource method builder
4310///
4311/// ```test_harness,no_run
4312/// # extern crate hyper;
4313/// # extern crate hyper_rustls;
4314/// # extern crate google_firestore1_beta1 as firestore1_beta1;
4315/// # async fn dox() {
4316/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4317///
4318/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4319/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4320/// # .with_native_roots()
4321/// # .unwrap()
4322/// # .https_only()
4323/// # .enable_http2()
4324/// # .build();
4325///
4326/// # let executor = hyper_util::rt::TokioExecutor::new();
4327/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4328/// # secret,
4329/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4330/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4331/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4332/// # ),
4333/// # ).build().await.unwrap();
4334///
4335/// # let client = hyper_util::client::legacy::Client::builder(
4336/// # hyper_util::rt::TokioExecutor::new()
4337/// # )
4338/// # .build(
4339/// # hyper_rustls::HttpsConnectorBuilder::new()
4340/// # .with_native_roots()
4341/// # .unwrap()
4342/// # .https_or_http()
4343/// # .enable_http2()
4344/// # .build()
4345/// # );
4346/// # let mut hub = Firestore::new(client, auth);
4347/// // You can configure optional parameters by calling the respective setters at will, and
4348/// // execute the final call using `doit()`.
4349/// // Values shown here are possibly random and not representative !
4350/// let result = hub.projects().databases_documents_delete("name")
4351/// .current_document_update_time(chrono::Utc::now())
4352/// .current_document_exists(true)
4353/// .doit().await;
4354/// # }
4355/// ```
4356pub struct ProjectDatabaseDocumentDeleteCall<'a, C>
4357where
4358 C: 'a,
4359{
4360 hub: &'a Firestore<C>,
4361 _name: String,
4362 _current_document_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
4363 _current_document_exists: Option<bool>,
4364 _delegate: Option<&'a mut dyn common::Delegate>,
4365 _additional_params: HashMap<String, String>,
4366 _scopes: BTreeSet<String>,
4367}
4368
4369impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentDeleteCall<'a, C> {}
4370
4371impl<'a, C> ProjectDatabaseDocumentDeleteCall<'a, C>
4372where
4373 C: common::Connector,
4374{
4375 /// Perform the operation you have build so far.
4376 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4377 use std::borrow::Cow;
4378 use std::io::{Read, Seek};
4379
4380 use common::{url::Params, ToParts};
4381 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4382
4383 let mut dd = common::DefaultDelegate;
4384 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4385 dlg.begin(common::MethodInfo {
4386 id: "firestore.projects.databases.documents.delete",
4387 http_method: hyper::Method::DELETE,
4388 });
4389
4390 for &field in [
4391 "alt",
4392 "name",
4393 "currentDocument.updateTime",
4394 "currentDocument.exists",
4395 ]
4396 .iter()
4397 {
4398 if self._additional_params.contains_key(field) {
4399 dlg.finished(false);
4400 return Err(common::Error::FieldClash(field));
4401 }
4402 }
4403
4404 let mut params = Params::with_capacity(5 + self._additional_params.len());
4405 params.push("name", self._name);
4406 if let Some(value) = self._current_document_update_time.as_ref() {
4407 params.push(
4408 "currentDocument.updateTime",
4409 common::serde::datetime_to_string(&value),
4410 );
4411 }
4412 if let Some(value) = self._current_document_exists.as_ref() {
4413 params.push("currentDocument.exists", value.to_string());
4414 }
4415
4416 params.extend(self._additional_params.iter());
4417
4418 params.push("alt", "json");
4419 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4420 if self._scopes.is_empty() {
4421 self._scopes
4422 .insert(Scope::CloudPlatform.as_ref().to_string());
4423 }
4424
4425 #[allow(clippy::single_element_loop)]
4426 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4427 url = params.uri_replacement(url, param_name, find_this, true);
4428 }
4429 {
4430 let to_remove = ["name"];
4431 params.remove_params(&to_remove);
4432 }
4433
4434 let url = params.parse_with_url(&url);
4435
4436 loop {
4437 let token = match self
4438 .hub
4439 .auth
4440 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4441 .await
4442 {
4443 Ok(token) => token,
4444 Err(e) => match dlg.token(e) {
4445 Ok(token) => token,
4446 Err(e) => {
4447 dlg.finished(false);
4448 return Err(common::Error::MissingToken(e));
4449 }
4450 },
4451 };
4452 let mut req_result = {
4453 let client = &self.hub.client;
4454 dlg.pre_request();
4455 let mut req_builder = hyper::Request::builder()
4456 .method(hyper::Method::DELETE)
4457 .uri(url.as_str())
4458 .header(USER_AGENT, self.hub._user_agent.clone());
4459
4460 if let Some(token) = token.as_ref() {
4461 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4462 }
4463
4464 let request = req_builder
4465 .header(CONTENT_LENGTH, 0_u64)
4466 .body(common::to_body::<String>(None));
4467
4468 client.request(request.unwrap()).await
4469 };
4470
4471 match req_result {
4472 Err(err) => {
4473 if let common::Retry::After(d) = dlg.http_error(&err) {
4474 sleep(d).await;
4475 continue;
4476 }
4477 dlg.finished(false);
4478 return Err(common::Error::HttpError(err));
4479 }
4480 Ok(res) => {
4481 let (mut parts, body) = res.into_parts();
4482 let mut body = common::Body::new(body);
4483 if !parts.status.is_success() {
4484 let bytes = common::to_bytes(body).await.unwrap_or_default();
4485 let error = serde_json::from_str(&common::to_string(&bytes));
4486 let response = common::to_response(parts, bytes.into());
4487
4488 if let common::Retry::After(d) =
4489 dlg.http_failure(&response, error.as_ref().ok())
4490 {
4491 sleep(d).await;
4492 continue;
4493 }
4494
4495 dlg.finished(false);
4496
4497 return Err(match error {
4498 Ok(value) => common::Error::BadRequest(value),
4499 _ => common::Error::Failure(response),
4500 });
4501 }
4502 let response = {
4503 let bytes = common::to_bytes(body).await.unwrap_or_default();
4504 let encoded = common::to_string(&bytes);
4505 match serde_json::from_str(&encoded) {
4506 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4507 Err(error) => {
4508 dlg.response_json_decode_error(&encoded, &error);
4509 return Err(common::Error::JsonDecodeError(
4510 encoded.to_string(),
4511 error,
4512 ));
4513 }
4514 }
4515 };
4516
4517 dlg.finished(true);
4518 return Ok(response);
4519 }
4520 }
4521 }
4522 }
4523
4524 /// Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
4525 ///
4526 /// Sets the *name* path property to the given value.
4527 ///
4528 /// Even though the property as already been set when instantiating this call,
4529 /// we provide this method for API completeness.
4530 pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4531 self._name = new_value.to_string();
4532 self
4533 }
4534 /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
4535 ///
4536 /// Sets the *current document.update time* query property to the given value.
4537 pub fn current_document_update_time(
4538 mut self,
4539 new_value: chrono::DateTime<chrono::offset::Utc>,
4540 ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4541 self._current_document_update_time = Some(new_value);
4542 self
4543 }
4544 /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
4545 ///
4546 /// Sets the *current document.exists* query property to the given value.
4547 pub fn current_document_exists(
4548 mut self,
4549 new_value: bool,
4550 ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4551 self._current_document_exists = Some(new_value);
4552 self
4553 }
4554 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4555 /// while executing the actual API request.
4556 ///
4557 /// ````text
4558 /// It should be used to handle progress information, and to implement a certain level of resilience.
4559 /// ````
4560 ///
4561 /// Sets the *delegate* property to the given value.
4562 pub fn delegate(
4563 mut self,
4564 new_value: &'a mut dyn common::Delegate,
4565 ) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4566 self._delegate = Some(new_value);
4567 self
4568 }
4569
4570 /// Set any additional parameter of the query string used in the request.
4571 /// It should be used to set parameters which are not yet available through their own
4572 /// setters.
4573 ///
4574 /// Please note that this method must not be used to set any of the known parameters
4575 /// which have their own setter method. If done anyway, the request will fail.
4576 ///
4577 /// # Additional Parameters
4578 ///
4579 /// * *$.xgafv* (query-string) - V1 error format.
4580 /// * *access_token* (query-string) - OAuth access token.
4581 /// * *alt* (query-string) - Data format for response.
4582 /// * *callback* (query-string) - JSONP
4583 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4584 /// * *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.
4585 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4586 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4587 /// * *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.
4588 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4589 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4590 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentDeleteCall<'a, C>
4591 where
4592 T: AsRef<str>,
4593 {
4594 self._additional_params
4595 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4596 self
4597 }
4598
4599 /// Identifies the authorization scope for the method you are building.
4600 ///
4601 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4602 /// [`Scope::CloudPlatform`].
4603 ///
4604 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4605 /// tokens for more than one scope.
4606 ///
4607 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4608 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4609 /// sufficient, a read-write scope will do as well.
4610 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentDeleteCall<'a, C>
4611 where
4612 St: AsRef<str>,
4613 {
4614 self._scopes.insert(String::from(scope.as_ref()));
4615 self
4616 }
4617 /// Identifies the authorization scope(s) for the method you are building.
4618 ///
4619 /// See [`Self::add_scope()`] for details.
4620 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentDeleteCall<'a, C>
4621 where
4622 I: IntoIterator<Item = St>,
4623 St: AsRef<str>,
4624 {
4625 self._scopes
4626 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4627 self
4628 }
4629
4630 /// Removes all scopes, and no default scope will be used either.
4631 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4632 /// for details).
4633 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentDeleteCall<'a, C> {
4634 self._scopes.clear();
4635 self
4636 }
4637}
4638
4639/// Executes a pipeline query.
4640///
4641/// A builder for the *databases.documents.executePipeline* method supported by a *project* resource.
4642/// It is not used directly, but through a [`ProjectMethods`] instance.
4643///
4644/// # Example
4645///
4646/// Instantiate a resource method builder
4647///
4648/// ```test_harness,no_run
4649/// # extern crate hyper;
4650/// # extern crate hyper_rustls;
4651/// # extern crate google_firestore1_beta1 as firestore1_beta1;
4652/// use firestore1_beta1::api::ExecutePipelineRequest;
4653/// # async fn dox() {
4654/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4655///
4656/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4657/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4658/// # .with_native_roots()
4659/// # .unwrap()
4660/// # .https_only()
4661/// # .enable_http2()
4662/// # .build();
4663///
4664/// # let executor = hyper_util::rt::TokioExecutor::new();
4665/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4666/// # secret,
4667/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4668/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4669/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4670/// # ),
4671/// # ).build().await.unwrap();
4672///
4673/// # let client = hyper_util::client::legacy::Client::builder(
4674/// # hyper_util::rt::TokioExecutor::new()
4675/// # )
4676/// # .build(
4677/// # hyper_rustls::HttpsConnectorBuilder::new()
4678/// # .with_native_roots()
4679/// # .unwrap()
4680/// # .https_or_http()
4681/// # .enable_http2()
4682/// # .build()
4683/// # );
4684/// # let mut hub = Firestore::new(client, auth);
4685/// // As the method needs a request, you would usually fill it with the desired information
4686/// // into the respective structure. Some of the parts shown here might not be applicable !
4687/// // Values shown here are possibly random and not representative !
4688/// let mut req = ExecutePipelineRequest::default();
4689///
4690/// // You can configure optional parameters by calling the respective setters at will, and
4691/// // execute the final call using `doit()`.
4692/// // Values shown here are possibly random and not representative !
4693/// let result = hub.projects().databases_documents_execute_pipeline(req, "database")
4694/// .doit().await;
4695/// # }
4696/// ```
4697pub struct ProjectDatabaseDocumentExecutePipelineCall<'a, C>
4698where
4699 C: 'a,
4700{
4701 hub: &'a Firestore<C>,
4702 _request: ExecutePipelineRequest,
4703 _database: String,
4704 _delegate: Option<&'a mut dyn common::Delegate>,
4705 _additional_params: HashMap<String, String>,
4706 _scopes: BTreeSet<String>,
4707}
4708
4709impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentExecutePipelineCall<'a, C> {}
4710
4711impl<'a, C> ProjectDatabaseDocumentExecutePipelineCall<'a, C>
4712where
4713 C: common::Connector,
4714{
4715 /// Perform the operation you have build so far.
4716 pub async fn doit(mut self) -> common::Result<(common::Response, ExecutePipelineResponse)> {
4717 use std::borrow::Cow;
4718 use std::io::{Read, Seek};
4719
4720 use common::{url::Params, ToParts};
4721 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4722
4723 let mut dd = common::DefaultDelegate;
4724 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4725 dlg.begin(common::MethodInfo {
4726 id: "firestore.projects.databases.documents.executePipeline",
4727 http_method: hyper::Method::POST,
4728 });
4729
4730 for &field in ["alt", "database"].iter() {
4731 if self._additional_params.contains_key(field) {
4732 dlg.finished(false);
4733 return Err(common::Error::FieldClash(field));
4734 }
4735 }
4736
4737 let mut params = Params::with_capacity(4 + self._additional_params.len());
4738 params.push("database", self._database);
4739
4740 params.extend(self._additional_params.iter());
4741
4742 params.push("alt", "json");
4743 let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:executePipeline";
4744 if self._scopes.is_empty() {
4745 self._scopes
4746 .insert(Scope::CloudPlatform.as_ref().to_string());
4747 }
4748
4749 #[allow(clippy::single_element_loop)]
4750 for &(find_this, param_name) in [("{+database}", "database")].iter() {
4751 url = params.uri_replacement(url, param_name, find_this, true);
4752 }
4753 {
4754 let to_remove = ["database"];
4755 params.remove_params(&to_remove);
4756 }
4757
4758 let url = params.parse_with_url(&url);
4759
4760 let mut json_mime_type = mime::APPLICATION_JSON;
4761 let mut request_value_reader = {
4762 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4763 common::remove_json_null_values(&mut value);
4764 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4765 serde_json::to_writer(&mut dst, &value).unwrap();
4766 dst
4767 };
4768 let request_size = request_value_reader
4769 .seek(std::io::SeekFrom::End(0))
4770 .unwrap();
4771 request_value_reader
4772 .seek(std::io::SeekFrom::Start(0))
4773 .unwrap();
4774
4775 loop {
4776 let token = match self
4777 .hub
4778 .auth
4779 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4780 .await
4781 {
4782 Ok(token) => token,
4783 Err(e) => match dlg.token(e) {
4784 Ok(token) => token,
4785 Err(e) => {
4786 dlg.finished(false);
4787 return Err(common::Error::MissingToken(e));
4788 }
4789 },
4790 };
4791 request_value_reader
4792 .seek(std::io::SeekFrom::Start(0))
4793 .unwrap();
4794 let mut req_result = {
4795 let client = &self.hub.client;
4796 dlg.pre_request();
4797 let mut req_builder = hyper::Request::builder()
4798 .method(hyper::Method::POST)
4799 .uri(url.as_str())
4800 .header(USER_AGENT, self.hub._user_agent.clone());
4801
4802 if let Some(token) = token.as_ref() {
4803 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4804 }
4805
4806 let request = req_builder
4807 .header(CONTENT_TYPE, json_mime_type.to_string())
4808 .header(CONTENT_LENGTH, request_size as u64)
4809 .body(common::to_body(
4810 request_value_reader.get_ref().clone().into(),
4811 ));
4812
4813 client.request(request.unwrap()).await
4814 };
4815
4816 match req_result {
4817 Err(err) => {
4818 if let common::Retry::After(d) = dlg.http_error(&err) {
4819 sleep(d).await;
4820 continue;
4821 }
4822 dlg.finished(false);
4823 return Err(common::Error::HttpError(err));
4824 }
4825 Ok(res) => {
4826 let (mut parts, body) = res.into_parts();
4827 let mut body = common::Body::new(body);
4828 if !parts.status.is_success() {
4829 let bytes = common::to_bytes(body).await.unwrap_or_default();
4830 let error = serde_json::from_str(&common::to_string(&bytes));
4831 let response = common::to_response(parts, bytes.into());
4832
4833 if let common::Retry::After(d) =
4834 dlg.http_failure(&response, error.as_ref().ok())
4835 {
4836 sleep(d).await;
4837 continue;
4838 }
4839
4840 dlg.finished(false);
4841
4842 return Err(match error {
4843 Ok(value) => common::Error::BadRequest(value),
4844 _ => common::Error::Failure(response),
4845 });
4846 }
4847 let response = {
4848 let bytes = common::to_bytes(body).await.unwrap_or_default();
4849 let encoded = common::to_string(&bytes);
4850 match serde_json::from_str(&encoded) {
4851 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4852 Err(error) => {
4853 dlg.response_json_decode_error(&encoded, &error);
4854 return Err(common::Error::JsonDecodeError(
4855 encoded.to_string(),
4856 error,
4857 ));
4858 }
4859 }
4860 };
4861
4862 dlg.finished(true);
4863 return Ok(response);
4864 }
4865 }
4866 }
4867 }
4868
4869 ///
4870 /// Sets the *request* property to the given value.
4871 ///
4872 /// Even though the property as already been set when instantiating this call,
4873 /// we provide this method for API completeness.
4874 pub fn request(
4875 mut self,
4876 new_value: ExecutePipelineRequest,
4877 ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
4878 self._request = new_value;
4879 self
4880 }
4881 /// Required. Database identifier, in the form `projects/{project}/databases/{database}`.
4882 ///
4883 /// Sets the *database* path property to the given value.
4884 ///
4885 /// Even though the property as already been set when instantiating this call,
4886 /// we provide this method for API completeness.
4887 pub fn database(
4888 mut self,
4889 new_value: &str,
4890 ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
4891 self._database = new_value.to_string();
4892 self
4893 }
4894 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4895 /// while executing the actual API request.
4896 ///
4897 /// ````text
4898 /// It should be used to handle progress information, and to implement a certain level of resilience.
4899 /// ````
4900 ///
4901 /// Sets the *delegate* property to the given value.
4902 pub fn delegate(
4903 mut self,
4904 new_value: &'a mut dyn common::Delegate,
4905 ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
4906 self._delegate = Some(new_value);
4907 self
4908 }
4909
4910 /// Set any additional parameter of the query string used in the request.
4911 /// It should be used to set parameters which are not yet available through their own
4912 /// setters.
4913 ///
4914 /// Please note that this method must not be used to set any of the known parameters
4915 /// which have their own setter method. If done anyway, the request will fail.
4916 ///
4917 /// # Additional Parameters
4918 ///
4919 /// * *$.xgafv* (query-string) - V1 error format.
4920 /// * *access_token* (query-string) - OAuth access token.
4921 /// * *alt* (query-string) - Data format for response.
4922 /// * *callback* (query-string) - JSONP
4923 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4924 /// * *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.
4925 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4926 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4927 /// * *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.
4928 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4929 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4930 pub fn param<T>(
4931 mut self,
4932 name: T,
4933 value: T,
4934 ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C>
4935 where
4936 T: AsRef<str>,
4937 {
4938 self._additional_params
4939 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4940 self
4941 }
4942
4943 /// Identifies the authorization scope for the method you are building.
4944 ///
4945 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4946 /// [`Scope::CloudPlatform`].
4947 ///
4948 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4949 /// tokens for more than one scope.
4950 ///
4951 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4952 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4953 /// sufficient, a read-write scope will do as well.
4954 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C>
4955 where
4956 St: AsRef<str>,
4957 {
4958 self._scopes.insert(String::from(scope.as_ref()));
4959 self
4960 }
4961 /// Identifies the authorization scope(s) for the method you are building.
4962 ///
4963 /// See [`Self::add_scope()`] for details.
4964 pub fn add_scopes<I, St>(
4965 mut self,
4966 scopes: I,
4967 ) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C>
4968 where
4969 I: IntoIterator<Item = St>,
4970 St: AsRef<str>,
4971 {
4972 self._scopes
4973 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4974 self
4975 }
4976
4977 /// Removes all scopes, and no default scope will be used either.
4978 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4979 /// for details).
4980 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentExecutePipelineCall<'a, C> {
4981 self._scopes.clear();
4982 self
4983 }
4984}
4985
4986/// Gets a single document.
4987///
4988/// A builder for the *databases.documents.get* method supported by a *project* resource.
4989/// It is not used directly, but through a [`ProjectMethods`] instance.
4990///
4991/// # Example
4992///
4993/// Instantiate a resource method builder
4994///
4995/// ```test_harness,no_run
4996/// # extern crate hyper;
4997/// # extern crate hyper_rustls;
4998/// # extern crate google_firestore1_beta1 as firestore1_beta1;
4999/// # async fn dox() {
5000/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5001///
5002/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5003/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5004/// # .with_native_roots()
5005/// # .unwrap()
5006/// # .https_only()
5007/// # .enable_http2()
5008/// # .build();
5009///
5010/// # let executor = hyper_util::rt::TokioExecutor::new();
5011/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5012/// # secret,
5013/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5014/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5015/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5016/// # ),
5017/// # ).build().await.unwrap();
5018///
5019/// # let client = hyper_util::client::legacy::Client::builder(
5020/// # hyper_util::rt::TokioExecutor::new()
5021/// # )
5022/// # .build(
5023/// # hyper_rustls::HttpsConnectorBuilder::new()
5024/// # .with_native_roots()
5025/// # .unwrap()
5026/// # .https_or_http()
5027/// # .enable_http2()
5028/// # .build()
5029/// # );
5030/// # let mut hub = Firestore::new(client, auth);
5031/// // You can configure optional parameters by calling the respective setters at will, and
5032/// // execute the final call using `doit()`.
5033/// // Values shown here are possibly random and not representative !
5034/// let result = hub.projects().databases_documents_get("name")
5035/// .transaction(vec![0, 1, 2, 3])
5036/// .read_time(chrono::Utc::now())
5037/// .add_mask_field_paths("gubergren")
5038/// .doit().await;
5039/// # }
5040/// ```
5041pub struct ProjectDatabaseDocumentGetCall<'a, C>
5042where
5043 C: 'a,
5044{
5045 hub: &'a Firestore<C>,
5046 _name: String,
5047 _transaction: Option<Vec<u8>>,
5048 _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
5049 _mask_field_paths: Vec<String>,
5050 _delegate: Option<&'a mut dyn common::Delegate>,
5051 _additional_params: HashMap<String, String>,
5052 _scopes: BTreeSet<String>,
5053}
5054
5055impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentGetCall<'a, C> {}
5056
5057impl<'a, C> ProjectDatabaseDocumentGetCall<'a, C>
5058where
5059 C: common::Connector,
5060{
5061 /// Perform the operation you have build so far.
5062 pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
5063 use std::borrow::Cow;
5064 use std::io::{Read, Seek};
5065
5066 use common::{url::Params, ToParts};
5067 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5068
5069 let mut dd = common::DefaultDelegate;
5070 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5071 dlg.begin(common::MethodInfo {
5072 id: "firestore.projects.databases.documents.get",
5073 http_method: hyper::Method::GET,
5074 });
5075
5076 for &field in ["alt", "name", "transaction", "readTime", "mask.fieldPaths"].iter() {
5077 if self._additional_params.contains_key(field) {
5078 dlg.finished(false);
5079 return Err(common::Error::FieldClash(field));
5080 }
5081 }
5082
5083 let mut params = Params::with_capacity(6 + self._additional_params.len());
5084 params.push("name", self._name);
5085 if let Some(value) = self._transaction.as_ref() {
5086 params.push(
5087 "transaction",
5088 common::serde::standard_base64::to_string(&value),
5089 );
5090 }
5091 if let Some(value) = self._read_time.as_ref() {
5092 params.push("readTime", common::serde::datetime_to_string(&value));
5093 }
5094 if !self._mask_field_paths.is_empty() {
5095 for f in self._mask_field_paths.iter() {
5096 params.push("mask.fieldPaths", f);
5097 }
5098 }
5099
5100 params.extend(self._additional_params.iter());
5101
5102 params.push("alt", "json");
5103 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
5104 if self._scopes.is_empty() {
5105 self._scopes
5106 .insert(Scope::CloudPlatform.as_ref().to_string());
5107 }
5108
5109 #[allow(clippy::single_element_loop)]
5110 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5111 url = params.uri_replacement(url, param_name, find_this, true);
5112 }
5113 {
5114 let to_remove = ["name"];
5115 params.remove_params(&to_remove);
5116 }
5117
5118 let url = params.parse_with_url(&url);
5119
5120 loop {
5121 let token = match self
5122 .hub
5123 .auth
5124 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5125 .await
5126 {
5127 Ok(token) => token,
5128 Err(e) => match dlg.token(e) {
5129 Ok(token) => token,
5130 Err(e) => {
5131 dlg.finished(false);
5132 return Err(common::Error::MissingToken(e));
5133 }
5134 },
5135 };
5136 let mut req_result = {
5137 let client = &self.hub.client;
5138 dlg.pre_request();
5139 let mut req_builder = hyper::Request::builder()
5140 .method(hyper::Method::GET)
5141 .uri(url.as_str())
5142 .header(USER_AGENT, self.hub._user_agent.clone());
5143
5144 if let Some(token) = token.as_ref() {
5145 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5146 }
5147
5148 let request = req_builder
5149 .header(CONTENT_LENGTH, 0_u64)
5150 .body(common::to_body::<String>(None));
5151
5152 client.request(request.unwrap()).await
5153 };
5154
5155 match req_result {
5156 Err(err) => {
5157 if let common::Retry::After(d) = dlg.http_error(&err) {
5158 sleep(d).await;
5159 continue;
5160 }
5161 dlg.finished(false);
5162 return Err(common::Error::HttpError(err));
5163 }
5164 Ok(res) => {
5165 let (mut parts, body) = res.into_parts();
5166 let mut body = common::Body::new(body);
5167 if !parts.status.is_success() {
5168 let bytes = common::to_bytes(body).await.unwrap_or_default();
5169 let error = serde_json::from_str(&common::to_string(&bytes));
5170 let response = common::to_response(parts, bytes.into());
5171
5172 if let common::Retry::After(d) =
5173 dlg.http_failure(&response, error.as_ref().ok())
5174 {
5175 sleep(d).await;
5176 continue;
5177 }
5178
5179 dlg.finished(false);
5180
5181 return Err(match error {
5182 Ok(value) => common::Error::BadRequest(value),
5183 _ => common::Error::Failure(response),
5184 });
5185 }
5186 let response = {
5187 let bytes = common::to_bytes(body).await.unwrap_or_default();
5188 let encoded = common::to_string(&bytes);
5189 match serde_json::from_str(&encoded) {
5190 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5191 Err(error) => {
5192 dlg.response_json_decode_error(&encoded, &error);
5193 return Err(common::Error::JsonDecodeError(
5194 encoded.to_string(),
5195 error,
5196 ));
5197 }
5198 }
5199 };
5200
5201 dlg.finished(true);
5202 return Ok(response);
5203 }
5204 }
5205 }
5206 }
5207
5208 /// Required. The resource name of the Document to get. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
5209 ///
5210 /// Sets the *name* path property to the given value.
5211 ///
5212 /// Even though the property as already been set when instantiating this call,
5213 /// we provide this method for API completeness.
5214 pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentGetCall<'a, C> {
5215 self._name = new_value.to_string();
5216 self
5217 }
5218 /// Reads the document in a transaction.
5219 ///
5220 /// Sets the *transaction* query property to the given value.
5221 pub fn transaction(mut self, new_value: Vec<u8>) -> ProjectDatabaseDocumentGetCall<'a, C> {
5222 self._transaction = Some(new_value);
5223 self
5224 }
5225 /// 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.
5226 ///
5227 /// Sets the *read time* query property to the given value.
5228 pub fn read_time(
5229 mut self,
5230 new_value: chrono::DateTime<chrono::offset::Utc>,
5231 ) -> ProjectDatabaseDocumentGetCall<'a, C> {
5232 self._read_time = Some(new_value);
5233 self
5234 }
5235 /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
5236 ///
5237 /// Append the given value to the *mask.field paths* query property.
5238 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5239 pub fn add_mask_field_paths(
5240 mut self,
5241 new_value: &str,
5242 ) -> ProjectDatabaseDocumentGetCall<'a, C> {
5243 self._mask_field_paths.push(new_value.to_string());
5244 self
5245 }
5246 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5247 /// while executing the actual API request.
5248 ///
5249 /// ````text
5250 /// It should be used to handle progress information, and to implement a certain level of resilience.
5251 /// ````
5252 ///
5253 /// Sets the *delegate* property to the given value.
5254 pub fn delegate(
5255 mut self,
5256 new_value: &'a mut dyn common::Delegate,
5257 ) -> ProjectDatabaseDocumentGetCall<'a, C> {
5258 self._delegate = Some(new_value);
5259 self
5260 }
5261
5262 /// Set any additional parameter of the query string used in the request.
5263 /// It should be used to set parameters which are not yet available through their own
5264 /// setters.
5265 ///
5266 /// Please note that this method must not be used to set any of the known parameters
5267 /// which have their own setter method. If done anyway, the request will fail.
5268 ///
5269 /// # Additional Parameters
5270 ///
5271 /// * *$.xgafv* (query-string) - V1 error format.
5272 /// * *access_token* (query-string) - OAuth access token.
5273 /// * *alt* (query-string) - Data format for response.
5274 /// * *callback* (query-string) - JSONP
5275 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5276 /// * *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.
5277 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5278 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5279 /// * *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.
5280 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5281 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5282 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentGetCall<'a, C>
5283 where
5284 T: AsRef<str>,
5285 {
5286 self._additional_params
5287 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5288 self
5289 }
5290
5291 /// Identifies the authorization scope for the method you are building.
5292 ///
5293 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5294 /// [`Scope::CloudPlatform`].
5295 ///
5296 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5297 /// tokens for more than one scope.
5298 ///
5299 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5300 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5301 /// sufficient, a read-write scope will do as well.
5302 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentGetCall<'a, C>
5303 where
5304 St: AsRef<str>,
5305 {
5306 self._scopes.insert(String::from(scope.as_ref()));
5307 self
5308 }
5309 /// Identifies the authorization scope(s) for the method you are building.
5310 ///
5311 /// See [`Self::add_scope()`] for details.
5312 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentGetCall<'a, C>
5313 where
5314 I: IntoIterator<Item = St>,
5315 St: AsRef<str>,
5316 {
5317 self._scopes
5318 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5319 self
5320 }
5321
5322 /// Removes all scopes, and no default scope will be used either.
5323 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5324 /// for details).
5325 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentGetCall<'a, C> {
5326 self._scopes.clear();
5327 self
5328 }
5329}
5330
5331/// Lists documents.
5332///
5333/// A builder for the *databases.documents.list* method supported by a *project* resource.
5334/// It is not used directly, but through a [`ProjectMethods`] instance.
5335///
5336/// # Example
5337///
5338/// Instantiate a resource method builder
5339///
5340/// ```test_harness,no_run
5341/// # extern crate hyper;
5342/// # extern crate hyper_rustls;
5343/// # extern crate google_firestore1_beta1 as firestore1_beta1;
5344/// # async fn dox() {
5345/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5346///
5347/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5348/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5349/// # .with_native_roots()
5350/// # .unwrap()
5351/// # .https_only()
5352/// # .enable_http2()
5353/// # .build();
5354///
5355/// # let executor = hyper_util::rt::TokioExecutor::new();
5356/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5357/// # secret,
5358/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5359/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5360/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5361/// # ),
5362/// # ).build().await.unwrap();
5363///
5364/// # let client = hyper_util::client::legacy::Client::builder(
5365/// # hyper_util::rt::TokioExecutor::new()
5366/// # )
5367/// # .build(
5368/// # hyper_rustls::HttpsConnectorBuilder::new()
5369/// # .with_native_roots()
5370/// # .unwrap()
5371/// # .https_or_http()
5372/// # .enable_http2()
5373/// # .build()
5374/// # );
5375/// # let mut hub = Firestore::new(client, auth);
5376/// // You can configure optional parameters by calling the respective setters at will, and
5377/// // execute the final call using `doit()`.
5378/// // Values shown here are possibly random and not representative !
5379/// let result = hub.projects().databases_documents_list("parent", "collectionId")
5380/// .transaction(vec![0, 1, 2, 3])
5381/// .show_missing(true)
5382/// .read_time(chrono::Utc::now())
5383/// .page_token("invidunt")
5384/// .page_size(-47)
5385/// .order_by("duo")
5386/// .add_mask_field_paths("ipsum")
5387/// .doit().await;
5388/// # }
5389/// ```
5390pub struct ProjectDatabaseDocumentListCall<'a, C>
5391where
5392 C: 'a,
5393{
5394 hub: &'a Firestore<C>,
5395 _parent: String,
5396 _collection_id: String,
5397 _transaction: Option<Vec<u8>>,
5398 _show_missing: Option<bool>,
5399 _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
5400 _page_token: Option<String>,
5401 _page_size: Option<i32>,
5402 _order_by: Option<String>,
5403 _mask_field_paths: Vec<String>,
5404 _delegate: Option<&'a mut dyn common::Delegate>,
5405 _additional_params: HashMap<String, String>,
5406 _scopes: BTreeSet<String>,
5407}
5408
5409impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListCall<'a, C> {}
5410
5411impl<'a, C> ProjectDatabaseDocumentListCall<'a, C>
5412where
5413 C: common::Connector,
5414{
5415 /// Perform the operation you have build so far.
5416 pub async fn doit(mut self) -> common::Result<(common::Response, ListDocumentsResponse)> {
5417 use std::borrow::Cow;
5418 use std::io::{Read, Seek};
5419
5420 use common::{url::Params, ToParts};
5421 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5422
5423 let mut dd = common::DefaultDelegate;
5424 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5425 dlg.begin(common::MethodInfo {
5426 id: "firestore.projects.databases.documents.list",
5427 http_method: hyper::Method::GET,
5428 });
5429
5430 for &field in [
5431 "alt",
5432 "parent",
5433 "collectionId",
5434 "transaction",
5435 "showMissing",
5436 "readTime",
5437 "pageToken",
5438 "pageSize",
5439 "orderBy",
5440 "mask.fieldPaths",
5441 ]
5442 .iter()
5443 {
5444 if self._additional_params.contains_key(field) {
5445 dlg.finished(false);
5446 return Err(common::Error::FieldClash(field));
5447 }
5448 }
5449
5450 let mut params = Params::with_capacity(11 + self._additional_params.len());
5451 params.push("parent", self._parent);
5452 params.push("collectionId", self._collection_id);
5453 if let Some(value) = self._transaction.as_ref() {
5454 params.push(
5455 "transaction",
5456 common::serde::standard_base64::to_string(&value),
5457 );
5458 }
5459 if let Some(value) = self._show_missing.as_ref() {
5460 params.push("showMissing", value.to_string());
5461 }
5462 if let Some(value) = self._read_time.as_ref() {
5463 params.push("readTime", common::serde::datetime_to_string(&value));
5464 }
5465 if let Some(value) = self._page_token.as_ref() {
5466 params.push("pageToken", value);
5467 }
5468 if let Some(value) = self._page_size.as_ref() {
5469 params.push("pageSize", value.to_string());
5470 }
5471 if let Some(value) = self._order_by.as_ref() {
5472 params.push("orderBy", value);
5473 }
5474 if !self._mask_field_paths.is_empty() {
5475 for f in self._mask_field_paths.iter() {
5476 params.push("mask.fieldPaths", f);
5477 }
5478 }
5479
5480 params.extend(self._additional_params.iter());
5481
5482 params.push("alt", "json");
5483 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/{collectionId}";
5484 if self._scopes.is_empty() {
5485 self._scopes
5486 .insert(Scope::CloudPlatform.as_ref().to_string());
5487 }
5488
5489 #[allow(clippy::single_element_loop)]
5490 for &(find_this, param_name) in
5491 [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
5492 {
5493 url = params.uri_replacement(url, param_name, find_this, true);
5494 }
5495 {
5496 let to_remove = ["collectionId", "parent"];
5497 params.remove_params(&to_remove);
5498 }
5499
5500 let url = params.parse_with_url(&url);
5501
5502 loop {
5503 let token = match self
5504 .hub
5505 .auth
5506 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5507 .await
5508 {
5509 Ok(token) => token,
5510 Err(e) => match dlg.token(e) {
5511 Ok(token) => token,
5512 Err(e) => {
5513 dlg.finished(false);
5514 return Err(common::Error::MissingToken(e));
5515 }
5516 },
5517 };
5518 let mut req_result = {
5519 let client = &self.hub.client;
5520 dlg.pre_request();
5521 let mut req_builder = hyper::Request::builder()
5522 .method(hyper::Method::GET)
5523 .uri(url.as_str())
5524 .header(USER_AGENT, self.hub._user_agent.clone());
5525
5526 if let Some(token) = token.as_ref() {
5527 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5528 }
5529
5530 let request = req_builder
5531 .header(CONTENT_LENGTH, 0_u64)
5532 .body(common::to_body::<String>(None));
5533
5534 client.request(request.unwrap()).await
5535 };
5536
5537 match req_result {
5538 Err(err) => {
5539 if let common::Retry::After(d) = dlg.http_error(&err) {
5540 sleep(d).await;
5541 continue;
5542 }
5543 dlg.finished(false);
5544 return Err(common::Error::HttpError(err));
5545 }
5546 Ok(res) => {
5547 let (mut parts, body) = res.into_parts();
5548 let mut body = common::Body::new(body);
5549 if !parts.status.is_success() {
5550 let bytes = common::to_bytes(body).await.unwrap_or_default();
5551 let error = serde_json::from_str(&common::to_string(&bytes));
5552 let response = common::to_response(parts, bytes.into());
5553
5554 if let common::Retry::After(d) =
5555 dlg.http_failure(&response, error.as_ref().ok())
5556 {
5557 sleep(d).await;
5558 continue;
5559 }
5560
5561 dlg.finished(false);
5562
5563 return Err(match error {
5564 Ok(value) => common::Error::BadRequest(value),
5565 _ => common::Error::Failure(response),
5566 });
5567 }
5568 let response = {
5569 let bytes = common::to_bytes(body).await.unwrap_or_default();
5570 let encoded = common::to_string(&bytes);
5571 match serde_json::from_str(&encoded) {
5572 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5573 Err(error) => {
5574 dlg.response_json_decode_error(&encoded, &error);
5575 return Err(common::Error::JsonDecodeError(
5576 encoded.to_string(),
5577 error,
5578 ));
5579 }
5580 }
5581 };
5582
5583 dlg.finished(true);
5584 return Ok(response);
5585 }
5586 }
5587 }
5588 }
5589
5590 /// 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`
5591 ///
5592 /// Sets the *parent* path property to the given value.
5593 ///
5594 /// Even though the property as already been set when instantiating this call,
5595 /// we provide this method for API completeness.
5596 pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
5597 self._parent = new_value.to_string();
5598 self
5599 }
5600 /// 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`.
5601 ///
5602 /// Sets the *collection id* path property to the given value.
5603 ///
5604 /// Even though the property as already been set when instantiating this call,
5605 /// we provide this method for API completeness.
5606 pub fn collection_id(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
5607 self._collection_id = new_value.to_string();
5608 self
5609 }
5610 /// Perform the read as part of an already active transaction.
5611 ///
5612 /// Sets the *transaction* query property to the given value.
5613 pub fn transaction(mut self, new_value: Vec<u8>) -> ProjectDatabaseDocumentListCall<'a, C> {
5614 self._transaction = Some(new_value);
5615 self
5616 }
5617 /// 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`.
5618 ///
5619 /// Sets the *show missing* query property to the given value.
5620 pub fn show_missing(mut self, new_value: bool) -> ProjectDatabaseDocumentListCall<'a, C> {
5621 self._show_missing = Some(new_value);
5622 self
5623 }
5624 /// 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.
5625 ///
5626 /// Sets the *read time* query property to the given value.
5627 pub fn read_time(
5628 mut self,
5629 new_value: chrono::DateTime<chrono::offset::Utc>,
5630 ) -> ProjectDatabaseDocumentListCall<'a, C> {
5631 self._read_time = Some(new_value);
5632 self
5633 }
5634 /// 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.
5635 ///
5636 /// Sets the *page token* query property to the given value.
5637 pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
5638 self._page_token = Some(new_value.to_string());
5639 self
5640 }
5641 /// Optional. The maximum number of documents to return in a single response. Firestore may return fewer than this value.
5642 ///
5643 /// Sets the *page size* query property to the given value.
5644 pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseDocumentListCall<'a, C> {
5645 self._page_size = Some(new_value);
5646 self
5647 }
5648 /// 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`.
5649 ///
5650 /// Sets the *order by* query property to the given value.
5651 pub fn order_by(mut self, new_value: &str) -> ProjectDatabaseDocumentListCall<'a, C> {
5652 self._order_by = Some(new_value.to_string());
5653 self
5654 }
5655 /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
5656 ///
5657 /// Append the given value to the *mask.field paths* query property.
5658 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5659 pub fn add_mask_field_paths(
5660 mut self,
5661 new_value: &str,
5662 ) -> ProjectDatabaseDocumentListCall<'a, C> {
5663 self._mask_field_paths.push(new_value.to_string());
5664 self
5665 }
5666 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5667 /// while executing the actual API request.
5668 ///
5669 /// ````text
5670 /// It should be used to handle progress information, and to implement a certain level of resilience.
5671 /// ````
5672 ///
5673 /// Sets the *delegate* property to the given value.
5674 pub fn delegate(
5675 mut self,
5676 new_value: &'a mut dyn common::Delegate,
5677 ) -> ProjectDatabaseDocumentListCall<'a, C> {
5678 self._delegate = Some(new_value);
5679 self
5680 }
5681
5682 /// Set any additional parameter of the query string used in the request.
5683 /// It should be used to set parameters which are not yet available through their own
5684 /// setters.
5685 ///
5686 /// Please note that this method must not be used to set any of the known parameters
5687 /// which have their own setter method. If done anyway, the request will fail.
5688 ///
5689 /// # Additional Parameters
5690 ///
5691 /// * *$.xgafv* (query-string) - V1 error format.
5692 /// * *access_token* (query-string) - OAuth access token.
5693 /// * *alt* (query-string) - Data format for response.
5694 /// * *callback* (query-string) - JSONP
5695 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5696 /// * *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.
5697 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5698 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5699 /// * *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.
5700 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5701 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5702 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListCall<'a, C>
5703 where
5704 T: AsRef<str>,
5705 {
5706 self._additional_params
5707 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5708 self
5709 }
5710
5711 /// Identifies the authorization scope for the method you are building.
5712 ///
5713 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5714 /// [`Scope::CloudPlatform`].
5715 ///
5716 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5717 /// tokens for more than one scope.
5718 ///
5719 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5720 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5721 /// sufficient, a read-write scope will do as well.
5722 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListCall<'a, C>
5723 where
5724 St: AsRef<str>,
5725 {
5726 self._scopes.insert(String::from(scope.as_ref()));
5727 self
5728 }
5729 /// Identifies the authorization scope(s) for the method you are building.
5730 ///
5731 /// See [`Self::add_scope()`] for details.
5732 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListCall<'a, C>
5733 where
5734 I: IntoIterator<Item = St>,
5735 St: AsRef<str>,
5736 {
5737 self._scopes
5738 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5739 self
5740 }
5741
5742 /// Removes all scopes, and no default scope will be used either.
5743 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5744 /// for details).
5745 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListCall<'a, C> {
5746 self._scopes.clear();
5747 self
5748 }
5749}
5750
5751/// Lists all the collection IDs underneath a document.
5752///
5753/// A builder for the *databases.documents.listCollectionIds* method supported by a *project* resource.
5754/// It is not used directly, but through a [`ProjectMethods`] instance.
5755///
5756/// # Example
5757///
5758/// Instantiate a resource method builder
5759///
5760/// ```test_harness,no_run
5761/// # extern crate hyper;
5762/// # extern crate hyper_rustls;
5763/// # extern crate google_firestore1_beta1 as firestore1_beta1;
5764/// use firestore1_beta1::api::ListCollectionIdsRequest;
5765/// # async fn dox() {
5766/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5767///
5768/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5769/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5770/// # .with_native_roots()
5771/// # .unwrap()
5772/// # .https_only()
5773/// # .enable_http2()
5774/// # .build();
5775///
5776/// # let executor = hyper_util::rt::TokioExecutor::new();
5777/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5778/// # secret,
5779/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5780/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5781/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5782/// # ),
5783/// # ).build().await.unwrap();
5784///
5785/// # let client = hyper_util::client::legacy::Client::builder(
5786/// # hyper_util::rt::TokioExecutor::new()
5787/// # )
5788/// # .build(
5789/// # hyper_rustls::HttpsConnectorBuilder::new()
5790/// # .with_native_roots()
5791/// # .unwrap()
5792/// # .https_or_http()
5793/// # .enable_http2()
5794/// # .build()
5795/// # );
5796/// # let mut hub = Firestore::new(client, auth);
5797/// // As the method needs a request, you would usually fill it with the desired information
5798/// // into the respective structure. Some of the parts shown here might not be applicable !
5799/// // Values shown here are possibly random and not representative !
5800/// let mut req = ListCollectionIdsRequest::default();
5801///
5802/// // You can configure optional parameters by calling the respective setters at will, and
5803/// // execute the final call using `doit()`.
5804/// // Values shown here are possibly random and not representative !
5805/// let result = hub.projects().databases_documents_list_collection_ids(req, "parent")
5806/// .doit().await;
5807/// # }
5808/// ```
5809pub struct ProjectDatabaseDocumentListCollectionIdCall<'a, C>
5810where
5811 C: 'a,
5812{
5813 hub: &'a Firestore<C>,
5814 _request: ListCollectionIdsRequest,
5815 _parent: String,
5816 _delegate: Option<&'a mut dyn common::Delegate>,
5817 _additional_params: HashMap<String, String>,
5818 _scopes: BTreeSet<String>,
5819}
5820
5821impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListCollectionIdCall<'a, C> {}
5822
5823impl<'a, C> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
5824where
5825 C: common::Connector,
5826{
5827 /// Perform the operation you have build so far.
5828 pub async fn doit(mut self) -> common::Result<(common::Response, ListCollectionIdsResponse)> {
5829 use std::borrow::Cow;
5830 use std::io::{Read, Seek};
5831
5832 use common::{url::Params, ToParts};
5833 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5834
5835 let mut dd = common::DefaultDelegate;
5836 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5837 dlg.begin(common::MethodInfo {
5838 id: "firestore.projects.databases.documents.listCollectionIds",
5839 http_method: hyper::Method::POST,
5840 });
5841
5842 for &field in ["alt", "parent"].iter() {
5843 if self._additional_params.contains_key(field) {
5844 dlg.finished(false);
5845 return Err(common::Error::FieldClash(field));
5846 }
5847 }
5848
5849 let mut params = Params::with_capacity(4 + self._additional_params.len());
5850 params.push("parent", self._parent);
5851
5852 params.extend(self._additional_params.iter());
5853
5854 params.push("alt", "json");
5855 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}:listCollectionIds";
5856 if self._scopes.is_empty() {
5857 self._scopes
5858 .insert(Scope::CloudPlatform.as_ref().to_string());
5859 }
5860
5861 #[allow(clippy::single_element_loop)]
5862 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5863 url = params.uri_replacement(url, param_name, find_this, true);
5864 }
5865 {
5866 let to_remove = ["parent"];
5867 params.remove_params(&to_remove);
5868 }
5869
5870 let url = params.parse_with_url(&url);
5871
5872 let mut json_mime_type = mime::APPLICATION_JSON;
5873 let mut request_value_reader = {
5874 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5875 common::remove_json_null_values(&mut value);
5876 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5877 serde_json::to_writer(&mut dst, &value).unwrap();
5878 dst
5879 };
5880 let request_size = request_value_reader
5881 .seek(std::io::SeekFrom::End(0))
5882 .unwrap();
5883 request_value_reader
5884 .seek(std::io::SeekFrom::Start(0))
5885 .unwrap();
5886
5887 loop {
5888 let token = match self
5889 .hub
5890 .auth
5891 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5892 .await
5893 {
5894 Ok(token) => token,
5895 Err(e) => match dlg.token(e) {
5896 Ok(token) => token,
5897 Err(e) => {
5898 dlg.finished(false);
5899 return Err(common::Error::MissingToken(e));
5900 }
5901 },
5902 };
5903 request_value_reader
5904 .seek(std::io::SeekFrom::Start(0))
5905 .unwrap();
5906 let mut req_result = {
5907 let client = &self.hub.client;
5908 dlg.pre_request();
5909 let mut req_builder = hyper::Request::builder()
5910 .method(hyper::Method::POST)
5911 .uri(url.as_str())
5912 .header(USER_AGENT, self.hub._user_agent.clone());
5913
5914 if let Some(token) = token.as_ref() {
5915 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5916 }
5917
5918 let request = req_builder
5919 .header(CONTENT_TYPE, json_mime_type.to_string())
5920 .header(CONTENT_LENGTH, request_size as u64)
5921 .body(common::to_body(
5922 request_value_reader.get_ref().clone().into(),
5923 ));
5924
5925 client.request(request.unwrap()).await
5926 };
5927
5928 match req_result {
5929 Err(err) => {
5930 if let common::Retry::After(d) = dlg.http_error(&err) {
5931 sleep(d).await;
5932 continue;
5933 }
5934 dlg.finished(false);
5935 return Err(common::Error::HttpError(err));
5936 }
5937 Ok(res) => {
5938 let (mut parts, body) = res.into_parts();
5939 let mut body = common::Body::new(body);
5940 if !parts.status.is_success() {
5941 let bytes = common::to_bytes(body).await.unwrap_or_default();
5942 let error = serde_json::from_str(&common::to_string(&bytes));
5943 let response = common::to_response(parts, bytes.into());
5944
5945 if let common::Retry::After(d) =
5946 dlg.http_failure(&response, error.as_ref().ok())
5947 {
5948 sleep(d).await;
5949 continue;
5950 }
5951
5952 dlg.finished(false);
5953
5954 return Err(match error {
5955 Ok(value) => common::Error::BadRequest(value),
5956 _ => common::Error::Failure(response),
5957 });
5958 }
5959 let response = {
5960 let bytes = common::to_bytes(body).await.unwrap_or_default();
5961 let encoded = common::to_string(&bytes);
5962 match serde_json::from_str(&encoded) {
5963 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5964 Err(error) => {
5965 dlg.response_json_decode_error(&encoded, &error);
5966 return Err(common::Error::JsonDecodeError(
5967 encoded.to_string(),
5968 error,
5969 ));
5970 }
5971 }
5972 };
5973
5974 dlg.finished(true);
5975 return Ok(response);
5976 }
5977 }
5978 }
5979 }
5980
5981 ///
5982 /// Sets the *request* property to the given value.
5983 ///
5984 /// Even though the property as already been set when instantiating this call,
5985 /// we provide this method for API completeness.
5986 pub fn request(
5987 mut self,
5988 new_value: ListCollectionIdsRequest,
5989 ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
5990 self._request = new_value;
5991 self
5992 }
5993 /// 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`
5994 ///
5995 /// Sets the *parent* path property to the given value.
5996 ///
5997 /// Even though the property as already been set when instantiating this call,
5998 /// we provide this method for API completeness.
5999 pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
6000 self._parent = new_value.to_string();
6001 self
6002 }
6003 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6004 /// while executing the actual API request.
6005 ///
6006 /// ````text
6007 /// It should be used to handle progress information, and to implement a certain level of resilience.
6008 /// ````
6009 ///
6010 /// Sets the *delegate* property to the given value.
6011 pub fn delegate(
6012 mut self,
6013 new_value: &'a mut dyn common::Delegate,
6014 ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
6015 self._delegate = Some(new_value);
6016 self
6017 }
6018
6019 /// Set any additional parameter of the query string used in the request.
6020 /// It should be used to set parameters which are not yet available through their own
6021 /// setters.
6022 ///
6023 /// Please note that this method must not be used to set any of the known parameters
6024 /// which have their own setter method. If done anyway, the request will fail.
6025 ///
6026 /// # Additional Parameters
6027 ///
6028 /// * *$.xgafv* (query-string) - V1 error format.
6029 /// * *access_token* (query-string) - OAuth access token.
6030 /// * *alt* (query-string) - Data format for response.
6031 /// * *callback* (query-string) - JSONP
6032 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6033 /// * *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.
6034 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6035 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6036 /// * *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.
6037 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6038 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6039 pub fn param<T>(
6040 mut self,
6041 name: T,
6042 value: T,
6043 ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
6044 where
6045 T: AsRef<str>,
6046 {
6047 self._additional_params
6048 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6049 self
6050 }
6051
6052 /// Identifies the authorization scope for the method you are building.
6053 ///
6054 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6055 /// [`Scope::CloudPlatform`].
6056 ///
6057 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6058 /// tokens for more than one scope.
6059 ///
6060 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6061 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6062 /// sufficient, a read-write scope will do as well.
6063 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
6064 where
6065 St: AsRef<str>,
6066 {
6067 self._scopes.insert(String::from(scope.as_ref()));
6068 self
6069 }
6070 /// Identifies the authorization scope(s) for the method you are building.
6071 ///
6072 /// See [`Self::add_scope()`] for details.
6073 pub fn add_scopes<I, St>(
6074 mut self,
6075 scopes: I,
6076 ) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C>
6077 where
6078 I: IntoIterator<Item = St>,
6079 St: AsRef<str>,
6080 {
6081 self._scopes
6082 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6083 self
6084 }
6085
6086 /// Removes all scopes, and no default scope will be used either.
6087 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6088 /// for details).
6089 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListCollectionIdCall<'a, C> {
6090 self._scopes.clear();
6091 self
6092 }
6093}
6094
6095/// Lists documents.
6096///
6097/// A builder for the *databases.documents.listDocuments* method supported by a *project* resource.
6098/// It is not used directly, but through a [`ProjectMethods`] instance.
6099///
6100/// # Example
6101///
6102/// Instantiate a resource method builder
6103///
6104/// ```test_harness,no_run
6105/// # extern crate hyper;
6106/// # extern crate hyper_rustls;
6107/// # extern crate google_firestore1_beta1 as firestore1_beta1;
6108/// # async fn dox() {
6109/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6110///
6111/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6112/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6113/// # .with_native_roots()
6114/// # .unwrap()
6115/// # .https_only()
6116/// # .enable_http2()
6117/// # .build();
6118///
6119/// # let executor = hyper_util::rt::TokioExecutor::new();
6120/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6121/// # secret,
6122/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6123/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6124/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6125/// # ),
6126/// # ).build().await.unwrap();
6127///
6128/// # let client = hyper_util::client::legacy::Client::builder(
6129/// # hyper_util::rt::TokioExecutor::new()
6130/// # )
6131/// # .build(
6132/// # hyper_rustls::HttpsConnectorBuilder::new()
6133/// # .with_native_roots()
6134/// # .unwrap()
6135/// # .https_or_http()
6136/// # .enable_http2()
6137/// # .build()
6138/// # );
6139/// # let mut hub = Firestore::new(client, auth);
6140/// // You can configure optional parameters by calling the respective setters at will, and
6141/// // execute the final call using `doit()`.
6142/// // Values shown here are possibly random and not representative !
6143/// let result = hub.projects().databases_documents_list_documents("parent", "collectionId")
6144/// .transaction(vec![0, 1, 2, 3])
6145/// .show_missing(true)
6146/// .read_time(chrono::Utc::now())
6147/// .page_token("ipsum")
6148/// .page_size(-50)
6149/// .order_by("est")
6150/// .add_mask_field_paths("gubergren")
6151/// .doit().await;
6152/// # }
6153/// ```
6154pub struct ProjectDatabaseDocumentListDocumentCall<'a, C>
6155where
6156 C: 'a,
6157{
6158 hub: &'a Firestore<C>,
6159 _parent: String,
6160 _collection_id: String,
6161 _transaction: Option<Vec<u8>>,
6162 _show_missing: Option<bool>,
6163 _read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
6164 _page_token: Option<String>,
6165 _page_size: Option<i32>,
6166 _order_by: Option<String>,
6167 _mask_field_paths: Vec<String>,
6168 _delegate: Option<&'a mut dyn common::Delegate>,
6169 _additional_params: HashMap<String, String>,
6170 _scopes: BTreeSet<String>,
6171}
6172
6173impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListDocumentCall<'a, C> {}
6174
6175impl<'a, C> ProjectDatabaseDocumentListDocumentCall<'a, C>
6176where
6177 C: common::Connector,
6178{
6179 /// Perform the operation you have build so far.
6180 pub async fn doit(mut self) -> common::Result<(common::Response, ListDocumentsResponse)> {
6181 use std::borrow::Cow;
6182 use std::io::{Read, Seek};
6183
6184 use common::{url::Params, ToParts};
6185 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6186
6187 let mut dd = common::DefaultDelegate;
6188 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6189 dlg.begin(common::MethodInfo {
6190 id: "firestore.projects.databases.documents.listDocuments",
6191 http_method: hyper::Method::GET,
6192 });
6193
6194 for &field in [
6195 "alt",
6196 "parent",
6197 "collectionId",
6198 "transaction",
6199 "showMissing",
6200 "readTime",
6201 "pageToken",
6202 "pageSize",
6203 "orderBy",
6204 "mask.fieldPaths",
6205 ]
6206 .iter()
6207 {
6208 if self._additional_params.contains_key(field) {
6209 dlg.finished(false);
6210 return Err(common::Error::FieldClash(field));
6211 }
6212 }
6213
6214 let mut params = Params::with_capacity(11 + self._additional_params.len());
6215 params.push("parent", self._parent);
6216 params.push("collectionId", self._collection_id);
6217 if let Some(value) = self._transaction.as_ref() {
6218 params.push(
6219 "transaction",
6220 common::serde::standard_base64::to_string(&value),
6221 );
6222 }
6223 if let Some(value) = self._show_missing.as_ref() {
6224 params.push("showMissing", value.to_string());
6225 }
6226 if let Some(value) = self._read_time.as_ref() {
6227 params.push("readTime", common::serde::datetime_to_string(&value));
6228 }
6229 if let Some(value) = self._page_token.as_ref() {
6230 params.push("pageToken", value);
6231 }
6232 if let Some(value) = self._page_size.as_ref() {
6233 params.push("pageSize", value.to_string());
6234 }
6235 if let Some(value) = self._order_by.as_ref() {
6236 params.push("orderBy", value);
6237 }
6238 if !self._mask_field_paths.is_empty() {
6239 for f in self._mask_field_paths.iter() {
6240 params.push("mask.fieldPaths", f);
6241 }
6242 }
6243
6244 params.extend(self._additional_params.iter());
6245
6246 params.push("alt", "json");
6247 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/{collectionId}";
6248 if self._scopes.is_empty() {
6249 self._scopes
6250 .insert(Scope::CloudPlatform.as_ref().to_string());
6251 }
6252
6253 #[allow(clippy::single_element_loop)]
6254 for &(find_this, param_name) in
6255 [("{+parent}", "parent"), ("{collectionId}", "collectionId")].iter()
6256 {
6257 url = params.uri_replacement(url, param_name, find_this, true);
6258 }
6259 {
6260 let to_remove = ["collectionId", "parent"];
6261 params.remove_params(&to_remove);
6262 }
6263
6264 let url = params.parse_with_url(&url);
6265
6266 loop {
6267 let token = match self
6268 .hub
6269 .auth
6270 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6271 .await
6272 {
6273 Ok(token) => token,
6274 Err(e) => match dlg.token(e) {
6275 Ok(token) => token,
6276 Err(e) => {
6277 dlg.finished(false);
6278 return Err(common::Error::MissingToken(e));
6279 }
6280 },
6281 };
6282 let mut req_result = {
6283 let client = &self.hub.client;
6284 dlg.pre_request();
6285 let mut req_builder = hyper::Request::builder()
6286 .method(hyper::Method::GET)
6287 .uri(url.as_str())
6288 .header(USER_AGENT, self.hub._user_agent.clone());
6289
6290 if let Some(token) = token.as_ref() {
6291 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6292 }
6293
6294 let request = req_builder
6295 .header(CONTENT_LENGTH, 0_u64)
6296 .body(common::to_body::<String>(None));
6297
6298 client.request(request.unwrap()).await
6299 };
6300
6301 match req_result {
6302 Err(err) => {
6303 if let common::Retry::After(d) = dlg.http_error(&err) {
6304 sleep(d).await;
6305 continue;
6306 }
6307 dlg.finished(false);
6308 return Err(common::Error::HttpError(err));
6309 }
6310 Ok(res) => {
6311 let (mut parts, body) = res.into_parts();
6312 let mut body = common::Body::new(body);
6313 if !parts.status.is_success() {
6314 let bytes = common::to_bytes(body).await.unwrap_or_default();
6315 let error = serde_json::from_str(&common::to_string(&bytes));
6316 let response = common::to_response(parts, bytes.into());
6317
6318 if let common::Retry::After(d) =
6319 dlg.http_failure(&response, error.as_ref().ok())
6320 {
6321 sleep(d).await;
6322 continue;
6323 }
6324
6325 dlg.finished(false);
6326
6327 return Err(match error {
6328 Ok(value) => common::Error::BadRequest(value),
6329 _ => common::Error::Failure(response),
6330 });
6331 }
6332 let response = {
6333 let bytes = common::to_bytes(body).await.unwrap_or_default();
6334 let encoded = common::to_string(&bytes);
6335 match serde_json::from_str(&encoded) {
6336 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6337 Err(error) => {
6338 dlg.response_json_decode_error(&encoded, &error);
6339 return Err(common::Error::JsonDecodeError(
6340 encoded.to_string(),
6341 error,
6342 ));
6343 }
6344 }
6345 };
6346
6347 dlg.finished(true);
6348 return Ok(response);
6349 }
6350 }
6351 }
6352 }
6353
6354 /// 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`
6355 ///
6356 /// Sets the *parent* path property to the given value.
6357 ///
6358 /// Even though the property as already been set when instantiating this call,
6359 /// we provide this method for API completeness.
6360 pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6361 self._parent = new_value.to_string();
6362 self
6363 }
6364 /// 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`.
6365 ///
6366 /// Sets the *collection id* path property to the given value.
6367 ///
6368 /// Even though the property as already been set when instantiating this call,
6369 /// we provide this method for API completeness.
6370 pub fn collection_id(
6371 mut self,
6372 new_value: &str,
6373 ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6374 self._collection_id = new_value.to_string();
6375 self
6376 }
6377 /// Perform the read as part of an already active transaction.
6378 ///
6379 /// Sets the *transaction* query property to the given value.
6380 pub fn transaction(
6381 mut self,
6382 new_value: Vec<u8>,
6383 ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6384 self._transaction = Some(new_value);
6385 self
6386 }
6387 /// 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`.
6388 ///
6389 /// Sets the *show missing* query property to the given value.
6390 pub fn show_missing(
6391 mut self,
6392 new_value: bool,
6393 ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6394 self._show_missing = Some(new_value);
6395 self
6396 }
6397 /// 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.
6398 ///
6399 /// Sets the *read time* query property to the given value.
6400 pub fn read_time(
6401 mut self,
6402 new_value: chrono::DateTime<chrono::offset::Utc>,
6403 ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6404 self._read_time = Some(new_value);
6405 self
6406 }
6407 /// 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.
6408 ///
6409 /// Sets the *page token* query property to the given value.
6410 pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6411 self._page_token = Some(new_value.to_string());
6412 self
6413 }
6414 /// Optional. The maximum number of documents to return in a single response. Firestore may return fewer than this value.
6415 ///
6416 /// Sets the *page size* query property to the given value.
6417 pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6418 self._page_size = Some(new_value);
6419 self
6420 }
6421 /// 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`.
6422 ///
6423 /// Sets the *order by* query property to the given value.
6424 pub fn order_by(mut self, new_value: &str) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6425 self._order_by = Some(new_value.to_string());
6426 self
6427 }
6428 /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
6429 ///
6430 /// Append the given value to the *mask.field paths* query property.
6431 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
6432 pub fn add_mask_field_paths(
6433 mut self,
6434 new_value: &str,
6435 ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6436 self._mask_field_paths.push(new_value.to_string());
6437 self
6438 }
6439 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6440 /// while executing the actual API request.
6441 ///
6442 /// ````text
6443 /// It should be used to handle progress information, and to implement a certain level of resilience.
6444 /// ````
6445 ///
6446 /// Sets the *delegate* property to the given value.
6447 pub fn delegate(
6448 mut self,
6449 new_value: &'a mut dyn common::Delegate,
6450 ) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6451 self._delegate = Some(new_value);
6452 self
6453 }
6454
6455 /// Set any additional parameter of the query string used in the request.
6456 /// It should be used to set parameters which are not yet available through their own
6457 /// setters.
6458 ///
6459 /// Please note that this method must not be used to set any of the known parameters
6460 /// which have their own setter method. If done anyway, the request will fail.
6461 ///
6462 /// # Additional Parameters
6463 ///
6464 /// * *$.xgafv* (query-string) - V1 error format.
6465 /// * *access_token* (query-string) - OAuth access token.
6466 /// * *alt* (query-string) - Data format for response.
6467 /// * *callback* (query-string) - JSONP
6468 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6469 /// * *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.
6470 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6471 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6472 /// * *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.
6473 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6474 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6475 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListDocumentCall<'a, C>
6476 where
6477 T: AsRef<str>,
6478 {
6479 self._additional_params
6480 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6481 self
6482 }
6483
6484 /// Identifies the authorization scope for the method you are building.
6485 ///
6486 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6487 /// [`Scope::CloudPlatform`].
6488 ///
6489 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6490 /// tokens for more than one scope.
6491 ///
6492 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6493 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6494 /// sufficient, a read-write scope will do as well.
6495 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListDocumentCall<'a, C>
6496 where
6497 St: AsRef<str>,
6498 {
6499 self._scopes.insert(String::from(scope.as_ref()));
6500 self
6501 }
6502 /// Identifies the authorization scope(s) for the method you are building.
6503 ///
6504 /// See [`Self::add_scope()`] for details.
6505 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListDocumentCall<'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) -> ProjectDatabaseDocumentListDocumentCall<'a, C> {
6519 self._scopes.clear();
6520 self
6521 }
6522}
6523
6524/// Listens to changes. This method is only available via gRPC or WebChannel (not REST).
6525///
6526/// A builder for the *databases.documents.listen* 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::ListenRequest;
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 connector = hyper_rustls::HttpsConnectorBuilder::new()
6543/// # .with_native_roots()
6544/// # .unwrap()
6545/// # .https_only()
6546/// # .enable_http2()
6547/// # .build();
6548///
6549/// # let executor = hyper_util::rt::TokioExecutor::new();
6550/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6551/// # secret,
6552/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6553/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6554/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6555/// # ),
6556/// # ).build().await.unwrap();
6557///
6558/// # let client = hyper_util::client::legacy::Client::builder(
6559/// # hyper_util::rt::TokioExecutor::new()
6560/// # )
6561/// # .build(
6562/// # hyper_rustls::HttpsConnectorBuilder::new()
6563/// # .with_native_roots()
6564/// # .unwrap()
6565/// # .https_or_http()
6566/// # .enable_http2()
6567/// # .build()
6568/// # );
6569/// # let mut hub = Firestore::new(client, auth);
6570/// // As the method needs a request, you would usually fill it with the desired information
6571/// // into the respective structure. Some of the parts shown here might not be applicable !
6572/// // Values shown here are possibly random and not representative !
6573/// let mut req = ListenRequest::default();
6574///
6575/// // You can configure optional parameters by calling the respective setters at will, and
6576/// // execute the final call using `doit()`.
6577/// // Values shown here are possibly random and not representative !
6578/// let result = hub.projects().databases_documents_listen(req, "database")
6579/// .doit().await;
6580/// # }
6581/// ```
6582pub struct ProjectDatabaseDocumentListenCall<'a, C>
6583where
6584 C: 'a,
6585{
6586 hub: &'a Firestore<C>,
6587 _request: ListenRequest,
6588 _database: String,
6589 _delegate: Option<&'a mut dyn common::Delegate>,
6590 _additional_params: HashMap<String, String>,
6591 _scopes: BTreeSet<String>,
6592}
6593
6594impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentListenCall<'a, C> {}
6595
6596impl<'a, C> ProjectDatabaseDocumentListenCall<'a, C>
6597where
6598 C: common::Connector,
6599{
6600 /// Perform the operation you have build so far.
6601 pub async fn doit(mut self) -> common::Result<(common::Response, ListenResponse)> {
6602 use std::borrow::Cow;
6603 use std::io::{Read, Seek};
6604
6605 use common::{url::Params, ToParts};
6606 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6607
6608 let mut dd = common::DefaultDelegate;
6609 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6610 dlg.begin(common::MethodInfo {
6611 id: "firestore.projects.databases.documents.listen",
6612 http_method: hyper::Method::POST,
6613 });
6614
6615 for &field in ["alt", "database"].iter() {
6616 if self._additional_params.contains_key(field) {
6617 dlg.finished(false);
6618 return Err(common::Error::FieldClash(field));
6619 }
6620 }
6621
6622 let mut params = Params::with_capacity(4 + self._additional_params.len());
6623 params.push("database", self._database);
6624
6625 params.extend(self._additional_params.iter());
6626
6627 params.push("alt", "json");
6628 let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:listen";
6629 if self._scopes.is_empty() {
6630 self._scopes
6631 .insert(Scope::CloudPlatform.as_ref().to_string());
6632 }
6633
6634 #[allow(clippy::single_element_loop)]
6635 for &(find_this, param_name) in [("{+database}", "database")].iter() {
6636 url = params.uri_replacement(url, param_name, find_this, true);
6637 }
6638 {
6639 let to_remove = ["database"];
6640 params.remove_params(&to_remove);
6641 }
6642
6643 let url = params.parse_with_url(&url);
6644
6645 let mut json_mime_type = mime::APPLICATION_JSON;
6646 let mut request_value_reader = {
6647 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6648 common::remove_json_null_values(&mut value);
6649 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6650 serde_json::to_writer(&mut dst, &value).unwrap();
6651 dst
6652 };
6653 let request_size = request_value_reader
6654 .seek(std::io::SeekFrom::End(0))
6655 .unwrap();
6656 request_value_reader
6657 .seek(std::io::SeekFrom::Start(0))
6658 .unwrap();
6659
6660 loop {
6661 let token = match self
6662 .hub
6663 .auth
6664 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6665 .await
6666 {
6667 Ok(token) => token,
6668 Err(e) => match dlg.token(e) {
6669 Ok(token) => token,
6670 Err(e) => {
6671 dlg.finished(false);
6672 return Err(common::Error::MissingToken(e));
6673 }
6674 },
6675 };
6676 request_value_reader
6677 .seek(std::io::SeekFrom::Start(0))
6678 .unwrap();
6679 let mut req_result = {
6680 let client = &self.hub.client;
6681 dlg.pre_request();
6682 let mut req_builder = hyper::Request::builder()
6683 .method(hyper::Method::POST)
6684 .uri(url.as_str())
6685 .header(USER_AGENT, self.hub._user_agent.clone());
6686
6687 if let Some(token) = token.as_ref() {
6688 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6689 }
6690
6691 let request = req_builder
6692 .header(CONTENT_TYPE, json_mime_type.to_string())
6693 .header(CONTENT_LENGTH, request_size as u64)
6694 .body(common::to_body(
6695 request_value_reader.get_ref().clone().into(),
6696 ));
6697
6698 client.request(request.unwrap()).await
6699 };
6700
6701 match req_result {
6702 Err(err) => {
6703 if let common::Retry::After(d) = dlg.http_error(&err) {
6704 sleep(d).await;
6705 continue;
6706 }
6707 dlg.finished(false);
6708 return Err(common::Error::HttpError(err));
6709 }
6710 Ok(res) => {
6711 let (mut parts, body) = res.into_parts();
6712 let mut body = common::Body::new(body);
6713 if !parts.status.is_success() {
6714 let bytes = common::to_bytes(body).await.unwrap_or_default();
6715 let error = serde_json::from_str(&common::to_string(&bytes));
6716 let response = common::to_response(parts, bytes.into());
6717
6718 if let common::Retry::After(d) =
6719 dlg.http_failure(&response, error.as_ref().ok())
6720 {
6721 sleep(d).await;
6722 continue;
6723 }
6724
6725 dlg.finished(false);
6726
6727 return Err(match error {
6728 Ok(value) => common::Error::BadRequest(value),
6729 _ => common::Error::Failure(response),
6730 });
6731 }
6732 let response = {
6733 let bytes = common::to_bytes(body).await.unwrap_or_default();
6734 let encoded = common::to_string(&bytes);
6735 match serde_json::from_str(&encoded) {
6736 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6737 Err(error) => {
6738 dlg.response_json_decode_error(&encoded, &error);
6739 return Err(common::Error::JsonDecodeError(
6740 encoded.to_string(),
6741 error,
6742 ));
6743 }
6744 }
6745 };
6746
6747 dlg.finished(true);
6748 return Ok(response);
6749 }
6750 }
6751 }
6752 }
6753
6754 ///
6755 /// Sets the *request* property to the given value.
6756 ///
6757 /// Even though the property as already been set when instantiating this call,
6758 /// we provide this method for API completeness.
6759 pub fn request(mut self, new_value: ListenRequest) -> ProjectDatabaseDocumentListenCall<'a, C> {
6760 self._request = new_value;
6761 self
6762 }
6763 /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
6764 ///
6765 /// Sets the *database* path property to the given value.
6766 ///
6767 /// Even though the property as already been set when instantiating this call,
6768 /// we provide this method for API completeness.
6769 pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentListenCall<'a, C> {
6770 self._database = new_value.to_string();
6771 self
6772 }
6773 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6774 /// while executing the actual API request.
6775 ///
6776 /// ````text
6777 /// It should be used to handle progress information, and to implement a certain level of resilience.
6778 /// ````
6779 ///
6780 /// Sets the *delegate* property to the given value.
6781 pub fn delegate(
6782 mut self,
6783 new_value: &'a mut dyn common::Delegate,
6784 ) -> ProjectDatabaseDocumentListenCall<'a, C> {
6785 self._delegate = Some(new_value);
6786 self
6787 }
6788
6789 /// Set any additional parameter of the query string used in the request.
6790 /// It should be used to set parameters which are not yet available through their own
6791 /// setters.
6792 ///
6793 /// Please note that this method must not be used to set any of the known parameters
6794 /// which have their own setter method. If done anyway, the request will fail.
6795 ///
6796 /// # Additional Parameters
6797 ///
6798 /// * *$.xgafv* (query-string) - V1 error format.
6799 /// * *access_token* (query-string) - OAuth access token.
6800 /// * *alt* (query-string) - Data format for response.
6801 /// * *callback* (query-string) - JSONP
6802 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6803 /// * *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.
6804 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6805 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6806 /// * *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.
6807 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6808 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6809 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentListenCall<'a, C>
6810 where
6811 T: AsRef<str>,
6812 {
6813 self._additional_params
6814 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6815 self
6816 }
6817
6818 /// Identifies the authorization scope for the method you are building.
6819 ///
6820 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6821 /// [`Scope::CloudPlatform`].
6822 ///
6823 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6824 /// tokens for more than one scope.
6825 ///
6826 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6827 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6828 /// sufficient, a read-write scope will do as well.
6829 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentListenCall<'a, C>
6830 where
6831 St: AsRef<str>,
6832 {
6833 self._scopes.insert(String::from(scope.as_ref()));
6834 self
6835 }
6836 /// Identifies the authorization scope(s) for the method you are building.
6837 ///
6838 /// See [`Self::add_scope()`] for details.
6839 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentListenCall<'a, C>
6840 where
6841 I: IntoIterator<Item = St>,
6842 St: AsRef<str>,
6843 {
6844 self._scopes
6845 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6846 self
6847 }
6848
6849 /// Removes all scopes, and no default scope will be used either.
6850 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6851 /// for details).
6852 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentListenCall<'a, C> {
6853 self._scopes.clear();
6854 self
6855 }
6856}
6857
6858/// 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.
6859///
6860/// A builder for the *databases.documents.partitionQuery* method supported by a *project* resource.
6861/// It is not used directly, but through a [`ProjectMethods`] instance.
6862///
6863/// # Example
6864///
6865/// Instantiate a resource method builder
6866///
6867/// ```test_harness,no_run
6868/// # extern crate hyper;
6869/// # extern crate hyper_rustls;
6870/// # extern crate google_firestore1_beta1 as firestore1_beta1;
6871/// use firestore1_beta1::api::PartitionQueryRequest;
6872/// # async fn dox() {
6873/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6874///
6875/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6876/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6877/// # .with_native_roots()
6878/// # .unwrap()
6879/// # .https_only()
6880/// # .enable_http2()
6881/// # .build();
6882///
6883/// # let executor = hyper_util::rt::TokioExecutor::new();
6884/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6885/// # secret,
6886/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6887/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6888/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6889/// # ),
6890/// # ).build().await.unwrap();
6891///
6892/// # let client = hyper_util::client::legacy::Client::builder(
6893/// # hyper_util::rt::TokioExecutor::new()
6894/// # )
6895/// # .build(
6896/// # hyper_rustls::HttpsConnectorBuilder::new()
6897/// # .with_native_roots()
6898/// # .unwrap()
6899/// # .https_or_http()
6900/// # .enable_http2()
6901/// # .build()
6902/// # );
6903/// # let mut hub = Firestore::new(client, auth);
6904/// // As the method needs a request, you would usually fill it with the desired information
6905/// // into the respective structure. Some of the parts shown here might not be applicable !
6906/// // Values shown here are possibly random and not representative !
6907/// let mut req = PartitionQueryRequest::default();
6908///
6909/// // You can configure optional parameters by calling the respective setters at will, and
6910/// // execute the final call using `doit()`.
6911/// // Values shown here are possibly random and not representative !
6912/// let result = hub.projects().databases_documents_partition_query(req, "parent")
6913/// .doit().await;
6914/// # }
6915/// ```
6916pub struct ProjectDatabaseDocumentPartitionQueryCall<'a, C>
6917where
6918 C: 'a,
6919{
6920 hub: &'a Firestore<C>,
6921 _request: PartitionQueryRequest,
6922 _parent: String,
6923 _delegate: Option<&'a mut dyn common::Delegate>,
6924 _additional_params: HashMap<String, String>,
6925 _scopes: BTreeSet<String>,
6926}
6927
6928impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentPartitionQueryCall<'a, C> {}
6929
6930impl<'a, C> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
6931where
6932 C: common::Connector,
6933{
6934 /// Perform the operation you have build so far.
6935 pub async fn doit(mut self) -> common::Result<(common::Response, PartitionQueryResponse)> {
6936 use std::borrow::Cow;
6937 use std::io::{Read, Seek};
6938
6939 use common::{url::Params, ToParts};
6940 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6941
6942 let mut dd = common::DefaultDelegate;
6943 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6944 dlg.begin(common::MethodInfo {
6945 id: "firestore.projects.databases.documents.partitionQuery",
6946 http_method: hyper::Method::POST,
6947 });
6948
6949 for &field in ["alt", "parent"].iter() {
6950 if self._additional_params.contains_key(field) {
6951 dlg.finished(false);
6952 return Err(common::Error::FieldClash(field));
6953 }
6954 }
6955
6956 let mut params = Params::with_capacity(4 + self._additional_params.len());
6957 params.push("parent", self._parent);
6958
6959 params.extend(self._additional_params.iter());
6960
6961 params.push("alt", "json");
6962 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}:partitionQuery";
6963 if self._scopes.is_empty() {
6964 self._scopes
6965 .insert(Scope::CloudPlatform.as_ref().to_string());
6966 }
6967
6968 #[allow(clippy::single_element_loop)]
6969 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6970 url = params.uri_replacement(url, param_name, find_this, true);
6971 }
6972 {
6973 let to_remove = ["parent"];
6974 params.remove_params(&to_remove);
6975 }
6976
6977 let url = params.parse_with_url(&url);
6978
6979 let mut json_mime_type = mime::APPLICATION_JSON;
6980 let mut request_value_reader = {
6981 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6982 common::remove_json_null_values(&mut value);
6983 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6984 serde_json::to_writer(&mut dst, &value).unwrap();
6985 dst
6986 };
6987 let request_size = request_value_reader
6988 .seek(std::io::SeekFrom::End(0))
6989 .unwrap();
6990 request_value_reader
6991 .seek(std::io::SeekFrom::Start(0))
6992 .unwrap();
6993
6994 loop {
6995 let token = match self
6996 .hub
6997 .auth
6998 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6999 .await
7000 {
7001 Ok(token) => token,
7002 Err(e) => match dlg.token(e) {
7003 Ok(token) => token,
7004 Err(e) => {
7005 dlg.finished(false);
7006 return Err(common::Error::MissingToken(e));
7007 }
7008 },
7009 };
7010 request_value_reader
7011 .seek(std::io::SeekFrom::Start(0))
7012 .unwrap();
7013 let mut req_result = {
7014 let client = &self.hub.client;
7015 dlg.pre_request();
7016 let mut req_builder = hyper::Request::builder()
7017 .method(hyper::Method::POST)
7018 .uri(url.as_str())
7019 .header(USER_AGENT, self.hub._user_agent.clone());
7020
7021 if let Some(token) = token.as_ref() {
7022 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7023 }
7024
7025 let request = req_builder
7026 .header(CONTENT_TYPE, json_mime_type.to_string())
7027 .header(CONTENT_LENGTH, request_size as u64)
7028 .body(common::to_body(
7029 request_value_reader.get_ref().clone().into(),
7030 ));
7031
7032 client.request(request.unwrap()).await
7033 };
7034
7035 match req_result {
7036 Err(err) => {
7037 if let common::Retry::After(d) = dlg.http_error(&err) {
7038 sleep(d).await;
7039 continue;
7040 }
7041 dlg.finished(false);
7042 return Err(common::Error::HttpError(err));
7043 }
7044 Ok(res) => {
7045 let (mut parts, body) = res.into_parts();
7046 let mut body = common::Body::new(body);
7047 if !parts.status.is_success() {
7048 let bytes = common::to_bytes(body).await.unwrap_or_default();
7049 let error = serde_json::from_str(&common::to_string(&bytes));
7050 let response = common::to_response(parts, bytes.into());
7051
7052 if let common::Retry::After(d) =
7053 dlg.http_failure(&response, error.as_ref().ok())
7054 {
7055 sleep(d).await;
7056 continue;
7057 }
7058
7059 dlg.finished(false);
7060
7061 return Err(match error {
7062 Ok(value) => common::Error::BadRequest(value),
7063 _ => common::Error::Failure(response),
7064 });
7065 }
7066 let response = {
7067 let bytes = common::to_bytes(body).await.unwrap_or_default();
7068 let encoded = common::to_string(&bytes);
7069 match serde_json::from_str(&encoded) {
7070 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7071 Err(error) => {
7072 dlg.response_json_decode_error(&encoded, &error);
7073 return Err(common::Error::JsonDecodeError(
7074 encoded.to_string(),
7075 error,
7076 ));
7077 }
7078 }
7079 };
7080
7081 dlg.finished(true);
7082 return Ok(response);
7083 }
7084 }
7085 }
7086 }
7087
7088 ///
7089 /// Sets the *request* property to the given value.
7090 ///
7091 /// Even though the property as already been set when instantiating this call,
7092 /// we provide this method for API completeness.
7093 pub fn request(
7094 mut self,
7095 new_value: PartitionQueryRequest,
7096 ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
7097 self._request = new_value;
7098 self
7099 }
7100 /// 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.
7101 ///
7102 /// Sets the *parent* path property to the given value.
7103 ///
7104 /// Even though the property as already been set when instantiating this call,
7105 /// we provide this method for API completeness.
7106 pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
7107 self._parent = new_value.to_string();
7108 self
7109 }
7110 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7111 /// while executing the actual API request.
7112 ///
7113 /// ````text
7114 /// It should be used to handle progress information, and to implement a certain level of resilience.
7115 /// ````
7116 ///
7117 /// Sets the *delegate* property to the given value.
7118 pub fn delegate(
7119 mut self,
7120 new_value: &'a mut dyn common::Delegate,
7121 ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
7122 self._delegate = Some(new_value);
7123 self
7124 }
7125
7126 /// Set any additional parameter of the query string used in the request.
7127 /// It should be used to set parameters which are not yet available through their own
7128 /// setters.
7129 ///
7130 /// Please note that this method must not be used to set any of the known parameters
7131 /// which have their own setter method. If done anyway, the request will fail.
7132 ///
7133 /// # Additional Parameters
7134 ///
7135 /// * *$.xgafv* (query-string) - V1 error format.
7136 /// * *access_token* (query-string) - OAuth access token.
7137 /// * *alt* (query-string) - Data format for response.
7138 /// * *callback* (query-string) - JSONP
7139 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7140 /// * *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.
7141 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7142 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7143 /// * *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.
7144 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7145 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7146 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
7147 where
7148 T: AsRef<str>,
7149 {
7150 self._additional_params
7151 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7152 self
7153 }
7154
7155 /// Identifies the authorization scope for the method you are building.
7156 ///
7157 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7158 /// [`Scope::CloudPlatform`].
7159 ///
7160 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7161 /// tokens for more than one scope.
7162 ///
7163 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7164 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7165 /// sufficient, a read-write scope will do as well.
7166 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
7167 where
7168 St: AsRef<str>,
7169 {
7170 self._scopes.insert(String::from(scope.as_ref()));
7171 self
7172 }
7173 /// Identifies the authorization scope(s) for the method you are building.
7174 ///
7175 /// See [`Self::add_scope()`] for details.
7176 pub fn add_scopes<I, St>(
7177 mut self,
7178 scopes: I,
7179 ) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C>
7180 where
7181 I: IntoIterator<Item = St>,
7182 St: AsRef<str>,
7183 {
7184 self._scopes
7185 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7186 self
7187 }
7188
7189 /// Removes all scopes, and no default scope will be used either.
7190 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7191 /// for details).
7192 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentPartitionQueryCall<'a, C> {
7193 self._scopes.clear();
7194 self
7195 }
7196}
7197
7198/// Updates or inserts a document.
7199///
7200/// A builder for the *databases.documents.patch* method supported by a *project* resource.
7201/// It is not used directly, but through a [`ProjectMethods`] instance.
7202///
7203/// # Example
7204///
7205/// Instantiate a resource method builder
7206///
7207/// ```test_harness,no_run
7208/// # extern crate hyper;
7209/// # extern crate hyper_rustls;
7210/// # extern crate google_firestore1_beta1 as firestore1_beta1;
7211/// use firestore1_beta1::api::Document;
7212/// # async fn dox() {
7213/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7214///
7215/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7216/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7217/// # .with_native_roots()
7218/// # .unwrap()
7219/// # .https_only()
7220/// # .enable_http2()
7221/// # .build();
7222///
7223/// # let executor = hyper_util::rt::TokioExecutor::new();
7224/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7225/// # secret,
7226/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7227/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7228/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7229/// # ),
7230/// # ).build().await.unwrap();
7231///
7232/// # let client = hyper_util::client::legacy::Client::builder(
7233/// # hyper_util::rt::TokioExecutor::new()
7234/// # )
7235/// # .build(
7236/// # hyper_rustls::HttpsConnectorBuilder::new()
7237/// # .with_native_roots()
7238/// # .unwrap()
7239/// # .https_or_http()
7240/// # .enable_http2()
7241/// # .build()
7242/// # );
7243/// # let mut hub = Firestore::new(client, auth);
7244/// // As the method needs a request, you would usually fill it with the desired information
7245/// // into the respective structure. Some of the parts shown here might not be applicable !
7246/// // Values shown here are possibly random and not representative !
7247/// let mut req = Document::default();
7248///
7249/// // You can configure optional parameters by calling the respective setters at will, and
7250/// // execute the final call using `doit()`.
7251/// // Values shown here are possibly random and not representative !
7252/// let result = hub.projects().databases_documents_patch(req, "name")
7253/// .add_update_mask_field_paths("eos")
7254/// .add_mask_field_paths("labore")
7255/// .current_document_update_time(chrono::Utc::now())
7256/// .current_document_exists(true)
7257/// .doit().await;
7258/// # }
7259/// ```
7260pub struct ProjectDatabaseDocumentPatchCall<'a, C>
7261where
7262 C: 'a,
7263{
7264 hub: &'a Firestore<C>,
7265 _request: Document,
7266 _name: String,
7267 _update_mask_field_paths: Vec<String>,
7268 _mask_field_paths: Vec<String>,
7269 _current_document_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
7270 _current_document_exists: Option<bool>,
7271 _delegate: Option<&'a mut dyn common::Delegate>,
7272 _additional_params: HashMap<String, String>,
7273 _scopes: BTreeSet<String>,
7274}
7275
7276impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentPatchCall<'a, C> {}
7277
7278impl<'a, C> ProjectDatabaseDocumentPatchCall<'a, C>
7279where
7280 C: common::Connector,
7281{
7282 /// Perform the operation you have build so far.
7283 pub async fn doit(mut self) -> common::Result<(common::Response, Document)> {
7284 use std::borrow::Cow;
7285 use std::io::{Read, Seek};
7286
7287 use common::{url::Params, ToParts};
7288 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7289
7290 let mut dd = common::DefaultDelegate;
7291 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7292 dlg.begin(common::MethodInfo {
7293 id: "firestore.projects.databases.documents.patch",
7294 http_method: hyper::Method::PATCH,
7295 });
7296
7297 for &field in [
7298 "alt",
7299 "name",
7300 "updateMask.fieldPaths",
7301 "mask.fieldPaths",
7302 "currentDocument.updateTime",
7303 "currentDocument.exists",
7304 ]
7305 .iter()
7306 {
7307 if self._additional_params.contains_key(field) {
7308 dlg.finished(false);
7309 return Err(common::Error::FieldClash(field));
7310 }
7311 }
7312
7313 let mut params = Params::with_capacity(8 + self._additional_params.len());
7314 params.push("name", self._name);
7315 if !self._update_mask_field_paths.is_empty() {
7316 for f in self._update_mask_field_paths.iter() {
7317 params.push("updateMask.fieldPaths", f);
7318 }
7319 }
7320 if !self._mask_field_paths.is_empty() {
7321 for f in self._mask_field_paths.iter() {
7322 params.push("mask.fieldPaths", f);
7323 }
7324 }
7325 if let Some(value) = self._current_document_update_time.as_ref() {
7326 params.push(
7327 "currentDocument.updateTime",
7328 common::serde::datetime_to_string(&value),
7329 );
7330 }
7331 if let Some(value) = self._current_document_exists.as_ref() {
7332 params.push("currentDocument.exists", value.to_string());
7333 }
7334
7335 params.extend(self._additional_params.iter());
7336
7337 params.push("alt", "json");
7338 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7339 if self._scopes.is_empty() {
7340 self._scopes
7341 .insert(Scope::CloudPlatform.as_ref().to_string());
7342 }
7343
7344 #[allow(clippy::single_element_loop)]
7345 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7346 url = params.uri_replacement(url, param_name, find_this, true);
7347 }
7348 {
7349 let to_remove = ["name"];
7350 params.remove_params(&to_remove);
7351 }
7352
7353 let url = params.parse_with_url(&url);
7354
7355 let mut json_mime_type = mime::APPLICATION_JSON;
7356 let mut request_value_reader = {
7357 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7358 common::remove_json_null_values(&mut value);
7359 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7360 serde_json::to_writer(&mut dst, &value).unwrap();
7361 dst
7362 };
7363 let request_size = request_value_reader
7364 .seek(std::io::SeekFrom::End(0))
7365 .unwrap();
7366 request_value_reader
7367 .seek(std::io::SeekFrom::Start(0))
7368 .unwrap();
7369
7370 loop {
7371 let token = match self
7372 .hub
7373 .auth
7374 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7375 .await
7376 {
7377 Ok(token) => token,
7378 Err(e) => match dlg.token(e) {
7379 Ok(token) => token,
7380 Err(e) => {
7381 dlg.finished(false);
7382 return Err(common::Error::MissingToken(e));
7383 }
7384 },
7385 };
7386 request_value_reader
7387 .seek(std::io::SeekFrom::Start(0))
7388 .unwrap();
7389 let mut req_result = {
7390 let client = &self.hub.client;
7391 dlg.pre_request();
7392 let mut req_builder = hyper::Request::builder()
7393 .method(hyper::Method::PATCH)
7394 .uri(url.as_str())
7395 .header(USER_AGENT, self.hub._user_agent.clone());
7396
7397 if let Some(token) = token.as_ref() {
7398 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7399 }
7400
7401 let request = req_builder
7402 .header(CONTENT_TYPE, json_mime_type.to_string())
7403 .header(CONTENT_LENGTH, request_size as u64)
7404 .body(common::to_body(
7405 request_value_reader.get_ref().clone().into(),
7406 ));
7407
7408 client.request(request.unwrap()).await
7409 };
7410
7411 match req_result {
7412 Err(err) => {
7413 if let common::Retry::After(d) = dlg.http_error(&err) {
7414 sleep(d).await;
7415 continue;
7416 }
7417 dlg.finished(false);
7418 return Err(common::Error::HttpError(err));
7419 }
7420 Ok(res) => {
7421 let (mut parts, body) = res.into_parts();
7422 let mut body = common::Body::new(body);
7423 if !parts.status.is_success() {
7424 let bytes = common::to_bytes(body).await.unwrap_or_default();
7425 let error = serde_json::from_str(&common::to_string(&bytes));
7426 let response = common::to_response(parts, bytes.into());
7427
7428 if let common::Retry::After(d) =
7429 dlg.http_failure(&response, error.as_ref().ok())
7430 {
7431 sleep(d).await;
7432 continue;
7433 }
7434
7435 dlg.finished(false);
7436
7437 return Err(match error {
7438 Ok(value) => common::Error::BadRequest(value),
7439 _ => common::Error::Failure(response),
7440 });
7441 }
7442 let response = {
7443 let bytes = common::to_bytes(body).await.unwrap_or_default();
7444 let encoded = common::to_string(&bytes);
7445 match serde_json::from_str(&encoded) {
7446 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7447 Err(error) => {
7448 dlg.response_json_decode_error(&encoded, &error);
7449 return Err(common::Error::JsonDecodeError(
7450 encoded.to_string(),
7451 error,
7452 ));
7453 }
7454 }
7455 };
7456
7457 dlg.finished(true);
7458 return Ok(response);
7459 }
7460 }
7461 }
7462 }
7463
7464 ///
7465 /// Sets the *request* property to the given value.
7466 ///
7467 /// Even though the property as already been set when instantiating this call,
7468 /// we provide this method for API completeness.
7469 pub fn request(mut self, new_value: Document) -> ProjectDatabaseDocumentPatchCall<'a, C> {
7470 self._request = new_value;
7471 self
7472 }
7473 /// The resource name of the document, for example `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
7474 ///
7475 /// Sets the *name* path property to the given value.
7476 ///
7477 /// Even though the property as already been set when instantiating this call,
7478 /// we provide this method for API completeness.
7479 pub fn name(mut self, new_value: &str) -> ProjectDatabaseDocumentPatchCall<'a, C> {
7480 self._name = new_value.to_string();
7481 self
7482 }
7483 /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
7484 ///
7485 /// Append the given value to the *update mask.field paths* query property.
7486 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7487 pub fn add_update_mask_field_paths(
7488 mut self,
7489 new_value: &str,
7490 ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
7491 self._update_mask_field_paths.push(new_value.to_string());
7492 self
7493 }
7494 /// The list of field paths in the mask. See Document.fields for a field path syntax reference.
7495 ///
7496 /// Append the given value to the *mask.field paths* query property.
7497 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7498 pub fn add_mask_field_paths(
7499 mut self,
7500 new_value: &str,
7501 ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
7502 self._mask_field_paths.push(new_value.to_string());
7503 self
7504 }
7505 /// When set, the target document must exist and have been last updated at that time. Timestamp must be microsecond aligned.
7506 ///
7507 /// Sets the *current document.update time* query property to the given value.
7508 pub fn current_document_update_time(
7509 mut self,
7510 new_value: chrono::DateTime<chrono::offset::Utc>,
7511 ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
7512 self._current_document_update_time = Some(new_value);
7513 self
7514 }
7515 /// When set to `true`, the target document must exist. When set to `false`, the target document must not exist.
7516 ///
7517 /// Sets the *current document.exists* query property to the given value.
7518 pub fn current_document_exists(
7519 mut self,
7520 new_value: bool,
7521 ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
7522 self._current_document_exists = Some(new_value);
7523 self
7524 }
7525 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7526 /// while executing the actual API request.
7527 ///
7528 /// ````text
7529 /// It should be used to handle progress information, and to implement a certain level of resilience.
7530 /// ````
7531 ///
7532 /// Sets the *delegate* property to the given value.
7533 pub fn delegate(
7534 mut self,
7535 new_value: &'a mut dyn common::Delegate,
7536 ) -> ProjectDatabaseDocumentPatchCall<'a, C> {
7537 self._delegate = Some(new_value);
7538 self
7539 }
7540
7541 /// Set any additional parameter of the query string used in the request.
7542 /// It should be used to set parameters which are not yet available through their own
7543 /// setters.
7544 ///
7545 /// Please note that this method must not be used to set any of the known parameters
7546 /// which have their own setter method. If done anyway, the request will fail.
7547 ///
7548 /// # Additional Parameters
7549 ///
7550 /// * *$.xgafv* (query-string) - V1 error format.
7551 /// * *access_token* (query-string) - OAuth access token.
7552 /// * *alt* (query-string) - Data format for response.
7553 /// * *callback* (query-string) - JSONP
7554 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7555 /// * *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.
7556 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7557 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7558 /// * *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.
7559 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7560 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7561 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentPatchCall<'a, C>
7562 where
7563 T: AsRef<str>,
7564 {
7565 self._additional_params
7566 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7567 self
7568 }
7569
7570 /// Identifies the authorization scope for the method you are building.
7571 ///
7572 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7573 /// [`Scope::CloudPlatform`].
7574 ///
7575 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7576 /// tokens for more than one scope.
7577 ///
7578 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7579 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7580 /// sufficient, a read-write scope will do as well.
7581 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentPatchCall<'a, C>
7582 where
7583 St: AsRef<str>,
7584 {
7585 self._scopes.insert(String::from(scope.as_ref()));
7586 self
7587 }
7588 /// Identifies the authorization scope(s) for the method you are building.
7589 ///
7590 /// See [`Self::add_scope()`] for details.
7591 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentPatchCall<'a, C>
7592 where
7593 I: IntoIterator<Item = St>,
7594 St: AsRef<str>,
7595 {
7596 self._scopes
7597 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7598 self
7599 }
7600
7601 /// Removes all scopes, and no default scope will be used either.
7602 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7603 /// for details).
7604 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentPatchCall<'a, C> {
7605 self._scopes.clear();
7606 self
7607 }
7608}
7609
7610/// Rolls back a transaction.
7611///
7612/// A builder for the *databases.documents.rollback* method supported by a *project* resource.
7613/// It is not used directly, but through a [`ProjectMethods`] instance.
7614///
7615/// # Example
7616///
7617/// Instantiate a resource method builder
7618///
7619/// ```test_harness,no_run
7620/// # extern crate hyper;
7621/// # extern crate hyper_rustls;
7622/// # extern crate google_firestore1_beta1 as firestore1_beta1;
7623/// use firestore1_beta1::api::RollbackRequest;
7624/// # async fn dox() {
7625/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7626///
7627/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7628/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7629/// # .with_native_roots()
7630/// # .unwrap()
7631/// # .https_only()
7632/// # .enable_http2()
7633/// # .build();
7634///
7635/// # let executor = hyper_util::rt::TokioExecutor::new();
7636/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7637/// # secret,
7638/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7639/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7640/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7641/// # ),
7642/// # ).build().await.unwrap();
7643///
7644/// # let client = hyper_util::client::legacy::Client::builder(
7645/// # hyper_util::rt::TokioExecutor::new()
7646/// # )
7647/// # .build(
7648/// # hyper_rustls::HttpsConnectorBuilder::new()
7649/// # .with_native_roots()
7650/// # .unwrap()
7651/// # .https_or_http()
7652/// # .enable_http2()
7653/// # .build()
7654/// # );
7655/// # let mut hub = Firestore::new(client, auth);
7656/// // As the method needs a request, you would usually fill it with the desired information
7657/// // into the respective structure. Some of the parts shown here might not be applicable !
7658/// // Values shown here are possibly random and not representative !
7659/// let mut req = RollbackRequest::default();
7660///
7661/// // You can configure optional parameters by calling the respective setters at will, and
7662/// // execute the final call using `doit()`.
7663/// // Values shown here are possibly random and not representative !
7664/// let result = hub.projects().databases_documents_rollback(req, "database")
7665/// .doit().await;
7666/// # }
7667/// ```
7668pub struct ProjectDatabaseDocumentRollbackCall<'a, C>
7669where
7670 C: 'a,
7671{
7672 hub: &'a Firestore<C>,
7673 _request: RollbackRequest,
7674 _database: String,
7675 _delegate: Option<&'a mut dyn common::Delegate>,
7676 _additional_params: HashMap<String, String>,
7677 _scopes: BTreeSet<String>,
7678}
7679
7680impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRollbackCall<'a, C> {}
7681
7682impl<'a, C> ProjectDatabaseDocumentRollbackCall<'a, C>
7683where
7684 C: common::Connector,
7685{
7686 /// Perform the operation you have build so far.
7687 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7688 use std::borrow::Cow;
7689 use std::io::{Read, Seek};
7690
7691 use common::{url::Params, ToParts};
7692 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7693
7694 let mut dd = common::DefaultDelegate;
7695 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7696 dlg.begin(common::MethodInfo {
7697 id: "firestore.projects.databases.documents.rollback",
7698 http_method: hyper::Method::POST,
7699 });
7700
7701 for &field in ["alt", "database"].iter() {
7702 if self._additional_params.contains_key(field) {
7703 dlg.finished(false);
7704 return Err(common::Error::FieldClash(field));
7705 }
7706 }
7707
7708 let mut params = Params::with_capacity(4 + self._additional_params.len());
7709 params.push("database", self._database);
7710
7711 params.extend(self._additional_params.iter());
7712
7713 params.push("alt", "json");
7714 let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:rollback";
7715 if self._scopes.is_empty() {
7716 self._scopes
7717 .insert(Scope::CloudPlatform.as_ref().to_string());
7718 }
7719
7720 #[allow(clippy::single_element_loop)]
7721 for &(find_this, param_name) in [("{+database}", "database")].iter() {
7722 url = params.uri_replacement(url, param_name, find_this, true);
7723 }
7724 {
7725 let to_remove = ["database"];
7726 params.remove_params(&to_remove);
7727 }
7728
7729 let url = params.parse_with_url(&url);
7730
7731 let mut json_mime_type = mime::APPLICATION_JSON;
7732 let mut request_value_reader = {
7733 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7734 common::remove_json_null_values(&mut value);
7735 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7736 serde_json::to_writer(&mut dst, &value).unwrap();
7737 dst
7738 };
7739 let request_size = request_value_reader
7740 .seek(std::io::SeekFrom::End(0))
7741 .unwrap();
7742 request_value_reader
7743 .seek(std::io::SeekFrom::Start(0))
7744 .unwrap();
7745
7746 loop {
7747 let token = match self
7748 .hub
7749 .auth
7750 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7751 .await
7752 {
7753 Ok(token) => token,
7754 Err(e) => match dlg.token(e) {
7755 Ok(token) => token,
7756 Err(e) => {
7757 dlg.finished(false);
7758 return Err(common::Error::MissingToken(e));
7759 }
7760 },
7761 };
7762 request_value_reader
7763 .seek(std::io::SeekFrom::Start(0))
7764 .unwrap();
7765 let mut req_result = {
7766 let client = &self.hub.client;
7767 dlg.pre_request();
7768 let mut req_builder = hyper::Request::builder()
7769 .method(hyper::Method::POST)
7770 .uri(url.as_str())
7771 .header(USER_AGENT, self.hub._user_agent.clone());
7772
7773 if let Some(token) = token.as_ref() {
7774 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7775 }
7776
7777 let request = req_builder
7778 .header(CONTENT_TYPE, json_mime_type.to_string())
7779 .header(CONTENT_LENGTH, request_size as u64)
7780 .body(common::to_body(
7781 request_value_reader.get_ref().clone().into(),
7782 ));
7783
7784 client.request(request.unwrap()).await
7785 };
7786
7787 match req_result {
7788 Err(err) => {
7789 if let common::Retry::After(d) = dlg.http_error(&err) {
7790 sleep(d).await;
7791 continue;
7792 }
7793 dlg.finished(false);
7794 return Err(common::Error::HttpError(err));
7795 }
7796 Ok(res) => {
7797 let (mut parts, body) = res.into_parts();
7798 let mut body = common::Body::new(body);
7799 if !parts.status.is_success() {
7800 let bytes = common::to_bytes(body).await.unwrap_or_default();
7801 let error = serde_json::from_str(&common::to_string(&bytes));
7802 let response = common::to_response(parts, bytes.into());
7803
7804 if let common::Retry::After(d) =
7805 dlg.http_failure(&response, error.as_ref().ok())
7806 {
7807 sleep(d).await;
7808 continue;
7809 }
7810
7811 dlg.finished(false);
7812
7813 return Err(match error {
7814 Ok(value) => common::Error::BadRequest(value),
7815 _ => common::Error::Failure(response),
7816 });
7817 }
7818 let response = {
7819 let bytes = common::to_bytes(body).await.unwrap_or_default();
7820 let encoded = common::to_string(&bytes);
7821 match serde_json::from_str(&encoded) {
7822 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7823 Err(error) => {
7824 dlg.response_json_decode_error(&encoded, &error);
7825 return Err(common::Error::JsonDecodeError(
7826 encoded.to_string(),
7827 error,
7828 ));
7829 }
7830 }
7831 };
7832
7833 dlg.finished(true);
7834 return Ok(response);
7835 }
7836 }
7837 }
7838 }
7839
7840 ///
7841 /// Sets the *request* property to the given value.
7842 ///
7843 /// Even though the property as already been set when instantiating this call,
7844 /// we provide this method for API completeness.
7845 pub fn request(
7846 mut self,
7847 new_value: RollbackRequest,
7848 ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
7849 self._request = new_value;
7850 self
7851 }
7852 /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.
7853 ///
7854 /// Sets the *database* path property to the given value.
7855 ///
7856 /// Even though the property as already been set when instantiating this call,
7857 /// we provide this method for API completeness.
7858 pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
7859 self._database = new_value.to_string();
7860 self
7861 }
7862 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7863 /// while executing the actual API request.
7864 ///
7865 /// ````text
7866 /// It should be used to handle progress information, and to implement a certain level of resilience.
7867 /// ````
7868 ///
7869 /// Sets the *delegate* property to the given value.
7870 pub fn delegate(
7871 mut self,
7872 new_value: &'a mut dyn common::Delegate,
7873 ) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
7874 self._delegate = Some(new_value);
7875 self
7876 }
7877
7878 /// Set any additional parameter of the query string used in the request.
7879 /// It should be used to set parameters which are not yet available through their own
7880 /// setters.
7881 ///
7882 /// Please note that this method must not be used to set any of the known parameters
7883 /// which have their own setter method. If done anyway, the request will fail.
7884 ///
7885 /// # Additional Parameters
7886 ///
7887 /// * *$.xgafv* (query-string) - V1 error format.
7888 /// * *access_token* (query-string) - OAuth access token.
7889 /// * *alt* (query-string) - Data format for response.
7890 /// * *callback* (query-string) - JSONP
7891 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7892 /// * *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.
7893 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7894 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7895 /// * *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.
7896 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7897 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7898 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentRollbackCall<'a, C>
7899 where
7900 T: AsRef<str>,
7901 {
7902 self._additional_params
7903 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7904 self
7905 }
7906
7907 /// Identifies the authorization scope for the method you are building.
7908 ///
7909 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7910 /// [`Scope::CloudPlatform`].
7911 ///
7912 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7913 /// tokens for more than one scope.
7914 ///
7915 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7916 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7917 /// sufficient, a read-write scope will do as well.
7918 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentRollbackCall<'a, C>
7919 where
7920 St: AsRef<str>,
7921 {
7922 self._scopes.insert(String::from(scope.as_ref()));
7923 self
7924 }
7925 /// Identifies the authorization scope(s) for the method you are building.
7926 ///
7927 /// See [`Self::add_scope()`] for details.
7928 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentRollbackCall<'a, C>
7929 where
7930 I: IntoIterator<Item = St>,
7931 St: AsRef<str>,
7932 {
7933 self._scopes
7934 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7935 self
7936 }
7937
7938 /// Removes all scopes, and no default scope will be used either.
7939 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7940 /// for details).
7941 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRollbackCall<'a, C> {
7942 self._scopes.clear();
7943 self
7944 }
7945}
7946
7947/// 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 ); ```
7948///
7949/// A builder for the *databases.documents.runAggregationQuery* method supported by a *project* resource.
7950/// It is not used directly, but through a [`ProjectMethods`] instance.
7951///
7952/// # Example
7953///
7954/// Instantiate a resource method builder
7955///
7956/// ```test_harness,no_run
7957/// # extern crate hyper;
7958/// # extern crate hyper_rustls;
7959/// # extern crate google_firestore1_beta1 as firestore1_beta1;
7960/// use firestore1_beta1::api::RunAggregationQueryRequest;
7961/// # async fn dox() {
7962/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7963///
7964/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7965/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7966/// # .with_native_roots()
7967/// # .unwrap()
7968/// # .https_only()
7969/// # .enable_http2()
7970/// # .build();
7971///
7972/// # let executor = hyper_util::rt::TokioExecutor::new();
7973/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7974/// # secret,
7975/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7976/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7977/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7978/// # ),
7979/// # ).build().await.unwrap();
7980///
7981/// # let client = hyper_util::client::legacy::Client::builder(
7982/// # hyper_util::rt::TokioExecutor::new()
7983/// # )
7984/// # .build(
7985/// # hyper_rustls::HttpsConnectorBuilder::new()
7986/// # .with_native_roots()
7987/// # .unwrap()
7988/// # .https_or_http()
7989/// # .enable_http2()
7990/// # .build()
7991/// # );
7992/// # let mut hub = Firestore::new(client, auth);
7993/// // As the method needs a request, you would usually fill it with the desired information
7994/// // into the respective structure. Some of the parts shown here might not be applicable !
7995/// // Values shown here are possibly random and not representative !
7996/// let mut req = RunAggregationQueryRequest::default();
7997///
7998/// // You can configure optional parameters by calling the respective setters at will, and
7999/// // execute the final call using `doit()`.
8000/// // Values shown here are possibly random and not representative !
8001/// let result = hub.projects().databases_documents_run_aggregation_query(req, "parent")
8002/// .doit().await;
8003/// # }
8004/// ```
8005pub struct ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
8006where
8007 C: 'a,
8008{
8009 hub: &'a Firestore<C>,
8010 _request: RunAggregationQueryRequest,
8011 _parent: String,
8012 _delegate: Option<&'a mut dyn common::Delegate>,
8013 _additional_params: HashMap<String, String>,
8014 _scopes: BTreeSet<String>,
8015}
8016
8017impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {}
8018
8019impl<'a, C> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
8020where
8021 C: common::Connector,
8022{
8023 /// Perform the operation you have build so far.
8024 pub async fn doit(mut self) -> common::Result<(common::Response, RunAggregationQueryResponse)> {
8025 use std::borrow::Cow;
8026 use std::io::{Read, Seek};
8027
8028 use common::{url::Params, ToParts};
8029 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8030
8031 let mut dd = common::DefaultDelegate;
8032 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8033 dlg.begin(common::MethodInfo {
8034 id: "firestore.projects.databases.documents.runAggregationQuery",
8035 http_method: hyper::Method::POST,
8036 });
8037
8038 for &field in ["alt", "parent"].iter() {
8039 if self._additional_params.contains_key(field) {
8040 dlg.finished(false);
8041 return Err(common::Error::FieldClash(field));
8042 }
8043 }
8044
8045 let mut params = Params::with_capacity(4 + self._additional_params.len());
8046 params.push("parent", self._parent);
8047
8048 params.extend(self._additional_params.iter());
8049
8050 params.push("alt", "json");
8051 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}:runAggregationQuery";
8052 if self._scopes.is_empty() {
8053 self._scopes
8054 .insert(Scope::CloudPlatform.as_ref().to_string());
8055 }
8056
8057 #[allow(clippy::single_element_loop)]
8058 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8059 url = params.uri_replacement(url, param_name, find_this, true);
8060 }
8061 {
8062 let to_remove = ["parent"];
8063 params.remove_params(&to_remove);
8064 }
8065
8066 let url = params.parse_with_url(&url);
8067
8068 let mut json_mime_type = mime::APPLICATION_JSON;
8069 let mut request_value_reader = {
8070 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8071 common::remove_json_null_values(&mut value);
8072 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8073 serde_json::to_writer(&mut dst, &value).unwrap();
8074 dst
8075 };
8076 let request_size = request_value_reader
8077 .seek(std::io::SeekFrom::End(0))
8078 .unwrap();
8079 request_value_reader
8080 .seek(std::io::SeekFrom::Start(0))
8081 .unwrap();
8082
8083 loop {
8084 let token = match self
8085 .hub
8086 .auth
8087 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8088 .await
8089 {
8090 Ok(token) => token,
8091 Err(e) => match dlg.token(e) {
8092 Ok(token) => token,
8093 Err(e) => {
8094 dlg.finished(false);
8095 return Err(common::Error::MissingToken(e));
8096 }
8097 },
8098 };
8099 request_value_reader
8100 .seek(std::io::SeekFrom::Start(0))
8101 .unwrap();
8102 let mut req_result = {
8103 let client = &self.hub.client;
8104 dlg.pre_request();
8105 let mut req_builder = hyper::Request::builder()
8106 .method(hyper::Method::POST)
8107 .uri(url.as_str())
8108 .header(USER_AGENT, self.hub._user_agent.clone());
8109
8110 if let Some(token) = token.as_ref() {
8111 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8112 }
8113
8114 let request = req_builder
8115 .header(CONTENT_TYPE, json_mime_type.to_string())
8116 .header(CONTENT_LENGTH, request_size as u64)
8117 .body(common::to_body(
8118 request_value_reader.get_ref().clone().into(),
8119 ));
8120
8121 client.request(request.unwrap()).await
8122 };
8123
8124 match req_result {
8125 Err(err) => {
8126 if let common::Retry::After(d) = dlg.http_error(&err) {
8127 sleep(d).await;
8128 continue;
8129 }
8130 dlg.finished(false);
8131 return Err(common::Error::HttpError(err));
8132 }
8133 Ok(res) => {
8134 let (mut parts, body) = res.into_parts();
8135 let mut body = common::Body::new(body);
8136 if !parts.status.is_success() {
8137 let bytes = common::to_bytes(body).await.unwrap_or_default();
8138 let error = serde_json::from_str(&common::to_string(&bytes));
8139 let response = common::to_response(parts, bytes.into());
8140
8141 if let common::Retry::After(d) =
8142 dlg.http_failure(&response, error.as_ref().ok())
8143 {
8144 sleep(d).await;
8145 continue;
8146 }
8147
8148 dlg.finished(false);
8149
8150 return Err(match error {
8151 Ok(value) => common::Error::BadRequest(value),
8152 _ => common::Error::Failure(response),
8153 });
8154 }
8155 let response = {
8156 let bytes = common::to_bytes(body).await.unwrap_or_default();
8157 let encoded = common::to_string(&bytes);
8158 match serde_json::from_str(&encoded) {
8159 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8160 Err(error) => {
8161 dlg.response_json_decode_error(&encoded, &error);
8162 return Err(common::Error::JsonDecodeError(
8163 encoded.to_string(),
8164 error,
8165 ));
8166 }
8167 }
8168 };
8169
8170 dlg.finished(true);
8171 return Ok(response);
8172 }
8173 }
8174 }
8175 }
8176
8177 ///
8178 /// Sets the *request* property to the given value.
8179 ///
8180 /// Even though the property as already been set when instantiating this call,
8181 /// we provide this method for API completeness.
8182 pub fn request(
8183 mut self,
8184 new_value: RunAggregationQueryRequest,
8185 ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
8186 self._request = new_value;
8187 self
8188 }
8189 /// 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`
8190 ///
8191 /// Sets the *parent* path property to the given value.
8192 ///
8193 /// Even though the property as already been set when instantiating this call,
8194 /// we provide this method for API completeness.
8195 pub fn parent(
8196 mut self,
8197 new_value: &str,
8198 ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
8199 self._parent = new_value.to_string();
8200 self
8201 }
8202 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8203 /// while executing the actual API request.
8204 ///
8205 /// ````text
8206 /// It should be used to handle progress information, and to implement a certain level of resilience.
8207 /// ````
8208 ///
8209 /// Sets the *delegate* property to the given value.
8210 pub fn delegate(
8211 mut self,
8212 new_value: &'a mut dyn common::Delegate,
8213 ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
8214 self._delegate = Some(new_value);
8215 self
8216 }
8217
8218 /// Set any additional parameter of the query string used in the request.
8219 /// It should be used to set parameters which are not yet available through their own
8220 /// setters.
8221 ///
8222 /// Please note that this method must not be used to set any of the known parameters
8223 /// which have their own setter method. If done anyway, the request will fail.
8224 ///
8225 /// # Additional Parameters
8226 ///
8227 /// * *$.xgafv* (query-string) - V1 error format.
8228 /// * *access_token* (query-string) - OAuth access token.
8229 /// * *alt* (query-string) - Data format for response.
8230 /// * *callback* (query-string) - JSONP
8231 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8232 /// * *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.
8233 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8234 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8235 /// * *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.
8236 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8237 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8238 pub fn param<T>(
8239 mut self,
8240 name: T,
8241 value: T,
8242 ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
8243 where
8244 T: AsRef<str>,
8245 {
8246 self._additional_params
8247 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8248 self
8249 }
8250
8251 /// Identifies the authorization scope for the method you are building.
8252 ///
8253 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8254 /// [`Scope::CloudPlatform`].
8255 ///
8256 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8257 /// tokens for more than one scope.
8258 ///
8259 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8260 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8261 /// sufficient, a read-write scope will do as well.
8262 pub fn add_scope<St>(
8263 mut self,
8264 scope: St,
8265 ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
8266 where
8267 St: AsRef<str>,
8268 {
8269 self._scopes.insert(String::from(scope.as_ref()));
8270 self
8271 }
8272 /// Identifies the authorization scope(s) for the method you are building.
8273 ///
8274 /// See [`Self::add_scope()`] for details.
8275 pub fn add_scopes<I, St>(
8276 mut self,
8277 scopes: I,
8278 ) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C>
8279 where
8280 I: IntoIterator<Item = St>,
8281 St: AsRef<str>,
8282 {
8283 self._scopes
8284 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8285 self
8286 }
8287
8288 /// Removes all scopes, and no default scope will be used either.
8289 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8290 /// for details).
8291 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRunAggregationQueryCall<'a, C> {
8292 self._scopes.clear();
8293 self
8294 }
8295}
8296
8297/// Runs a query.
8298///
8299/// A builder for the *databases.documents.runQuery* method supported by a *project* resource.
8300/// It is not used directly, but through a [`ProjectMethods`] instance.
8301///
8302/// # Example
8303///
8304/// Instantiate a resource method builder
8305///
8306/// ```test_harness,no_run
8307/// # extern crate hyper;
8308/// # extern crate hyper_rustls;
8309/// # extern crate google_firestore1_beta1 as firestore1_beta1;
8310/// use firestore1_beta1::api::RunQueryRequest;
8311/// # async fn dox() {
8312/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8313///
8314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8315/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8316/// # .with_native_roots()
8317/// # .unwrap()
8318/// # .https_only()
8319/// # .enable_http2()
8320/// # .build();
8321///
8322/// # let executor = hyper_util::rt::TokioExecutor::new();
8323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8324/// # secret,
8325/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8326/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8327/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8328/// # ),
8329/// # ).build().await.unwrap();
8330///
8331/// # let client = hyper_util::client::legacy::Client::builder(
8332/// # hyper_util::rt::TokioExecutor::new()
8333/// # )
8334/// # .build(
8335/// # hyper_rustls::HttpsConnectorBuilder::new()
8336/// # .with_native_roots()
8337/// # .unwrap()
8338/// # .https_or_http()
8339/// # .enable_http2()
8340/// # .build()
8341/// # );
8342/// # let mut hub = Firestore::new(client, auth);
8343/// // As the method needs a request, you would usually fill it with the desired information
8344/// // into the respective structure. Some of the parts shown here might not be applicable !
8345/// // Values shown here are possibly random and not representative !
8346/// let mut req = RunQueryRequest::default();
8347///
8348/// // You can configure optional parameters by calling the respective setters at will, and
8349/// // execute the final call using `doit()`.
8350/// // Values shown here are possibly random and not representative !
8351/// let result = hub.projects().databases_documents_run_query(req, "parent")
8352/// .doit().await;
8353/// # }
8354/// ```
8355pub struct ProjectDatabaseDocumentRunQueryCall<'a, C>
8356where
8357 C: 'a,
8358{
8359 hub: &'a Firestore<C>,
8360 _request: RunQueryRequest,
8361 _parent: String,
8362 _delegate: Option<&'a mut dyn common::Delegate>,
8363 _additional_params: HashMap<String, String>,
8364 _scopes: BTreeSet<String>,
8365}
8366
8367impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentRunQueryCall<'a, C> {}
8368
8369impl<'a, C> ProjectDatabaseDocumentRunQueryCall<'a, C>
8370where
8371 C: common::Connector,
8372{
8373 /// Perform the operation you have build so far.
8374 pub async fn doit(mut self) -> common::Result<(common::Response, RunQueryResponse)> {
8375 use std::borrow::Cow;
8376 use std::io::{Read, Seek};
8377
8378 use common::{url::Params, ToParts};
8379 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8380
8381 let mut dd = common::DefaultDelegate;
8382 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8383 dlg.begin(common::MethodInfo {
8384 id: "firestore.projects.databases.documents.runQuery",
8385 http_method: hyper::Method::POST,
8386 });
8387
8388 for &field in ["alt", "parent"].iter() {
8389 if self._additional_params.contains_key(field) {
8390 dlg.finished(false);
8391 return Err(common::Error::FieldClash(field));
8392 }
8393 }
8394
8395 let mut params = Params::with_capacity(4 + self._additional_params.len());
8396 params.push("parent", self._parent);
8397
8398 params.extend(self._additional_params.iter());
8399
8400 params.push("alt", "json");
8401 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}:runQuery";
8402 if self._scopes.is_empty() {
8403 self._scopes
8404 .insert(Scope::CloudPlatform.as_ref().to_string());
8405 }
8406
8407 #[allow(clippy::single_element_loop)]
8408 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8409 url = params.uri_replacement(url, param_name, find_this, true);
8410 }
8411 {
8412 let to_remove = ["parent"];
8413 params.remove_params(&to_remove);
8414 }
8415
8416 let url = params.parse_with_url(&url);
8417
8418 let mut json_mime_type = mime::APPLICATION_JSON;
8419 let mut request_value_reader = {
8420 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8421 common::remove_json_null_values(&mut value);
8422 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8423 serde_json::to_writer(&mut dst, &value).unwrap();
8424 dst
8425 };
8426 let request_size = request_value_reader
8427 .seek(std::io::SeekFrom::End(0))
8428 .unwrap();
8429 request_value_reader
8430 .seek(std::io::SeekFrom::Start(0))
8431 .unwrap();
8432
8433 loop {
8434 let token = match self
8435 .hub
8436 .auth
8437 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8438 .await
8439 {
8440 Ok(token) => token,
8441 Err(e) => match dlg.token(e) {
8442 Ok(token) => token,
8443 Err(e) => {
8444 dlg.finished(false);
8445 return Err(common::Error::MissingToken(e));
8446 }
8447 },
8448 };
8449 request_value_reader
8450 .seek(std::io::SeekFrom::Start(0))
8451 .unwrap();
8452 let mut req_result = {
8453 let client = &self.hub.client;
8454 dlg.pre_request();
8455 let mut req_builder = hyper::Request::builder()
8456 .method(hyper::Method::POST)
8457 .uri(url.as_str())
8458 .header(USER_AGENT, self.hub._user_agent.clone());
8459
8460 if let Some(token) = token.as_ref() {
8461 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8462 }
8463
8464 let request = req_builder
8465 .header(CONTENT_TYPE, json_mime_type.to_string())
8466 .header(CONTENT_LENGTH, request_size as u64)
8467 .body(common::to_body(
8468 request_value_reader.get_ref().clone().into(),
8469 ));
8470
8471 client.request(request.unwrap()).await
8472 };
8473
8474 match req_result {
8475 Err(err) => {
8476 if let common::Retry::After(d) = dlg.http_error(&err) {
8477 sleep(d).await;
8478 continue;
8479 }
8480 dlg.finished(false);
8481 return Err(common::Error::HttpError(err));
8482 }
8483 Ok(res) => {
8484 let (mut parts, body) = res.into_parts();
8485 let mut body = common::Body::new(body);
8486 if !parts.status.is_success() {
8487 let bytes = common::to_bytes(body).await.unwrap_or_default();
8488 let error = serde_json::from_str(&common::to_string(&bytes));
8489 let response = common::to_response(parts, bytes.into());
8490
8491 if let common::Retry::After(d) =
8492 dlg.http_failure(&response, error.as_ref().ok())
8493 {
8494 sleep(d).await;
8495 continue;
8496 }
8497
8498 dlg.finished(false);
8499
8500 return Err(match error {
8501 Ok(value) => common::Error::BadRequest(value),
8502 _ => common::Error::Failure(response),
8503 });
8504 }
8505 let response = {
8506 let bytes = common::to_bytes(body).await.unwrap_or_default();
8507 let encoded = common::to_string(&bytes);
8508 match serde_json::from_str(&encoded) {
8509 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8510 Err(error) => {
8511 dlg.response_json_decode_error(&encoded, &error);
8512 return Err(common::Error::JsonDecodeError(
8513 encoded.to_string(),
8514 error,
8515 ));
8516 }
8517 }
8518 };
8519
8520 dlg.finished(true);
8521 return Ok(response);
8522 }
8523 }
8524 }
8525 }
8526
8527 ///
8528 /// Sets the *request* property to the given value.
8529 ///
8530 /// Even though the property as already been set when instantiating this call,
8531 /// we provide this method for API completeness.
8532 pub fn request(
8533 mut self,
8534 new_value: RunQueryRequest,
8535 ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
8536 self._request = new_value;
8537 self
8538 }
8539 /// 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`
8540 ///
8541 /// Sets the *parent* path property to the given value.
8542 ///
8543 /// Even though the property as already been set when instantiating this call,
8544 /// we provide this method for API completeness.
8545 pub fn parent(mut self, new_value: &str) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
8546 self._parent = new_value.to_string();
8547 self
8548 }
8549 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8550 /// while executing the actual API request.
8551 ///
8552 /// ````text
8553 /// It should be used to handle progress information, and to implement a certain level of resilience.
8554 /// ````
8555 ///
8556 /// Sets the *delegate* property to the given value.
8557 pub fn delegate(
8558 mut self,
8559 new_value: &'a mut dyn common::Delegate,
8560 ) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
8561 self._delegate = Some(new_value);
8562 self
8563 }
8564
8565 /// Set any additional parameter of the query string used in the request.
8566 /// It should be used to set parameters which are not yet available through their own
8567 /// setters.
8568 ///
8569 /// Please note that this method must not be used to set any of the known parameters
8570 /// which have their own setter method. If done anyway, the request will fail.
8571 ///
8572 /// # Additional Parameters
8573 ///
8574 /// * *$.xgafv* (query-string) - V1 error format.
8575 /// * *access_token* (query-string) - OAuth access token.
8576 /// * *alt* (query-string) - Data format for response.
8577 /// * *callback* (query-string) - JSONP
8578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8579 /// * *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.
8580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8582 /// * *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.
8583 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8584 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8585 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
8586 where
8587 T: AsRef<str>,
8588 {
8589 self._additional_params
8590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8591 self
8592 }
8593
8594 /// Identifies the authorization scope for the method you are building.
8595 ///
8596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8597 /// [`Scope::CloudPlatform`].
8598 ///
8599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8600 /// tokens for more than one scope.
8601 ///
8602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8604 /// sufficient, a read-write scope will do as well.
8605 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
8606 where
8607 St: AsRef<str>,
8608 {
8609 self._scopes.insert(String::from(scope.as_ref()));
8610 self
8611 }
8612 /// Identifies the authorization scope(s) for the method you are building.
8613 ///
8614 /// See [`Self::add_scope()`] for details.
8615 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentRunQueryCall<'a, C>
8616 where
8617 I: IntoIterator<Item = St>,
8618 St: AsRef<str>,
8619 {
8620 self._scopes
8621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8622 self
8623 }
8624
8625 /// Removes all scopes, and no default scope will be used either.
8626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8627 /// for details).
8628 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentRunQueryCall<'a, C> {
8629 self._scopes.clear();
8630 self
8631 }
8632}
8633
8634/// Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).
8635///
8636/// A builder for the *databases.documents.write* method supported by a *project* resource.
8637/// It is not used directly, but through a [`ProjectMethods`] instance.
8638///
8639/// # Example
8640///
8641/// Instantiate a resource method builder
8642///
8643/// ```test_harness,no_run
8644/// # extern crate hyper;
8645/// # extern crate hyper_rustls;
8646/// # extern crate google_firestore1_beta1 as firestore1_beta1;
8647/// use firestore1_beta1::api::WriteRequest;
8648/// # async fn dox() {
8649/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8650///
8651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8652/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8653/// # .with_native_roots()
8654/// # .unwrap()
8655/// # .https_only()
8656/// # .enable_http2()
8657/// # .build();
8658///
8659/// # let executor = hyper_util::rt::TokioExecutor::new();
8660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8661/// # secret,
8662/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8663/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8664/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8665/// # ),
8666/// # ).build().await.unwrap();
8667///
8668/// # let client = hyper_util::client::legacy::Client::builder(
8669/// # hyper_util::rt::TokioExecutor::new()
8670/// # )
8671/// # .build(
8672/// # hyper_rustls::HttpsConnectorBuilder::new()
8673/// # .with_native_roots()
8674/// # .unwrap()
8675/// # .https_or_http()
8676/// # .enable_http2()
8677/// # .build()
8678/// # );
8679/// # let mut hub = Firestore::new(client, auth);
8680/// // As the method needs a request, you would usually fill it with the desired information
8681/// // into the respective structure. Some of the parts shown here might not be applicable !
8682/// // Values shown here are possibly random and not representative !
8683/// let mut req = WriteRequest::default();
8684///
8685/// // You can configure optional parameters by calling the respective setters at will, and
8686/// // execute the final call using `doit()`.
8687/// // Values shown here are possibly random and not representative !
8688/// let result = hub.projects().databases_documents_write(req, "database")
8689/// .doit().await;
8690/// # }
8691/// ```
8692pub struct ProjectDatabaseDocumentWriteCall<'a, C>
8693where
8694 C: 'a,
8695{
8696 hub: &'a Firestore<C>,
8697 _request: WriteRequest,
8698 _database: String,
8699 _delegate: Option<&'a mut dyn common::Delegate>,
8700 _additional_params: HashMap<String, String>,
8701 _scopes: BTreeSet<String>,
8702}
8703
8704impl<'a, C> common::CallBuilder for ProjectDatabaseDocumentWriteCall<'a, C> {}
8705
8706impl<'a, C> ProjectDatabaseDocumentWriteCall<'a, C>
8707where
8708 C: common::Connector,
8709{
8710 /// Perform the operation you have build so far.
8711 pub async fn doit(mut self) -> common::Result<(common::Response, WriteResponse)> {
8712 use std::borrow::Cow;
8713 use std::io::{Read, Seek};
8714
8715 use common::{url::Params, ToParts};
8716 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8717
8718 let mut dd = common::DefaultDelegate;
8719 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8720 dlg.begin(common::MethodInfo {
8721 id: "firestore.projects.databases.documents.write",
8722 http_method: hyper::Method::POST,
8723 });
8724
8725 for &field in ["alt", "database"].iter() {
8726 if self._additional_params.contains_key(field) {
8727 dlg.finished(false);
8728 return Err(common::Error::FieldClash(field));
8729 }
8730 }
8731
8732 let mut params = Params::with_capacity(4 + self._additional_params.len());
8733 params.push("database", self._database);
8734
8735 params.extend(self._additional_params.iter());
8736
8737 params.push("alt", "json");
8738 let mut url = self.hub._base_url.clone() + "v1beta1/{+database}/documents:write";
8739 if self._scopes.is_empty() {
8740 self._scopes
8741 .insert(Scope::CloudPlatform.as_ref().to_string());
8742 }
8743
8744 #[allow(clippy::single_element_loop)]
8745 for &(find_this, param_name) in [("{+database}", "database")].iter() {
8746 url = params.uri_replacement(url, param_name, find_this, true);
8747 }
8748 {
8749 let to_remove = ["database"];
8750 params.remove_params(&to_remove);
8751 }
8752
8753 let url = params.parse_with_url(&url);
8754
8755 let mut json_mime_type = mime::APPLICATION_JSON;
8756 let mut request_value_reader = {
8757 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8758 common::remove_json_null_values(&mut value);
8759 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8760 serde_json::to_writer(&mut dst, &value).unwrap();
8761 dst
8762 };
8763 let request_size = request_value_reader
8764 .seek(std::io::SeekFrom::End(0))
8765 .unwrap();
8766 request_value_reader
8767 .seek(std::io::SeekFrom::Start(0))
8768 .unwrap();
8769
8770 loop {
8771 let token = match self
8772 .hub
8773 .auth
8774 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8775 .await
8776 {
8777 Ok(token) => token,
8778 Err(e) => match dlg.token(e) {
8779 Ok(token) => token,
8780 Err(e) => {
8781 dlg.finished(false);
8782 return Err(common::Error::MissingToken(e));
8783 }
8784 },
8785 };
8786 request_value_reader
8787 .seek(std::io::SeekFrom::Start(0))
8788 .unwrap();
8789 let mut req_result = {
8790 let client = &self.hub.client;
8791 dlg.pre_request();
8792 let mut req_builder = hyper::Request::builder()
8793 .method(hyper::Method::POST)
8794 .uri(url.as_str())
8795 .header(USER_AGENT, self.hub._user_agent.clone());
8796
8797 if let Some(token) = token.as_ref() {
8798 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8799 }
8800
8801 let request = req_builder
8802 .header(CONTENT_TYPE, json_mime_type.to_string())
8803 .header(CONTENT_LENGTH, request_size as u64)
8804 .body(common::to_body(
8805 request_value_reader.get_ref().clone().into(),
8806 ));
8807
8808 client.request(request.unwrap()).await
8809 };
8810
8811 match req_result {
8812 Err(err) => {
8813 if let common::Retry::After(d) = dlg.http_error(&err) {
8814 sleep(d).await;
8815 continue;
8816 }
8817 dlg.finished(false);
8818 return Err(common::Error::HttpError(err));
8819 }
8820 Ok(res) => {
8821 let (mut parts, body) = res.into_parts();
8822 let mut body = common::Body::new(body);
8823 if !parts.status.is_success() {
8824 let bytes = common::to_bytes(body).await.unwrap_or_default();
8825 let error = serde_json::from_str(&common::to_string(&bytes));
8826 let response = common::to_response(parts, bytes.into());
8827
8828 if let common::Retry::After(d) =
8829 dlg.http_failure(&response, error.as_ref().ok())
8830 {
8831 sleep(d).await;
8832 continue;
8833 }
8834
8835 dlg.finished(false);
8836
8837 return Err(match error {
8838 Ok(value) => common::Error::BadRequest(value),
8839 _ => common::Error::Failure(response),
8840 });
8841 }
8842 let response = {
8843 let bytes = common::to_bytes(body).await.unwrap_or_default();
8844 let encoded = common::to_string(&bytes);
8845 match serde_json::from_str(&encoded) {
8846 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8847 Err(error) => {
8848 dlg.response_json_decode_error(&encoded, &error);
8849 return Err(common::Error::JsonDecodeError(
8850 encoded.to_string(),
8851 error,
8852 ));
8853 }
8854 }
8855 };
8856
8857 dlg.finished(true);
8858 return Ok(response);
8859 }
8860 }
8861 }
8862 }
8863
8864 ///
8865 /// Sets the *request* property to the given value.
8866 ///
8867 /// Even though the property as already been set when instantiating this call,
8868 /// we provide this method for API completeness.
8869 pub fn request(mut self, new_value: WriteRequest) -> ProjectDatabaseDocumentWriteCall<'a, C> {
8870 self._request = new_value;
8871 self
8872 }
8873 /// Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. This is only required in the first message.
8874 ///
8875 /// Sets the *database* path property to the given value.
8876 ///
8877 /// Even though the property as already been set when instantiating this call,
8878 /// we provide this method for API completeness.
8879 pub fn database(mut self, new_value: &str) -> ProjectDatabaseDocumentWriteCall<'a, C> {
8880 self._database = new_value.to_string();
8881 self
8882 }
8883 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8884 /// while executing the actual API request.
8885 ///
8886 /// ````text
8887 /// It should be used to handle progress information, and to implement a certain level of resilience.
8888 /// ````
8889 ///
8890 /// Sets the *delegate* property to the given value.
8891 pub fn delegate(
8892 mut self,
8893 new_value: &'a mut dyn common::Delegate,
8894 ) -> ProjectDatabaseDocumentWriteCall<'a, C> {
8895 self._delegate = Some(new_value);
8896 self
8897 }
8898
8899 /// Set any additional parameter of the query string used in the request.
8900 /// It should be used to set parameters which are not yet available through their own
8901 /// setters.
8902 ///
8903 /// Please note that this method must not be used to set any of the known parameters
8904 /// which have their own setter method. If done anyway, the request will fail.
8905 ///
8906 /// # Additional Parameters
8907 ///
8908 /// * *$.xgafv* (query-string) - V1 error format.
8909 /// * *access_token* (query-string) - OAuth access token.
8910 /// * *alt* (query-string) - Data format for response.
8911 /// * *callback* (query-string) - JSONP
8912 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8913 /// * *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.
8914 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8915 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8916 /// * *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.
8917 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8918 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8919 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseDocumentWriteCall<'a, C>
8920 where
8921 T: AsRef<str>,
8922 {
8923 self._additional_params
8924 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8925 self
8926 }
8927
8928 /// Identifies the authorization scope for the method you are building.
8929 ///
8930 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8931 /// [`Scope::CloudPlatform`].
8932 ///
8933 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8934 /// tokens for more than one scope.
8935 ///
8936 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8937 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8938 /// sufficient, a read-write scope will do as well.
8939 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseDocumentWriteCall<'a, C>
8940 where
8941 St: AsRef<str>,
8942 {
8943 self._scopes.insert(String::from(scope.as_ref()));
8944 self
8945 }
8946 /// Identifies the authorization scope(s) for the method you are building.
8947 ///
8948 /// See [`Self::add_scope()`] for details.
8949 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseDocumentWriteCall<'a, C>
8950 where
8951 I: IntoIterator<Item = St>,
8952 St: AsRef<str>,
8953 {
8954 self._scopes
8955 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8956 self
8957 }
8958
8959 /// Removes all scopes, and no default scope will be used either.
8960 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8961 /// for details).
8962 pub fn clear_scopes(mut self) -> ProjectDatabaseDocumentWriteCall<'a, C> {
8963 self._scopes.clear();
8964 self
8965 }
8966}
8967
8968/// 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.
8969///
8970/// A builder for the *databases.indexes.create* method supported by a *project* resource.
8971/// It is not used directly, but through a [`ProjectMethods`] instance.
8972///
8973/// # Example
8974///
8975/// Instantiate a resource method builder
8976///
8977/// ```test_harness,no_run
8978/// # extern crate hyper;
8979/// # extern crate hyper_rustls;
8980/// # extern crate google_firestore1_beta1 as firestore1_beta1;
8981/// use firestore1_beta1::api::GoogleFirestoreAdminV1beta1Index;
8982/// # async fn dox() {
8983/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8984///
8985/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8986/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8987/// # .with_native_roots()
8988/// # .unwrap()
8989/// # .https_only()
8990/// # .enable_http2()
8991/// # .build();
8992///
8993/// # let executor = hyper_util::rt::TokioExecutor::new();
8994/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8995/// # secret,
8996/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8997/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8998/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8999/// # ),
9000/// # ).build().await.unwrap();
9001///
9002/// # let client = hyper_util::client::legacy::Client::builder(
9003/// # hyper_util::rt::TokioExecutor::new()
9004/// # )
9005/// # .build(
9006/// # hyper_rustls::HttpsConnectorBuilder::new()
9007/// # .with_native_roots()
9008/// # .unwrap()
9009/// # .https_or_http()
9010/// # .enable_http2()
9011/// # .build()
9012/// # );
9013/// # let mut hub = Firestore::new(client, auth);
9014/// // As the method needs a request, you would usually fill it with the desired information
9015/// // into the respective structure. Some of the parts shown here might not be applicable !
9016/// // Values shown here are possibly random and not representative !
9017/// let mut req = GoogleFirestoreAdminV1beta1Index::default();
9018///
9019/// // You can configure optional parameters by calling the respective setters at will, and
9020/// // execute the final call using `doit()`.
9021/// // Values shown here are possibly random and not representative !
9022/// let result = hub.projects().databases_indexes_create(req, "parent")
9023/// .doit().await;
9024/// # }
9025/// ```
9026pub struct ProjectDatabaseIndexCreateCall<'a, C>
9027where
9028 C: 'a,
9029{
9030 hub: &'a Firestore<C>,
9031 _request: GoogleFirestoreAdminV1beta1Index,
9032 _parent: String,
9033 _delegate: Option<&'a mut dyn common::Delegate>,
9034 _additional_params: HashMap<String, String>,
9035 _scopes: BTreeSet<String>,
9036}
9037
9038impl<'a, C> common::CallBuilder for ProjectDatabaseIndexCreateCall<'a, C> {}
9039
9040impl<'a, C> ProjectDatabaseIndexCreateCall<'a, C>
9041where
9042 C: common::Connector,
9043{
9044 /// Perform the operation you have build so far.
9045 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
9046 use std::borrow::Cow;
9047 use std::io::{Read, Seek};
9048
9049 use common::{url::Params, ToParts};
9050 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9051
9052 let mut dd = common::DefaultDelegate;
9053 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9054 dlg.begin(common::MethodInfo {
9055 id: "firestore.projects.databases.indexes.create",
9056 http_method: hyper::Method::POST,
9057 });
9058
9059 for &field in ["alt", "parent"].iter() {
9060 if self._additional_params.contains_key(field) {
9061 dlg.finished(false);
9062 return Err(common::Error::FieldClash(field));
9063 }
9064 }
9065
9066 let mut params = Params::with_capacity(4 + self._additional_params.len());
9067 params.push("parent", self._parent);
9068
9069 params.extend(self._additional_params.iter());
9070
9071 params.push("alt", "json");
9072 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/indexes";
9073 if self._scopes.is_empty() {
9074 self._scopes
9075 .insert(Scope::CloudPlatform.as_ref().to_string());
9076 }
9077
9078 #[allow(clippy::single_element_loop)]
9079 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9080 url = params.uri_replacement(url, param_name, find_this, true);
9081 }
9082 {
9083 let to_remove = ["parent"];
9084 params.remove_params(&to_remove);
9085 }
9086
9087 let url = params.parse_with_url(&url);
9088
9089 let mut json_mime_type = mime::APPLICATION_JSON;
9090 let mut request_value_reader = {
9091 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9092 common::remove_json_null_values(&mut value);
9093 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9094 serde_json::to_writer(&mut dst, &value).unwrap();
9095 dst
9096 };
9097 let request_size = request_value_reader
9098 .seek(std::io::SeekFrom::End(0))
9099 .unwrap();
9100 request_value_reader
9101 .seek(std::io::SeekFrom::Start(0))
9102 .unwrap();
9103
9104 loop {
9105 let token = match self
9106 .hub
9107 .auth
9108 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9109 .await
9110 {
9111 Ok(token) => token,
9112 Err(e) => match dlg.token(e) {
9113 Ok(token) => token,
9114 Err(e) => {
9115 dlg.finished(false);
9116 return Err(common::Error::MissingToken(e));
9117 }
9118 },
9119 };
9120 request_value_reader
9121 .seek(std::io::SeekFrom::Start(0))
9122 .unwrap();
9123 let mut req_result = {
9124 let client = &self.hub.client;
9125 dlg.pre_request();
9126 let mut req_builder = hyper::Request::builder()
9127 .method(hyper::Method::POST)
9128 .uri(url.as_str())
9129 .header(USER_AGENT, self.hub._user_agent.clone());
9130
9131 if let Some(token) = token.as_ref() {
9132 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9133 }
9134
9135 let request = req_builder
9136 .header(CONTENT_TYPE, json_mime_type.to_string())
9137 .header(CONTENT_LENGTH, request_size as u64)
9138 .body(common::to_body(
9139 request_value_reader.get_ref().clone().into(),
9140 ));
9141
9142 client.request(request.unwrap()).await
9143 };
9144
9145 match req_result {
9146 Err(err) => {
9147 if let common::Retry::After(d) = dlg.http_error(&err) {
9148 sleep(d).await;
9149 continue;
9150 }
9151 dlg.finished(false);
9152 return Err(common::Error::HttpError(err));
9153 }
9154 Ok(res) => {
9155 let (mut parts, body) = res.into_parts();
9156 let mut body = common::Body::new(body);
9157 if !parts.status.is_success() {
9158 let bytes = common::to_bytes(body).await.unwrap_or_default();
9159 let error = serde_json::from_str(&common::to_string(&bytes));
9160 let response = common::to_response(parts, bytes.into());
9161
9162 if let common::Retry::After(d) =
9163 dlg.http_failure(&response, error.as_ref().ok())
9164 {
9165 sleep(d).await;
9166 continue;
9167 }
9168
9169 dlg.finished(false);
9170
9171 return Err(match error {
9172 Ok(value) => common::Error::BadRequest(value),
9173 _ => common::Error::Failure(response),
9174 });
9175 }
9176 let response = {
9177 let bytes = common::to_bytes(body).await.unwrap_or_default();
9178 let encoded = common::to_string(&bytes);
9179 match serde_json::from_str(&encoded) {
9180 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9181 Err(error) => {
9182 dlg.response_json_decode_error(&encoded, &error);
9183 return Err(common::Error::JsonDecodeError(
9184 encoded.to_string(),
9185 error,
9186 ));
9187 }
9188 }
9189 };
9190
9191 dlg.finished(true);
9192 return Ok(response);
9193 }
9194 }
9195 }
9196 }
9197
9198 ///
9199 /// Sets the *request* property to the given value.
9200 ///
9201 /// Even though the property as already been set when instantiating this call,
9202 /// we provide this method for API completeness.
9203 pub fn request(
9204 mut self,
9205 new_value: GoogleFirestoreAdminV1beta1Index,
9206 ) -> ProjectDatabaseIndexCreateCall<'a, C> {
9207 self._request = new_value;
9208 self
9209 }
9210 /// The name of the database this index will apply to. For example: `projects/{project_id}/databases/{database_id}`
9211 ///
9212 /// Sets the *parent* path property to the given value.
9213 ///
9214 /// Even though the property as already been set when instantiating this call,
9215 /// we provide this method for API completeness.
9216 pub fn parent(mut self, new_value: &str) -> ProjectDatabaseIndexCreateCall<'a, C> {
9217 self._parent = new_value.to_string();
9218 self
9219 }
9220 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9221 /// while executing the actual API request.
9222 ///
9223 /// ````text
9224 /// It should be used to handle progress information, and to implement a certain level of resilience.
9225 /// ````
9226 ///
9227 /// Sets the *delegate* property to the given value.
9228 pub fn delegate(
9229 mut self,
9230 new_value: &'a mut dyn common::Delegate,
9231 ) -> ProjectDatabaseIndexCreateCall<'a, C> {
9232 self._delegate = Some(new_value);
9233 self
9234 }
9235
9236 /// Set any additional parameter of the query string used in the request.
9237 /// It should be used to set parameters which are not yet available through their own
9238 /// setters.
9239 ///
9240 /// Please note that this method must not be used to set any of the known parameters
9241 /// which have their own setter method. If done anyway, the request will fail.
9242 ///
9243 /// # Additional Parameters
9244 ///
9245 /// * *$.xgafv* (query-string) - V1 error format.
9246 /// * *access_token* (query-string) - OAuth access token.
9247 /// * *alt* (query-string) - Data format for response.
9248 /// * *callback* (query-string) - JSONP
9249 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9250 /// * *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.
9251 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9252 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9253 /// * *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.
9254 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9255 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9256 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseIndexCreateCall<'a, C>
9257 where
9258 T: AsRef<str>,
9259 {
9260 self._additional_params
9261 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9262 self
9263 }
9264
9265 /// Identifies the authorization scope for the method you are building.
9266 ///
9267 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9268 /// [`Scope::CloudPlatform`].
9269 ///
9270 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9271 /// tokens for more than one scope.
9272 ///
9273 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9274 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9275 /// sufficient, a read-write scope will do as well.
9276 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseIndexCreateCall<'a, C>
9277 where
9278 St: AsRef<str>,
9279 {
9280 self._scopes.insert(String::from(scope.as_ref()));
9281 self
9282 }
9283 /// Identifies the authorization scope(s) for the method you are building.
9284 ///
9285 /// See [`Self::add_scope()`] for details.
9286 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseIndexCreateCall<'a, C>
9287 where
9288 I: IntoIterator<Item = St>,
9289 St: AsRef<str>,
9290 {
9291 self._scopes
9292 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9293 self
9294 }
9295
9296 /// Removes all scopes, and no default scope will be used either.
9297 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9298 /// for details).
9299 pub fn clear_scopes(mut self) -> ProjectDatabaseIndexCreateCall<'a, C> {
9300 self._scopes.clear();
9301 self
9302 }
9303}
9304
9305/// Deletes an index.
9306///
9307/// A builder for the *databases.indexes.delete* method supported by a *project* resource.
9308/// It is not used directly, but through a [`ProjectMethods`] instance.
9309///
9310/// # Example
9311///
9312/// Instantiate a resource method builder
9313///
9314/// ```test_harness,no_run
9315/// # extern crate hyper;
9316/// # extern crate hyper_rustls;
9317/// # extern crate google_firestore1_beta1 as firestore1_beta1;
9318/// # async fn dox() {
9319/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9320///
9321/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9322/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9323/// # .with_native_roots()
9324/// # .unwrap()
9325/// # .https_only()
9326/// # .enable_http2()
9327/// # .build();
9328///
9329/// # let executor = hyper_util::rt::TokioExecutor::new();
9330/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9331/// # secret,
9332/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9333/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9334/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9335/// # ),
9336/// # ).build().await.unwrap();
9337///
9338/// # let client = hyper_util::client::legacy::Client::builder(
9339/// # hyper_util::rt::TokioExecutor::new()
9340/// # )
9341/// # .build(
9342/// # hyper_rustls::HttpsConnectorBuilder::new()
9343/// # .with_native_roots()
9344/// # .unwrap()
9345/// # .https_or_http()
9346/// # .enable_http2()
9347/// # .build()
9348/// # );
9349/// # let mut hub = Firestore::new(client, auth);
9350/// // You can configure optional parameters by calling the respective setters at will, and
9351/// // execute the final call using `doit()`.
9352/// // Values shown here are possibly random and not representative !
9353/// let result = hub.projects().databases_indexes_delete("name")
9354/// .doit().await;
9355/// # }
9356/// ```
9357pub struct ProjectDatabaseIndexDeleteCall<'a, C>
9358where
9359 C: 'a,
9360{
9361 hub: &'a Firestore<C>,
9362 _name: String,
9363 _delegate: Option<&'a mut dyn common::Delegate>,
9364 _additional_params: HashMap<String, String>,
9365 _scopes: BTreeSet<String>,
9366}
9367
9368impl<'a, C> common::CallBuilder for ProjectDatabaseIndexDeleteCall<'a, C> {}
9369
9370impl<'a, C> ProjectDatabaseIndexDeleteCall<'a, C>
9371where
9372 C: common::Connector,
9373{
9374 /// Perform the operation you have build so far.
9375 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9376 use std::borrow::Cow;
9377 use std::io::{Read, Seek};
9378
9379 use common::{url::Params, ToParts};
9380 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9381
9382 let mut dd = common::DefaultDelegate;
9383 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9384 dlg.begin(common::MethodInfo {
9385 id: "firestore.projects.databases.indexes.delete",
9386 http_method: hyper::Method::DELETE,
9387 });
9388
9389 for &field in ["alt", "name"].iter() {
9390 if self._additional_params.contains_key(field) {
9391 dlg.finished(false);
9392 return Err(common::Error::FieldClash(field));
9393 }
9394 }
9395
9396 let mut params = Params::with_capacity(3 + self._additional_params.len());
9397 params.push("name", self._name);
9398
9399 params.extend(self._additional_params.iter());
9400
9401 params.push("alt", "json");
9402 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
9403 if self._scopes.is_empty() {
9404 self._scopes
9405 .insert(Scope::CloudPlatform.as_ref().to_string());
9406 }
9407
9408 #[allow(clippy::single_element_loop)]
9409 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9410 url = params.uri_replacement(url, param_name, find_this, true);
9411 }
9412 {
9413 let to_remove = ["name"];
9414 params.remove_params(&to_remove);
9415 }
9416
9417 let url = params.parse_with_url(&url);
9418
9419 loop {
9420 let token = match self
9421 .hub
9422 .auth
9423 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9424 .await
9425 {
9426 Ok(token) => token,
9427 Err(e) => match dlg.token(e) {
9428 Ok(token) => token,
9429 Err(e) => {
9430 dlg.finished(false);
9431 return Err(common::Error::MissingToken(e));
9432 }
9433 },
9434 };
9435 let mut req_result = {
9436 let client = &self.hub.client;
9437 dlg.pre_request();
9438 let mut req_builder = hyper::Request::builder()
9439 .method(hyper::Method::DELETE)
9440 .uri(url.as_str())
9441 .header(USER_AGENT, self.hub._user_agent.clone());
9442
9443 if let Some(token) = token.as_ref() {
9444 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9445 }
9446
9447 let request = req_builder
9448 .header(CONTENT_LENGTH, 0_u64)
9449 .body(common::to_body::<String>(None));
9450
9451 client.request(request.unwrap()).await
9452 };
9453
9454 match req_result {
9455 Err(err) => {
9456 if let common::Retry::After(d) = dlg.http_error(&err) {
9457 sleep(d).await;
9458 continue;
9459 }
9460 dlg.finished(false);
9461 return Err(common::Error::HttpError(err));
9462 }
9463 Ok(res) => {
9464 let (mut parts, body) = res.into_parts();
9465 let mut body = common::Body::new(body);
9466 if !parts.status.is_success() {
9467 let bytes = common::to_bytes(body).await.unwrap_or_default();
9468 let error = serde_json::from_str(&common::to_string(&bytes));
9469 let response = common::to_response(parts, bytes.into());
9470
9471 if let common::Retry::After(d) =
9472 dlg.http_failure(&response, error.as_ref().ok())
9473 {
9474 sleep(d).await;
9475 continue;
9476 }
9477
9478 dlg.finished(false);
9479
9480 return Err(match error {
9481 Ok(value) => common::Error::BadRequest(value),
9482 _ => common::Error::Failure(response),
9483 });
9484 }
9485 let response = {
9486 let bytes = common::to_bytes(body).await.unwrap_or_default();
9487 let encoded = common::to_string(&bytes);
9488 match serde_json::from_str(&encoded) {
9489 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9490 Err(error) => {
9491 dlg.response_json_decode_error(&encoded, &error);
9492 return Err(common::Error::JsonDecodeError(
9493 encoded.to_string(),
9494 error,
9495 ));
9496 }
9497 }
9498 };
9499
9500 dlg.finished(true);
9501 return Ok(response);
9502 }
9503 }
9504 }
9505 }
9506
9507 /// The index name. For example: `projects/{project_id}/databases/{database_id}/indexes/{index_id}`
9508 ///
9509 /// Sets the *name* path property to the given value.
9510 ///
9511 /// Even though the property as already been set when instantiating this call,
9512 /// we provide this method for API completeness.
9513 pub fn name(mut self, new_value: &str) -> ProjectDatabaseIndexDeleteCall<'a, C> {
9514 self._name = new_value.to_string();
9515 self
9516 }
9517 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9518 /// while executing the actual API request.
9519 ///
9520 /// ````text
9521 /// It should be used to handle progress information, and to implement a certain level of resilience.
9522 /// ````
9523 ///
9524 /// Sets the *delegate* property to the given value.
9525 pub fn delegate(
9526 mut self,
9527 new_value: &'a mut dyn common::Delegate,
9528 ) -> ProjectDatabaseIndexDeleteCall<'a, C> {
9529 self._delegate = Some(new_value);
9530 self
9531 }
9532
9533 /// Set any additional parameter of the query string used in the request.
9534 /// It should be used to set parameters which are not yet available through their own
9535 /// setters.
9536 ///
9537 /// Please note that this method must not be used to set any of the known parameters
9538 /// which have their own setter method. If done anyway, the request will fail.
9539 ///
9540 /// # Additional Parameters
9541 ///
9542 /// * *$.xgafv* (query-string) - V1 error format.
9543 /// * *access_token* (query-string) - OAuth access token.
9544 /// * *alt* (query-string) - Data format for response.
9545 /// * *callback* (query-string) - JSONP
9546 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9547 /// * *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.
9548 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9549 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9550 /// * *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.
9551 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9552 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9553 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseIndexDeleteCall<'a, C>
9554 where
9555 T: AsRef<str>,
9556 {
9557 self._additional_params
9558 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9559 self
9560 }
9561
9562 /// Identifies the authorization scope for the method you are building.
9563 ///
9564 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9565 /// [`Scope::CloudPlatform`].
9566 ///
9567 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9568 /// tokens for more than one scope.
9569 ///
9570 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9571 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9572 /// sufficient, a read-write scope will do as well.
9573 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseIndexDeleteCall<'a, C>
9574 where
9575 St: AsRef<str>,
9576 {
9577 self._scopes.insert(String::from(scope.as_ref()));
9578 self
9579 }
9580 /// Identifies the authorization scope(s) for the method you are building.
9581 ///
9582 /// See [`Self::add_scope()`] for details.
9583 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseIndexDeleteCall<'a, C>
9584 where
9585 I: IntoIterator<Item = St>,
9586 St: AsRef<str>,
9587 {
9588 self._scopes
9589 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9590 self
9591 }
9592
9593 /// Removes all scopes, and no default scope will be used either.
9594 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9595 /// for details).
9596 pub fn clear_scopes(mut self) -> ProjectDatabaseIndexDeleteCall<'a, C> {
9597 self._scopes.clear();
9598 self
9599 }
9600}
9601
9602/// Gets an index.
9603///
9604/// A builder for the *databases.indexes.get* method supported by a *project* resource.
9605/// It is not used directly, but through a [`ProjectMethods`] instance.
9606///
9607/// # Example
9608///
9609/// Instantiate a resource method builder
9610///
9611/// ```test_harness,no_run
9612/// # extern crate hyper;
9613/// # extern crate hyper_rustls;
9614/// # extern crate google_firestore1_beta1 as firestore1_beta1;
9615/// # async fn dox() {
9616/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9617///
9618/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9619/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9620/// # .with_native_roots()
9621/// # .unwrap()
9622/// # .https_only()
9623/// # .enable_http2()
9624/// # .build();
9625///
9626/// # let executor = hyper_util::rt::TokioExecutor::new();
9627/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9628/// # secret,
9629/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9630/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9631/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9632/// # ),
9633/// # ).build().await.unwrap();
9634///
9635/// # let client = hyper_util::client::legacy::Client::builder(
9636/// # hyper_util::rt::TokioExecutor::new()
9637/// # )
9638/// # .build(
9639/// # hyper_rustls::HttpsConnectorBuilder::new()
9640/// # .with_native_roots()
9641/// # .unwrap()
9642/// # .https_or_http()
9643/// # .enable_http2()
9644/// # .build()
9645/// # );
9646/// # let mut hub = Firestore::new(client, auth);
9647/// // You can configure optional parameters by calling the respective setters at will, and
9648/// // execute the final call using `doit()`.
9649/// // Values shown here are possibly random and not representative !
9650/// let result = hub.projects().databases_indexes_get("name")
9651/// .doit().await;
9652/// # }
9653/// ```
9654pub struct ProjectDatabaseIndexGetCall<'a, C>
9655where
9656 C: 'a,
9657{
9658 hub: &'a Firestore<C>,
9659 _name: String,
9660 _delegate: Option<&'a mut dyn common::Delegate>,
9661 _additional_params: HashMap<String, String>,
9662 _scopes: BTreeSet<String>,
9663}
9664
9665impl<'a, C> common::CallBuilder for ProjectDatabaseIndexGetCall<'a, C> {}
9666
9667impl<'a, C> ProjectDatabaseIndexGetCall<'a, C>
9668where
9669 C: common::Connector,
9670{
9671 /// Perform the operation you have build so far.
9672 pub async fn doit(
9673 mut self,
9674 ) -> common::Result<(common::Response, GoogleFirestoreAdminV1beta1Index)> {
9675 use std::borrow::Cow;
9676 use std::io::{Read, Seek};
9677
9678 use common::{url::Params, ToParts};
9679 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9680
9681 let mut dd = common::DefaultDelegate;
9682 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9683 dlg.begin(common::MethodInfo {
9684 id: "firestore.projects.databases.indexes.get",
9685 http_method: hyper::Method::GET,
9686 });
9687
9688 for &field in ["alt", "name"].iter() {
9689 if self._additional_params.contains_key(field) {
9690 dlg.finished(false);
9691 return Err(common::Error::FieldClash(field));
9692 }
9693 }
9694
9695 let mut params = Params::with_capacity(3 + self._additional_params.len());
9696 params.push("name", self._name);
9697
9698 params.extend(self._additional_params.iter());
9699
9700 params.push("alt", "json");
9701 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
9702 if self._scopes.is_empty() {
9703 self._scopes
9704 .insert(Scope::CloudPlatform.as_ref().to_string());
9705 }
9706
9707 #[allow(clippy::single_element_loop)]
9708 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9709 url = params.uri_replacement(url, param_name, find_this, true);
9710 }
9711 {
9712 let to_remove = ["name"];
9713 params.remove_params(&to_remove);
9714 }
9715
9716 let url = params.parse_with_url(&url);
9717
9718 loop {
9719 let token = match self
9720 .hub
9721 .auth
9722 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9723 .await
9724 {
9725 Ok(token) => token,
9726 Err(e) => match dlg.token(e) {
9727 Ok(token) => token,
9728 Err(e) => {
9729 dlg.finished(false);
9730 return Err(common::Error::MissingToken(e));
9731 }
9732 },
9733 };
9734 let mut req_result = {
9735 let client = &self.hub.client;
9736 dlg.pre_request();
9737 let mut req_builder = hyper::Request::builder()
9738 .method(hyper::Method::GET)
9739 .uri(url.as_str())
9740 .header(USER_AGENT, self.hub._user_agent.clone());
9741
9742 if let Some(token) = token.as_ref() {
9743 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9744 }
9745
9746 let request = req_builder
9747 .header(CONTENT_LENGTH, 0_u64)
9748 .body(common::to_body::<String>(None));
9749
9750 client.request(request.unwrap()).await
9751 };
9752
9753 match req_result {
9754 Err(err) => {
9755 if let common::Retry::After(d) = dlg.http_error(&err) {
9756 sleep(d).await;
9757 continue;
9758 }
9759 dlg.finished(false);
9760 return Err(common::Error::HttpError(err));
9761 }
9762 Ok(res) => {
9763 let (mut parts, body) = res.into_parts();
9764 let mut body = common::Body::new(body);
9765 if !parts.status.is_success() {
9766 let bytes = common::to_bytes(body).await.unwrap_or_default();
9767 let error = serde_json::from_str(&common::to_string(&bytes));
9768 let response = common::to_response(parts, bytes.into());
9769
9770 if let common::Retry::After(d) =
9771 dlg.http_failure(&response, error.as_ref().ok())
9772 {
9773 sleep(d).await;
9774 continue;
9775 }
9776
9777 dlg.finished(false);
9778
9779 return Err(match error {
9780 Ok(value) => common::Error::BadRequest(value),
9781 _ => common::Error::Failure(response),
9782 });
9783 }
9784 let response = {
9785 let bytes = common::to_bytes(body).await.unwrap_or_default();
9786 let encoded = common::to_string(&bytes);
9787 match serde_json::from_str(&encoded) {
9788 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9789 Err(error) => {
9790 dlg.response_json_decode_error(&encoded, &error);
9791 return Err(common::Error::JsonDecodeError(
9792 encoded.to_string(),
9793 error,
9794 ));
9795 }
9796 }
9797 };
9798
9799 dlg.finished(true);
9800 return Ok(response);
9801 }
9802 }
9803 }
9804 }
9805
9806 /// The name of the index. For example: `projects/{project_id}/databases/{database_id}/indexes/{index_id}`
9807 ///
9808 /// Sets the *name* path property to the given value.
9809 ///
9810 /// Even though the property as already been set when instantiating this call,
9811 /// we provide this method for API completeness.
9812 pub fn name(mut self, new_value: &str) -> ProjectDatabaseIndexGetCall<'a, C> {
9813 self._name = new_value.to_string();
9814 self
9815 }
9816 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9817 /// while executing the actual API request.
9818 ///
9819 /// ````text
9820 /// It should be used to handle progress information, and to implement a certain level of resilience.
9821 /// ````
9822 ///
9823 /// Sets the *delegate* property to the given value.
9824 pub fn delegate(
9825 mut self,
9826 new_value: &'a mut dyn common::Delegate,
9827 ) -> ProjectDatabaseIndexGetCall<'a, C> {
9828 self._delegate = Some(new_value);
9829 self
9830 }
9831
9832 /// Set any additional parameter of the query string used in the request.
9833 /// It should be used to set parameters which are not yet available through their own
9834 /// setters.
9835 ///
9836 /// Please note that this method must not be used to set any of the known parameters
9837 /// which have their own setter method. If done anyway, the request will fail.
9838 ///
9839 /// # Additional Parameters
9840 ///
9841 /// * *$.xgafv* (query-string) - V1 error format.
9842 /// * *access_token* (query-string) - OAuth access token.
9843 /// * *alt* (query-string) - Data format for response.
9844 /// * *callback* (query-string) - JSONP
9845 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9846 /// * *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.
9847 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9848 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9849 /// * *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.
9850 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9851 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9852 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseIndexGetCall<'a, C>
9853 where
9854 T: AsRef<str>,
9855 {
9856 self._additional_params
9857 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9858 self
9859 }
9860
9861 /// Identifies the authorization scope for the method you are building.
9862 ///
9863 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9864 /// [`Scope::CloudPlatform`].
9865 ///
9866 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9867 /// tokens for more than one scope.
9868 ///
9869 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9870 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9871 /// sufficient, a read-write scope will do as well.
9872 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseIndexGetCall<'a, C>
9873 where
9874 St: AsRef<str>,
9875 {
9876 self._scopes.insert(String::from(scope.as_ref()));
9877 self
9878 }
9879 /// Identifies the authorization scope(s) for the method you are building.
9880 ///
9881 /// See [`Self::add_scope()`] for details.
9882 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseIndexGetCall<'a, C>
9883 where
9884 I: IntoIterator<Item = St>,
9885 St: AsRef<str>,
9886 {
9887 self._scopes
9888 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9889 self
9890 }
9891
9892 /// Removes all scopes, and no default scope will be used either.
9893 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9894 /// for details).
9895 pub fn clear_scopes(mut self) -> ProjectDatabaseIndexGetCall<'a, C> {
9896 self._scopes.clear();
9897 self
9898 }
9899}
9900
9901/// Lists the indexes that match the specified filters.
9902///
9903/// A builder for the *databases.indexes.list* method supported by a *project* resource.
9904/// It is not used directly, but through a [`ProjectMethods`] instance.
9905///
9906/// # Example
9907///
9908/// Instantiate a resource method builder
9909///
9910/// ```test_harness,no_run
9911/// # extern crate hyper;
9912/// # extern crate hyper_rustls;
9913/// # extern crate google_firestore1_beta1 as firestore1_beta1;
9914/// # async fn dox() {
9915/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9916///
9917/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9918/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9919/// # .with_native_roots()
9920/// # .unwrap()
9921/// # .https_only()
9922/// # .enable_http2()
9923/// # .build();
9924///
9925/// # let executor = hyper_util::rt::TokioExecutor::new();
9926/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9927/// # secret,
9928/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9929/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9930/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9931/// # ),
9932/// # ).build().await.unwrap();
9933///
9934/// # let client = hyper_util::client::legacy::Client::builder(
9935/// # hyper_util::rt::TokioExecutor::new()
9936/// # )
9937/// # .build(
9938/// # hyper_rustls::HttpsConnectorBuilder::new()
9939/// # .with_native_roots()
9940/// # .unwrap()
9941/// # .https_or_http()
9942/// # .enable_http2()
9943/// # .build()
9944/// # );
9945/// # let mut hub = Firestore::new(client, auth);
9946/// // You can configure optional parameters by calling the respective setters at will, and
9947/// // execute the final call using `doit()`.
9948/// // Values shown here are possibly random and not representative !
9949/// let result = hub.projects().databases_indexes_list("parent")
9950/// .page_token("et")
9951/// .page_size(-76)
9952/// .filter("erat")
9953/// .doit().await;
9954/// # }
9955/// ```
9956pub struct ProjectDatabaseIndexListCall<'a, C>
9957where
9958 C: 'a,
9959{
9960 hub: &'a Firestore<C>,
9961 _parent: String,
9962 _page_token: Option<String>,
9963 _page_size: Option<i32>,
9964 _filter: Option<String>,
9965 _delegate: Option<&'a mut dyn common::Delegate>,
9966 _additional_params: HashMap<String, String>,
9967 _scopes: BTreeSet<String>,
9968}
9969
9970impl<'a, C> common::CallBuilder for ProjectDatabaseIndexListCall<'a, C> {}
9971
9972impl<'a, C> ProjectDatabaseIndexListCall<'a, C>
9973where
9974 C: common::Connector,
9975{
9976 /// Perform the operation you have build so far.
9977 pub async fn doit(
9978 mut self,
9979 ) -> common::Result<(
9980 common::Response,
9981 GoogleFirestoreAdminV1beta1ListIndexesResponse,
9982 )> {
9983 use std::borrow::Cow;
9984 use std::io::{Read, Seek};
9985
9986 use common::{url::Params, ToParts};
9987 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9988
9989 let mut dd = common::DefaultDelegate;
9990 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9991 dlg.begin(common::MethodInfo {
9992 id: "firestore.projects.databases.indexes.list",
9993 http_method: hyper::Method::GET,
9994 });
9995
9996 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
9997 if self._additional_params.contains_key(field) {
9998 dlg.finished(false);
9999 return Err(common::Error::FieldClash(field));
10000 }
10001 }
10002
10003 let mut params = Params::with_capacity(6 + self._additional_params.len());
10004 params.push("parent", self._parent);
10005 if let Some(value) = self._page_token.as_ref() {
10006 params.push("pageToken", value);
10007 }
10008 if let Some(value) = self._page_size.as_ref() {
10009 params.push("pageSize", value.to_string());
10010 }
10011 if let Some(value) = self._filter.as_ref() {
10012 params.push("filter", value);
10013 }
10014
10015 params.extend(self._additional_params.iter());
10016
10017 params.push("alt", "json");
10018 let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/indexes";
10019 if self._scopes.is_empty() {
10020 self._scopes
10021 .insert(Scope::CloudPlatform.as_ref().to_string());
10022 }
10023
10024 #[allow(clippy::single_element_loop)]
10025 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10026 url = params.uri_replacement(url, param_name, find_this, true);
10027 }
10028 {
10029 let to_remove = ["parent"];
10030 params.remove_params(&to_remove);
10031 }
10032
10033 let url = params.parse_with_url(&url);
10034
10035 loop {
10036 let token = match self
10037 .hub
10038 .auth
10039 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10040 .await
10041 {
10042 Ok(token) => token,
10043 Err(e) => match dlg.token(e) {
10044 Ok(token) => token,
10045 Err(e) => {
10046 dlg.finished(false);
10047 return Err(common::Error::MissingToken(e));
10048 }
10049 },
10050 };
10051 let mut req_result = {
10052 let client = &self.hub.client;
10053 dlg.pre_request();
10054 let mut req_builder = hyper::Request::builder()
10055 .method(hyper::Method::GET)
10056 .uri(url.as_str())
10057 .header(USER_AGENT, self.hub._user_agent.clone());
10058
10059 if let Some(token) = token.as_ref() {
10060 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10061 }
10062
10063 let request = req_builder
10064 .header(CONTENT_LENGTH, 0_u64)
10065 .body(common::to_body::<String>(None));
10066
10067 client.request(request.unwrap()).await
10068 };
10069
10070 match req_result {
10071 Err(err) => {
10072 if let common::Retry::After(d) = dlg.http_error(&err) {
10073 sleep(d).await;
10074 continue;
10075 }
10076 dlg.finished(false);
10077 return Err(common::Error::HttpError(err));
10078 }
10079 Ok(res) => {
10080 let (mut parts, body) = res.into_parts();
10081 let mut body = common::Body::new(body);
10082 if !parts.status.is_success() {
10083 let bytes = common::to_bytes(body).await.unwrap_or_default();
10084 let error = serde_json::from_str(&common::to_string(&bytes));
10085 let response = common::to_response(parts, bytes.into());
10086
10087 if let common::Retry::After(d) =
10088 dlg.http_failure(&response, error.as_ref().ok())
10089 {
10090 sleep(d).await;
10091 continue;
10092 }
10093
10094 dlg.finished(false);
10095
10096 return Err(match error {
10097 Ok(value) => common::Error::BadRequest(value),
10098 _ => common::Error::Failure(response),
10099 });
10100 }
10101 let response = {
10102 let bytes = common::to_bytes(body).await.unwrap_or_default();
10103 let encoded = common::to_string(&bytes);
10104 match serde_json::from_str(&encoded) {
10105 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10106 Err(error) => {
10107 dlg.response_json_decode_error(&encoded, &error);
10108 return Err(common::Error::JsonDecodeError(
10109 encoded.to_string(),
10110 error,
10111 ));
10112 }
10113 }
10114 };
10115
10116 dlg.finished(true);
10117 return Ok(response);
10118 }
10119 }
10120 }
10121 }
10122
10123 /// The database name. For example: `projects/{project_id}/databases/{database_id}`
10124 ///
10125 /// Sets the *parent* path property to the given value.
10126 ///
10127 /// Even though the property as already been set when instantiating this call,
10128 /// we provide this method for API completeness.
10129 pub fn parent(mut self, new_value: &str) -> ProjectDatabaseIndexListCall<'a, C> {
10130 self._parent = new_value.to_string();
10131 self
10132 }
10133 /// The standard List page token.
10134 ///
10135 /// Sets the *page token* query property to the given value.
10136 pub fn page_token(mut self, new_value: &str) -> ProjectDatabaseIndexListCall<'a, C> {
10137 self._page_token = Some(new_value.to_string());
10138 self
10139 }
10140 /// The standard List page size.
10141 ///
10142 /// Sets the *page size* query property to the given value.
10143 pub fn page_size(mut self, new_value: i32) -> ProjectDatabaseIndexListCall<'a, C> {
10144 self._page_size = Some(new_value);
10145 self
10146 }
10147 ///
10148 /// Sets the *filter* query property to the given value.
10149 pub fn filter(mut self, new_value: &str) -> ProjectDatabaseIndexListCall<'a, C> {
10150 self._filter = Some(new_value.to_string());
10151 self
10152 }
10153 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10154 /// while executing the actual API request.
10155 ///
10156 /// ````text
10157 /// It should be used to handle progress information, and to implement a certain level of resilience.
10158 /// ````
10159 ///
10160 /// Sets the *delegate* property to the given value.
10161 pub fn delegate(
10162 mut self,
10163 new_value: &'a mut dyn common::Delegate,
10164 ) -> ProjectDatabaseIndexListCall<'a, C> {
10165 self._delegate = Some(new_value);
10166 self
10167 }
10168
10169 /// Set any additional parameter of the query string used in the request.
10170 /// It should be used to set parameters which are not yet available through their own
10171 /// setters.
10172 ///
10173 /// Please note that this method must not be used to set any of the known parameters
10174 /// which have their own setter method. If done anyway, the request will fail.
10175 ///
10176 /// # Additional Parameters
10177 ///
10178 /// * *$.xgafv* (query-string) - V1 error format.
10179 /// * *access_token* (query-string) - OAuth access token.
10180 /// * *alt* (query-string) - Data format for response.
10181 /// * *callback* (query-string) - JSONP
10182 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10183 /// * *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.
10184 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10185 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10186 /// * *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.
10187 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10188 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10189 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseIndexListCall<'a, C>
10190 where
10191 T: AsRef<str>,
10192 {
10193 self._additional_params
10194 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10195 self
10196 }
10197
10198 /// Identifies the authorization scope for the method you are building.
10199 ///
10200 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10201 /// [`Scope::CloudPlatform`].
10202 ///
10203 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10204 /// tokens for more than one scope.
10205 ///
10206 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10207 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10208 /// sufficient, a read-write scope will do as well.
10209 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseIndexListCall<'a, C>
10210 where
10211 St: AsRef<str>,
10212 {
10213 self._scopes.insert(String::from(scope.as_ref()));
10214 self
10215 }
10216 /// Identifies the authorization scope(s) for the method you are building.
10217 ///
10218 /// See [`Self::add_scope()`] for details.
10219 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseIndexListCall<'a, C>
10220 where
10221 I: IntoIterator<Item = St>,
10222 St: AsRef<str>,
10223 {
10224 self._scopes
10225 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10226 self
10227 }
10228
10229 /// Removes all scopes, and no default scope will be used either.
10230 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10231 /// for details).
10232 pub fn clear_scopes(mut self) -> ProjectDatabaseIndexListCall<'a, C> {
10233 self._scopes.clear();
10234 self
10235 }
10236}
10237
10238/// 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.
10239///
10240/// A builder for the *databases.exportDocuments* method supported by a *project* resource.
10241/// It is not used directly, but through a [`ProjectMethods`] instance.
10242///
10243/// # Example
10244///
10245/// Instantiate a resource method builder
10246///
10247/// ```test_harness,no_run
10248/// # extern crate hyper;
10249/// # extern crate hyper_rustls;
10250/// # extern crate google_firestore1_beta1 as firestore1_beta1;
10251/// use firestore1_beta1::api::GoogleFirestoreAdminV1beta1ExportDocumentsRequest;
10252/// # async fn dox() {
10253/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10254///
10255/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10256/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10257/// # .with_native_roots()
10258/// # .unwrap()
10259/// # .https_only()
10260/// # .enable_http2()
10261/// # .build();
10262///
10263/// # let executor = hyper_util::rt::TokioExecutor::new();
10264/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10265/// # secret,
10266/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10267/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10268/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10269/// # ),
10270/// # ).build().await.unwrap();
10271///
10272/// # let client = hyper_util::client::legacy::Client::builder(
10273/// # hyper_util::rt::TokioExecutor::new()
10274/// # )
10275/// # .build(
10276/// # hyper_rustls::HttpsConnectorBuilder::new()
10277/// # .with_native_roots()
10278/// # .unwrap()
10279/// # .https_or_http()
10280/// # .enable_http2()
10281/// # .build()
10282/// # );
10283/// # let mut hub = Firestore::new(client, auth);
10284/// // As the method needs a request, you would usually fill it with the desired information
10285/// // into the respective structure. Some of the parts shown here might not be applicable !
10286/// // Values shown here are possibly random and not representative !
10287/// let mut req = GoogleFirestoreAdminV1beta1ExportDocumentsRequest::default();
10288///
10289/// // You can configure optional parameters by calling the respective setters at will, and
10290/// // execute the final call using `doit()`.
10291/// // Values shown here are possibly random and not representative !
10292/// let result = hub.projects().databases_export_documents(req, "name")
10293/// .doit().await;
10294/// # }
10295/// ```
10296pub struct ProjectDatabaseExportDocumentCall<'a, C>
10297where
10298 C: 'a,
10299{
10300 hub: &'a Firestore<C>,
10301 _request: GoogleFirestoreAdminV1beta1ExportDocumentsRequest,
10302 _name: String,
10303 _delegate: Option<&'a mut dyn common::Delegate>,
10304 _additional_params: HashMap<String, String>,
10305 _scopes: BTreeSet<String>,
10306}
10307
10308impl<'a, C> common::CallBuilder for ProjectDatabaseExportDocumentCall<'a, C> {}
10309
10310impl<'a, C> ProjectDatabaseExportDocumentCall<'a, C>
10311where
10312 C: common::Connector,
10313{
10314 /// Perform the operation you have build so far.
10315 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10316 use std::borrow::Cow;
10317 use std::io::{Read, Seek};
10318
10319 use common::{url::Params, ToParts};
10320 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10321
10322 let mut dd = common::DefaultDelegate;
10323 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10324 dlg.begin(common::MethodInfo {
10325 id: "firestore.projects.databases.exportDocuments",
10326 http_method: hyper::Method::POST,
10327 });
10328
10329 for &field in ["alt", "name"].iter() {
10330 if self._additional_params.contains_key(field) {
10331 dlg.finished(false);
10332 return Err(common::Error::FieldClash(field));
10333 }
10334 }
10335
10336 let mut params = Params::with_capacity(4 + self._additional_params.len());
10337 params.push("name", self._name);
10338
10339 params.extend(self._additional_params.iter());
10340
10341 params.push("alt", "json");
10342 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:exportDocuments";
10343 if self._scopes.is_empty() {
10344 self._scopes
10345 .insert(Scope::CloudPlatform.as_ref().to_string());
10346 }
10347
10348 #[allow(clippy::single_element_loop)]
10349 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10350 url = params.uri_replacement(url, param_name, find_this, true);
10351 }
10352 {
10353 let to_remove = ["name"];
10354 params.remove_params(&to_remove);
10355 }
10356
10357 let url = params.parse_with_url(&url);
10358
10359 let mut json_mime_type = mime::APPLICATION_JSON;
10360 let mut request_value_reader = {
10361 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10362 common::remove_json_null_values(&mut value);
10363 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10364 serde_json::to_writer(&mut dst, &value).unwrap();
10365 dst
10366 };
10367 let request_size = request_value_reader
10368 .seek(std::io::SeekFrom::End(0))
10369 .unwrap();
10370 request_value_reader
10371 .seek(std::io::SeekFrom::Start(0))
10372 .unwrap();
10373
10374 loop {
10375 let token = match self
10376 .hub
10377 .auth
10378 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10379 .await
10380 {
10381 Ok(token) => token,
10382 Err(e) => match dlg.token(e) {
10383 Ok(token) => token,
10384 Err(e) => {
10385 dlg.finished(false);
10386 return Err(common::Error::MissingToken(e));
10387 }
10388 },
10389 };
10390 request_value_reader
10391 .seek(std::io::SeekFrom::Start(0))
10392 .unwrap();
10393 let mut req_result = {
10394 let client = &self.hub.client;
10395 dlg.pre_request();
10396 let mut req_builder = hyper::Request::builder()
10397 .method(hyper::Method::POST)
10398 .uri(url.as_str())
10399 .header(USER_AGENT, self.hub._user_agent.clone());
10400
10401 if let Some(token) = token.as_ref() {
10402 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10403 }
10404
10405 let request = req_builder
10406 .header(CONTENT_TYPE, json_mime_type.to_string())
10407 .header(CONTENT_LENGTH, request_size as u64)
10408 .body(common::to_body(
10409 request_value_reader.get_ref().clone().into(),
10410 ));
10411
10412 client.request(request.unwrap()).await
10413 };
10414
10415 match req_result {
10416 Err(err) => {
10417 if let common::Retry::After(d) = dlg.http_error(&err) {
10418 sleep(d).await;
10419 continue;
10420 }
10421 dlg.finished(false);
10422 return Err(common::Error::HttpError(err));
10423 }
10424 Ok(res) => {
10425 let (mut parts, body) = res.into_parts();
10426 let mut body = common::Body::new(body);
10427 if !parts.status.is_success() {
10428 let bytes = common::to_bytes(body).await.unwrap_or_default();
10429 let error = serde_json::from_str(&common::to_string(&bytes));
10430 let response = common::to_response(parts, bytes.into());
10431
10432 if let common::Retry::After(d) =
10433 dlg.http_failure(&response, error.as_ref().ok())
10434 {
10435 sleep(d).await;
10436 continue;
10437 }
10438
10439 dlg.finished(false);
10440
10441 return Err(match error {
10442 Ok(value) => common::Error::BadRequest(value),
10443 _ => common::Error::Failure(response),
10444 });
10445 }
10446 let response = {
10447 let bytes = common::to_bytes(body).await.unwrap_or_default();
10448 let encoded = common::to_string(&bytes);
10449 match serde_json::from_str(&encoded) {
10450 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10451 Err(error) => {
10452 dlg.response_json_decode_error(&encoded, &error);
10453 return Err(common::Error::JsonDecodeError(
10454 encoded.to_string(),
10455 error,
10456 ));
10457 }
10458 }
10459 };
10460
10461 dlg.finished(true);
10462 return Ok(response);
10463 }
10464 }
10465 }
10466 }
10467
10468 ///
10469 /// Sets the *request* property to the given value.
10470 ///
10471 /// Even though the property as already been set when instantiating this call,
10472 /// we provide this method for API completeness.
10473 pub fn request(
10474 mut self,
10475 new_value: GoogleFirestoreAdminV1beta1ExportDocumentsRequest,
10476 ) -> ProjectDatabaseExportDocumentCall<'a, C> {
10477 self._request = new_value;
10478 self
10479 }
10480 /// Database to export. Should be of the form: `projects/{project_id}/databases/{database_id}`.
10481 ///
10482 /// Sets the *name* path property to the given value.
10483 ///
10484 /// Even though the property as already been set when instantiating this call,
10485 /// we provide this method for API completeness.
10486 pub fn name(mut self, new_value: &str) -> ProjectDatabaseExportDocumentCall<'a, C> {
10487 self._name = new_value.to_string();
10488 self
10489 }
10490 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10491 /// while executing the actual API request.
10492 ///
10493 /// ````text
10494 /// It should be used to handle progress information, and to implement a certain level of resilience.
10495 /// ````
10496 ///
10497 /// Sets the *delegate* property to the given value.
10498 pub fn delegate(
10499 mut self,
10500 new_value: &'a mut dyn common::Delegate,
10501 ) -> ProjectDatabaseExportDocumentCall<'a, C> {
10502 self._delegate = Some(new_value);
10503 self
10504 }
10505
10506 /// Set any additional parameter of the query string used in the request.
10507 /// It should be used to set parameters which are not yet available through their own
10508 /// setters.
10509 ///
10510 /// Please note that this method must not be used to set any of the known parameters
10511 /// which have their own setter method. If done anyway, the request will fail.
10512 ///
10513 /// # Additional Parameters
10514 ///
10515 /// * *$.xgafv* (query-string) - V1 error format.
10516 /// * *access_token* (query-string) - OAuth access token.
10517 /// * *alt* (query-string) - Data format for response.
10518 /// * *callback* (query-string) - JSONP
10519 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10520 /// * *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.
10521 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10522 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10523 /// * *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.
10524 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10525 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10526 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseExportDocumentCall<'a, C>
10527 where
10528 T: AsRef<str>,
10529 {
10530 self._additional_params
10531 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10532 self
10533 }
10534
10535 /// Identifies the authorization scope for the method you are building.
10536 ///
10537 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10538 /// [`Scope::CloudPlatform`].
10539 ///
10540 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10541 /// tokens for more than one scope.
10542 ///
10543 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10544 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10545 /// sufficient, a read-write scope will do as well.
10546 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseExportDocumentCall<'a, C>
10547 where
10548 St: AsRef<str>,
10549 {
10550 self._scopes.insert(String::from(scope.as_ref()));
10551 self
10552 }
10553 /// Identifies the authorization scope(s) for the method you are building.
10554 ///
10555 /// See [`Self::add_scope()`] for details.
10556 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseExportDocumentCall<'a, C>
10557 where
10558 I: IntoIterator<Item = St>,
10559 St: AsRef<str>,
10560 {
10561 self._scopes
10562 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10563 self
10564 }
10565
10566 /// Removes all scopes, and no default scope will be used either.
10567 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10568 /// for details).
10569 pub fn clear_scopes(mut self) -> ProjectDatabaseExportDocumentCall<'a, C> {
10570 self._scopes.clear();
10571 self
10572 }
10573}
10574
10575/// 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.
10576///
10577/// A builder for the *databases.importDocuments* method supported by a *project* resource.
10578/// It is not used directly, but through a [`ProjectMethods`] instance.
10579///
10580/// # Example
10581///
10582/// Instantiate a resource method builder
10583///
10584/// ```test_harness,no_run
10585/// # extern crate hyper;
10586/// # extern crate hyper_rustls;
10587/// # extern crate google_firestore1_beta1 as firestore1_beta1;
10588/// use firestore1_beta1::api::GoogleFirestoreAdminV1beta1ImportDocumentsRequest;
10589/// # async fn dox() {
10590/// # use firestore1_beta1::{Firestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10591///
10592/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10593/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10594/// # .with_native_roots()
10595/// # .unwrap()
10596/// # .https_only()
10597/// # .enable_http2()
10598/// # .build();
10599///
10600/// # let executor = hyper_util::rt::TokioExecutor::new();
10601/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10602/// # secret,
10603/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10604/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10605/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10606/// # ),
10607/// # ).build().await.unwrap();
10608///
10609/// # let client = hyper_util::client::legacy::Client::builder(
10610/// # hyper_util::rt::TokioExecutor::new()
10611/// # )
10612/// # .build(
10613/// # hyper_rustls::HttpsConnectorBuilder::new()
10614/// # .with_native_roots()
10615/// # .unwrap()
10616/// # .https_or_http()
10617/// # .enable_http2()
10618/// # .build()
10619/// # );
10620/// # let mut hub = Firestore::new(client, auth);
10621/// // As the method needs a request, you would usually fill it with the desired information
10622/// // into the respective structure. Some of the parts shown here might not be applicable !
10623/// // Values shown here are possibly random and not representative !
10624/// let mut req = GoogleFirestoreAdminV1beta1ImportDocumentsRequest::default();
10625///
10626/// // You can configure optional parameters by calling the respective setters at will, and
10627/// // execute the final call using `doit()`.
10628/// // Values shown here are possibly random and not representative !
10629/// let result = hub.projects().databases_import_documents(req, "name")
10630/// .doit().await;
10631/// # }
10632/// ```
10633pub struct ProjectDatabaseImportDocumentCall<'a, C>
10634where
10635 C: 'a,
10636{
10637 hub: &'a Firestore<C>,
10638 _request: GoogleFirestoreAdminV1beta1ImportDocumentsRequest,
10639 _name: String,
10640 _delegate: Option<&'a mut dyn common::Delegate>,
10641 _additional_params: HashMap<String, String>,
10642 _scopes: BTreeSet<String>,
10643}
10644
10645impl<'a, C> common::CallBuilder for ProjectDatabaseImportDocumentCall<'a, C> {}
10646
10647impl<'a, C> ProjectDatabaseImportDocumentCall<'a, C>
10648where
10649 C: common::Connector,
10650{
10651 /// Perform the operation you have build so far.
10652 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10653 use std::borrow::Cow;
10654 use std::io::{Read, Seek};
10655
10656 use common::{url::Params, ToParts};
10657 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10658
10659 let mut dd = common::DefaultDelegate;
10660 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10661 dlg.begin(common::MethodInfo {
10662 id: "firestore.projects.databases.importDocuments",
10663 http_method: hyper::Method::POST,
10664 });
10665
10666 for &field in ["alt", "name"].iter() {
10667 if self._additional_params.contains_key(field) {
10668 dlg.finished(false);
10669 return Err(common::Error::FieldClash(field));
10670 }
10671 }
10672
10673 let mut params = Params::with_capacity(4 + self._additional_params.len());
10674 params.push("name", self._name);
10675
10676 params.extend(self._additional_params.iter());
10677
10678 params.push("alt", "json");
10679 let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:importDocuments";
10680 if self._scopes.is_empty() {
10681 self._scopes
10682 .insert(Scope::CloudPlatform.as_ref().to_string());
10683 }
10684
10685 #[allow(clippy::single_element_loop)]
10686 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10687 url = params.uri_replacement(url, param_name, find_this, true);
10688 }
10689 {
10690 let to_remove = ["name"];
10691 params.remove_params(&to_remove);
10692 }
10693
10694 let url = params.parse_with_url(&url);
10695
10696 let mut json_mime_type = mime::APPLICATION_JSON;
10697 let mut request_value_reader = {
10698 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10699 common::remove_json_null_values(&mut value);
10700 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10701 serde_json::to_writer(&mut dst, &value).unwrap();
10702 dst
10703 };
10704 let request_size = request_value_reader
10705 .seek(std::io::SeekFrom::End(0))
10706 .unwrap();
10707 request_value_reader
10708 .seek(std::io::SeekFrom::Start(0))
10709 .unwrap();
10710
10711 loop {
10712 let token = match self
10713 .hub
10714 .auth
10715 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10716 .await
10717 {
10718 Ok(token) => token,
10719 Err(e) => match dlg.token(e) {
10720 Ok(token) => token,
10721 Err(e) => {
10722 dlg.finished(false);
10723 return Err(common::Error::MissingToken(e));
10724 }
10725 },
10726 };
10727 request_value_reader
10728 .seek(std::io::SeekFrom::Start(0))
10729 .unwrap();
10730 let mut req_result = {
10731 let client = &self.hub.client;
10732 dlg.pre_request();
10733 let mut req_builder = hyper::Request::builder()
10734 .method(hyper::Method::POST)
10735 .uri(url.as_str())
10736 .header(USER_AGENT, self.hub._user_agent.clone());
10737
10738 if let Some(token) = token.as_ref() {
10739 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10740 }
10741
10742 let request = req_builder
10743 .header(CONTENT_TYPE, json_mime_type.to_string())
10744 .header(CONTENT_LENGTH, request_size as u64)
10745 .body(common::to_body(
10746 request_value_reader.get_ref().clone().into(),
10747 ));
10748
10749 client.request(request.unwrap()).await
10750 };
10751
10752 match req_result {
10753 Err(err) => {
10754 if let common::Retry::After(d) = dlg.http_error(&err) {
10755 sleep(d).await;
10756 continue;
10757 }
10758 dlg.finished(false);
10759 return Err(common::Error::HttpError(err));
10760 }
10761 Ok(res) => {
10762 let (mut parts, body) = res.into_parts();
10763 let mut body = common::Body::new(body);
10764 if !parts.status.is_success() {
10765 let bytes = common::to_bytes(body).await.unwrap_or_default();
10766 let error = serde_json::from_str(&common::to_string(&bytes));
10767 let response = common::to_response(parts, bytes.into());
10768
10769 if let common::Retry::After(d) =
10770 dlg.http_failure(&response, error.as_ref().ok())
10771 {
10772 sleep(d).await;
10773 continue;
10774 }
10775
10776 dlg.finished(false);
10777
10778 return Err(match error {
10779 Ok(value) => common::Error::BadRequest(value),
10780 _ => common::Error::Failure(response),
10781 });
10782 }
10783 let response = {
10784 let bytes = common::to_bytes(body).await.unwrap_or_default();
10785 let encoded = common::to_string(&bytes);
10786 match serde_json::from_str(&encoded) {
10787 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10788 Err(error) => {
10789 dlg.response_json_decode_error(&encoded, &error);
10790 return Err(common::Error::JsonDecodeError(
10791 encoded.to_string(),
10792 error,
10793 ));
10794 }
10795 }
10796 };
10797
10798 dlg.finished(true);
10799 return Ok(response);
10800 }
10801 }
10802 }
10803 }
10804
10805 ///
10806 /// Sets the *request* property to the given value.
10807 ///
10808 /// Even though the property as already been set when instantiating this call,
10809 /// we provide this method for API completeness.
10810 pub fn request(
10811 mut self,
10812 new_value: GoogleFirestoreAdminV1beta1ImportDocumentsRequest,
10813 ) -> ProjectDatabaseImportDocumentCall<'a, C> {
10814 self._request = new_value;
10815 self
10816 }
10817 /// Database to import into. Should be of the form: `projects/{project_id}/databases/{database_id}`.
10818 ///
10819 /// Sets the *name* path property to the given value.
10820 ///
10821 /// Even though the property as already been set when instantiating this call,
10822 /// we provide this method for API completeness.
10823 pub fn name(mut self, new_value: &str) -> ProjectDatabaseImportDocumentCall<'a, C> {
10824 self._name = new_value.to_string();
10825 self
10826 }
10827 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10828 /// while executing the actual API request.
10829 ///
10830 /// ````text
10831 /// It should be used to handle progress information, and to implement a certain level of resilience.
10832 /// ````
10833 ///
10834 /// Sets the *delegate* property to the given value.
10835 pub fn delegate(
10836 mut self,
10837 new_value: &'a mut dyn common::Delegate,
10838 ) -> ProjectDatabaseImportDocumentCall<'a, C> {
10839 self._delegate = Some(new_value);
10840 self
10841 }
10842
10843 /// Set any additional parameter of the query string used in the request.
10844 /// It should be used to set parameters which are not yet available through their own
10845 /// setters.
10846 ///
10847 /// Please note that this method must not be used to set any of the known parameters
10848 /// which have their own setter method. If done anyway, the request will fail.
10849 ///
10850 /// # Additional Parameters
10851 ///
10852 /// * *$.xgafv* (query-string) - V1 error format.
10853 /// * *access_token* (query-string) - OAuth access token.
10854 /// * *alt* (query-string) - Data format for response.
10855 /// * *callback* (query-string) - JSONP
10856 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10857 /// * *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.
10858 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10859 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10860 /// * *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.
10861 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10862 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10863 pub fn param<T>(mut self, name: T, value: T) -> ProjectDatabaseImportDocumentCall<'a, C>
10864 where
10865 T: AsRef<str>,
10866 {
10867 self._additional_params
10868 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10869 self
10870 }
10871
10872 /// Identifies the authorization scope for the method you are building.
10873 ///
10874 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10875 /// [`Scope::CloudPlatform`].
10876 ///
10877 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10878 /// tokens for more than one scope.
10879 ///
10880 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10881 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10882 /// sufficient, a read-write scope will do as well.
10883 pub fn add_scope<St>(mut self, scope: St) -> ProjectDatabaseImportDocumentCall<'a, C>
10884 where
10885 St: AsRef<str>,
10886 {
10887 self._scopes.insert(String::from(scope.as_ref()));
10888 self
10889 }
10890 /// Identifies the authorization scope(s) for the method you are building.
10891 ///
10892 /// See [`Self::add_scope()`] for details.
10893 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDatabaseImportDocumentCall<'a, C>
10894 where
10895 I: IntoIterator<Item = St>,
10896 St: AsRef<str>,
10897 {
10898 self._scopes
10899 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10900 self
10901 }
10902
10903 /// Removes all scopes, and no default scope will be used either.
10904 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10905 /// for details).
10906 pub fn clear_scopes(mut self) -> ProjectDatabaseImportDocumentCall<'a, C> {
10907 self._scopes.clear();
10908 self
10909 }
10910}