google_datastore1/
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    Full,
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::Full => "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::Full
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Datastore 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_datastore1 as datastore1;
53/// use datastore1::api::GoogleDatastoreAdminV1Index;
54/// use datastore1::{Result, Error};
55/// # async fn dox() {
56/// use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67///     secret,
68///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69/// ).build().await.unwrap();
70///
71/// let client = hyper_util::client::legacy::Client::builder(
72///     hyper_util::rt::TokioExecutor::new()
73/// )
74/// .build(
75///     hyper_rustls::HttpsConnectorBuilder::new()
76///         .with_native_roots()
77///         .unwrap()
78///         .https_or_http()
79///         .enable_http1()
80///         .build()
81/// );
82/// let mut hub = Datastore::new(client, auth);
83/// // As the method needs a request, you would usually fill it with the desired information
84/// // into the respective structure. Some of the parts shown here might not be applicable !
85/// // Values shown here are possibly random and not representative !
86/// let mut req = GoogleDatastoreAdminV1Index::default();
87///
88/// // You can configure optional parameters by calling the respective setters at will, and
89/// // execute the final call using `doit()`.
90/// // Values shown here are possibly random and not representative !
91/// let result = hub.projects().indexes_create(req, "projectId")
92///              .doit().await;
93///
94/// match result {
95///     Err(e) => match e {
96///         // The Error enum provides details about what exactly happened.
97///         // You can also just use its `Debug`, `Display` or `Error` traits
98///          Error::HttpError(_)
99///         |Error::Io(_)
100///         |Error::MissingAPIKey
101///         |Error::MissingToken(_)
102///         |Error::Cancelled
103///         |Error::UploadSizeLimitExceeded(_, _)
104///         |Error::Failure(_)
105///         |Error::BadRequest(_)
106///         |Error::FieldClash(_)
107///         |Error::JsonDecodeError(_, _) => println!("{}", e),
108///     },
109///     Ok(res) => println!("Success: {:?}", res),
110/// }
111/// # }
112/// ```
113#[derive(Clone)]
114pub struct Datastore<C> {
115    pub client: common::Client<C>,
116    pub auth: Box<dyn common::GetToken>,
117    _user_agent: String,
118    _base_url: String,
119    _root_url: String,
120}
121
122impl<C> common::Hub for Datastore<C> {}
123
124impl<'a, C> Datastore<C> {
125    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Datastore<C> {
126        Datastore {
127            client,
128            auth: Box::new(auth),
129            _user_agent: "google-api-rust-client/6.0.0".to_string(),
130            _base_url: "https://datastore.googleapis.com/".to_string(),
131            _root_url: "https://datastore.googleapis.com/".to_string(),
132        }
133    }
134
135    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
136        ProjectMethods { hub: self }
137    }
138
139    /// Set the user-agent header field to use in all requests to the server.
140    /// It defaults to `google-api-rust-client/6.0.0`.
141    ///
142    /// Returns the previously set user-agent.
143    pub fn user_agent(&mut self, agent_name: String) -> String {
144        std::mem::replace(&mut self._user_agent, agent_name)
145    }
146
147    /// Set the base url to use in all requests to the server.
148    /// It defaults to `https://datastore.googleapis.com/`.
149    ///
150    /// Returns the previously set base url.
151    pub fn base_url(&mut self, new_base_url: String) -> String {
152        std::mem::replace(&mut self._base_url, new_base_url)
153    }
154
155    /// Set the root url to use in all requests to the server.
156    /// It defaults to `https://datastore.googleapis.com/`.
157    ///
158    /// Returns the previously set root url.
159    pub fn root_url(&mut self, new_root_url: String) -> String {
160        std::mem::replace(&mut self._root_url, new_root_url)
161    }
162}
163
164// ############
165// SCHEMAS ###
166// ##########
167/// Defines an aggregation that produces a single result.
168///
169/// This type is not used in any activity, and only used as *part* of another schema.
170///
171#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
172#[serde_with::serde_as]
173#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
174pub struct Aggregation {
175    /// Optional. Optional name of the property to store the result of the aggregation. If not provided, Datastore will pick a default name following the format `property_`. 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 property_1, COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) AS property_2 OVER ( ... ); ``` Requires: * Must be unique across all aggregation aliases. * Conform to entity property name limitations.
176    pub alias: Option<String>,
177    /// Average aggregator.
178    pub avg: Option<Avg>,
179    /// Count aggregator.
180    pub count: Option<Count>,
181    /// Sum aggregator.
182    pub sum: Option<Sum>,
183}
184
185impl common::Part for Aggregation {}
186
187/// Datastore query for running an aggregation over a Query.
188///
189/// This type is not used in any activity, and only used as *part* of another schema.
190///
191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
192#[serde_with::serde_as]
193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
194pub struct AggregationQuery {
195    /// Optional. Series of aggregations to apply over the results of the `nested_query`. Requires: * A minimum of one and maximum of five aggregations per query.
196    pub aggregations: Option<Vec<Aggregation>>,
197    /// Nested query for aggregation
198    #[serde(rename = "nestedQuery")]
199    pub nested_query: Option<Query>,
200}
201
202impl common::Part for AggregationQuery {}
203
204/// The result of a single bucket from a Datastore aggregation query. The keys of `aggregate_properties` are the same for all results in an aggregation query, unlike entity queries which can have different fields present for each result.
205///
206/// This type is not used in any activity, and only used as *part* of another schema.
207///
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209#[serde_with::serde_as]
210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
211pub struct AggregationResult {
212    /// The result of the aggregation functions, ex: `COUNT(*) AS total_entities`. 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.
213    #[serde(rename = "aggregateProperties")]
214    pub aggregate_properties: Option<HashMap<String, Value>>,
215}
216
217impl common::Part for AggregationResult {}
218
219/// A batch of aggregation results produced by an aggregation query.
220///
221/// This type is not used in any activity, and only used as *part* of another schema.
222///
223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
224#[serde_with::serde_as]
225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
226pub struct AggregationResultBatch {
227    /// The aggregation results for this batch.
228    #[serde(rename = "aggregationResults")]
229    pub aggregation_results: Option<Vec<AggregationResult>>,
230    /// The state of the query after the current batch. Only COUNT(*) aggregations are supported in the initial launch. Therefore, expected result type is limited to `NO_MORE_RESULTS`.
231    #[serde(rename = "moreResults")]
232    pub more_results: Option<String>,
233    /// Read timestamp this batch was returned from. In a single transaction, subsequent query result batches for the same query can have a greater timestamp. Each batch's read timestamp is valid for all preceding batches.
234    #[serde(rename = "readTime")]
235    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
236}
237
238impl common::Part for AggregationResultBatch {}
239
240/// The request for Datastore.AllocateIds.
241///
242/// # Activities
243///
244/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
245/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
246///
247/// * [allocate ids projects](ProjectAllocateIdCall) (request)
248#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
249#[serde_with::serde_as]
250#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
251pub struct AllocateIdsRequest {
252    /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
253    #[serde(rename = "databaseId")]
254    pub database_id: Option<String>,
255    /// Required. A list of keys with incomplete key paths for which to allocate IDs. No key may be reserved/read-only.
256    pub keys: Option<Vec<Key>>,
257}
258
259impl common::RequestValue for AllocateIdsRequest {}
260
261/// The response for Datastore.AllocateIds.
262///
263/// # Activities
264///
265/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
266/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
267///
268/// * [allocate ids projects](ProjectAllocateIdCall) (response)
269#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
270#[serde_with::serde_as]
271#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
272pub struct AllocateIdsResponse {
273    /// The keys specified in the request (in the same order), each with its key path completed with a newly allocated ID.
274    pub keys: Option<Vec<Key>>,
275}
276
277impl common::ResponseResult for AllocateIdsResponse {}
278
279/// An array value.
280///
281/// This type is not used in any activity, and only used as *part* of another schema.
282///
283#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
284#[serde_with::serde_as]
285#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
286pub struct ArrayValue {
287    /// Values in the array. The order of values in an array is preserved as long as all values have identical settings for 'exclude_from_indexes'.
288    pub values: Option<Vec<Value>>,
289}
290
291impl common::Part for ArrayValue {}
292
293/// Average of the values of the requested property. * 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.
294///
295/// This type is not used in any activity, and only used as *part* of another schema.
296///
297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
298#[serde_with::serde_as]
299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
300pub struct Avg {
301    /// The property to aggregate on.
302    pub property: Option<PropertyReference>,
303}
304
305impl common::Part for Avg {}
306
307/// The request for Datastore.BeginTransaction.
308///
309/// # Activities
310///
311/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
312/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
313///
314/// * [begin transaction projects](ProjectBeginTransactionCall) (request)
315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
316#[serde_with::serde_as]
317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
318pub struct BeginTransactionRequest {
319    /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
320    #[serde(rename = "databaseId")]
321    pub database_id: Option<String>,
322    /// Options for a new transaction.
323    #[serde(rename = "transactionOptions")]
324    pub transaction_options: Option<TransactionOptions>,
325}
326
327impl common::RequestValue for BeginTransactionRequest {}
328
329/// The response for Datastore.BeginTransaction.
330///
331/// # Activities
332///
333/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
334/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
335///
336/// * [begin transaction projects](ProjectBeginTransactionCall) (response)
337#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
338#[serde_with::serde_as]
339#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
340pub struct BeginTransactionResponse {
341    /// The transaction identifier (always present).
342    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
343    pub transaction: Option<Vec<u8>>,
344}
345
346impl common::ResponseResult for BeginTransactionResponse {}
347
348/// The request for Datastore.Commit.
349///
350/// # Activities
351///
352/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
353/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
354///
355/// * [commit projects](ProjectCommitCall) (request)
356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
357#[serde_with::serde_as]
358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
359pub struct CommitRequest {
360    /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
361    #[serde(rename = "databaseId")]
362    pub database_id: Option<String>,
363    /// The type of commit to perform. Defaults to `TRANSACTIONAL`.
364    pub mode: Option<String>,
365    /// The mutations to perform. When mode is `TRANSACTIONAL`, mutations affecting a single entity are applied in order. The following sequences of mutations affecting a single entity are not permitted in a single `Commit` request: - `insert` followed by `insert` - `update` followed by `insert` - `upsert` followed by `insert` - `delete` followed by `update` When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single entity.
366    pub mutations: Option<Vec<Mutation>>,
367    /// Options for beginning a new transaction for this request. The transaction is committed when the request completes. If specified, TransactionOptions.mode must be TransactionOptions.ReadWrite.
368    #[serde(rename = "singleUseTransaction")]
369    pub single_use_transaction: Option<TransactionOptions>,
370    /// The identifier of the transaction associated with the commit. A transaction identifier is returned by a call to Datastore.BeginTransaction.
371    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
372    pub transaction: Option<Vec<u8>>,
373}
374
375impl common::RequestValue for CommitRequest {}
376
377/// The response for Datastore.Commit.
378///
379/// # Activities
380///
381/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
382/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
383///
384/// * [commit projects](ProjectCommitCall) (response)
385#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
386#[serde_with::serde_as]
387#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
388pub struct CommitResponse {
389    /// The transaction commit timestamp. Not set for non-transactional commits.
390    #[serde(rename = "commitTime")]
391    pub commit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
392    /// The number of index entries updated during the commit, or zero if none were updated.
393    #[serde(rename = "indexUpdates")]
394    pub index_updates: Option<i32>,
395    /// The result of performing the mutations. The i-th mutation result corresponds to the i-th mutation in the request.
396    #[serde(rename = "mutationResults")]
397    pub mutation_results: Option<Vec<MutationResult>>,
398}
399
400impl common::ResponseResult for CommitResponse {}
401
402/// A filter that merges multiple other filters using the given operator.
403///
404/// This type is not used in any activity, and only used as *part* of another schema.
405///
406#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
407#[serde_with::serde_as]
408#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
409pub struct CompositeFilter {
410    /// The list of filters to combine. Requires: * At least one filter is present.
411    pub filters: Option<Vec<Filter>>,
412    /// The operator for combining multiple filters.
413    pub op: Option<String>,
414}
415
416impl common::Part for CompositeFilter {}
417
418/// Count of entities that match the query. The `COUNT(*)` aggregation function operates on the entire entity so it does not require a field reference.
419///
420/// This type is not used in any activity, and only used as *part* of another schema.
421///
422#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
423#[serde_with::serde_as]
424#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
425pub struct Count {
426    /// Optional. Optional constraint on the maximum number of entities to count. This provides a way to set an upper bound on the number of entities to scan, limiting latency, and cost. Unspecified is interpreted as no bound. If a zero value is provided, a count result of zero should always be expected. High-Level Example: ``` AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); ``` Requires: * Must be non-negative when present.
427    #[serde(rename = "upTo")]
428    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
429    pub up_to: Option<i64>,
430}
431
432impl common::Part for Count {}
433
434/// 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); }
435///
436/// # Activities
437///
438/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
439/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
440///
441/// * [operations cancel projects](ProjectOperationCancelCall) (response)
442/// * [operations delete projects](ProjectOperationDeleteCall) (response)
443#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
444#[serde_with::serde_as]
445#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
446pub struct Empty {
447    _never_set: Option<bool>,
448}
449
450impl common::ResponseResult for Empty {}
451
452/// A Datastore data object. Must not exceed 1 MiB - 4 bytes.
453///
454/// This type is not used in any activity, and only used as *part* of another schema.
455///
456#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
457#[serde_with::serde_as]
458#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
459pub struct Entity {
460    /// The entity's key. An entity must have a key, unless otherwise documented (for example, an entity in `Value.entity_value` may have no key). An entity's kind is its key path's last element's kind, or null if it has no key.
461    pub key: Option<Key>,
462    /// The entity's properties. The map's keys are property names. A property name matching regex `__.*__` is reserved. A reserved property name is forbidden in certain documented contexts. The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be empty.
463    pub properties: Option<HashMap<String, Value>>,
464}
465
466impl common::Part for Entity {}
467
468/// The result of fetching an entity from Datastore.
469///
470/// This type is not used in any activity, and only used as *part* of another schema.
471///
472#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
473#[serde_with::serde_as]
474#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
475pub struct EntityResult {
476    /// The time at which the entity was created. This field is set for `FULL` entity results. If this entity is missing, this field will not be set.
477    #[serde(rename = "createTime")]
478    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
479    /// A cursor that points to the position after the result entity. Set only when the `EntityResult` is part of a `QueryResultBatch` message.
480    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
481    pub cursor: Option<Vec<u8>>,
482    /// The resulting entity.
483    pub entity: Option<Entity>,
484    /// The time at which the entity was last changed. This field is set for `FULL` entity results. If this entity is missing, this field will not be set.
485    #[serde(rename = "updateTime")]
486    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
487    /// The version of the entity, a strictly positive number that monotonically increases with changes to the entity. This field is set for `FULL` entity results. For missing entities in `LookupResponse`, this is the version of the snapshot that was used to look up the entity, and it is always set except for eventually consistent reads.
488    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
489    pub version: Option<i64>,
490}
491
492impl common::Part for EntityResult {}
493
494/// Execution statistics for the query.
495///
496/// This type is not used in any activity, and only used as *part* of another schema.
497///
498#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
499#[serde_with::serde_as]
500#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
501pub struct ExecutionStats {
502    /// 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" } }
503    #[serde(rename = "debugStats")]
504    pub debug_stats: Option<HashMap<String, serde_json::Value>>,
505    /// Total time to execute the query in the backend.
506    #[serde(rename = "executionDuration")]
507    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
508    pub execution_duration: Option<chrono::Duration>,
509    /// Total billable read operations.
510    #[serde(rename = "readOperations")]
511    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
512    pub read_operations: Option<i64>,
513    /// Total number of results returned, including documents, projections, aggregation results, keys.
514    #[serde(rename = "resultsReturned")]
515    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
516    pub results_returned: Option<i64>,
517}
518
519impl common::Part for ExecutionStats {}
520
521/// Explain metrics for the query.
522///
523/// This type is not used in any activity, and only used as *part* of another schema.
524///
525#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
526#[serde_with::serde_as]
527#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
528pub struct ExplainMetrics {
529    /// Aggregated stats from the execution of the query. Only present when ExplainOptions.analyze is set to true.
530    #[serde(rename = "executionStats")]
531    pub execution_stats: Option<ExecutionStats>,
532    /// Planning phase information for the query.
533    #[serde(rename = "planSummary")]
534    pub plan_summary: Option<PlanSummary>,
535}
536
537impl common::Part for ExplainMetrics {}
538
539/// Explain options for the query.
540///
541/// This type is not used in any activity, and only used as *part* of another schema.
542///
543#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
544#[serde_with::serde_as]
545#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
546pub struct ExplainOptions {
547    /// 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.
548    pub analyze: Option<bool>,
549}
550
551impl common::Part for ExplainOptions {}
552
553/// A holder for any type of filter.
554///
555/// This type is not used in any activity, and only used as *part* of another schema.
556///
557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
558#[serde_with::serde_as]
559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
560pub struct Filter {
561    /// A composite filter.
562    #[serde(rename = "compositeFilter")]
563    pub composite_filter: Option<CompositeFilter>,
564    /// A filter on a property.
565    #[serde(rename = "propertyFilter")]
566    pub property_filter: Option<PropertyFilter>,
567}
568
569impl common::Part for Filter {}
570
571/// Identifies a subset of entities in a project. This is specified as combinations of kinds and namespaces (either or both of which may be all, as described in the following examples). Example usage: Entire project: kinds=[], namespace_ids=[] Kinds Foo and Bar in all namespaces: kinds=['Foo', 'Bar'], namespace_ids=[] Kinds Foo and Bar only in the default namespace: kinds=['Foo', 'Bar'], namespace_ids=[''] Kinds Foo and Bar in both the default and Baz namespaces: kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz'] The entire Baz namespace: kinds=[], namespace_ids=['Baz']
572///
573/// This type is not used in any activity, and only used as *part* of another schema.
574///
575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
576#[serde_with::serde_as]
577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
578pub struct GoogleDatastoreAdminV1EntityFilter {
579    /// If empty, then this represents all kinds.
580    pub kinds: Option<Vec<String>>,
581    /// An empty list represents all namespaces. This is the preferred usage for projects that don't use namespaces. An empty string element represents the default namespace. This should be used if the project has data in non-default namespaces, but doesn't want to include them. Each namespace in this list must be unique.
582    #[serde(rename = "namespaceIds")]
583    pub namespace_ids: Option<Vec<String>>,
584}
585
586impl common::Part for GoogleDatastoreAdminV1EntityFilter {}
587
588/// The request for google.datastore.admin.v1.DatastoreAdmin.ExportEntities.
589///
590/// # Activities
591///
592/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
593/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
594///
595/// * [export projects](ProjectExportCall) (request)
596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
597#[serde_with::serde_as]
598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
599pub struct GoogleDatastoreAdminV1ExportEntitiesRequest {
600    /// Description of what data from the project is included in the export.
601    #[serde(rename = "entityFilter")]
602    pub entity_filter: Option<GoogleDatastoreAdminV1EntityFilter>,
603    /// Client-assigned labels.
604    pub labels: Option<HashMap<String, String>>,
605    /// Required. Location for the export metadata and data files. The full resource URL of the external storage location. Currently, only Google Cloud Storage is supported. So output_url_prefix should be of the form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud Storage namespace path (this is not a Cloud Datastore namespace). For more information about Cloud Storage namespace paths, see [Object name considerations](https://cloud.google.com/storage/docs/naming#object-considerations). The resulting files will be nested deeper than the specified URL prefix. The final output URL will be provided in the google.datastore.admin.v1.ExportEntitiesResponse.output_url field. That value should be used for subsequent ImportEntities operations. By nesting the data files deeper, the same Cloud Storage bucket can be used in multiple ExportEntities operations without conflict.
606    #[serde(rename = "outputUrlPrefix")]
607    pub output_url_prefix: Option<String>,
608}
609
610impl common::RequestValue for GoogleDatastoreAdminV1ExportEntitiesRequest {}
611
612/// The request for google.datastore.admin.v1.DatastoreAdmin.ImportEntities.
613///
614/// # Activities
615///
616/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
617/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
618///
619/// * [import projects](ProjectImportCall) (request)
620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
621#[serde_with::serde_as]
622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
623pub struct GoogleDatastoreAdminV1ImportEntitiesRequest {
624    /// Optionally specify which kinds/namespaces are to be imported. If provided, the list must be a subset of the EntityFilter used in creating the export, otherwise a FAILED_PRECONDITION error will be returned. If no filter is specified then all entities from the export are imported.
625    #[serde(rename = "entityFilter")]
626    pub entity_filter: Option<GoogleDatastoreAdminV1EntityFilter>,
627    /// Required. The full resource URL of the external storage location. Currently, only Google Cloud Storage is supported. So input_url should be of the form: `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is an optional Cloud Storage namespace path (this is not a Cloud Datastore namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written by the ExportEntities operation. For more information about Cloud Storage namespace paths, see [Object name considerations](https://cloud.google.com/storage/docs/naming#object-considerations). For more information, see google.datastore.admin.v1.ExportEntitiesResponse.output_url.
628    #[serde(rename = "inputUrl")]
629    pub input_url: Option<String>,
630    /// Client-assigned labels.
631    pub labels: Option<HashMap<String, String>>,
632}
633
634impl common::RequestValue for GoogleDatastoreAdminV1ImportEntitiesRequest {}
635
636/// Datastore composite index definition.
637///
638/// # Activities
639///
640/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
641/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
642///
643/// * [indexes create projects](ProjectIndexCreateCall) (request)
644/// * [indexes get projects](ProjectIndexGetCall) (response)
645#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
646#[serde_with::serde_as]
647#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
648pub struct GoogleDatastoreAdminV1Index {
649    /// Required. The index's ancestor mode. Must not be ANCESTOR_MODE_UNSPECIFIED.
650    pub ancestor: Option<String>,
651    /// Output only. The resource ID of the index.
652    #[serde(rename = "indexId")]
653    pub index_id: Option<String>,
654    /// Required. The entity kind to which this index applies.
655    pub kind: Option<String>,
656    /// Output only. Project ID.
657    #[serde(rename = "projectId")]
658    pub project_id: Option<String>,
659    /// Required. An ordered sequence of property names and their index attributes. Requires: * A maximum of 100 properties.
660    pub properties: Option<Vec<GoogleDatastoreAdminV1IndexedProperty>>,
661    /// Output only. The state of the index.
662    pub state: Option<String>,
663}
664
665impl common::RequestValue for GoogleDatastoreAdminV1Index {}
666impl common::ResponseResult for GoogleDatastoreAdminV1Index {}
667
668/// A property of an index.
669///
670/// This type is not used in any activity, and only used as *part* of another schema.
671///
672#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
673#[serde_with::serde_as]
674#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
675pub struct GoogleDatastoreAdminV1IndexedProperty {
676    /// Required. The indexed property's direction. Must not be DIRECTION_UNSPECIFIED.
677    pub direction: Option<String>,
678    /// Required. The property name to index.
679    pub name: Option<String>,
680}
681
682impl common::Part for GoogleDatastoreAdminV1IndexedProperty {}
683
684/// The response for google.datastore.admin.v1.DatastoreAdmin.ListIndexes.
685///
686/// # Activities
687///
688/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
689/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
690///
691/// * [indexes list projects](ProjectIndexListCall) (response)
692#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
693#[serde_with::serde_as]
694#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
695pub struct GoogleDatastoreAdminV1ListIndexesResponse {
696    /// The indexes.
697    pub indexes: Option<Vec<GoogleDatastoreAdminV1Index>>,
698    /// The standard List next-page token.
699    #[serde(rename = "nextPageToken")]
700    pub next_page_token: Option<String>,
701}
702
703impl common::ResponseResult for GoogleDatastoreAdminV1ListIndexesResponse {}
704
705/// The response message for Operations.ListOperations.
706///
707/// # Activities
708///
709/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
710/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
711///
712/// * [operations list projects](ProjectOperationListCall) (response)
713#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
714#[serde_with::serde_as]
715#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
716pub struct GoogleLongrunningListOperationsResponse {
717    /// The standard List next-page token.
718    #[serde(rename = "nextPageToken")]
719    pub next_page_token: Option<String>,
720    /// A list of operations that matches the specified filter in the request.
721    pub operations: Option<Vec<GoogleLongrunningOperation>>,
722}
723
724impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
725
726/// This resource represents a long-running operation that is the result of a network API call.
727///
728/// # Activities
729///
730/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
731/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
732///
733/// * [indexes create projects](ProjectIndexCreateCall) (response)
734/// * [indexes delete projects](ProjectIndexDeleteCall) (response)
735/// * [operations get projects](ProjectOperationGetCall) (response)
736/// * [export projects](ProjectExportCall) (response)
737/// * [import projects](ProjectImportCall) (response)
738#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
739#[serde_with::serde_as]
740#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
741pub struct GoogleLongrunningOperation {
742    /// 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.
743    pub done: Option<bool>,
744    /// The error result of the operation in case of failure or cancellation.
745    pub error: Option<Status>,
746    /// 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.
747    pub metadata: Option<HashMap<String, serde_json::Value>>,
748    /// 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}`.
749    pub name: Option<String>,
750    /// 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`.
751    pub response: Option<HashMap<String, serde_json::Value>>,
752}
753
754impl common::ResponseResult for GoogleLongrunningOperation {}
755
756/// A [GQL query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
757///
758/// This type is not used in any activity, and only used as *part* of another schema.
759///
760#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
761#[serde_with::serde_as]
762#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
763pub struct GqlQuery {
764    /// When false, the query string must not contain any literals and instead must bind all values. For example, `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while `SELECT * FROM Kind WHERE a = @value` is.
765    #[serde(rename = "allowLiterals")]
766    pub allow_literals: Option<bool>,
767    /// For each non-reserved named binding site in the query string, there must be a named parameter with that name, but not necessarily the inverse. Key must match regex `A-Za-z_$*`, must not match regex `__.*__`, and must not be `""`.
768    #[serde(rename = "namedBindings")]
769    pub named_bindings: Option<HashMap<String, GqlQueryParameter>>,
770    /// Numbered binding site @1 references the first numbered parameter, effectively using 1-based indexing, rather than the usual 0. For each binding site numbered i in `query_string`, there must be an i-th numbered parameter. The inverse must also be true.
771    #[serde(rename = "positionalBindings")]
772    pub positional_bindings: Option<Vec<GqlQueryParameter>>,
773    /// A string of the format described [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
774    #[serde(rename = "queryString")]
775    pub query_string: Option<String>,
776}
777
778impl common::Part for GqlQuery {}
779
780/// A binding parameter for a GQL query.
781///
782/// This type is not used in any activity, and only used as *part* of another schema.
783///
784#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
785#[serde_with::serde_as]
786#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
787pub struct GqlQueryParameter {
788    /// A query cursor. Query cursors are returned in query result batches.
789    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
790    pub cursor: Option<Vec<u8>>,
791    /// A value parameter.
792    pub value: Option<Value>,
793}
794
795impl common::Part for GqlQueryParameter {}
796
797/// A unique identifier for an entity. If a key's partition ID or any of its path kinds or names are reserved/read-only, the key is reserved/read-only. A reserved/read-only key is forbidden in certain documented contexts.
798///
799/// This type is not used in any activity, and only used as *part* of another schema.
800///
801#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
802#[serde_with::serde_as]
803#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
804pub struct Key {
805    /// Entities are partitioned into subsets, currently identified by a project ID and namespace ID. Queries are scoped to a single partition.
806    #[serde(rename = "partitionId")]
807    pub partition_id: Option<PartitionId>,
808    /// The entity path. An entity path consists of one or more elements composed of a kind and a string or numerical identifier, which identify entities. The first element identifies a _root entity_, the second element identifies a _child_ of the root entity, the third element identifies a child of the second entity, and so forth. The entities identified by all prefixes of the path are called the element's _ancestors_. An entity path is always fully complete: *all* of the entity's ancestors are required to be in the path along with the entity identifier itself. The only exception is that in some documented cases, the identifier in the last path element (for the entity) itself may be omitted. For example, the last path element of the key of `Mutation.insert` may have no identifier. A path can never be empty, and a path can have at most 100 elements.
809    pub path: Option<Vec<PathElement>>,
810}
811
812impl common::Part for Key {}
813
814/// A representation of a kind.
815///
816/// This type is not used in any activity, and only used as *part* of another schema.
817///
818#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
819#[serde_with::serde_as]
820#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
821pub struct KindExpression {
822    /// The name of the kind.
823    pub name: Option<String>,
824}
825
826impl common::Part for KindExpression {}
827
828/// 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.
829///
830/// This type is not used in any activity, and only used as *part* of another schema.
831///
832#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
833#[serde_with::serde_as]
834#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
835pub struct LatLng {
836    /// The latitude in degrees. It must be in the range [-90.0, +90.0].
837    pub latitude: Option<f64>,
838    /// The longitude in degrees. It must be in the range [-180.0, +180.0].
839    pub longitude: Option<f64>,
840}
841
842impl common::Part for LatLng {}
843
844/// The request for Datastore.Lookup.
845///
846/// # Activities
847///
848/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
849/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
850///
851/// * [lookup projects](ProjectLookupCall) (request)
852#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
853#[serde_with::serde_as]
854#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
855pub struct LookupRequest {
856    /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
857    #[serde(rename = "databaseId")]
858    pub database_id: Option<String>,
859    /// Required. Keys of entities to look up.
860    pub keys: Option<Vec<Key>>,
861    /// The properties to return. Defaults to returning all properties. If this field is set and an entity has a property not referenced in the mask, it will be absent from LookupResponse.found.entity.properties. The entity's key is always returned.
862    #[serde(rename = "propertyMask")]
863    pub property_mask: Option<PropertyMask>,
864    /// The options for this lookup request.
865    #[serde(rename = "readOptions")]
866    pub read_options: Option<ReadOptions>,
867}
868
869impl common::RequestValue for LookupRequest {}
870
871/// The response for Datastore.Lookup.
872///
873/// # Activities
874///
875/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
876/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
877///
878/// * [lookup projects](ProjectLookupCall) (response)
879#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
880#[serde_with::serde_as]
881#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
882pub struct LookupResponse {
883    /// A list of keys that were not looked up due to resource constraints. The order of results in this field is undefined and has no relation to the order of the keys in the input.
884    pub deferred: Option<Vec<Key>>,
885    /// Entities found as `ResultType.FULL` entities. The order of results in this field is undefined and has no relation to the order of the keys in the input.
886    pub found: Option<Vec<EntityResult>>,
887    /// Entities not found as `ResultType.KEY_ONLY` entities. The order of results in this field is undefined and has no relation to the order of the keys in the input.
888    pub missing: Option<Vec<EntityResult>>,
889    /// The time at which these entities were read or found missing.
890    #[serde(rename = "readTime")]
891    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
892    /// The identifier of the transaction that was started as part of this Lookup request. Set only when ReadOptions.new_transaction was set in LookupRequest.read_options.
893    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
894    pub transaction: Option<Vec<u8>>,
895}
896
897impl common::ResponseResult for LookupResponse {}
898
899/// A mutation to apply to an entity.
900///
901/// This type is not used in any activity, and only used as *part* of another schema.
902///
903#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
904#[serde_with::serde_as]
905#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
906pub struct Mutation {
907    /// The version of the entity that this mutation is being applied to. If this does not match the current version on the server, the mutation conflicts.
908    #[serde(rename = "baseVersion")]
909    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
910    pub base_version: Option<i64>,
911    /// The key of the entity to delete. The entity may or may not already exist. Must have a complete key path and must not be reserved/read-only.
912    pub delete: Option<Key>,
913    /// The entity to insert. The entity must not already exist. The entity key's final path element may be incomplete.
914    pub insert: Option<Entity>,
915    /// The properties to write in this mutation. None of the properties in the mask may have a reserved name, except for `__key__`. This field is ignored for `delete`. If the entity already exists, only properties referenced in the mask are updated, others are left untouched. Properties referenced in the mask but not in the entity are deleted.
916    #[serde(rename = "propertyMask")]
917    pub property_mask: Option<PropertyMask>,
918    /// The entity to update. The entity must already exist. Must have a complete key path.
919    pub update: Option<Entity>,
920    /// The update time of the entity that this mutation is being applied to. If this does not match the current update time on the server, the mutation conflicts.
921    #[serde(rename = "updateTime")]
922    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
923    /// The entity to upsert. The entity may or may not already exist. The entity key's final path element may be incomplete.
924    pub upsert: Option<Entity>,
925}
926
927impl common::Part for Mutation {}
928
929/// The result of applying a mutation.
930///
931/// This type is not used in any activity, and only used as *part* of another schema.
932///
933#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
934#[serde_with::serde_as]
935#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
936pub struct MutationResult {
937    /// Whether a conflict was detected for this mutation. Always false when a conflict detection strategy field is not set in the mutation.
938    #[serde(rename = "conflictDetected")]
939    pub conflict_detected: Option<bool>,
940    /// The create time of the entity. This field will not be set after a 'delete'.
941    #[serde(rename = "createTime")]
942    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
943    /// The automatically allocated key. Set only when the mutation allocated a key.
944    pub key: Option<Key>,
945    /// The update time of the entity on the server after processing the mutation. If the mutation doesn't change anything on the server, then the timestamp will be the update timestamp of the current entity. This field will not be set after a 'delete'.
946    #[serde(rename = "updateTime")]
947    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
948    /// The version of the entity on the server after processing the mutation. If the mutation doesn't change anything on the server, then the version will be the version of the current entity or, if no entity is present, a version that is strictly greater than the version of any previous entity and less than the version of any possible future entity.
949    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
950    pub version: Option<i64>,
951}
952
953impl common::Part for MutationResult {}
954
955/// A partition ID identifies a grouping of entities. The grouping is always by project and namespace, however the namespace ID may be empty. A partition ID contains several dimensions: project ID and namespace ID. Partition dimensions: - May be `""`. - Must be valid UTF-8 bytes. - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}` If the value of any dimension matches regex `__.*__`, the partition is reserved/read-only. A reserved/read-only partition ID is forbidden in certain documented contexts. Foreign partition IDs (in which the project ID does not match the context project ID ) are discouraged. Reads and writes of foreign partition IDs may fail if the project is not in an active state.
956///
957/// This type is not used in any activity, and only used as *part* of another schema.
958///
959#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
960#[serde_with::serde_as]
961#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
962pub struct PartitionId {
963    /// If not empty, the ID of the database to which the entities belong.
964    #[serde(rename = "databaseId")]
965    pub database_id: Option<String>,
966    /// If not empty, the ID of the namespace to which the entities belong.
967    #[serde(rename = "namespaceId")]
968    pub namespace_id: Option<String>,
969    /// The ID of the project to which the entities belong.
970    #[serde(rename = "projectId")]
971    pub project_id: Option<String>,
972}
973
974impl common::Part for PartitionId {}
975
976/// A (kind, ID/name) pair used to construct a key path. If either name or ID is set, the element is complete. If neither is set, the element is incomplete.
977///
978/// This type is not used in any activity, and only used as *part* of another schema.
979///
980#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
981#[serde_with::serde_as]
982#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
983pub struct PathElement {
984    /// The auto-allocated ID of the entity. Never equal to zero. Values less than zero are discouraged and may not be supported in the future.
985    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
986    pub id: Option<i64>,
987    /// The kind of the entity. A kind matching regex `__.*__` is reserved/read-only. A kind must not contain more than 1500 bytes when UTF-8 encoded. Cannot be `""`. Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are encoded as `__bytes__` where `` is the base-64 encoding of the bytes.
988    pub kind: Option<String>,
989    /// The name of the entity. A name matching regex `__.*__` is reserved/read-only. A name must not be more than 1500 bytes when UTF-8 encoded. Cannot be `""`. Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are encoded as `__bytes__` where `` is the base-64 encoding of the bytes.
990    pub name: Option<String>,
991}
992
993impl common::Part for PathElement {}
994
995/// Planning phase information for the query.
996///
997/// This type is not used in any activity, and only used as *part* of another schema.
998///
999#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1000#[serde_with::serde_as]
1001#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1002pub struct PlanSummary {
1003    /// The indexes selected for the query. For example: [ {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} ]
1004    #[serde(rename = "indexesUsed")]
1005    pub indexes_used: Option<Vec<HashMap<String, serde_json::Value>>>,
1006}
1007
1008impl common::Part for PlanSummary {}
1009
1010/// A representation of a property in a projection.
1011///
1012/// This type is not used in any activity, and only used as *part* of another schema.
1013///
1014#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1015#[serde_with::serde_as]
1016#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1017pub struct Projection {
1018    /// The property to project.
1019    pub property: Option<PropertyReference>,
1020}
1021
1022impl common::Part for Projection {}
1023
1024/// A filter on a specific property.
1025///
1026/// This type is not used in any activity, and only used as *part* of another schema.
1027///
1028#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1029#[serde_with::serde_as]
1030#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1031pub struct PropertyFilter {
1032    /// The operator to filter by.
1033    pub op: Option<String>,
1034    /// The property to filter by.
1035    pub property: Option<PropertyReference>,
1036    /// The value to compare the property to.
1037    pub value: Option<Value>,
1038}
1039
1040impl common::Part for PropertyFilter {}
1041
1042/// The set of arbitrarily nested property paths used to restrict an operation to only a subset of properties in an entity.
1043///
1044/// This type is not used in any activity, and only used as *part* of another schema.
1045///
1046#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1047#[serde_with::serde_as]
1048#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1049pub struct PropertyMask {
1050    /// The paths to the properties covered by this mask. A path is a list of property names separated by dots (`.`), for example `foo.bar` means the property `bar` inside the entity property `foo` inside the entity associated with this path. If a property name contains a dot `.` or a backslash `\`, then that name must be escaped. A path must not be empty, and may not reference a value inside an array value.
1051    pub paths: Option<Vec<String>>,
1052}
1053
1054impl common::Part for PropertyMask {}
1055
1056/// The desired order for a specific property.
1057///
1058/// This type is not used in any activity, and only used as *part* of another schema.
1059///
1060#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1061#[serde_with::serde_as]
1062#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1063pub struct PropertyOrder {
1064    /// The direction to order by. Defaults to `ASCENDING`.
1065    pub direction: Option<String>,
1066    /// The property to order by.
1067    pub property: Option<PropertyReference>,
1068}
1069
1070impl common::Part for PropertyOrder {}
1071
1072/// A reference to a property relative to the kind expressions.
1073///
1074/// This type is not used in any activity, and only used as *part* of another schema.
1075///
1076#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1077#[serde_with::serde_as]
1078#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1079pub struct PropertyReference {
1080    /// A reference to a property. Requires: * MUST be a dot-delimited (`.`) string of segments, where each segment conforms to entity property name limitations.
1081    pub name: Option<String>,
1082}
1083
1084impl common::Part for PropertyReference {}
1085
1086/// A query for entities.
1087///
1088/// This type is not used in any activity, and only used as *part* of another schema.
1089///
1090#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1091#[serde_with::serde_as]
1092#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1093pub struct Query {
1094    /// The properties to make distinct. The query results will contain the first result for each distinct combination of values for the given properties (if empty, all results are returned). Requires: * If `order` is specified, the set of distinct on properties must appear before the non-distinct on properties in `order`.
1095    #[serde(rename = "distinctOn")]
1096    pub distinct_on: Option<Vec<PropertyReference>>,
1097    /// An ending point for the query results. Query cursors are returned in query result batches and [can only be used to limit the same query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
1098    #[serde(rename = "endCursor")]
1099    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1100    pub end_cursor: Option<Vec<u8>>,
1101    /// The filter to apply.
1102    pub filter: Option<Filter>,
1103    /// The kinds to query (if empty, returns entities of all kinds). Currently at most 1 kind may be specified.
1104    pub kind: Option<Vec<KindExpression>>,
1105    /// The maximum number of results to return. Applies after all other constraints. Optional. Unspecified is interpreted as no limit. Must be >= 0 if specified.
1106    pub limit: Option<i32>,
1107    /// The number of results to skip. Applies before limit, but after all other constraints. Optional. Must be >= 0 if specified.
1108    pub offset: Option<i32>,
1109    /// The order to apply to the query results (if empty, order is unspecified).
1110    pub order: Option<Vec<PropertyOrder>>,
1111    /// The projection to return. Defaults to returning all properties.
1112    pub projection: Option<Vec<Projection>>,
1113    /// A starting point for the query results. Query cursors are returned in query result batches and [can only be used to continue the same query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
1114    #[serde(rename = "startCursor")]
1115    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1116    pub start_cursor: Option<Vec<u8>>,
1117}
1118
1119impl common::Part for Query {}
1120
1121/// A batch of results produced by a query.
1122///
1123/// This type is not used in any activity, and only used as *part* of another schema.
1124///
1125#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1126#[serde_with::serde_as]
1127#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1128pub struct QueryResultBatch {
1129    /// A cursor that points to the position after the last result in the batch.
1130    #[serde(rename = "endCursor")]
1131    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1132    pub end_cursor: Option<Vec<u8>>,
1133    /// The result type for every entity in `entity_results`.
1134    #[serde(rename = "entityResultType")]
1135    pub entity_result_type: Option<String>,
1136    /// The results for this batch.
1137    #[serde(rename = "entityResults")]
1138    pub entity_results: Option<Vec<EntityResult>>,
1139    /// The state of the query after the current batch.
1140    #[serde(rename = "moreResults")]
1141    pub more_results: Option<String>,
1142    /// Read timestamp this batch was returned from. This applies to the range of results from the query's `start_cursor` (or the beginning of the query if no cursor was given) to this batch's `end_cursor` (not the query's `end_cursor`). In a single transaction, subsequent query result batches for the same query can have a greater timestamp. Each batch's read timestamp is valid for all preceding batches. This value will not be set for eventually consistent queries in Cloud Datastore.
1143    #[serde(rename = "readTime")]
1144    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1145    /// A cursor that points to the position after the last skipped result. Will be set when `skipped_results` != 0.
1146    #[serde(rename = "skippedCursor")]
1147    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1148    pub skipped_cursor: Option<Vec<u8>>,
1149    /// The number of results skipped, typically because of an offset.
1150    #[serde(rename = "skippedResults")]
1151    pub skipped_results: Option<i32>,
1152    /// The version number of the snapshot this batch was returned from. This applies to the range of results from the query's `start_cursor` (or the beginning of the query if no cursor was given) to this batch's `end_cursor` (not the query's `end_cursor`). In a single transaction, subsequent query result batches for the same query can have a greater snapshot version number. Each batch's snapshot version is valid for all preceding batches. The value will be zero for eventually consistent queries.
1153    #[serde(rename = "snapshotVersion")]
1154    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1155    pub snapshot_version: Option<i64>,
1156}
1157
1158impl common::Part for QueryResultBatch {}
1159
1160/// Options specific to read-only transactions.
1161///
1162/// This type is not used in any activity, and only used as *part* of another schema.
1163///
1164#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1165#[serde_with::serde_as]
1166#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1167pub struct ReadOnly {
1168    /// Reads entities 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.
1169    #[serde(rename = "readTime")]
1170    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1171}
1172
1173impl common::Part for ReadOnly {}
1174
1175/// The options shared by read requests.
1176///
1177/// This type is not used in any activity, and only used as *part* of another schema.
1178///
1179#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1180#[serde_with::serde_as]
1181#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1182pub struct ReadOptions {
1183    /// Options for beginning a new transaction for this request. The new transaction identifier will be returned in the corresponding response as either LookupResponse.transaction or RunQueryResponse.transaction.
1184    #[serde(rename = "newTransaction")]
1185    pub new_transaction: Option<TransactionOptions>,
1186    /// The non-transactional read consistency to use.
1187    #[serde(rename = "readConsistency")]
1188    pub read_consistency: Option<String>,
1189    /// Reads entities as they were at the given time. This value is only supported for Cloud Firestore in Datastore mode. 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.
1190    #[serde(rename = "readTime")]
1191    pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1192    /// The identifier of the transaction in which to read. A transaction identifier is returned by a call to Datastore.BeginTransaction.
1193    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1194    pub transaction: Option<Vec<u8>>,
1195}
1196
1197impl common::Part for ReadOptions {}
1198
1199/// Options specific to read / write transactions.
1200///
1201/// This type is not used in any activity, and only used as *part* of another schema.
1202///
1203#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1204#[serde_with::serde_as]
1205#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1206pub struct ReadWrite {
1207    /// The transaction identifier of the transaction being retried.
1208    #[serde(rename = "previousTransaction")]
1209    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1210    pub previous_transaction: Option<Vec<u8>>,
1211}
1212
1213impl common::Part for ReadWrite {}
1214
1215/// The request for Datastore.ReserveIds.
1216///
1217/// # Activities
1218///
1219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1221///
1222/// * [reserve ids projects](ProjectReserveIdCall) (request)
1223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1224#[serde_with::serde_as]
1225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1226pub struct ReserveIdsRequest {
1227    /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
1228    #[serde(rename = "databaseId")]
1229    pub database_id: Option<String>,
1230    /// Required. A list of keys with complete key paths whose numeric IDs should not be auto-allocated.
1231    pub keys: Option<Vec<Key>>,
1232}
1233
1234impl common::RequestValue for ReserveIdsRequest {}
1235
1236/// The response for Datastore.ReserveIds.
1237///
1238/// # Activities
1239///
1240/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1241/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1242///
1243/// * [reserve ids projects](ProjectReserveIdCall) (response)
1244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1245#[serde_with::serde_as]
1246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1247pub struct ReserveIdsResponse {
1248    _never_set: Option<bool>,
1249}
1250
1251impl common::ResponseResult for ReserveIdsResponse {}
1252
1253/// The request for Datastore.Rollback.
1254///
1255/// # Activities
1256///
1257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1259///
1260/// * [rollback projects](ProjectRollbackCall) (request)
1261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1262#[serde_with::serde_as]
1263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1264pub struct RollbackRequest {
1265    /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
1266    #[serde(rename = "databaseId")]
1267    pub database_id: Option<String>,
1268    /// Required. The transaction identifier, returned by a call to Datastore.BeginTransaction.
1269    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1270    pub transaction: Option<Vec<u8>>,
1271}
1272
1273impl common::RequestValue for RollbackRequest {}
1274
1275/// The response for Datastore.Rollback. (an empty message).
1276///
1277/// # Activities
1278///
1279/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1280/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1281///
1282/// * [rollback projects](ProjectRollbackCall) (response)
1283#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1284#[serde_with::serde_as]
1285#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1286pub struct RollbackResponse {
1287    _never_set: Option<bool>,
1288}
1289
1290impl common::ResponseResult for RollbackResponse {}
1291
1292/// The request for Datastore.RunAggregationQuery.
1293///
1294/// # Activities
1295///
1296/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1297/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1298///
1299/// * [run aggregation query projects](ProjectRunAggregationQueryCall) (request)
1300#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1301#[serde_with::serde_as]
1302#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1303pub struct RunAggregationQueryRequest {
1304    /// The query to run.
1305    #[serde(rename = "aggregationQuery")]
1306    pub aggregation_query: Option<AggregationQuery>,
1307    /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
1308    #[serde(rename = "databaseId")]
1309    pub database_id: Option<String>,
1310    /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
1311    #[serde(rename = "explainOptions")]
1312    pub explain_options: Option<ExplainOptions>,
1313    /// The GQL query to run. This query must be an aggregation query.
1314    #[serde(rename = "gqlQuery")]
1315    pub gql_query: Option<GqlQuery>,
1316    /// Entities are partitioned into subsets, identified by a partition ID. Queries are scoped to a single partition. This partition ID is normalized with the standard default context partition ID.
1317    #[serde(rename = "partitionId")]
1318    pub partition_id: Option<PartitionId>,
1319    /// The options for this query.
1320    #[serde(rename = "readOptions")]
1321    pub read_options: Option<ReadOptions>,
1322}
1323
1324impl common::RequestValue for RunAggregationQueryRequest {}
1325
1326/// The response for Datastore.RunAggregationQuery.
1327///
1328/// # Activities
1329///
1330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1332///
1333/// * [run aggregation query projects](ProjectRunAggregationQueryCall) (response)
1334#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1335#[serde_with::serde_as]
1336#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1337pub struct RunAggregationQueryResponse {
1338    /// A batch of aggregation results. Always present.
1339    pub batch: Option<AggregationResultBatch>,
1340    /// 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.
1341    #[serde(rename = "explainMetrics")]
1342    pub explain_metrics: Option<ExplainMetrics>,
1343    /// The parsed form of the `GqlQuery` from the request, if it was set.
1344    pub query: Option<AggregationQuery>,
1345    /// The identifier of the transaction that was started as part of this RunAggregationQuery request. Set only when ReadOptions.new_transaction was set in RunAggregationQueryRequest.read_options.
1346    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1347    pub transaction: Option<Vec<u8>>,
1348}
1349
1350impl common::ResponseResult for RunAggregationQueryResponse {}
1351
1352/// The request for Datastore.RunQuery.
1353///
1354/// # Activities
1355///
1356/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1357/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1358///
1359/// * [run query projects](ProjectRunQueryCall) (request)
1360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1361#[serde_with::serde_as]
1362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1363pub struct RunQueryRequest {
1364    /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
1365    #[serde(rename = "databaseId")]
1366    pub database_id: Option<String>,
1367    /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
1368    #[serde(rename = "explainOptions")]
1369    pub explain_options: Option<ExplainOptions>,
1370    /// The GQL query to run. This query must be a non-aggregation query.
1371    #[serde(rename = "gqlQuery")]
1372    pub gql_query: Option<GqlQuery>,
1373    /// Entities are partitioned into subsets, identified by a partition ID. Queries are scoped to a single partition. This partition ID is normalized with the standard default context partition ID.
1374    #[serde(rename = "partitionId")]
1375    pub partition_id: Option<PartitionId>,
1376    /// The properties to return. This field must not be set for a projection query. See LookupRequest.property_mask.
1377    #[serde(rename = "propertyMask")]
1378    pub property_mask: Option<PropertyMask>,
1379    /// The query to run.
1380    pub query: Option<Query>,
1381    /// The options for this query.
1382    #[serde(rename = "readOptions")]
1383    pub read_options: Option<ReadOptions>,
1384}
1385
1386impl common::RequestValue for RunQueryRequest {}
1387
1388/// The response for Datastore.RunQuery.
1389///
1390/// # Activities
1391///
1392/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1393/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1394///
1395/// * [run query projects](ProjectRunQueryCall) (response)
1396#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1397#[serde_with::serde_as]
1398#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1399pub struct RunQueryResponse {
1400    /// A batch of query results (always present).
1401    pub batch: Option<QueryResultBatch>,
1402    /// 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.
1403    #[serde(rename = "explainMetrics")]
1404    pub explain_metrics: Option<ExplainMetrics>,
1405    /// The parsed form of the `GqlQuery` from the request, if it was set.
1406    pub query: Option<Query>,
1407    /// The identifier of the transaction that was started as part of this RunQuery request. Set only when ReadOptions.new_transaction was set in RunQueryRequest.read_options.
1408    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1409    pub transaction: Option<Vec<u8>>,
1410}
1411
1412impl common::ResponseResult for RunQueryResponse {}
1413
1414/// 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).
1415///
1416/// This type is not used in any activity, and only used as *part* of another schema.
1417///
1418#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1419#[serde_with::serde_as]
1420#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1421pub struct Status {
1422    /// The status code, which should be an enum value of google.rpc.Code.
1423    pub code: Option<i32>,
1424    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1425    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1426    /// 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.
1427    pub message: Option<String>,
1428}
1429
1430impl common::Part for Status {}
1431
1432/// Sum of the values of the requested property. * 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.
1433///
1434/// This type is not used in any activity, and only used as *part* of another schema.
1435///
1436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1437#[serde_with::serde_as]
1438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1439pub struct Sum {
1440    /// The property to aggregate on.
1441    pub property: Option<PropertyReference>,
1442}
1443
1444impl common::Part for Sum {}
1445
1446/// Options for beginning a new transaction. Transactions can be created explicitly with calls to Datastore.BeginTransaction or implicitly by setting ReadOptions.new_transaction in read requests.
1447///
1448/// This type is not used in any activity, and only used as *part* of another schema.
1449///
1450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1451#[serde_with::serde_as]
1452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1453pub struct TransactionOptions {
1454    /// The transaction should only allow reads.
1455    #[serde(rename = "readOnly")]
1456    pub read_only: Option<ReadOnly>,
1457    /// The transaction should allow both reads and writes.
1458    #[serde(rename = "readWrite")]
1459    pub read_write: Option<ReadWrite>,
1460}
1461
1462impl common::Part for TransactionOptions {}
1463
1464/// A message that can hold any of the supported value types and associated metadata.
1465///
1466/// This type is not used in any activity, and only used as *part* of another schema.
1467///
1468#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1469#[serde_with::serde_as]
1470#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1471pub struct Value {
1472    /// An array value. Cannot contain another array value. A `Value` instance that sets field `array_value` must not set fields `meaning` or `exclude_from_indexes`.
1473    #[serde(rename = "arrayValue")]
1474    pub array_value: Option<ArrayValue>,
1475    /// A blob value. May have at most 1,000,000 bytes. When `exclude_from_indexes` is false, may have at most 1500 bytes. In JSON requests, must be base64-encoded.
1476    #[serde(rename = "blobValue")]
1477    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1478    pub blob_value: Option<Vec<u8>>,
1479    /// A boolean value.
1480    #[serde(rename = "booleanValue")]
1481    pub boolean_value: Option<bool>,
1482    /// A double value.
1483    #[serde(rename = "doubleValue")]
1484    pub double_value: Option<f64>,
1485    /// An entity value. - May have no key. - May have a key with an incomplete key path. - May have a reserved/read-only key.
1486    #[serde(rename = "entityValue")]
1487    pub entity_value: Option<Entity>,
1488    /// If the value should be excluded from all indexes including those defined explicitly.
1489    #[serde(rename = "excludeFromIndexes")]
1490    pub exclude_from_indexes: Option<bool>,
1491    /// A geo point value representing a point on the surface of Earth.
1492    #[serde(rename = "geoPointValue")]
1493    pub geo_point_value: Option<LatLng>,
1494    /// An integer value.
1495    #[serde(rename = "integerValue")]
1496    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1497    pub integer_value: Option<i64>,
1498    /// A key value.
1499    #[serde(rename = "keyValue")]
1500    pub key_value: Option<Key>,
1501    /// The `meaning` field should only be populated for backwards compatibility.
1502    pub meaning: Option<i32>,
1503    /// A null value.
1504    #[serde(rename = "nullValue")]
1505    pub null_value: Option<String>,
1506    /// A UTF-8 encoded string value. When `exclude_from_indexes` is false (it is indexed) , may have at most 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
1507    #[serde(rename = "stringValue")]
1508    pub string_value: Option<String>,
1509    /// A timestamp value. When stored in the Datastore, precise only to microseconds; any additional precision is rounded down.
1510    #[serde(rename = "timestampValue")]
1511    pub timestamp_value: Option<chrono::DateTime<chrono::offset::Utc>>,
1512}
1513
1514impl common::Part for Value {}
1515
1516// ###################
1517// MethodBuilders ###
1518// #################
1519
1520/// A builder providing access to all methods supported on *project* resources.
1521/// It is not used directly, but through the [`Datastore`] hub.
1522///
1523/// # Example
1524///
1525/// Instantiate a resource builder
1526///
1527/// ```test_harness,no_run
1528/// extern crate hyper;
1529/// extern crate hyper_rustls;
1530/// extern crate google_datastore1 as datastore1;
1531///
1532/// # async fn dox() {
1533/// use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1534///
1535/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1536/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1537///     secret,
1538///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1539/// ).build().await.unwrap();
1540///
1541/// let client = hyper_util::client::legacy::Client::builder(
1542///     hyper_util::rt::TokioExecutor::new()
1543/// )
1544/// .build(
1545///     hyper_rustls::HttpsConnectorBuilder::new()
1546///         .with_native_roots()
1547///         .unwrap()
1548///         .https_or_http()
1549///         .enable_http1()
1550///         .build()
1551/// );
1552/// let mut hub = Datastore::new(client, auth);
1553/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1554/// // like `allocate_ids(...)`, `begin_transaction(...)`, `commit(...)`, `export(...)`, `import(...)`, `indexes_create(...)`, `indexes_delete(...)`, `indexes_get(...)`, `indexes_list(...)`, `lookup(...)`, `operations_cancel(...)`, `operations_delete(...)`, `operations_get(...)`, `operations_list(...)`, `reserve_ids(...)`, `rollback(...)`, `run_aggregation_query(...)` and `run_query(...)`
1555/// // to build up your call.
1556/// let rb = hub.projects();
1557/// # }
1558/// ```
1559pub struct ProjectMethods<'a, C>
1560where
1561    C: 'a,
1562{
1563    hub: &'a Datastore<C>,
1564}
1565
1566impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1567
1568impl<'a, C> ProjectMethods<'a, C> {
1569    /// Create a builder to help you perform the following task:
1570    ///
1571    /// 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 index 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 property cannot be created.
1572    ///
1573    /// # Arguments
1574    ///
1575    /// * `request` - No description provided.
1576    /// * `projectId` - Project ID against which to make the request.
1577    pub fn indexes_create(
1578        &self,
1579        request: GoogleDatastoreAdminV1Index,
1580        project_id: &str,
1581    ) -> ProjectIndexCreateCall<'a, C> {
1582        ProjectIndexCreateCall {
1583            hub: self.hub,
1584            _request: request,
1585            _project_id: project_id.to_string(),
1586            _delegate: Default::default(),
1587            _additional_params: Default::default(),
1588            _scopes: Default::default(),
1589        }
1590    }
1591
1592    /// Create a builder to help you perform the following task:
1593    ///
1594    /// Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. On successful execution of the request, the index will be in a `DELETING` state. And on completion of the returned google.longrunning.Operation, the index will be removed. During index deletion, 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, followed by calling delete again.
1595    ///
1596    /// # Arguments
1597    ///
1598    /// * `projectId` - Project ID against which to make the request.
1599    /// * `indexId` - The resource ID of the index to delete.
1600    pub fn indexes_delete(
1601        &self,
1602        project_id: &str,
1603        index_id: &str,
1604    ) -> ProjectIndexDeleteCall<'a, C> {
1605        ProjectIndexDeleteCall {
1606            hub: self.hub,
1607            _project_id: project_id.to_string(),
1608            _index_id: index_id.to_string(),
1609            _delegate: Default::default(),
1610            _additional_params: Default::default(),
1611            _scopes: Default::default(),
1612        }
1613    }
1614
1615    /// Create a builder to help you perform the following task:
1616    ///
1617    /// Gets an index.
1618    ///
1619    /// # Arguments
1620    ///
1621    /// * `projectId` - Project ID against which to make the request.
1622    /// * `indexId` - The resource ID of the index to get.
1623    pub fn indexes_get(&self, project_id: &str, index_id: &str) -> ProjectIndexGetCall<'a, C> {
1624        ProjectIndexGetCall {
1625            hub: self.hub,
1626            _project_id: project_id.to_string(),
1627            _index_id: index_id.to_string(),
1628            _delegate: Default::default(),
1629            _additional_params: Default::default(),
1630            _scopes: Default::default(),
1631        }
1632    }
1633
1634    /// Create a builder to help you perform the following task:
1635    ///
1636    /// Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.
1637    ///
1638    /// # Arguments
1639    ///
1640    /// * `projectId` - Project ID against which to make the request.
1641    pub fn indexes_list(&self, project_id: &str) -> ProjectIndexListCall<'a, C> {
1642        ProjectIndexListCall {
1643            hub: self.hub,
1644            _project_id: project_id.to_string(),
1645            _page_token: Default::default(),
1646            _page_size: Default::default(),
1647            _filter: Default::default(),
1648            _delegate: Default::default(),
1649            _additional_params: Default::default(),
1650            _scopes: Default::default(),
1651        }
1652    }
1653
1654    /// Create a builder to help you perform the following task:
1655    ///
1656    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
1657    ///
1658    /// # Arguments
1659    ///
1660    /// * `name` - The name of the operation resource to be cancelled.
1661    pub fn operations_cancel(&self, name: &str) -> ProjectOperationCancelCall<'a, C> {
1662        ProjectOperationCancelCall {
1663            hub: self.hub,
1664            _name: name.to_string(),
1665            _delegate: Default::default(),
1666            _additional_params: Default::default(),
1667            _scopes: Default::default(),
1668        }
1669    }
1670
1671    /// Create a builder to help you perform the following task:
1672    ///
1673    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
1674    ///
1675    /// # Arguments
1676    ///
1677    /// * `name` - The name of the operation resource to be deleted.
1678    pub fn operations_delete(&self, name: &str) -> ProjectOperationDeleteCall<'a, C> {
1679        ProjectOperationDeleteCall {
1680            hub: self.hub,
1681            _name: name.to_string(),
1682            _delegate: Default::default(),
1683            _additional_params: Default::default(),
1684            _scopes: Default::default(),
1685        }
1686    }
1687
1688    /// Create a builder to help you perform the following task:
1689    ///
1690    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1691    ///
1692    /// # Arguments
1693    ///
1694    /// * `name` - The name of the operation resource.
1695    pub fn operations_get(&self, name: &str) -> ProjectOperationGetCall<'a, C> {
1696        ProjectOperationGetCall {
1697            hub: self.hub,
1698            _name: name.to_string(),
1699            _delegate: Default::default(),
1700            _additional_params: Default::default(),
1701            _scopes: Default::default(),
1702        }
1703    }
1704
1705    /// Create a builder to help you perform the following task:
1706    ///
1707    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1708    ///
1709    /// # Arguments
1710    ///
1711    /// * `name` - The name of the operation's parent resource.
1712    pub fn operations_list(&self, name: &str) -> ProjectOperationListCall<'a, C> {
1713        ProjectOperationListCall {
1714            hub: self.hub,
1715            _name: name.to_string(),
1716            _page_token: Default::default(),
1717            _page_size: Default::default(),
1718            _filter: Default::default(),
1719            _delegate: Default::default(),
1720            _additional_params: Default::default(),
1721            _scopes: Default::default(),
1722        }
1723    }
1724
1725    /// Create a builder to help you perform the following task:
1726    ///
1727    /// Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
1728    ///
1729    /// # Arguments
1730    ///
1731    /// * `request` - No description provided.
1732    /// * `projectId` - Required. The ID of the project against which to make the request.
1733    pub fn allocate_ids(
1734        &self,
1735        request: AllocateIdsRequest,
1736        project_id: &str,
1737    ) -> ProjectAllocateIdCall<'a, C> {
1738        ProjectAllocateIdCall {
1739            hub: self.hub,
1740            _request: request,
1741            _project_id: project_id.to_string(),
1742            _delegate: Default::default(),
1743            _additional_params: Default::default(),
1744            _scopes: Default::default(),
1745        }
1746    }
1747
1748    /// Create a builder to help you perform the following task:
1749    ///
1750    /// Begins a new transaction.
1751    ///
1752    /// # Arguments
1753    ///
1754    /// * `request` - No description provided.
1755    /// * `projectId` - Required. The ID of the project against which to make the request.
1756    pub fn begin_transaction(
1757        &self,
1758        request: BeginTransactionRequest,
1759        project_id: &str,
1760    ) -> ProjectBeginTransactionCall<'a, C> {
1761        ProjectBeginTransactionCall {
1762            hub: self.hub,
1763            _request: request,
1764            _project_id: project_id.to_string(),
1765            _delegate: Default::default(),
1766            _additional_params: Default::default(),
1767            _scopes: Default::default(),
1768        }
1769    }
1770
1771    /// Create a builder to help you perform the following task:
1772    ///
1773    /// Commits a transaction, optionally creating, deleting or modifying some entities.
1774    ///
1775    /// # Arguments
1776    ///
1777    /// * `request` - No description provided.
1778    /// * `projectId` - Required. The ID of the project against which to make the request.
1779    pub fn commit(&self, request: CommitRequest, project_id: &str) -> ProjectCommitCall<'a, C> {
1780        ProjectCommitCall {
1781            hub: self.hub,
1782            _request: request,
1783            _project_id: project_id.to_string(),
1784            _delegate: Default::default(),
1785            _additional_params: Default::default(),
1786            _scopes: Default::default(),
1787        }
1788    }
1789
1790    /// Create a builder to help you perform the following task:
1791    ///
1792    /// Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities 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.
1793    ///
1794    /// # Arguments
1795    ///
1796    /// * `request` - No description provided.
1797    /// * `projectId` - Required. Project ID against which to make the request.
1798    pub fn export(
1799        &self,
1800        request: GoogleDatastoreAdminV1ExportEntitiesRequest,
1801        project_id: &str,
1802    ) -> ProjectExportCall<'a, C> {
1803        ProjectExportCall {
1804            hub: self.hub,
1805            _request: request,
1806            _project_id: project_id.to_string(),
1807            _delegate: Default::default(),
1808            _additional_params: Default::default(),
1809            _scopes: Default::default(),
1810        }
1811    }
1812
1813    /// Create a builder to help you perform the following task:
1814    ///
1815    /// Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.
1816    ///
1817    /// # Arguments
1818    ///
1819    /// * `request` - No description provided.
1820    /// * `projectId` - Required. Project ID against which to make the request.
1821    pub fn import(
1822        &self,
1823        request: GoogleDatastoreAdminV1ImportEntitiesRequest,
1824        project_id: &str,
1825    ) -> ProjectImportCall<'a, C> {
1826        ProjectImportCall {
1827            hub: self.hub,
1828            _request: request,
1829            _project_id: project_id.to_string(),
1830            _delegate: Default::default(),
1831            _additional_params: Default::default(),
1832            _scopes: Default::default(),
1833        }
1834    }
1835
1836    /// Create a builder to help you perform the following task:
1837    ///
1838    /// Looks up entities by key.
1839    ///
1840    /// # Arguments
1841    ///
1842    /// * `request` - No description provided.
1843    /// * `projectId` - Required. The ID of the project against which to make the request.
1844    pub fn lookup(&self, request: LookupRequest, project_id: &str) -> ProjectLookupCall<'a, C> {
1845        ProjectLookupCall {
1846            hub: self.hub,
1847            _request: request,
1848            _project_id: project_id.to_string(),
1849            _delegate: Default::default(),
1850            _additional_params: Default::default(),
1851            _scopes: Default::default(),
1852        }
1853    }
1854
1855    /// Create a builder to help you perform the following task:
1856    ///
1857    /// Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
1858    ///
1859    /// # Arguments
1860    ///
1861    /// * `request` - No description provided.
1862    /// * `projectId` - Required. The ID of the project against which to make the request.
1863    pub fn reserve_ids(
1864        &self,
1865        request: ReserveIdsRequest,
1866        project_id: &str,
1867    ) -> ProjectReserveIdCall<'a, C> {
1868        ProjectReserveIdCall {
1869            hub: self.hub,
1870            _request: request,
1871            _project_id: project_id.to_string(),
1872            _delegate: Default::default(),
1873            _additional_params: Default::default(),
1874            _scopes: Default::default(),
1875        }
1876    }
1877
1878    /// Create a builder to help you perform the following task:
1879    ///
1880    /// Rolls back a transaction.
1881    ///
1882    /// # Arguments
1883    ///
1884    /// * `request` - No description provided.
1885    /// * `projectId` - Required. The ID of the project against which to make the request.
1886    pub fn rollback(
1887        &self,
1888        request: RollbackRequest,
1889        project_id: &str,
1890    ) -> ProjectRollbackCall<'a, C> {
1891        ProjectRollbackCall {
1892            hub: self.hub,
1893            _request: request,
1894            _project_id: project_id.to_string(),
1895            _delegate: Default::default(),
1896            _additional_params: Default::default(),
1897            _scopes: Default::default(),
1898        }
1899    }
1900
1901    /// Create a builder to help you perform the following task:
1902    ///
1903    /// Runs an aggregation query.
1904    ///
1905    /// # Arguments
1906    ///
1907    /// * `request` - No description provided.
1908    /// * `projectId` - Required. The ID of the project against which to make the request.
1909    pub fn run_aggregation_query(
1910        &self,
1911        request: RunAggregationQueryRequest,
1912        project_id: &str,
1913    ) -> ProjectRunAggregationQueryCall<'a, C> {
1914        ProjectRunAggregationQueryCall {
1915            hub: self.hub,
1916            _request: request,
1917            _project_id: project_id.to_string(),
1918            _delegate: Default::default(),
1919            _additional_params: Default::default(),
1920            _scopes: Default::default(),
1921        }
1922    }
1923
1924    /// Create a builder to help you perform the following task:
1925    ///
1926    /// Queries for entities.
1927    ///
1928    /// # Arguments
1929    ///
1930    /// * `request` - No description provided.
1931    /// * `projectId` - Required. The ID of the project against which to make the request.
1932    pub fn run_query(
1933        &self,
1934        request: RunQueryRequest,
1935        project_id: &str,
1936    ) -> ProjectRunQueryCall<'a, C> {
1937        ProjectRunQueryCall {
1938            hub: self.hub,
1939            _request: request,
1940            _project_id: project_id.to_string(),
1941            _delegate: Default::default(),
1942            _additional_params: Default::default(),
1943            _scopes: Default::default(),
1944        }
1945    }
1946}
1947
1948// ###################
1949// CallBuilders   ###
1950// #################
1951
1952/// 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 index 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 property cannot be created.
1953///
1954/// A builder for the *indexes.create* method supported by a *project* resource.
1955/// It is not used directly, but through a [`ProjectMethods`] instance.
1956///
1957/// # Example
1958///
1959/// Instantiate a resource method builder
1960///
1961/// ```test_harness,no_run
1962/// # extern crate hyper;
1963/// # extern crate hyper_rustls;
1964/// # extern crate google_datastore1 as datastore1;
1965/// use datastore1::api::GoogleDatastoreAdminV1Index;
1966/// # async fn dox() {
1967/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1968///
1969/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1970/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1971/// #     secret,
1972/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1973/// # ).build().await.unwrap();
1974///
1975/// # let client = hyper_util::client::legacy::Client::builder(
1976/// #     hyper_util::rt::TokioExecutor::new()
1977/// # )
1978/// # .build(
1979/// #     hyper_rustls::HttpsConnectorBuilder::new()
1980/// #         .with_native_roots()
1981/// #         .unwrap()
1982/// #         .https_or_http()
1983/// #         .enable_http1()
1984/// #         .build()
1985/// # );
1986/// # let mut hub = Datastore::new(client, auth);
1987/// // As the method needs a request, you would usually fill it with the desired information
1988/// // into the respective structure. Some of the parts shown here might not be applicable !
1989/// // Values shown here are possibly random and not representative !
1990/// let mut req = GoogleDatastoreAdminV1Index::default();
1991///
1992/// // You can configure optional parameters by calling the respective setters at will, and
1993/// // execute the final call using `doit()`.
1994/// // Values shown here are possibly random and not representative !
1995/// let result = hub.projects().indexes_create(req, "projectId")
1996///              .doit().await;
1997/// # }
1998/// ```
1999pub struct ProjectIndexCreateCall<'a, C>
2000where
2001    C: 'a,
2002{
2003    hub: &'a Datastore<C>,
2004    _request: GoogleDatastoreAdminV1Index,
2005    _project_id: String,
2006    _delegate: Option<&'a mut dyn common::Delegate>,
2007    _additional_params: HashMap<String, String>,
2008    _scopes: BTreeSet<String>,
2009}
2010
2011impl<'a, C> common::CallBuilder for ProjectIndexCreateCall<'a, C> {}
2012
2013impl<'a, C> ProjectIndexCreateCall<'a, C>
2014where
2015    C: common::Connector,
2016{
2017    /// Perform the operation you have build so far.
2018    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
2019        use std::borrow::Cow;
2020        use std::io::{Read, Seek};
2021
2022        use common::{url::Params, ToParts};
2023        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2024
2025        let mut dd = common::DefaultDelegate;
2026        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2027        dlg.begin(common::MethodInfo {
2028            id: "datastore.projects.indexes.create",
2029            http_method: hyper::Method::POST,
2030        });
2031
2032        for &field in ["alt", "projectId"].iter() {
2033            if self._additional_params.contains_key(field) {
2034                dlg.finished(false);
2035                return Err(common::Error::FieldClash(field));
2036            }
2037        }
2038
2039        let mut params = Params::with_capacity(4 + self._additional_params.len());
2040        params.push("projectId", self._project_id);
2041
2042        params.extend(self._additional_params.iter());
2043
2044        params.push("alt", "json");
2045        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/indexes";
2046        if self._scopes.is_empty() {
2047            self._scopes
2048                .insert(Scope::CloudPlatform.as_ref().to_string());
2049        }
2050
2051        #[allow(clippy::single_element_loop)]
2052        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
2053            url = params.uri_replacement(url, param_name, find_this, false);
2054        }
2055        {
2056            let to_remove = ["projectId"];
2057            params.remove_params(&to_remove);
2058        }
2059
2060        let url = params.parse_with_url(&url);
2061
2062        let mut json_mime_type = mime::APPLICATION_JSON;
2063        let mut request_value_reader = {
2064            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2065            common::remove_json_null_values(&mut value);
2066            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2067            serde_json::to_writer(&mut dst, &value).unwrap();
2068            dst
2069        };
2070        let request_size = request_value_reader
2071            .seek(std::io::SeekFrom::End(0))
2072            .unwrap();
2073        request_value_reader
2074            .seek(std::io::SeekFrom::Start(0))
2075            .unwrap();
2076
2077        loop {
2078            let token = match self
2079                .hub
2080                .auth
2081                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2082                .await
2083            {
2084                Ok(token) => token,
2085                Err(e) => match dlg.token(e) {
2086                    Ok(token) => token,
2087                    Err(e) => {
2088                        dlg.finished(false);
2089                        return Err(common::Error::MissingToken(e));
2090                    }
2091                },
2092            };
2093            request_value_reader
2094                .seek(std::io::SeekFrom::Start(0))
2095                .unwrap();
2096            let mut req_result = {
2097                let client = &self.hub.client;
2098                dlg.pre_request();
2099                let mut req_builder = hyper::Request::builder()
2100                    .method(hyper::Method::POST)
2101                    .uri(url.as_str())
2102                    .header(USER_AGENT, self.hub._user_agent.clone());
2103
2104                if let Some(token) = token.as_ref() {
2105                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2106                }
2107
2108                let request = req_builder
2109                    .header(CONTENT_TYPE, json_mime_type.to_string())
2110                    .header(CONTENT_LENGTH, request_size as u64)
2111                    .body(common::to_body(
2112                        request_value_reader.get_ref().clone().into(),
2113                    ));
2114
2115                client.request(request.unwrap()).await
2116            };
2117
2118            match req_result {
2119                Err(err) => {
2120                    if let common::Retry::After(d) = dlg.http_error(&err) {
2121                        sleep(d).await;
2122                        continue;
2123                    }
2124                    dlg.finished(false);
2125                    return Err(common::Error::HttpError(err));
2126                }
2127                Ok(res) => {
2128                    let (mut parts, body) = res.into_parts();
2129                    let mut body = common::Body::new(body);
2130                    if !parts.status.is_success() {
2131                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2132                        let error = serde_json::from_str(&common::to_string(&bytes));
2133                        let response = common::to_response(parts, bytes.into());
2134
2135                        if let common::Retry::After(d) =
2136                            dlg.http_failure(&response, error.as_ref().ok())
2137                        {
2138                            sleep(d).await;
2139                            continue;
2140                        }
2141
2142                        dlg.finished(false);
2143
2144                        return Err(match error {
2145                            Ok(value) => common::Error::BadRequest(value),
2146                            _ => common::Error::Failure(response),
2147                        });
2148                    }
2149                    let response = {
2150                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2151                        let encoded = common::to_string(&bytes);
2152                        match serde_json::from_str(&encoded) {
2153                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2154                            Err(error) => {
2155                                dlg.response_json_decode_error(&encoded, &error);
2156                                return Err(common::Error::JsonDecodeError(
2157                                    encoded.to_string(),
2158                                    error,
2159                                ));
2160                            }
2161                        }
2162                    };
2163
2164                    dlg.finished(true);
2165                    return Ok(response);
2166                }
2167            }
2168        }
2169    }
2170
2171    ///
2172    /// Sets the *request* property to the given value.
2173    ///
2174    /// Even though the property as already been set when instantiating this call,
2175    /// we provide this method for API completeness.
2176    pub fn request(
2177        mut self,
2178        new_value: GoogleDatastoreAdminV1Index,
2179    ) -> ProjectIndexCreateCall<'a, C> {
2180        self._request = new_value;
2181        self
2182    }
2183    /// Project ID against which to make the request.
2184    ///
2185    /// Sets the *project id* path property to the given value.
2186    ///
2187    /// Even though the property as already been set when instantiating this call,
2188    /// we provide this method for API completeness.
2189    pub fn project_id(mut self, new_value: &str) -> ProjectIndexCreateCall<'a, C> {
2190        self._project_id = new_value.to_string();
2191        self
2192    }
2193    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2194    /// while executing the actual API request.
2195    ///
2196    /// ````text
2197    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2198    /// ````
2199    ///
2200    /// Sets the *delegate* property to the given value.
2201    pub fn delegate(
2202        mut self,
2203        new_value: &'a mut dyn common::Delegate,
2204    ) -> ProjectIndexCreateCall<'a, C> {
2205        self._delegate = Some(new_value);
2206        self
2207    }
2208
2209    /// Set any additional parameter of the query string used in the request.
2210    /// It should be used to set parameters which are not yet available through their own
2211    /// setters.
2212    ///
2213    /// Please note that this method must not be used to set any of the known parameters
2214    /// which have their own setter method. If done anyway, the request will fail.
2215    ///
2216    /// # Additional Parameters
2217    ///
2218    /// * *$.xgafv* (query-string) - V1 error format.
2219    /// * *access_token* (query-string) - OAuth access token.
2220    /// * *alt* (query-string) - Data format for response.
2221    /// * *callback* (query-string) - JSONP
2222    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2223    /// * *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.
2224    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2225    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2226    /// * *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.
2227    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2228    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2229    pub fn param<T>(mut self, name: T, value: T) -> ProjectIndexCreateCall<'a, C>
2230    where
2231        T: AsRef<str>,
2232    {
2233        self._additional_params
2234            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2235        self
2236    }
2237
2238    /// Identifies the authorization scope for the method you are building.
2239    ///
2240    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2241    /// [`Scope::CloudPlatform`].
2242    ///
2243    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2244    /// tokens for more than one scope.
2245    ///
2246    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2247    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2248    /// sufficient, a read-write scope will do as well.
2249    pub fn add_scope<St>(mut self, scope: St) -> ProjectIndexCreateCall<'a, C>
2250    where
2251        St: AsRef<str>,
2252    {
2253        self._scopes.insert(String::from(scope.as_ref()));
2254        self
2255    }
2256    /// Identifies the authorization scope(s) for the method you are building.
2257    ///
2258    /// See [`Self::add_scope()`] for details.
2259    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectIndexCreateCall<'a, C>
2260    where
2261        I: IntoIterator<Item = St>,
2262        St: AsRef<str>,
2263    {
2264        self._scopes
2265            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2266        self
2267    }
2268
2269    /// Removes all scopes, and no default scope will be used either.
2270    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2271    /// for details).
2272    pub fn clear_scopes(mut self) -> ProjectIndexCreateCall<'a, C> {
2273        self._scopes.clear();
2274        self
2275    }
2276}
2277
2278/// Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. On successful execution of the request, the index will be in a `DELETING` state. And on completion of the returned google.longrunning.Operation, the index will be removed. During index deletion, 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, followed by calling delete again.
2279///
2280/// A builder for the *indexes.delete* method supported by a *project* resource.
2281/// It is not used directly, but through a [`ProjectMethods`] instance.
2282///
2283/// # Example
2284///
2285/// Instantiate a resource method builder
2286///
2287/// ```test_harness,no_run
2288/// # extern crate hyper;
2289/// # extern crate hyper_rustls;
2290/// # extern crate google_datastore1 as datastore1;
2291/// # async fn dox() {
2292/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2293///
2294/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2295/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2296/// #     secret,
2297/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2298/// # ).build().await.unwrap();
2299///
2300/// # let client = hyper_util::client::legacy::Client::builder(
2301/// #     hyper_util::rt::TokioExecutor::new()
2302/// # )
2303/// # .build(
2304/// #     hyper_rustls::HttpsConnectorBuilder::new()
2305/// #         .with_native_roots()
2306/// #         .unwrap()
2307/// #         .https_or_http()
2308/// #         .enable_http1()
2309/// #         .build()
2310/// # );
2311/// # let mut hub = Datastore::new(client, auth);
2312/// // You can configure optional parameters by calling the respective setters at will, and
2313/// // execute the final call using `doit()`.
2314/// // Values shown here are possibly random and not representative !
2315/// let result = hub.projects().indexes_delete("projectId", "indexId")
2316///              .doit().await;
2317/// # }
2318/// ```
2319pub struct ProjectIndexDeleteCall<'a, C>
2320where
2321    C: 'a,
2322{
2323    hub: &'a Datastore<C>,
2324    _project_id: String,
2325    _index_id: String,
2326    _delegate: Option<&'a mut dyn common::Delegate>,
2327    _additional_params: HashMap<String, String>,
2328    _scopes: BTreeSet<String>,
2329}
2330
2331impl<'a, C> common::CallBuilder for ProjectIndexDeleteCall<'a, C> {}
2332
2333impl<'a, C> ProjectIndexDeleteCall<'a, C>
2334where
2335    C: common::Connector,
2336{
2337    /// Perform the operation you have build so far.
2338    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
2339        use std::borrow::Cow;
2340        use std::io::{Read, Seek};
2341
2342        use common::{url::Params, ToParts};
2343        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2344
2345        let mut dd = common::DefaultDelegate;
2346        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2347        dlg.begin(common::MethodInfo {
2348            id: "datastore.projects.indexes.delete",
2349            http_method: hyper::Method::DELETE,
2350        });
2351
2352        for &field in ["alt", "projectId", "indexId"].iter() {
2353            if self._additional_params.contains_key(field) {
2354                dlg.finished(false);
2355                return Err(common::Error::FieldClash(field));
2356            }
2357        }
2358
2359        let mut params = Params::with_capacity(4 + self._additional_params.len());
2360        params.push("projectId", self._project_id);
2361        params.push("indexId", self._index_id);
2362
2363        params.extend(self._additional_params.iter());
2364
2365        params.push("alt", "json");
2366        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/indexes/{indexId}";
2367        if self._scopes.is_empty() {
2368            self._scopes
2369                .insert(Scope::CloudPlatform.as_ref().to_string());
2370        }
2371
2372        #[allow(clippy::single_element_loop)]
2373        for &(find_this, param_name) in
2374            [("{projectId}", "projectId"), ("{indexId}", "indexId")].iter()
2375        {
2376            url = params.uri_replacement(url, param_name, find_this, false);
2377        }
2378        {
2379            let to_remove = ["indexId", "projectId"];
2380            params.remove_params(&to_remove);
2381        }
2382
2383        let url = params.parse_with_url(&url);
2384
2385        loop {
2386            let token = match self
2387                .hub
2388                .auth
2389                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2390                .await
2391            {
2392                Ok(token) => token,
2393                Err(e) => match dlg.token(e) {
2394                    Ok(token) => token,
2395                    Err(e) => {
2396                        dlg.finished(false);
2397                        return Err(common::Error::MissingToken(e));
2398                    }
2399                },
2400            };
2401            let mut req_result = {
2402                let client = &self.hub.client;
2403                dlg.pre_request();
2404                let mut req_builder = hyper::Request::builder()
2405                    .method(hyper::Method::DELETE)
2406                    .uri(url.as_str())
2407                    .header(USER_AGENT, self.hub._user_agent.clone());
2408
2409                if let Some(token) = token.as_ref() {
2410                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2411                }
2412
2413                let request = req_builder
2414                    .header(CONTENT_LENGTH, 0_u64)
2415                    .body(common::to_body::<String>(None));
2416
2417                client.request(request.unwrap()).await
2418            };
2419
2420            match req_result {
2421                Err(err) => {
2422                    if let common::Retry::After(d) = dlg.http_error(&err) {
2423                        sleep(d).await;
2424                        continue;
2425                    }
2426                    dlg.finished(false);
2427                    return Err(common::Error::HttpError(err));
2428                }
2429                Ok(res) => {
2430                    let (mut parts, body) = res.into_parts();
2431                    let mut body = common::Body::new(body);
2432                    if !parts.status.is_success() {
2433                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2434                        let error = serde_json::from_str(&common::to_string(&bytes));
2435                        let response = common::to_response(parts, bytes.into());
2436
2437                        if let common::Retry::After(d) =
2438                            dlg.http_failure(&response, error.as_ref().ok())
2439                        {
2440                            sleep(d).await;
2441                            continue;
2442                        }
2443
2444                        dlg.finished(false);
2445
2446                        return Err(match error {
2447                            Ok(value) => common::Error::BadRequest(value),
2448                            _ => common::Error::Failure(response),
2449                        });
2450                    }
2451                    let response = {
2452                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2453                        let encoded = common::to_string(&bytes);
2454                        match serde_json::from_str(&encoded) {
2455                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2456                            Err(error) => {
2457                                dlg.response_json_decode_error(&encoded, &error);
2458                                return Err(common::Error::JsonDecodeError(
2459                                    encoded.to_string(),
2460                                    error,
2461                                ));
2462                            }
2463                        }
2464                    };
2465
2466                    dlg.finished(true);
2467                    return Ok(response);
2468                }
2469            }
2470        }
2471    }
2472
2473    /// Project ID against which to make the request.
2474    ///
2475    /// Sets the *project id* path property to the given value.
2476    ///
2477    /// Even though the property as already been set when instantiating this call,
2478    /// we provide this method for API completeness.
2479    pub fn project_id(mut self, new_value: &str) -> ProjectIndexDeleteCall<'a, C> {
2480        self._project_id = new_value.to_string();
2481        self
2482    }
2483    /// The resource ID of the index to delete.
2484    ///
2485    /// Sets the *index id* path property to the given value.
2486    ///
2487    /// Even though the property as already been set when instantiating this call,
2488    /// we provide this method for API completeness.
2489    pub fn index_id(mut self, new_value: &str) -> ProjectIndexDeleteCall<'a, C> {
2490        self._index_id = new_value.to_string();
2491        self
2492    }
2493    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2494    /// while executing the actual API request.
2495    ///
2496    /// ````text
2497    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2498    /// ````
2499    ///
2500    /// Sets the *delegate* property to the given value.
2501    pub fn delegate(
2502        mut self,
2503        new_value: &'a mut dyn common::Delegate,
2504    ) -> ProjectIndexDeleteCall<'a, C> {
2505        self._delegate = Some(new_value);
2506        self
2507    }
2508
2509    /// Set any additional parameter of the query string used in the request.
2510    /// It should be used to set parameters which are not yet available through their own
2511    /// setters.
2512    ///
2513    /// Please note that this method must not be used to set any of the known parameters
2514    /// which have their own setter method. If done anyway, the request will fail.
2515    ///
2516    /// # Additional Parameters
2517    ///
2518    /// * *$.xgafv* (query-string) - V1 error format.
2519    /// * *access_token* (query-string) - OAuth access token.
2520    /// * *alt* (query-string) - Data format for response.
2521    /// * *callback* (query-string) - JSONP
2522    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2523    /// * *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.
2524    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2525    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2526    /// * *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.
2527    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2528    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2529    pub fn param<T>(mut self, name: T, value: T) -> ProjectIndexDeleteCall<'a, C>
2530    where
2531        T: AsRef<str>,
2532    {
2533        self._additional_params
2534            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2535        self
2536    }
2537
2538    /// Identifies the authorization scope for the method you are building.
2539    ///
2540    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2541    /// [`Scope::CloudPlatform`].
2542    ///
2543    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2544    /// tokens for more than one scope.
2545    ///
2546    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2547    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2548    /// sufficient, a read-write scope will do as well.
2549    pub fn add_scope<St>(mut self, scope: St) -> ProjectIndexDeleteCall<'a, C>
2550    where
2551        St: AsRef<str>,
2552    {
2553        self._scopes.insert(String::from(scope.as_ref()));
2554        self
2555    }
2556    /// Identifies the authorization scope(s) for the method you are building.
2557    ///
2558    /// See [`Self::add_scope()`] for details.
2559    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectIndexDeleteCall<'a, C>
2560    where
2561        I: IntoIterator<Item = St>,
2562        St: AsRef<str>,
2563    {
2564        self._scopes
2565            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2566        self
2567    }
2568
2569    /// Removes all scopes, and no default scope will be used either.
2570    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2571    /// for details).
2572    pub fn clear_scopes(mut self) -> ProjectIndexDeleteCall<'a, C> {
2573        self._scopes.clear();
2574        self
2575    }
2576}
2577
2578/// Gets an index.
2579///
2580/// A builder for the *indexes.get* method supported by a *project* resource.
2581/// It is not used directly, but through a [`ProjectMethods`] instance.
2582///
2583/// # Example
2584///
2585/// Instantiate a resource method builder
2586///
2587/// ```test_harness,no_run
2588/// # extern crate hyper;
2589/// # extern crate hyper_rustls;
2590/// # extern crate google_datastore1 as datastore1;
2591/// # async fn dox() {
2592/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2593///
2594/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2595/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2596/// #     secret,
2597/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2598/// # ).build().await.unwrap();
2599///
2600/// # let client = hyper_util::client::legacy::Client::builder(
2601/// #     hyper_util::rt::TokioExecutor::new()
2602/// # )
2603/// # .build(
2604/// #     hyper_rustls::HttpsConnectorBuilder::new()
2605/// #         .with_native_roots()
2606/// #         .unwrap()
2607/// #         .https_or_http()
2608/// #         .enable_http1()
2609/// #         .build()
2610/// # );
2611/// # let mut hub = Datastore::new(client, auth);
2612/// // You can configure optional parameters by calling the respective setters at will, and
2613/// // execute the final call using `doit()`.
2614/// // Values shown here are possibly random and not representative !
2615/// let result = hub.projects().indexes_get("projectId", "indexId")
2616///              .doit().await;
2617/// # }
2618/// ```
2619pub struct ProjectIndexGetCall<'a, C>
2620where
2621    C: 'a,
2622{
2623    hub: &'a Datastore<C>,
2624    _project_id: String,
2625    _index_id: String,
2626    _delegate: Option<&'a mut dyn common::Delegate>,
2627    _additional_params: HashMap<String, String>,
2628    _scopes: BTreeSet<String>,
2629}
2630
2631impl<'a, C> common::CallBuilder for ProjectIndexGetCall<'a, C> {}
2632
2633impl<'a, C> ProjectIndexGetCall<'a, C>
2634where
2635    C: common::Connector,
2636{
2637    /// Perform the operation you have build so far.
2638    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleDatastoreAdminV1Index)> {
2639        use std::borrow::Cow;
2640        use std::io::{Read, Seek};
2641
2642        use common::{url::Params, ToParts};
2643        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2644
2645        let mut dd = common::DefaultDelegate;
2646        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2647        dlg.begin(common::MethodInfo {
2648            id: "datastore.projects.indexes.get",
2649            http_method: hyper::Method::GET,
2650        });
2651
2652        for &field in ["alt", "projectId", "indexId"].iter() {
2653            if self._additional_params.contains_key(field) {
2654                dlg.finished(false);
2655                return Err(common::Error::FieldClash(field));
2656            }
2657        }
2658
2659        let mut params = Params::with_capacity(4 + self._additional_params.len());
2660        params.push("projectId", self._project_id);
2661        params.push("indexId", self._index_id);
2662
2663        params.extend(self._additional_params.iter());
2664
2665        params.push("alt", "json");
2666        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/indexes/{indexId}";
2667        if self._scopes.is_empty() {
2668            self._scopes
2669                .insert(Scope::CloudPlatform.as_ref().to_string());
2670        }
2671
2672        #[allow(clippy::single_element_loop)]
2673        for &(find_this, param_name) in
2674            [("{projectId}", "projectId"), ("{indexId}", "indexId")].iter()
2675        {
2676            url = params.uri_replacement(url, param_name, find_this, false);
2677        }
2678        {
2679            let to_remove = ["indexId", "projectId"];
2680            params.remove_params(&to_remove);
2681        }
2682
2683        let url = params.parse_with_url(&url);
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            let mut req_result = {
2702                let client = &self.hub.client;
2703                dlg.pre_request();
2704                let mut req_builder = hyper::Request::builder()
2705                    .method(hyper::Method::GET)
2706                    .uri(url.as_str())
2707                    .header(USER_AGENT, self.hub._user_agent.clone());
2708
2709                if let Some(token) = token.as_ref() {
2710                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2711                }
2712
2713                let request = req_builder
2714                    .header(CONTENT_LENGTH, 0_u64)
2715                    .body(common::to_body::<String>(None));
2716
2717                client.request(request.unwrap()).await
2718            };
2719
2720            match req_result {
2721                Err(err) => {
2722                    if let common::Retry::After(d) = dlg.http_error(&err) {
2723                        sleep(d).await;
2724                        continue;
2725                    }
2726                    dlg.finished(false);
2727                    return Err(common::Error::HttpError(err));
2728                }
2729                Ok(res) => {
2730                    let (mut parts, body) = res.into_parts();
2731                    let mut body = common::Body::new(body);
2732                    if !parts.status.is_success() {
2733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2734                        let error = serde_json::from_str(&common::to_string(&bytes));
2735                        let response = common::to_response(parts, bytes.into());
2736
2737                        if let common::Retry::After(d) =
2738                            dlg.http_failure(&response, error.as_ref().ok())
2739                        {
2740                            sleep(d).await;
2741                            continue;
2742                        }
2743
2744                        dlg.finished(false);
2745
2746                        return Err(match error {
2747                            Ok(value) => common::Error::BadRequest(value),
2748                            _ => common::Error::Failure(response),
2749                        });
2750                    }
2751                    let response = {
2752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2753                        let encoded = common::to_string(&bytes);
2754                        match serde_json::from_str(&encoded) {
2755                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2756                            Err(error) => {
2757                                dlg.response_json_decode_error(&encoded, &error);
2758                                return Err(common::Error::JsonDecodeError(
2759                                    encoded.to_string(),
2760                                    error,
2761                                ));
2762                            }
2763                        }
2764                    };
2765
2766                    dlg.finished(true);
2767                    return Ok(response);
2768                }
2769            }
2770        }
2771    }
2772
2773    /// Project ID against which to make the request.
2774    ///
2775    /// Sets the *project id* path property to the given value.
2776    ///
2777    /// Even though the property as already been set when instantiating this call,
2778    /// we provide this method for API completeness.
2779    pub fn project_id(mut self, new_value: &str) -> ProjectIndexGetCall<'a, C> {
2780        self._project_id = new_value.to_string();
2781        self
2782    }
2783    /// The resource ID of the index to get.
2784    ///
2785    /// Sets the *index id* path property to the given value.
2786    ///
2787    /// Even though the property as already been set when instantiating this call,
2788    /// we provide this method for API completeness.
2789    pub fn index_id(mut self, new_value: &str) -> ProjectIndexGetCall<'a, C> {
2790        self._index_id = new_value.to_string();
2791        self
2792    }
2793    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2794    /// while executing the actual API request.
2795    ///
2796    /// ````text
2797    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2798    /// ````
2799    ///
2800    /// Sets the *delegate* property to the given value.
2801    pub fn delegate(
2802        mut self,
2803        new_value: &'a mut dyn common::Delegate,
2804    ) -> ProjectIndexGetCall<'a, C> {
2805        self._delegate = Some(new_value);
2806        self
2807    }
2808
2809    /// Set any additional parameter of the query string used in the request.
2810    /// It should be used to set parameters which are not yet available through their own
2811    /// setters.
2812    ///
2813    /// Please note that this method must not be used to set any of the known parameters
2814    /// which have their own setter method. If done anyway, the request will fail.
2815    ///
2816    /// # Additional Parameters
2817    ///
2818    /// * *$.xgafv* (query-string) - V1 error format.
2819    /// * *access_token* (query-string) - OAuth access token.
2820    /// * *alt* (query-string) - Data format for response.
2821    /// * *callback* (query-string) - JSONP
2822    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2823    /// * *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.
2824    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2825    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2826    /// * *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.
2827    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2828    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2829    pub fn param<T>(mut self, name: T, value: T) -> ProjectIndexGetCall<'a, C>
2830    where
2831        T: AsRef<str>,
2832    {
2833        self._additional_params
2834            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2835        self
2836    }
2837
2838    /// Identifies the authorization scope for the method you are building.
2839    ///
2840    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2841    /// [`Scope::CloudPlatform`].
2842    ///
2843    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2844    /// tokens for more than one scope.
2845    ///
2846    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2847    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2848    /// sufficient, a read-write scope will do as well.
2849    pub fn add_scope<St>(mut self, scope: St) -> ProjectIndexGetCall<'a, C>
2850    where
2851        St: AsRef<str>,
2852    {
2853        self._scopes.insert(String::from(scope.as_ref()));
2854        self
2855    }
2856    /// Identifies the authorization scope(s) for the method you are building.
2857    ///
2858    /// See [`Self::add_scope()`] for details.
2859    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectIndexGetCall<'a, C>
2860    where
2861        I: IntoIterator<Item = St>,
2862        St: AsRef<str>,
2863    {
2864        self._scopes
2865            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2866        self
2867    }
2868
2869    /// Removes all scopes, and no default scope will be used either.
2870    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2871    /// for details).
2872    pub fn clear_scopes(mut self) -> ProjectIndexGetCall<'a, C> {
2873        self._scopes.clear();
2874        self
2875    }
2876}
2877
2878/// Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.
2879///
2880/// A builder for the *indexes.list* method supported by a *project* resource.
2881/// It is not used directly, but through a [`ProjectMethods`] instance.
2882///
2883/// # Example
2884///
2885/// Instantiate a resource method builder
2886///
2887/// ```test_harness,no_run
2888/// # extern crate hyper;
2889/// # extern crate hyper_rustls;
2890/// # extern crate google_datastore1 as datastore1;
2891/// # async fn dox() {
2892/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2893///
2894/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2895/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2896/// #     secret,
2897/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2898/// # ).build().await.unwrap();
2899///
2900/// # let client = hyper_util::client::legacy::Client::builder(
2901/// #     hyper_util::rt::TokioExecutor::new()
2902/// # )
2903/// # .build(
2904/// #     hyper_rustls::HttpsConnectorBuilder::new()
2905/// #         .with_native_roots()
2906/// #         .unwrap()
2907/// #         .https_or_http()
2908/// #         .enable_http1()
2909/// #         .build()
2910/// # );
2911/// # let mut hub = Datastore::new(client, auth);
2912/// // You can configure optional parameters by calling the respective setters at will, and
2913/// // execute the final call using `doit()`.
2914/// // Values shown here are possibly random and not representative !
2915/// let result = hub.projects().indexes_list("projectId")
2916///              .page_token("takimata")
2917///              .page_size(-52)
2918///              .filter("duo")
2919///              .doit().await;
2920/// # }
2921/// ```
2922pub struct ProjectIndexListCall<'a, C>
2923where
2924    C: 'a,
2925{
2926    hub: &'a Datastore<C>,
2927    _project_id: String,
2928    _page_token: Option<String>,
2929    _page_size: Option<i32>,
2930    _filter: Option<String>,
2931    _delegate: Option<&'a mut dyn common::Delegate>,
2932    _additional_params: HashMap<String, String>,
2933    _scopes: BTreeSet<String>,
2934}
2935
2936impl<'a, C> common::CallBuilder for ProjectIndexListCall<'a, C> {}
2937
2938impl<'a, C> ProjectIndexListCall<'a, C>
2939where
2940    C: common::Connector,
2941{
2942    /// Perform the operation you have build so far.
2943    pub async fn doit(
2944        mut self,
2945    ) -> common::Result<(common::Response, GoogleDatastoreAdminV1ListIndexesResponse)> {
2946        use std::borrow::Cow;
2947        use std::io::{Read, Seek};
2948
2949        use common::{url::Params, ToParts};
2950        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2951
2952        let mut dd = common::DefaultDelegate;
2953        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2954        dlg.begin(common::MethodInfo {
2955            id: "datastore.projects.indexes.list",
2956            http_method: hyper::Method::GET,
2957        });
2958
2959        for &field in ["alt", "projectId", "pageToken", "pageSize", "filter"].iter() {
2960            if self._additional_params.contains_key(field) {
2961                dlg.finished(false);
2962                return Err(common::Error::FieldClash(field));
2963            }
2964        }
2965
2966        let mut params = Params::with_capacity(6 + self._additional_params.len());
2967        params.push("projectId", self._project_id);
2968        if let Some(value) = self._page_token.as_ref() {
2969            params.push("pageToken", value);
2970        }
2971        if let Some(value) = self._page_size.as_ref() {
2972            params.push("pageSize", value.to_string());
2973        }
2974        if let Some(value) = self._filter.as_ref() {
2975            params.push("filter", value);
2976        }
2977
2978        params.extend(self._additional_params.iter());
2979
2980        params.push("alt", "json");
2981        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/indexes";
2982        if self._scopes.is_empty() {
2983            self._scopes
2984                .insert(Scope::CloudPlatform.as_ref().to_string());
2985        }
2986
2987        #[allow(clippy::single_element_loop)]
2988        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
2989            url = params.uri_replacement(url, param_name, find_this, false);
2990        }
2991        {
2992            let to_remove = ["projectId"];
2993            params.remove_params(&to_remove);
2994        }
2995
2996        let url = params.parse_with_url(&url);
2997
2998        loop {
2999            let token = match self
3000                .hub
3001                .auth
3002                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3003                .await
3004            {
3005                Ok(token) => token,
3006                Err(e) => match dlg.token(e) {
3007                    Ok(token) => token,
3008                    Err(e) => {
3009                        dlg.finished(false);
3010                        return Err(common::Error::MissingToken(e));
3011                    }
3012                },
3013            };
3014            let mut req_result = {
3015                let client = &self.hub.client;
3016                dlg.pre_request();
3017                let mut req_builder = hyper::Request::builder()
3018                    .method(hyper::Method::GET)
3019                    .uri(url.as_str())
3020                    .header(USER_AGENT, self.hub._user_agent.clone());
3021
3022                if let Some(token) = token.as_ref() {
3023                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3024                }
3025
3026                let request = req_builder
3027                    .header(CONTENT_LENGTH, 0_u64)
3028                    .body(common::to_body::<String>(None));
3029
3030                client.request(request.unwrap()).await
3031            };
3032
3033            match req_result {
3034                Err(err) => {
3035                    if let common::Retry::After(d) = dlg.http_error(&err) {
3036                        sleep(d).await;
3037                        continue;
3038                    }
3039                    dlg.finished(false);
3040                    return Err(common::Error::HttpError(err));
3041                }
3042                Ok(res) => {
3043                    let (mut parts, body) = res.into_parts();
3044                    let mut body = common::Body::new(body);
3045                    if !parts.status.is_success() {
3046                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3047                        let error = serde_json::from_str(&common::to_string(&bytes));
3048                        let response = common::to_response(parts, bytes.into());
3049
3050                        if let common::Retry::After(d) =
3051                            dlg.http_failure(&response, error.as_ref().ok())
3052                        {
3053                            sleep(d).await;
3054                            continue;
3055                        }
3056
3057                        dlg.finished(false);
3058
3059                        return Err(match error {
3060                            Ok(value) => common::Error::BadRequest(value),
3061                            _ => common::Error::Failure(response),
3062                        });
3063                    }
3064                    let response = {
3065                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3066                        let encoded = common::to_string(&bytes);
3067                        match serde_json::from_str(&encoded) {
3068                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3069                            Err(error) => {
3070                                dlg.response_json_decode_error(&encoded, &error);
3071                                return Err(common::Error::JsonDecodeError(
3072                                    encoded.to_string(),
3073                                    error,
3074                                ));
3075                            }
3076                        }
3077                    };
3078
3079                    dlg.finished(true);
3080                    return Ok(response);
3081                }
3082            }
3083        }
3084    }
3085
3086    /// Project ID against which to make the request.
3087    ///
3088    /// Sets the *project id* path property to the given value.
3089    ///
3090    /// Even though the property as already been set when instantiating this call,
3091    /// we provide this method for API completeness.
3092    pub fn project_id(mut self, new_value: &str) -> ProjectIndexListCall<'a, C> {
3093        self._project_id = new_value.to_string();
3094        self
3095    }
3096    /// The next_page_token value returned from a previous List request, if any.
3097    ///
3098    /// Sets the *page token* query property to the given value.
3099    pub fn page_token(mut self, new_value: &str) -> ProjectIndexListCall<'a, C> {
3100        self._page_token = Some(new_value.to_string());
3101        self
3102    }
3103    /// The maximum number of items to return. If zero, then all results will be returned.
3104    ///
3105    /// Sets the *page size* query property to the given value.
3106    pub fn page_size(mut self, new_value: i32) -> ProjectIndexListCall<'a, C> {
3107        self._page_size = Some(new_value);
3108        self
3109    }
3110    ///
3111    /// Sets the *filter* query property to the given value.
3112    pub fn filter(mut self, new_value: &str) -> ProjectIndexListCall<'a, C> {
3113        self._filter = Some(new_value.to_string());
3114        self
3115    }
3116    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3117    /// while executing the actual API request.
3118    ///
3119    /// ````text
3120    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3121    /// ````
3122    ///
3123    /// Sets the *delegate* property to the given value.
3124    pub fn delegate(
3125        mut self,
3126        new_value: &'a mut dyn common::Delegate,
3127    ) -> ProjectIndexListCall<'a, C> {
3128        self._delegate = Some(new_value);
3129        self
3130    }
3131
3132    /// Set any additional parameter of the query string used in the request.
3133    /// It should be used to set parameters which are not yet available through their own
3134    /// setters.
3135    ///
3136    /// Please note that this method must not be used to set any of the known parameters
3137    /// which have their own setter method. If done anyway, the request will fail.
3138    ///
3139    /// # Additional Parameters
3140    ///
3141    /// * *$.xgafv* (query-string) - V1 error format.
3142    /// * *access_token* (query-string) - OAuth access token.
3143    /// * *alt* (query-string) - Data format for response.
3144    /// * *callback* (query-string) - JSONP
3145    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3146    /// * *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.
3147    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3148    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3149    /// * *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.
3150    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3151    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3152    pub fn param<T>(mut self, name: T, value: T) -> ProjectIndexListCall<'a, C>
3153    where
3154        T: AsRef<str>,
3155    {
3156        self._additional_params
3157            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3158        self
3159    }
3160
3161    /// Identifies the authorization scope for the method you are building.
3162    ///
3163    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3164    /// [`Scope::CloudPlatform`].
3165    ///
3166    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3167    /// tokens for more than one scope.
3168    ///
3169    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3170    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3171    /// sufficient, a read-write scope will do as well.
3172    pub fn add_scope<St>(mut self, scope: St) -> ProjectIndexListCall<'a, C>
3173    where
3174        St: AsRef<str>,
3175    {
3176        self._scopes.insert(String::from(scope.as_ref()));
3177        self
3178    }
3179    /// Identifies the authorization scope(s) for the method you are building.
3180    ///
3181    /// See [`Self::add_scope()`] for details.
3182    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectIndexListCall<'a, C>
3183    where
3184        I: IntoIterator<Item = St>,
3185        St: AsRef<str>,
3186    {
3187        self._scopes
3188            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3189        self
3190    }
3191
3192    /// Removes all scopes, and no default scope will be used either.
3193    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3194    /// for details).
3195    pub fn clear_scopes(mut self) -> ProjectIndexListCall<'a, C> {
3196        self._scopes.clear();
3197        self
3198    }
3199}
3200
3201/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
3202///
3203/// A builder for the *operations.cancel* method supported by a *project* resource.
3204/// It is not used directly, but through a [`ProjectMethods`] instance.
3205///
3206/// # Example
3207///
3208/// Instantiate a resource method builder
3209///
3210/// ```test_harness,no_run
3211/// # extern crate hyper;
3212/// # extern crate hyper_rustls;
3213/// # extern crate google_datastore1 as datastore1;
3214/// # async fn dox() {
3215/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3216///
3217/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3218/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3219/// #     secret,
3220/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3221/// # ).build().await.unwrap();
3222///
3223/// # let client = hyper_util::client::legacy::Client::builder(
3224/// #     hyper_util::rt::TokioExecutor::new()
3225/// # )
3226/// # .build(
3227/// #     hyper_rustls::HttpsConnectorBuilder::new()
3228/// #         .with_native_roots()
3229/// #         .unwrap()
3230/// #         .https_or_http()
3231/// #         .enable_http1()
3232/// #         .build()
3233/// # );
3234/// # let mut hub = Datastore::new(client, auth);
3235/// // You can configure optional parameters by calling the respective setters at will, and
3236/// // execute the final call using `doit()`.
3237/// // Values shown here are possibly random and not representative !
3238/// let result = hub.projects().operations_cancel("name")
3239///              .doit().await;
3240/// # }
3241/// ```
3242pub struct ProjectOperationCancelCall<'a, C>
3243where
3244    C: 'a,
3245{
3246    hub: &'a Datastore<C>,
3247    _name: String,
3248    _delegate: Option<&'a mut dyn common::Delegate>,
3249    _additional_params: HashMap<String, String>,
3250    _scopes: BTreeSet<String>,
3251}
3252
3253impl<'a, C> common::CallBuilder for ProjectOperationCancelCall<'a, C> {}
3254
3255impl<'a, C> ProjectOperationCancelCall<'a, C>
3256where
3257    C: common::Connector,
3258{
3259    /// Perform the operation you have build so far.
3260    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3261        use std::borrow::Cow;
3262        use std::io::{Read, Seek};
3263
3264        use common::{url::Params, ToParts};
3265        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3266
3267        let mut dd = common::DefaultDelegate;
3268        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3269        dlg.begin(common::MethodInfo {
3270            id: "datastore.projects.operations.cancel",
3271            http_method: hyper::Method::POST,
3272        });
3273
3274        for &field in ["alt", "name"].iter() {
3275            if self._additional_params.contains_key(field) {
3276                dlg.finished(false);
3277                return Err(common::Error::FieldClash(field));
3278            }
3279        }
3280
3281        let mut params = Params::with_capacity(3 + self._additional_params.len());
3282        params.push("name", self._name);
3283
3284        params.extend(self._additional_params.iter());
3285
3286        params.push("alt", "json");
3287        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
3288        if self._scopes.is_empty() {
3289            self._scopes
3290                .insert(Scope::CloudPlatform.as_ref().to_string());
3291        }
3292
3293        #[allow(clippy::single_element_loop)]
3294        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3295            url = params.uri_replacement(url, param_name, find_this, true);
3296        }
3297        {
3298            let to_remove = ["name"];
3299            params.remove_params(&to_remove);
3300        }
3301
3302        let url = params.parse_with_url(&url);
3303
3304        loop {
3305            let token = match self
3306                .hub
3307                .auth
3308                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3309                .await
3310            {
3311                Ok(token) => token,
3312                Err(e) => match dlg.token(e) {
3313                    Ok(token) => token,
3314                    Err(e) => {
3315                        dlg.finished(false);
3316                        return Err(common::Error::MissingToken(e));
3317                    }
3318                },
3319            };
3320            let mut req_result = {
3321                let client = &self.hub.client;
3322                dlg.pre_request();
3323                let mut req_builder = hyper::Request::builder()
3324                    .method(hyper::Method::POST)
3325                    .uri(url.as_str())
3326                    .header(USER_AGENT, self.hub._user_agent.clone());
3327
3328                if let Some(token) = token.as_ref() {
3329                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3330                }
3331
3332                let request = req_builder
3333                    .header(CONTENT_LENGTH, 0_u64)
3334                    .body(common::to_body::<String>(None));
3335
3336                client.request(request.unwrap()).await
3337            };
3338
3339            match req_result {
3340                Err(err) => {
3341                    if let common::Retry::After(d) = dlg.http_error(&err) {
3342                        sleep(d).await;
3343                        continue;
3344                    }
3345                    dlg.finished(false);
3346                    return Err(common::Error::HttpError(err));
3347                }
3348                Ok(res) => {
3349                    let (mut parts, body) = res.into_parts();
3350                    let mut body = common::Body::new(body);
3351                    if !parts.status.is_success() {
3352                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3353                        let error = serde_json::from_str(&common::to_string(&bytes));
3354                        let response = common::to_response(parts, bytes.into());
3355
3356                        if let common::Retry::After(d) =
3357                            dlg.http_failure(&response, error.as_ref().ok())
3358                        {
3359                            sleep(d).await;
3360                            continue;
3361                        }
3362
3363                        dlg.finished(false);
3364
3365                        return Err(match error {
3366                            Ok(value) => common::Error::BadRequest(value),
3367                            _ => common::Error::Failure(response),
3368                        });
3369                    }
3370                    let response = {
3371                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3372                        let encoded = common::to_string(&bytes);
3373                        match serde_json::from_str(&encoded) {
3374                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3375                            Err(error) => {
3376                                dlg.response_json_decode_error(&encoded, &error);
3377                                return Err(common::Error::JsonDecodeError(
3378                                    encoded.to_string(),
3379                                    error,
3380                                ));
3381                            }
3382                        }
3383                    };
3384
3385                    dlg.finished(true);
3386                    return Ok(response);
3387                }
3388            }
3389        }
3390    }
3391
3392    /// The name of the operation resource to be cancelled.
3393    ///
3394    /// Sets the *name* path property to the given value.
3395    ///
3396    /// Even though the property as already been set when instantiating this call,
3397    /// we provide this method for API completeness.
3398    pub fn name(mut self, new_value: &str) -> ProjectOperationCancelCall<'a, C> {
3399        self._name = new_value.to_string();
3400        self
3401    }
3402    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3403    /// while executing the actual API request.
3404    ///
3405    /// ````text
3406    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3407    /// ````
3408    ///
3409    /// Sets the *delegate* property to the given value.
3410    pub fn delegate(
3411        mut self,
3412        new_value: &'a mut dyn common::Delegate,
3413    ) -> ProjectOperationCancelCall<'a, C> {
3414        self._delegate = Some(new_value);
3415        self
3416    }
3417
3418    /// Set any additional parameter of the query string used in the request.
3419    /// It should be used to set parameters which are not yet available through their own
3420    /// setters.
3421    ///
3422    /// Please note that this method must not be used to set any of the known parameters
3423    /// which have their own setter method. If done anyway, the request will fail.
3424    ///
3425    /// # Additional Parameters
3426    ///
3427    /// * *$.xgafv* (query-string) - V1 error format.
3428    /// * *access_token* (query-string) - OAuth access token.
3429    /// * *alt* (query-string) - Data format for response.
3430    /// * *callback* (query-string) - JSONP
3431    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3432    /// * *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.
3433    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3434    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3435    /// * *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.
3436    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3437    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3438    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationCancelCall<'a, C>
3439    where
3440        T: AsRef<str>,
3441    {
3442        self._additional_params
3443            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3444        self
3445    }
3446
3447    /// Identifies the authorization scope for the method you are building.
3448    ///
3449    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3450    /// [`Scope::CloudPlatform`].
3451    ///
3452    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3453    /// tokens for more than one scope.
3454    ///
3455    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3456    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3457    /// sufficient, a read-write scope will do as well.
3458    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationCancelCall<'a, C>
3459    where
3460        St: AsRef<str>,
3461    {
3462        self._scopes.insert(String::from(scope.as_ref()));
3463        self
3464    }
3465    /// Identifies the authorization scope(s) for the method you are building.
3466    ///
3467    /// See [`Self::add_scope()`] for details.
3468    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationCancelCall<'a, C>
3469    where
3470        I: IntoIterator<Item = St>,
3471        St: AsRef<str>,
3472    {
3473        self._scopes
3474            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3475        self
3476    }
3477
3478    /// Removes all scopes, and no default scope will be used either.
3479    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3480    /// for details).
3481    pub fn clear_scopes(mut self) -> ProjectOperationCancelCall<'a, C> {
3482        self._scopes.clear();
3483        self
3484    }
3485}
3486
3487/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
3488///
3489/// A builder for the *operations.delete* method supported by a *project* resource.
3490/// It is not used directly, but through a [`ProjectMethods`] instance.
3491///
3492/// # Example
3493///
3494/// Instantiate a resource method builder
3495///
3496/// ```test_harness,no_run
3497/// # extern crate hyper;
3498/// # extern crate hyper_rustls;
3499/// # extern crate google_datastore1 as datastore1;
3500/// # async fn dox() {
3501/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3502///
3503/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3504/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3505/// #     secret,
3506/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3507/// # ).build().await.unwrap();
3508///
3509/// # let client = hyper_util::client::legacy::Client::builder(
3510/// #     hyper_util::rt::TokioExecutor::new()
3511/// # )
3512/// # .build(
3513/// #     hyper_rustls::HttpsConnectorBuilder::new()
3514/// #         .with_native_roots()
3515/// #         .unwrap()
3516/// #         .https_or_http()
3517/// #         .enable_http1()
3518/// #         .build()
3519/// # );
3520/// # let mut hub = Datastore::new(client, auth);
3521/// // You can configure optional parameters by calling the respective setters at will, and
3522/// // execute the final call using `doit()`.
3523/// // Values shown here are possibly random and not representative !
3524/// let result = hub.projects().operations_delete("name")
3525///              .doit().await;
3526/// # }
3527/// ```
3528pub struct ProjectOperationDeleteCall<'a, C>
3529where
3530    C: 'a,
3531{
3532    hub: &'a Datastore<C>,
3533    _name: String,
3534    _delegate: Option<&'a mut dyn common::Delegate>,
3535    _additional_params: HashMap<String, String>,
3536    _scopes: BTreeSet<String>,
3537}
3538
3539impl<'a, C> common::CallBuilder for ProjectOperationDeleteCall<'a, C> {}
3540
3541impl<'a, C> ProjectOperationDeleteCall<'a, C>
3542where
3543    C: common::Connector,
3544{
3545    /// Perform the operation you have build so far.
3546    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3547        use std::borrow::Cow;
3548        use std::io::{Read, Seek};
3549
3550        use common::{url::Params, ToParts};
3551        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3552
3553        let mut dd = common::DefaultDelegate;
3554        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3555        dlg.begin(common::MethodInfo {
3556            id: "datastore.projects.operations.delete",
3557            http_method: hyper::Method::DELETE,
3558        });
3559
3560        for &field in ["alt", "name"].iter() {
3561            if self._additional_params.contains_key(field) {
3562                dlg.finished(false);
3563                return Err(common::Error::FieldClash(field));
3564            }
3565        }
3566
3567        let mut params = Params::with_capacity(3 + self._additional_params.len());
3568        params.push("name", self._name);
3569
3570        params.extend(self._additional_params.iter());
3571
3572        params.push("alt", "json");
3573        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3574        if self._scopes.is_empty() {
3575            self._scopes
3576                .insert(Scope::CloudPlatform.as_ref().to_string());
3577        }
3578
3579        #[allow(clippy::single_element_loop)]
3580        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3581            url = params.uri_replacement(url, param_name, find_this, true);
3582        }
3583        {
3584            let to_remove = ["name"];
3585            params.remove_params(&to_remove);
3586        }
3587
3588        let url = params.parse_with_url(&url);
3589
3590        loop {
3591            let token = match self
3592                .hub
3593                .auth
3594                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3595                .await
3596            {
3597                Ok(token) => token,
3598                Err(e) => match dlg.token(e) {
3599                    Ok(token) => token,
3600                    Err(e) => {
3601                        dlg.finished(false);
3602                        return Err(common::Error::MissingToken(e));
3603                    }
3604                },
3605            };
3606            let mut req_result = {
3607                let client = &self.hub.client;
3608                dlg.pre_request();
3609                let mut req_builder = hyper::Request::builder()
3610                    .method(hyper::Method::DELETE)
3611                    .uri(url.as_str())
3612                    .header(USER_AGENT, self.hub._user_agent.clone());
3613
3614                if let Some(token) = token.as_ref() {
3615                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3616                }
3617
3618                let request = req_builder
3619                    .header(CONTENT_LENGTH, 0_u64)
3620                    .body(common::to_body::<String>(None));
3621
3622                client.request(request.unwrap()).await
3623            };
3624
3625            match req_result {
3626                Err(err) => {
3627                    if let common::Retry::After(d) = dlg.http_error(&err) {
3628                        sleep(d).await;
3629                        continue;
3630                    }
3631                    dlg.finished(false);
3632                    return Err(common::Error::HttpError(err));
3633                }
3634                Ok(res) => {
3635                    let (mut parts, body) = res.into_parts();
3636                    let mut body = common::Body::new(body);
3637                    if !parts.status.is_success() {
3638                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3639                        let error = serde_json::from_str(&common::to_string(&bytes));
3640                        let response = common::to_response(parts, bytes.into());
3641
3642                        if let common::Retry::After(d) =
3643                            dlg.http_failure(&response, error.as_ref().ok())
3644                        {
3645                            sleep(d).await;
3646                            continue;
3647                        }
3648
3649                        dlg.finished(false);
3650
3651                        return Err(match error {
3652                            Ok(value) => common::Error::BadRequest(value),
3653                            _ => common::Error::Failure(response),
3654                        });
3655                    }
3656                    let response = {
3657                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3658                        let encoded = common::to_string(&bytes);
3659                        match serde_json::from_str(&encoded) {
3660                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3661                            Err(error) => {
3662                                dlg.response_json_decode_error(&encoded, &error);
3663                                return Err(common::Error::JsonDecodeError(
3664                                    encoded.to_string(),
3665                                    error,
3666                                ));
3667                            }
3668                        }
3669                    };
3670
3671                    dlg.finished(true);
3672                    return Ok(response);
3673                }
3674            }
3675        }
3676    }
3677
3678    /// The name of the operation resource to be deleted.
3679    ///
3680    /// Sets the *name* path property to the given value.
3681    ///
3682    /// Even though the property as already been set when instantiating this call,
3683    /// we provide this method for API completeness.
3684    pub fn name(mut self, new_value: &str) -> ProjectOperationDeleteCall<'a, C> {
3685        self._name = new_value.to_string();
3686        self
3687    }
3688    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3689    /// while executing the actual API request.
3690    ///
3691    /// ````text
3692    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3693    /// ````
3694    ///
3695    /// Sets the *delegate* property to the given value.
3696    pub fn delegate(
3697        mut self,
3698        new_value: &'a mut dyn common::Delegate,
3699    ) -> ProjectOperationDeleteCall<'a, C> {
3700        self._delegate = Some(new_value);
3701        self
3702    }
3703
3704    /// Set any additional parameter of the query string used in the request.
3705    /// It should be used to set parameters which are not yet available through their own
3706    /// setters.
3707    ///
3708    /// Please note that this method must not be used to set any of the known parameters
3709    /// which have their own setter method. If done anyway, the request will fail.
3710    ///
3711    /// # Additional Parameters
3712    ///
3713    /// * *$.xgafv* (query-string) - V1 error format.
3714    /// * *access_token* (query-string) - OAuth access token.
3715    /// * *alt* (query-string) - Data format for response.
3716    /// * *callback* (query-string) - JSONP
3717    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3718    /// * *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.
3719    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3720    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3721    /// * *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.
3722    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3723    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3724    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationDeleteCall<'a, C>
3725    where
3726        T: AsRef<str>,
3727    {
3728        self._additional_params
3729            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3730        self
3731    }
3732
3733    /// Identifies the authorization scope for the method you are building.
3734    ///
3735    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3736    /// [`Scope::CloudPlatform`].
3737    ///
3738    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3739    /// tokens for more than one scope.
3740    ///
3741    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3742    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3743    /// sufficient, a read-write scope will do as well.
3744    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationDeleteCall<'a, C>
3745    where
3746        St: AsRef<str>,
3747    {
3748        self._scopes.insert(String::from(scope.as_ref()));
3749        self
3750    }
3751    /// Identifies the authorization scope(s) for the method you are building.
3752    ///
3753    /// See [`Self::add_scope()`] for details.
3754    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationDeleteCall<'a, C>
3755    where
3756        I: IntoIterator<Item = St>,
3757        St: AsRef<str>,
3758    {
3759        self._scopes
3760            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3761        self
3762    }
3763
3764    /// Removes all scopes, and no default scope will be used either.
3765    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3766    /// for details).
3767    pub fn clear_scopes(mut self) -> ProjectOperationDeleteCall<'a, C> {
3768        self._scopes.clear();
3769        self
3770    }
3771}
3772
3773/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3774///
3775/// A builder for the *operations.get* method supported by a *project* resource.
3776/// It is not used directly, but through a [`ProjectMethods`] instance.
3777///
3778/// # Example
3779///
3780/// Instantiate a resource method builder
3781///
3782/// ```test_harness,no_run
3783/// # extern crate hyper;
3784/// # extern crate hyper_rustls;
3785/// # extern crate google_datastore1 as datastore1;
3786/// # async fn dox() {
3787/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3788///
3789/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3790/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3791/// #     secret,
3792/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3793/// # ).build().await.unwrap();
3794///
3795/// # let client = hyper_util::client::legacy::Client::builder(
3796/// #     hyper_util::rt::TokioExecutor::new()
3797/// # )
3798/// # .build(
3799/// #     hyper_rustls::HttpsConnectorBuilder::new()
3800/// #         .with_native_roots()
3801/// #         .unwrap()
3802/// #         .https_or_http()
3803/// #         .enable_http1()
3804/// #         .build()
3805/// # );
3806/// # let mut hub = Datastore::new(client, auth);
3807/// // You can configure optional parameters by calling the respective setters at will, and
3808/// // execute the final call using `doit()`.
3809/// // Values shown here are possibly random and not representative !
3810/// let result = hub.projects().operations_get("name")
3811///              .doit().await;
3812/// # }
3813/// ```
3814pub struct ProjectOperationGetCall<'a, C>
3815where
3816    C: 'a,
3817{
3818    hub: &'a Datastore<C>,
3819    _name: String,
3820    _delegate: Option<&'a mut dyn common::Delegate>,
3821    _additional_params: HashMap<String, String>,
3822    _scopes: BTreeSet<String>,
3823}
3824
3825impl<'a, C> common::CallBuilder for ProjectOperationGetCall<'a, C> {}
3826
3827impl<'a, C> ProjectOperationGetCall<'a, C>
3828where
3829    C: common::Connector,
3830{
3831    /// Perform the operation you have build so far.
3832    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
3833        use std::borrow::Cow;
3834        use std::io::{Read, Seek};
3835
3836        use common::{url::Params, ToParts};
3837        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3838
3839        let mut dd = common::DefaultDelegate;
3840        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3841        dlg.begin(common::MethodInfo {
3842            id: "datastore.projects.operations.get",
3843            http_method: hyper::Method::GET,
3844        });
3845
3846        for &field in ["alt", "name"].iter() {
3847            if self._additional_params.contains_key(field) {
3848                dlg.finished(false);
3849                return Err(common::Error::FieldClash(field));
3850            }
3851        }
3852
3853        let mut params = Params::with_capacity(3 + self._additional_params.len());
3854        params.push("name", self._name);
3855
3856        params.extend(self._additional_params.iter());
3857
3858        params.push("alt", "json");
3859        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3860        if self._scopes.is_empty() {
3861            self._scopes
3862                .insert(Scope::CloudPlatform.as_ref().to_string());
3863        }
3864
3865        #[allow(clippy::single_element_loop)]
3866        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3867            url = params.uri_replacement(url, param_name, find_this, true);
3868        }
3869        {
3870            let to_remove = ["name"];
3871            params.remove_params(&to_remove);
3872        }
3873
3874        let url = params.parse_with_url(&url);
3875
3876        loop {
3877            let token = match self
3878                .hub
3879                .auth
3880                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3881                .await
3882            {
3883                Ok(token) => token,
3884                Err(e) => match dlg.token(e) {
3885                    Ok(token) => token,
3886                    Err(e) => {
3887                        dlg.finished(false);
3888                        return Err(common::Error::MissingToken(e));
3889                    }
3890                },
3891            };
3892            let mut req_result = {
3893                let client = &self.hub.client;
3894                dlg.pre_request();
3895                let mut req_builder = hyper::Request::builder()
3896                    .method(hyper::Method::GET)
3897                    .uri(url.as_str())
3898                    .header(USER_AGENT, self.hub._user_agent.clone());
3899
3900                if let Some(token) = token.as_ref() {
3901                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3902                }
3903
3904                let request = req_builder
3905                    .header(CONTENT_LENGTH, 0_u64)
3906                    .body(common::to_body::<String>(None));
3907
3908                client.request(request.unwrap()).await
3909            };
3910
3911            match req_result {
3912                Err(err) => {
3913                    if let common::Retry::After(d) = dlg.http_error(&err) {
3914                        sleep(d).await;
3915                        continue;
3916                    }
3917                    dlg.finished(false);
3918                    return Err(common::Error::HttpError(err));
3919                }
3920                Ok(res) => {
3921                    let (mut parts, body) = res.into_parts();
3922                    let mut body = common::Body::new(body);
3923                    if !parts.status.is_success() {
3924                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3925                        let error = serde_json::from_str(&common::to_string(&bytes));
3926                        let response = common::to_response(parts, bytes.into());
3927
3928                        if let common::Retry::After(d) =
3929                            dlg.http_failure(&response, error.as_ref().ok())
3930                        {
3931                            sleep(d).await;
3932                            continue;
3933                        }
3934
3935                        dlg.finished(false);
3936
3937                        return Err(match error {
3938                            Ok(value) => common::Error::BadRequest(value),
3939                            _ => common::Error::Failure(response),
3940                        });
3941                    }
3942                    let response = {
3943                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3944                        let encoded = common::to_string(&bytes);
3945                        match serde_json::from_str(&encoded) {
3946                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3947                            Err(error) => {
3948                                dlg.response_json_decode_error(&encoded, &error);
3949                                return Err(common::Error::JsonDecodeError(
3950                                    encoded.to_string(),
3951                                    error,
3952                                ));
3953                            }
3954                        }
3955                    };
3956
3957                    dlg.finished(true);
3958                    return Ok(response);
3959                }
3960            }
3961        }
3962    }
3963
3964    /// The name of the operation resource.
3965    ///
3966    /// Sets the *name* path property to the given value.
3967    ///
3968    /// Even though the property as already been set when instantiating this call,
3969    /// we provide this method for API completeness.
3970    pub fn name(mut self, new_value: &str) -> ProjectOperationGetCall<'a, C> {
3971        self._name = new_value.to_string();
3972        self
3973    }
3974    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3975    /// while executing the actual API request.
3976    ///
3977    /// ````text
3978    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3979    /// ````
3980    ///
3981    /// Sets the *delegate* property to the given value.
3982    pub fn delegate(
3983        mut self,
3984        new_value: &'a mut dyn common::Delegate,
3985    ) -> ProjectOperationGetCall<'a, C> {
3986        self._delegate = Some(new_value);
3987        self
3988    }
3989
3990    /// Set any additional parameter of the query string used in the request.
3991    /// It should be used to set parameters which are not yet available through their own
3992    /// setters.
3993    ///
3994    /// Please note that this method must not be used to set any of the known parameters
3995    /// which have their own setter method. If done anyway, the request will fail.
3996    ///
3997    /// # Additional Parameters
3998    ///
3999    /// * *$.xgafv* (query-string) - V1 error format.
4000    /// * *access_token* (query-string) - OAuth access token.
4001    /// * *alt* (query-string) - Data format for response.
4002    /// * *callback* (query-string) - JSONP
4003    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4004    /// * *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.
4005    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4006    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4007    /// * *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.
4008    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4009    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4010    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationGetCall<'a, C>
4011    where
4012        T: AsRef<str>,
4013    {
4014        self._additional_params
4015            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4016        self
4017    }
4018
4019    /// Identifies the authorization scope for the method you are building.
4020    ///
4021    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4022    /// [`Scope::CloudPlatform`].
4023    ///
4024    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4025    /// tokens for more than one scope.
4026    ///
4027    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4028    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4029    /// sufficient, a read-write scope will do as well.
4030    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationGetCall<'a, C>
4031    where
4032        St: AsRef<str>,
4033    {
4034        self._scopes.insert(String::from(scope.as_ref()));
4035        self
4036    }
4037    /// Identifies the authorization scope(s) for the method you are building.
4038    ///
4039    /// See [`Self::add_scope()`] for details.
4040    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationGetCall<'a, C>
4041    where
4042        I: IntoIterator<Item = St>,
4043        St: AsRef<str>,
4044    {
4045        self._scopes
4046            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4047        self
4048    }
4049
4050    /// Removes all scopes, and no default scope will be used either.
4051    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4052    /// for details).
4053    pub fn clear_scopes(mut self) -> ProjectOperationGetCall<'a, C> {
4054        self._scopes.clear();
4055        self
4056    }
4057}
4058
4059/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4060///
4061/// A builder for the *operations.list* method supported by a *project* resource.
4062/// It is not used directly, but through a [`ProjectMethods`] instance.
4063///
4064/// # Example
4065///
4066/// Instantiate a resource method builder
4067///
4068/// ```test_harness,no_run
4069/// # extern crate hyper;
4070/// # extern crate hyper_rustls;
4071/// # extern crate google_datastore1 as datastore1;
4072/// # async fn dox() {
4073/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4074///
4075/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4076/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4077/// #     secret,
4078/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4079/// # ).build().await.unwrap();
4080///
4081/// # let client = hyper_util::client::legacy::Client::builder(
4082/// #     hyper_util::rt::TokioExecutor::new()
4083/// # )
4084/// # .build(
4085/// #     hyper_rustls::HttpsConnectorBuilder::new()
4086/// #         .with_native_roots()
4087/// #         .unwrap()
4088/// #         .https_or_http()
4089/// #         .enable_http1()
4090/// #         .build()
4091/// # );
4092/// # let mut hub = Datastore::new(client, auth);
4093/// // You can configure optional parameters by calling the respective setters at will, and
4094/// // execute the final call using `doit()`.
4095/// // Values shown here are possibly random and not representative !
4096/// let result = hub.projects().operations_list("name")
4097///              .page_token("eos")
4098///              .page_size(-4)
4099///              .filter("ea")
4100///              .doit().await;
4101/// # }
4102/// ```
4103pub struct ProjectOperationListCall<'a, C>
4104where
4105    C: 'a,
4106{
4107    hub: &'a Datastore<C>,
4108    _name: String,
4109    _page_token: Option<String>,
4110    _page_size: Option<i32>,
4111    _filter: Option<String>,
4112    _delegate: Option<&'a mut dyn common::Delegate>,
4113    _additional_params: HashMap<String, String>,
4114    _scopes: BTreeSet<String>,
4115}
4116
4117impl<'a, C> common::CallBuilder for ProjectOperationListCall<'a, C> {}
4118
4119impl<'a, C> ProjectOperationListCall<'a, C>
4120where
4121    C: common::Connector,
4122{
4123    /// Perform the operation you have build so far.
4124    pub async fn doit(
4125        mut self,
4126    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
4127        use std::borrow::Cow;
4128        use std::io::{Read, Seek};
4129
4130        use common::{url::Params, ToParts};
4131        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4132
4133        let mut dd = common::DefaultDelegate;
4134        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4135        dlg.begin(common::MethodInfo {
4136            id: "datastore.projects.operations.list",
4137            http_method: hyper::Method::GET,
4138        });
4139
4140        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
4141            if self._additional_params.contains_key(field) {
4142                dlg.finished(false);
4143                return Err(common::Error::FieldClash(field));
4144            }
4145        }
4146
4147        let mut params = Params::with_capacity(6 + self._additional_params.len());
4148        params.push("name", self._name);
4149        if let Some(value) = self._page_token.as_ref() {
4150            params.push("pageToken", value);
4151        }
4152        if let Some(value) = self._page_size.as_ref() {
4153            params.push("pageSize", value.to_string());
4154        }
4155        if let Some(value) = self._filter.as_ref() {
4156            params.push("filter", value);
4157        }
4158
4159        params.extend(self._additional_params.iter());
4160
4161        params.push("alt", "json");
4162        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
4163        if self._scopes.is_empty() {
4164            self._scopes
4165                .insert(Scope::CloudPlatform.as_ref().to_string());
4166        }
4167
4168        #[allow(clippy::single_element_loop)]
4169        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4170            url = params.uri_replacement(url, param_name, find_this, true);
4171        }
4172        {
4173            let to_remove = ["name"];
4174            params.remove_params(&to_remove);
4175        }
4176
4177        let url = params.parse_with_url(&url);
4178
4179        loop {
4180            let token = match self
4181                .hub
4182                .auth
4183                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4184                .await
4185            {
4186                Ok(token) => token,
4187                Err(e) => match dlg.token(e) {
4188                    Ok(token) => token,
4189                    Err(e) => {
4190                        dlg.finished(false);
4191                        return Err(common::Error::MissingToken(e));
4192                    }
4193                },
4194            };
4195            let mut req_result = {
4196                let client = &self.hub.client;
4197                dlg.pre_request();
4198                let mut req_builder = hyper::Request::builder()
4199                    .method(hyper::Method::GET)
4200                    .uri(url.as_str())
4201                    .header(USER_AGENT, self.hub._user_agent.clone());
4202
4203                if let Some(token) = token.as_ref() {
4204                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4205                }
4206
4207                let request = req_builder
4208                    .header(CONTENT_LENGTH, 0_u64)
4209                    .body(common::to_body::<String>(None));
4210
4211                client.request(request.unwrap()).await
4212            };
4213
4214            match req_result {
4215                Err(err) => {
4216                    if let common::Retry::After(d) = dlg.http_error(&err) {
4217                        sleep(d).await;
4218                        continue;
4219                    }
4220                    dlg.finished(false);
4221                    return Err(common::Error::HttpError(err));
4222                }
4223                Ok(res) => {
4224                    let (mut parts, body) = res.into_parts();
4225                    let mut body = common::Body::new(body);
4226                    if !parts.status.is_success() {
4227                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4228                        let error = serde_json::from_str(&common::to_string(&bytes));
4229                        let response = common::to_response(parts, bytes.into());
4230
4231                        if let common::Retry::After(d) =
4232                            dlg.http_failure(&response, error.as_ref().ok())
4233                        {
4234                            sleep(d).await;
4235                            continue;
4236                        }
4237
4238                        dlg.finished(false);
4239
4240                        return Err(match error {
4241                            Ok(value) => common::Error::BadRequest(value),
4242                            _ => common::Error::Failure(response),
4243                        });
4244                    }
4245                    let response = {
4246                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4247                        let encoded = common::to_string(&bytes);
4248                        match serde_json::from_str(&encoded) {
4249                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4250                            Err(error) => {
4251                                dlg.response_json_decode_error(&encoded, &error);
4252                                return Err(common::Error::JsonDecodeError(
4253                                    encoded.to_string(),
4254                                    error,
4255                                ));
4256                            }
4257                        }
4258                    };
4259
4260                    dlg.finished(true);
4261                    return Ok(response);
4262                }
4263            }
4264        }
4265    }
4266
4267    /// The name of the operation's parent resource.
4268    ///
4269    /// Sets the *name* path property to the given value.
4270    ///
4271    /// Even though the property as already been set when instantiating this call,
4272    /// we provide this method for API completeness.
4273    pub fn name(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
4274        self._name = new_value.to_string();
4275        self
4276    }
4277    /// The standard list page token.
4278    ///
4279    /// Sets the *page token* query property to the given value.
4280    pub fn page_token(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
4281        self._page_token = Some(new_value.to_string());
4282        self
4283    }
4284    /// The standard list page size.
4285    ///
4286    /// Sets the *page size* query property to the given value.
4287    pub fn page_size(mut self, new_value: i32) -> ProjectOperationListCall<'a, C> {
4288        self._page_size = Some(new_value);
4289        self
4290    }
4291    /// The standard list filter.
4292    ///
4293    /// Sets the *filter* query property to the given value.
4294    pub fn filter(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
4295        self._filter = Some(new_value.to_string());
4296        self
4297    }
4298    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4299    /// while executing the actual API request.
4300    ///
4301    /// ````text
4302    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4303    /// ````
4304    ///
4305    /// Sets the *delegate* property to the given value.
4306    pub fn delegate(
4307        mut self,
4308        new_value: &'a mut dyn common::Delegate,
4309    ) -> ProjectOperationListCall<'a, C> {
4310        self._delegate = Some(new_value);
4311        self
4312    }
4313
4314    /// Set any additional parameter of the query string used in the request.
4315    /// It should be used to set parameters which are not yet available through their own
4316    /// setters.
4317    ///
4318    /// Please note that this method must not be used to set any of the known parameters
4319    /// which have their own setter method. If done anyway, the request will fail.
4320    ///
4321    /// # Additional Parameters
4322    ///
4323    /// * *$.xgafv* (query-string) - V1 error format.
4324    /// * *access_token* (query-string) - OAuth access token.
4325    /// * *alt* (query-string) - Data format for response.
4326    /// * *callback* (query-string) - JSONP
4327    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4328    /// * *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.
4329    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4330    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4331    /// * *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.
4332    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4333    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4334    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationListCall<'a, C>
4335    where
4336        T: AsRef<str>,
4337    {
4338        self._additional_params
4339            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4340        self
4341    }
4342
4343    /// Identifies the authorization scope for the method you are building.
4344    ///
4345    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4346    /// [`Scope::CloudPlatform`].
4347    ///
4348    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4349    /// tokens for more than one scope.
4350    ///
4351    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4352    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4353    /// sufficient, a read-write scope will do as well.
4354    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationListCall<'a, C>
4355    where
4356        St: AsRef<str>,
4357    {
4358        self._scopes.insert(String::from(scope.as_ref()));
4359        self
4360    }
4361    /// Identifies the authorization scope(s) for the method you are building.
4362    ///
4363    /// See [`Self::add_scope()`] for details.
4364    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationListCall<'a, C>
4365    where
4366        I: IntoIterator<Item = St>,
4367        St: AsRef<str>,
4368    {
4369        self._scopes
4370            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4371        self
4372    }
4373
4374    /// Removes all scopes, and no default scope will be used either.
4375    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4376    /// for details).
4377    pub fn clear_scopes(mut self) -> ProjectOperationListCall<'a, C> {
4378        self._scopes.clear();
4379        self
4380    }
4381}
4382
4383/// Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
4384///
4385/// A builder for the *allocateIds* method supported by a *project* resource.
4386/// It is not used directly, but through a [`ProjectMethods`] instance.
4387///
4388/// # Example
4389///
4390/// Instantiate a resource method builder
4391///
4392/// ```test_harness,no_run
4393/// # extern crate hyper;
4394/// # extern crate hyper_rustls;
4395/// # extern crate google_datastore1 as datastore1;
4396/// use datastore1::api::AllocateIdsRequest;
4397/// # async fn dox() {
4398/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4399///
4400/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4401/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4402/// #     secret,
4403/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4404/// # ).build().await.unwrap();
4405///
4406/// # let client = hyper_util::client::legacy::Client::builder(
4407/// #     hyper_util::rt::TokioExecutor::new()
4408/// # )
4409/// # .build(
4410/// #     hyper_rustls::HttpsConnectorBuilder::new()
4411/// #         .with_native_roots()
4412/// #         .unwrap()
4413/// #         .https_or_http()
4414/// #         .enable_http1()
4415/// #         .build()
4416/// # );
4417/// # let mut hub = Datastore::new(client, auth);
4418/// // As the method needs a request, you would usually fill it with the desired information
4419/// // into the respective structure. Some of the parts shown here might not be applicable !
4420/// // Values shown here are possibly random and not representative !
4421/// let mut req = AllocateIdsRequest::default();
4422///
4423/// // You can configure optional parameters by calling the respective setters at will, and
4424/// // execute the final call using `doit()`.
4425/// // Values shown here are possibly random and not representative !
4426/// let result = hub.projects().allocate_ids(req, "projectId")
4427///              .doit().await;
4428/// # }
4429/// ```
4430pub struct ProjectAllocateIdCall<'a, C>
4431where
4432    C: 'a,
4433{
4434    hub: &'a Datastore<C>,
4435    _request: AllocateIdsRequest,
4436    _project_id: String,
4437    _delegate: Option<&'a mut dyn common::Delegate>,
4438    _additional_params: HashMap<String, String>,
4439    _scopes: BTreeSet<String>,
4440}
4441
4442impl<'a, C> common::CallBuilder for ProjectAllocateIdCall<'a, C> {}
4443
4444impl<'a, C> ProjectAllocateIdCall<'a, C>
4445where
4446    C: common::Connector,
4447{
4448    /// Perform the operation you have build so far.
4449    pub async fn doit(mut self) -> common::Result<(common::Response, AllocateIdsResponse)> {
4450        use std::borrow::Cow;
4451        use std::io::{Read, Seek};
4452
4453        use common::{url::Params, ToParts};
4454        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4455
4456        let mut dd = common::DefaultDelegate;
4457        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4458        dlg.begin(common::MethodInfo {
4459            id: "datastore.projects.allocateIds",
4460            http_method: hyper::Method::POST,
4461        });
4462
4463        for &field in ["alt", "projectId"].iter() {
4464            if self._additional_params.contains_key(field) {
4465                dlg.finished(false);
4466                return Err(common::Error::FieldClash(field));
4467            }
4468        }
4469
4470        let mut params = Params::with_capacity(4 + self._additional_params.len());
4471        params.push("projectId", self._project_id);
4472
4473        params.extend(self._additional_params.iter());
4474
4475        params.push("alt", "json");
4476        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:allocateIds";
4477        if self._scopes.is_empty() {
4478            self._scopes
4479                .insert(Scope::CloudPlatform.as_ref().to_string());
4480        }
4481
4482        #[allow(clippy::single_element_loop)]
4483        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
4484            url = params.uri_replacement(url, param_name, find_this, false);
4485        }
4486        {
4487            let to_remove = ["projectId"];
4488            params.remove_params(&to_remove);
4489        }
4490
4491        let url = params.parse_with_url(&url);
4492
4493        let mut json_mime_type = mime::APPLICATION_JSON;
4494        let mut request_value_reader = {
4495            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4496            common::remove_json_null_values(&mut value);
4497            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4498            serde_json::to_writer(&mut dst, &value).unwrap();
4499            dst
4500        };
4501        let request_size = request_value_reader
4502            .seek(std::io::SeekFrom::End(0))
4503            .unwrap();
4504        request_value_reader
4505            .seek(std::io::SeekFrom::Start(0))
4506            .unwrap();
4507
4508        loop {
4509            let token = match self
4510                .hub
4511                .auth
4512                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4513                .await
4514            {
4515                Ok(token) => token,
4516                Err(e) => match dlg.token(e) {
4517                    Ok(token) => token,
4518                    Err(e) => {
4519                        dlg.finished(false);
4520                        return Err(common::Error::MissingToken(e));
4521                    }
4522                },
4523            };
4524            request_value_reader
4525                .seek(std::io::SeekFrom::Start(0))
4526                .unwrap();
4527            let mut req_result = {
4528                let client = &self.hub.client;
4529                dlg.pre_request();
4530                let mut req_builder = hyper::Request::builder()
4531                    .method(hyper::Method::POST)
4532                    .uri(url.as_str())
4533                    .header(USER_AGENT, self.hub._user_agent.clone());
4534
4535                if let Some(token) = token.as_ref() {
4536                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4537                }
4538
4539                let request = req_builder
4540                    .header(CONTENT_TYPE, json_mime_type.to_string())
4541                    .header(CONTENT_LENGTH, request_size as u64)
4542                    .body(common::to_body(
4543                        request_value_reader.get_ref().clone().into(),
4544                    ));
4545
4546                client.request(request.unwrap()).await
4547            };
4548
4549            match req_result {
4550                Err(err) => {
4551                    if let common::Retry::After(d) = dlg.http_error(&err) {
4552                        sleep(d).await;
4553                        continue;
4554                    }
4555                    dlg.finished(false);
4556                    return Err(common::Error::HttpError(err));
4557                }
4558                Ok(res) => {
4559                    let (mut parts, body) = res.into_parts();
4560                    let mut body = common::Body::new(body);
4561                    if !parts.status.is_success() {
4562                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4563                        let error = serde_json::from_str(&common::to_string(&bytes));
4564                        let response = common::to_response(parts, bytes.into());
4565
4566                        if let common::Retry::After(d) =
4567                            dlg.http_failure(&response, error.as_ref().ok())
4568                        {
4569                            sleep(d).await;
4570                            continue;
4571                        }
4572
4573                        dlg.finished(false);
4574
4575                        return Err(match error {
4576                            Ok(value) => common::Error::BadRequest(value),
4577                            _ => common::Error::Failure(response),
4578                        });
4579                    }
4580                    let response = {
4581                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4582                        let encoded = common::to_string(&bytes);
4583                        match serde_json::from_str(&encoded) {
4584                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4585                            Err(error) => {
4586                                dlg.response_json_decode_error(&encoded, &error);
4587                                return Err(common::Error::JsonDecodeError(
4588                                    encoded.to_string(),
4589                                    error,
4590                                ));
4591                            }
4592                        }
4593                    };
4594
4595                    dlg.finished(true);
4596                    return Ok(response);
4597                }
4598            }
4599        }
4600    }
4601
4602    ///
4603    /// Sets the *request* property to the given value.
4604    ///
4605    /// Even though the property as already been set when instantiating this call,
4606    /// we provide this method for API completeness.
4607    pub fn request(mut self, new_value: AllocateIdsRequest) -> ProjectAllocateIdCall<'a, C> {
4608        self._request = new_value;
4609        self
4610    }
4611    /// Required. The ID of the project against which to make the request.
4612    ///
4613    /// Sets the *project id* path property to the given value.
4614    ///
4615    /// Even though the property as already been set when instantiating this call,
4616    /// we provide this method for API completeness.
4617    pub fn project_id(mut self, new_value: &str) -> ProjectAllocateIdCall<'a, C> {
4618        self._project_id = new_value.to_string();
4619        self
4620    }
4621    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4622    /// while executing the actual API request.
4623    ///
4624    /// ````text
4625    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4626    /// ````
4627    ///
4628    /// Sets the *delegate* property to the given value.
4629    pub fn delegate(
4630        mut self,
4631        new_value: &'a mut dyn common::Delegate,
4632    ) -> ProjectAllocateIdCall<'a, C> {
4633        self._delegate = Some(new_value);
4634        self
4635    }
4636
4637    /// Set any additional parameter of the query string used in the request.
4638    /// It should be used to set parameters which are not yet available through their own
4639    /// setters.
4640    ///
4641    /// Please note that this method must not be used to set any of the known parameters
4642    /// which have their own setter method. If done anyway, the request will fail.
4643    ///
4644    /// # Additional Parameters
4645    ///
4646    /// * *$.xgafv* (query-string) - V1 error format.
4647    /// * *access_token* (query-string) - OAuth access token.
4648    /// * *alt* (query-string) - Data format for response.
4649    /// * *callback* (query-string) - JSONP
4650    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4651    /// * *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.
4652    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4653    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4654    /// * *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.
4655    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4656    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4657    pub fn param<T>(mut self, name: T, value: T) -> ProjectAllocateIdCall<'a, C>
4658    where
4659        T: AsRef<str>,
4660    {
4661        self._additional_params
4662            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4663        self
4664    }
4665
4666    /// Identifies the authorization scope for the method you are building.
4667    ///
4668    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4669    /// [`Scope::CloudPlatform`].
4670    ///
4671    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4672    /// tokens for more than one scope.
4673    ///
4674    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4675    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4676    /// sufficient, a read-write scope will do as well.
4677    pub fn add_scope<St>(mut self, scope: St) -> ProjectAllocateIdCall<'a, C>
4678    where
4679        St: AsRef<str>,
4680    {
4681        self._scopes.insert(String::from(scope.as_ref()));
4682        self
4683    }
4684    /// Identifies the authorization scope(s) for the method you are building.
4685    ///
4686    /// See [`Self::add_scope()`] for details.
4687    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAllocateIdCall<'a, C>
4688    where
4689        I: IntoIterator<Item = St>,
4690        St: AsRef<str>,
4691    {
4692        self._scopes
4693            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4694        self
4695    }
4696
4697    /// Removes all scopes, and no default scope will be used either.
4698    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4699    /// for details).
4700    pub fn clear_scopes(mut self) -> ProjectAllocateIdCall<'a, C> {
4701        self._scopes.clear();
4702        self
4703    }
4704}
4705
4706/// Begins a new transaction.
4707///
4708/// A builder for the *beginTransaction* method supported by a *project* resource.
4709/// It is not used directly, but through a [`ProjectMethods`] instance.
4710///
4711/// # Example
4712///
4713/// Instantiate a resource method builder
4714///
4715/// ```test_harness,no_run
4716/// # extern crate hyper;
4717/// # extern crate hyper_rustls;
4718/// # extern crate google_datastore1 as datastore1;
4719/// use datastore1::api::BeginTransactionRequest;
4720/// # async fn dox() {
4721/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4722///
4723/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4724/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4725/// #     secret,
4726/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4727/// # ).build().await.unwrap();
4728///
4729/// # let client = hyper_util::client::legacy::Client::builder(
4730/// #     hyper_util::rt::TokioExecutor::new()
4731/// # )
4732/// # .build(
4733/// #     hyper_rustls::HttpsConnectorBuilder::new()
4734/// #         .with_native_roots()
4735/// #         .unwrap()
4736/// #         .https_or_http()
4737/// #         .enable_http1()
4738/// #         .build()
4739/// # );
4740/// # let mut hub = Datastore::new(client, auth);
4741/// // As the method needs a request, you would usually fill it with the desired information
4742/// // into the respective structure. Some of the parts shown here might not be applicable !
4743/// // Values shown here are possibly random and not representative !
4744/// let mut req = BeginTransactionRequest::default();
4745///
4746/// // You can configure optional parameters by calling the respective setters at will, and
4747/// // execute the final call using `doit()`.
4748/// // Values shown here are possibly random and not representative !
4749/// let result = hub.projects().begin_transaction(req, "projectId")
4750///              .doit().await;
4751/// # }
4752/// ```
4753pub struct ProjectBeginTransactionCall<'a, C>
4754where
4755    C: 'a,
4756{
4757    hub: &'a Datastore<C>,
4758    _request: BeginTransactionRequest,
4759    _project_id: String,
4760    _delegate: Option<&'a mut dyn common::Delegate>,
4761    _additional_params: HashMap<String, String>,
4762    _scopes: BTreeSet<String>,
4763}
4764
4765impl<'a, C> common::CallBuilder for ProjectBeginTransactionCall<'a, C> {}
4766
4767impl<'a, C> ProjectBeginTransactionCall<'a, C>
4768where
4769    C: common::Connector,
4770{
4771    /// Perform the operation you have build so far.
4772    pub async fn doit(mut self) -> common::Result<(common::Response, BeginTransactionResponse)> {
4773        use std::borrow::Cow;
4774        use std::io::{Read, Seek};
4775
4776        use common::{url::Params, ToParts};
4777        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4778
4779        let mut dd = common::DefaultDelegate;
4780        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4781        dlg.begin(common::MethodInfo {
4782            id: "datastore.projects.beginTransaction",
4783            http_method: hyper::Method::POST,
4784        });
4785
4786        for &field in ["alt", "projectId"].iter() {
4787            if self._additional_params.contains_key(field) {
4788                dlg.finished(false);
4789                return Err(common::Error::FieldClash(field));
4790            }
4791        }
4792
4793        let mut params = Params::with_capacity(4 + self._additional_params.len());
4794        params.push("projectId", self._project_id);
4795
4796        params.extend(self._additional_params.iter());
4797
4798        params.push("alt", "json");
4799        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:beginTransaction";
4800        if self._scopes.is_empty() {
4801            self._scopes
4802                .insert(Scope::CloudPlatform.as_ref().to_string());
4803        }
4804
4805        #[allow(clippy::single_element_loop)]
4806        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
4807            url = params.uri_replacement(url, param_name, find_this, false);
4808        }
4809        {
4810            let to_remove = ["projectId"];
4811            params.remove_params(&to_remove);
4812        }
4813
4814        let url = params.parse_with_url(&url);
4815
4816        let mut json_mime_type = mime::APPLICATION_JSON;
4817        let mut request_value_reader = {
4818            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4819            common::remove_json_null_values(&mut value);
4820            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4821            serde_json::to_writer(&mut dst, &value).unwrap();
4822            dst
4823        };
4824        let request_size = request_value_reader
4825            .seek(std::io::SeekFrom::End(0))
4826            .unwrap();
4827        request_value_reader
4828            .seek(std::io::SeekFrom::Start(0))
4829            .unwrap();
4830
4831        loop {
4832            let token = match self
4833                .hub
4834                .auth
4835                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4836                .await
4837            {
4838                Ok(token) => token,
4839                Err(e) => match dlg.token(e) {
4840                    Ok(token) => token,
4841                    Err(e) => {
4842                        dlg.finished(false);
4843                        return Err(common::Error::MissingToken(e));
4844                    }
4845                },
4846            };
4847            request_value_reader
4848                .seek(std::io::SeekFrom::Start(0))
4849                .unwrap();
4850            let mut req_result = {
4851                let client = &self.hub.client;
4852                dlg.pre_request();
4853                let mut req_builder = hyper::Request::builder()
4854                    .method(hyper::Method::POST)
4855                    .uri(url.as_str())
4856                    .header(USER_AGENT, self.hub._user_agent.clone());
4857
4858                if let Some(token) = token.as_ref() {
4859                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4860                }
4861
4862                let request = req_builder
4863                    .header(CONTENT_TYPE, json_mime_type.to_string())
4864                    .header(CONTENT_LENGTH, request_size as u64)
4865                    .body(common::to_body(
4866                        request_value_reader.get_ref().clone().into(),
4867                    ));
4868
4869                client.request(request.unwrap()).await
4870            };
4871
4872            match req_result {
4873                Err(err) => {
4874                    if let common::Retry::After(d) = dlg.http_error(&err) {
4875                        sleep(d).await;
4876                        continue;
4877                    }
4878                    dlg.finished(false);
4879                    return Err(common::Error::HttpError(err));
4880                }
4881                Ok(res) => {
4882                    let (mut parts, body) = res.into_parts();
4883                    let mut body = common::Body::new(body);
4884                    if !parts.status.is_success() {
4885                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4886                        let error = serde_json::from_str(&common::to_string(&bytes));
4887                        let response = common::to_response(parts, bytes.into());
4888
4889                        if let common::Retry::After(d) =
4890                            dlg.http_failure(&response, error.as_ref().ok())
4891                        {
4892                            sleep(d).await;
4893                            continue;
4894                        }
4895
4896                        dlg.finished(false);
4897
4898                        return Err(match error {
4899                            Ok(value) => common::Error::BadRequest(value),
4900                            _ => common::Error::Failure(response),
4901                        });
4902                    }
4903                    let response = {
4904                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4905                        let encoded = common::to_string(&bytes);
4906                        match serde_json::from_str(&encoded) {
4907                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4908                            Err(error) => {
4909                                dlg.response_json_decode_error(&encoded, &error);
4910                                return Err(common::Error::JsonDecodeError(
4911                                    encoded.to_string(),
4912                                    error,
4913                                ));
4914                            }
4915                        }
4916                    };
4917
4918                    dlg.finished(true);
4919                    return Ok(response);
4920                }
4921            }
4922        }
4923    }
4924
4925    ///
4926    /// Sets the *request* property to the given value.
4927    ///
4928    /// Even though the property as already been set when instantiating this call,
4929    /// we provide this method for API completeness.
4930    pub fn request(
4931        mut self,
4932        new_value: BeginTransactionRequest,
4933    ) -> ProjectBeginTransactionCall<'a, C> {
4934        self._request = new_value;
4935        self
4936    }
4937    /// Required. The ID of the project against which to make the request.
4938    ///
4939    /// Sets the *project id* path property to the given value.
4940    ///
4941    /// Even though the property as already been set when instantiating this call,
4942    /// we provide this method for API completeness.
4943    pub fn project_id(mut self, new_value: &str) -> ProjectBeginTransactionCall<'a, C> {
4944        self._project_id = new_value.to_string();
4945        self
4946    }
4947    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4948    /// while executing the actual API request.
4949    ///
4950    /// ````text
4951    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4952    /// ````
4953    ///
4954    /// Sets the *delegate* property to the given value.
4955    pub fn delegate(
4956        mut self,
4957        new_value: &'a mut dyn common::Delegate,
4958    ) -> ProjectBeginTransactionCall<'a, C> {
4959        self._delegate = Some(new_value);
4960        self
4961    }
4962
4963    /// Set any additional parameter of the query string used in the request.
4964    /// It should be used to set parameters which are not yet available through their own
4965    /// setters.
4966    ///
4967    /// Please note that this method must not be used to set any of the known parameters
4968    /// which have their own setter method. If done anyway, the request will fail.
4969    ///
4970    /// # Additional Parameters
4971    ///
4972    /// * *$.xgafv* (query-string) - V1 error format.
4973    /// * *access_token* (query-string) - OAuth access token.
4974    /// * *alt* (query-string) - Data format for response.
4975    /// * *callback* (query-string) - JSONP
4976    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4977    /// * *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.
4978    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4979    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4980    /// * *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.
4981    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4982    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4983    pub fn param<T>(mut self, name: T, value: T) -> ProjectBeginTransactionCall<'a, C>
4984    where
4985        T: AsRef<str>,
4986    {
4987        self._additional_params
4988            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4989        self
4990    }
4991
4992    /// Identifies the authorization scope for the method you are building.
4993    ///
4994    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4995    /// [`Scope::CloudPlatform`].
4996    ///
4997    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4998    /// tokens for more than one scope.
4999    ///
5000    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5001    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5002    /// sufficient, a read-write scope will do as well.
5003    pub fn add_scope<St>(mut self, scope: St) -> ProjectBeginTransactionCall<'a, C>
5004    where
5005        St: AsRef<str>,
5006    {
5007        self._scopes.insert(String::from(scope.as_ref()));
5008        self
5009    }
5010    /// Identifies the authorization scope(s) for the method you are building.
5011    ///
5012    /// See [`Self::add_scope()`] for details.
5013    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBeginTransactionCall<'a, C>
5014    where
5015        I: IntoIterator<Item = St>,
5016        St: AsRef<str>,
5017    {
5018        self._scopes
5019            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5020        self
5021    }
5022
5023    /// Removes all scopes, and no default scope will be used either.
5024    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5025    /// for details).
5026    pub fn clear_scopes(mut self) -> ProjectBeginTransactionCall<'a, C> {
5027        self._scopes.clear();
5028        self
5029    }
5030}
5031
5032/// Commits a transaction, optionally creating, deleting or modifying some entities.
5033///
5034/// A builder for the *commit* method supported by a *project* resource.
5035/// It is not used directly, but through a [`ProjectMethods`] instance.
5036///
5037/// # Example
5038///
5039/// Instantiate a resource method builder
5040///
5041/// ```test_harness,no_run
5042/// # extern crate hyper;
5043/// # extern crate hyper_rustls;
5044/// # extern crate google_datastore1 as datastore1;
5045/// use datastore1::api::CommitRequest;
5046/// # async fn dox() {
5047/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5048///
5049/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5050/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5051/// #     secret,
5052/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5053/// # ).build().await.unwrap();
5054///
5055/// # let client = hyper_util::client::legacy::Client::builder(
5056/// #     hyper_util::rt::TokioExecutor::new()
5057/// # )
5058/// # .build(
5059/// #     hyper_rustls::HttpsConnectorBuilder::new()
5060/// #         .with_native_roots()
5061/// #         .unwrap()
5062/// #         .https_or_http()
5063/// #         .enable_http1()
5064/// #         .build()
5065/// # );
5066/// # let mut hub = Datastore::new(client, auth);
5067/// // As the method needs a request, you would usually fill it with the desired information
5068/// // into the respective structure. Some of the parts shown here might not be applicable !
5069/// // Values shown here are possibly random and not representative !
5070/// let mut req = CommitRequest::default();
5071///
5072/// // You can configure optional parameters by calling the respective setters at will, and
5073/// // execute the final call using `doit()`.
5074/// // Values shown here are possibly random and not representative !
5075/// let result = hub.projects().commit(req, "projectId")
5076///              .doit().await;
5077/// # }
5078/// ```
5079pub struct ProjectCommitCall<'a, C>
5080where
5081    C: 'a,
5082{
5083    hub: &'a Datastore<C>,
5084    _request: CommitRequest,
5085    _project_id: String,
5086    _delegate: Option<&'a mut dyn common::Delegate>,
5087    _additional_params: HashMap<String, String>,
5088    _scopes: BTreeSet<String>,
5089}
5090
5091impl<'a, C> common::CallBuilder for ProjectCommitCall<'a, C> {}
5092
5093impl<'a, C> ProjectCommitCall<'a, C>
5094where
5095    C: common::Connector,
5096{
5097    /// Perform the operation you have build so far.
5098    pub async fn doit(mut self) -> common::Result<(common::Response, CommitResponse)> {
5099        use std::borrow::Cow;
5100        use std::io::{Read, Seek};
5101
5102        use common::{url::Params, ToParts};
5103        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5104
5105        let mut dd = common::DefaultDelegate;
5106        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5107        dlg.begin(common::MethodInfo {
5108            id: "datastore.projects.commit",
5109            http_method: hyper::Method::POST,
5110        });
5111
5112        for &field in ["alt", "projectId"].iter() {
5113            if self._additional_params.contains_key(field) {
5114                dlg.finished(false);
5115                return Err(common::Error::FieldClash(field));
5116            }
5117        }
5118
5119        let mut params = Params::with_capacity(4 + self._additional_params.len());
5120        params.push("projectId", self._project_id);
5121
5122        params.extend(self._additional_params.iter());
5123
5124        params.push("alt", "json");
5125        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:commit";
5126        if self._scopes.is_empty() {
5127            self._scopes
5128                .insert(Scope::CloudPlatform.as_ref().to_string());
5129        }
5130
5131        #[allow(clippy::single_element_loop)]
5132        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
5133            url = params.uri_replacement(url, param_name, find_this, false);
5134        }
5135        {
5136            let to_remove = ["projectId"];
5137            params.remove_params(&to_remove);
5138        }
5139
5140        let url = params.parse_with_url(&url);
5141
5142        let mut json_mime_type = mime::APPLICATION_JSON;
5143        let mut request_value_reader = {
5144            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5145            common::remove_json_null_values(&mut value);
5146            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5147            serde_json::to_writer(&mut dst, &value).unwrap();
5148            dst
5149        };
5150        let request_size = request_value_reader
5151            .seek(std::io::SeekFrom::End(0))
5152            .unwrap();
5153        request_value_reader
5154            .seek(std::io::SeekFrom::Start(0))
5155            .unwrap();
5156
5157        loop {
5158            let token = match self
5159                .hub
5160                .auth
5161                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5162                .await
5163            {
5164                Ok(token) => token,
5165                Err(e) => match dlg.token(e) {
5166                    Ok(token) => token,
5167                    Err(e) => {
5168                        dlg.finished(false);
5169                        return Err(common::Error::MissingToken(e));
5170                    }
5171                },
5172            };
5173            request_value_reader
5174                .seek(std::io::SeekFrom::Start(0))
5175                .unwrap();
5176            let mut req_result = {
5177                let client = &self.hub.client;
5178                dlg.pre_request();
5179                let mut req_builder = hyper::Request::builder()
5180                    .method(hyper::Method::POST)
5181                    .uri(url.as_str())
5182                    .header(USER_AGENT, self.hub._user_agent.clone());
5183
5184                if let Some(token) = token.as_ref() {
5185                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5186                }
5187
5188                let request = req_builder
5189                    .header(CONTENT_TYPE, json_mime_type.to_string())
5190                    .header(CONTENT_LENGTH, request_size as u64)
5191                    .body(common::to_body(
5192                        request_value_reader.get_ref().clone().into(),
5193                    ));
5194
5195                client.request(request.unwrap()).await
5196            };
5197
5198            match req_result {
5199                Err(err) => {
5200                    if let common::Retry::After(d) = dlg.http_error(&err) {
5201                        sleep(d).await;
5202                        continue;
5203                    }
5204                    dlg.finished(false);
5205                    return Err(common::Error::HttpError(err));
5206                }
5207                Ok(res) => {
5208                    let (mut parts, body) = res.into_parts();
5209                    let mut body = common::Body::new(body);
5210                    if !parts.status.is_success() {
5211                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5212                        let error = serde_json::from_str(&common::to_string(&bytes));
5213                        let response = common::to_response(parts, bytes.into());
5214
5215                        if let common::Retry::After(d) =
5216                            dlg.http_failure(&response, error.as_ref().ok())
5217                        {
5218                            sleep(d).await;
5219                            continue;
5220                        }
5221
5222                        dlg.finished(false);
5223
5224                        return Err(match error {
5225                            Ok(value) => common::Error::BadRequest(value),
5226                            _ => common::Error::Failure(response),
5227                        });
5228                    }
5229                    let response = {
5230                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5231                        let encoded = common::to_string(&bytes);
5232                        match serde_json::from_str(&encoded) {
5233                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5234                            Err(error) => {
5235                                dlg.response_json_decode_error(&encoded, &error);
5236                                return Err(common::Error::JsonDecodeError(
5237                                    encoded.to_string(),
5238                                    error,
5239                                ));
5240                            }
5241                        }
5242                    };
5243
5244                    dlg.finished(true);
5245                    return Ok(response);
5246                }
5247            }
5248        }
5249    }
5250
5251    ///
5252    /// Sets the *request* property to the given value.
5253    ///
5254    /// Even though the property as already been set when instantiating this call,
5255    /// we provide this method for API completeness.
5256    pub fn request(mut self, new_value: CommitRequest) -> ProjectCommitCall<'a, C> {
5257        self._request = new_value;
5258        self
5259    }
5260    /// Required. The ID of the project against which to make the request.
5261    ///
5262    /// Sets the *project id* path property to the given value.
5263    ///
5264    /// Even though the property as already been set when instantiating this call,
5265    /// we provide this method for API completeness.
5266    pub fn project_id(mut self, new_value: &str) -> ProjectCommitCall<'a, C> {
5267        self._project_id = new_value.to_string();
5268        self
5269    }
5270    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5271    /// while executing the actual API request.
5272    ///
5273    /// ````text
5274    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5275    /// ````
5276    ///
5277    /// Sets the *delegate* property to the given value.
5278    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectCommitCall<'a, C> {
5279        self._delegate = Some(new_value);
5280        self
5281    }
5282
5283    /// Set any additional parameter of the query string used in the request.
5284    /// It should be used to set parameters which are not yet available through their own
5285    /// setters.
5286    ///
5287    /// Please note that this method must not be used to set any of the known parameters
5288    /// which have their own setter method. If done anyway, the request will fail.
5289    ///
5290    /// # Additional Parameters
5291    ///
5292    /// * *$.xgafv* (query-string) - V1 error format.
5293    /// * *access_token* (query-string) - OAuth access token.
5294    /// * *alt* (query-string) - Data format for response.
5295    /// * *callback* (query-string) - JSONP
5296    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5297    /// * *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.
5298    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5299    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5300    /// * *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.
5301    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5302    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5303    pub fn param<T>(mut self, name: T, value: T) -> ProjectCommitCall<'a, C>
5304    where
5305        T: AsRef<str>,
5306    {
5307        self._additional_params
5308            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5309        self
5310    }
5311
5312    /// Identifies the authorization scope for the method you are building.
5313    ///
5314    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5315    /// [`Scope::CloudPlatform`].
5316    ///
5317    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5318    /// tokens for more than one scope.
5319    ///
5320    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5321    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5322    /// sufficient, a read-write scope will do as well.
5323    pub fn add_scope<St>(mut self, scope: St) -> ProjectCommitCall<'a, C>
5324    where
5325        St: AsRef<str>,
5326    {
5327        self._scopes.insert(String::from(scope.as_ref()));
5328        self
5329    }
5330    /// Identifies the authorization scope(s) for the method you are building.
5331    ///
5332    /// See [`Self::add_scope()`] for details.
5333    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectCommitCall<'a, C>
5334    where
5335        I: IntoIterator<Item = St>,
5336        St: AsRef<str>,
5337    {
5338        self._scopes
5339            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5340        self
5341    }
5342
5343    /// Removes all scopes, and no default scope will be used either.
5344    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5345    /// for details).
5346    pub fn clear_scopes(mut self) -> ProjectCommitCall<'a, C> {
5347        self._scopes.clear();
5348        self
5349    }
5350}
5351
5352/// Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities 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.
5353///
5354/// A builder for the *export* method supported by a *project* resource.
5355/// It is not used directly, but through a [`ProjectMethods`] instance.
5356///
5357/// # Example
5358///
5359/// Instantiate a resource method builder
5360///
5361/// ```test_harness,no_run
5362/// # extern crate hyper;
5363/// # extern crate hyper_rustls;
5364/// # extern crate google_datastore1 as datastore1;
5365/// use datastore1::api::GoogleDatastoreAdminV1ExportEntitiesRequest;
5366/// # async fn dox() {
5367/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5368///
5369/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5370/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5371/// #     secret,
5372/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5373/// # ).build().await.unwrap();
5374///
5375/// # let client = hyper_util::client::legacy::Client::builder(
5376/// #     hyper_util::rt::TokioExecutor::new()
5377/// # )
5378/// # .build(
5379/// #     hyper_rustls::HttpsConnectorBuilder::new()
5380/// #         .with_native_roots()
5381/// #         .unwrap()
5382/// #         .https_or_http()
5383/// #         .enable_http1()
5384/// #         .build()
5385/// # );
5386/// # let mut hub = Datastore::new(client, auth);
5387/// // As the method needs a request, you would usually fill it with the desired information
5388/// // into the respective structure. Some of the parts shown here might not be applicable !
5389/// // Values shown here are possibly random and not representative !
5390/// let mut req = GoogleDatastoreAdminV1ExportEntitiesRequest::default();
5391///
5392/// // You can configure optional parameters by calling the respective setters at will, and
5393/// // execute the final call using `doit()`.
5394/// // Values shown here are possibly random and not representative !
5395/// let result = hub.projects().export(req, "projectId")
5396///              .doit().await;
5397/// # }
5398/// ```
5399pub struct ProjectExportCall<'a, C>
5400where
5401    C: 'a,
5402{
5403    hub: &'a Datastore<C>,
5404    _request: GoogleDatastoreAdminV1ExportEntitiesRequest,
5405    _project_id: String,
5406    _delegate: Option<&'a mut dyn common::Delegate>,
5407    _additional_params: HashMap<String, String>,
5408    _scopes: BTreeSet<String>,
5409}
5410
5411impl<'a, C> common::CallBuilder for ProjectExportCall<'a, C> {}
5412
5413impl<'a, C> ProjectExportCall<'a, C>
5414where
5415    C: common::Connector,
5416{
5417    /// Perform the operation you have build so far.
5418    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
5419        use std::borrow::Cow;
5420        use std::io::{Read, Seek};
5421
5422        use common::{url::Params, ToParts};
5423        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5424
5425        let mut dd = common::DefaultDelegate;
5426        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5427        dlg.begin(common::MethodInfo {
5428            id: "datastore.projects.export",
5429            http_method: hyper::Method::POST,
5430        });
5431
5432        for &field in ["alt", "projectId"].iter() {
5433            if self._additional_params.contains_key(field) {
5434                dlg.finished(false);
5435                return Err(common::Error::FieldClash(field));
5436            }
5437        }
5438
5439        let mut params = Params::with_capacity(4 + self._additional_params.len());
5440        params.push("projectId", self._project_id);
5441
5442        params.extend(self._additional_params.iter());
5443
5444        params.push("alt", "json");
5445        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:export";
5446        if self._scopes.is_empty() {
5447            self._scopes
5448                .insert(Scope::CloudPlatform.as_ref().to_string());
5449        }
5450
5451        #[allow(clippy::single_element_loop)]
5452        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
5453            url = params.uri_replacement(url, param_name, find_this, false);
5454        }
5455        {
5456            let to_remove = ["projectId"];
5457            params.remove_params(&to_remove);
5458        }
5459
5460        let url = params.parse_with_url(&url);
5461
5462        let mut json_mime_type = mime::APPLICATION_JSON;
5463        let mut request_value_reader = {
5464            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5465            common::remove_json_null_values(&mut value);
5466            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5467            serde_json::to_writer(&mut dst, &value).unwrap();
5468            dst
5469        };
5470        let request_size = request_value_reader
5471            .seek(std::io::SeekFrom::End(0))
5472            .unwrap();
5473        request_value_reader
5474            .seek(std::io::SeekFrom::Start(0))
5475            .unwrap();
5476
5477        loop {
5478            let token = match self
5479                .hub
5480                .auth
5481                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5482                .await
5483            {
5484                Ok(token) => token,
5485                Err(e) => match dlg.token(e) {
5486                    Ok(token) => token,
5487                    Err(e) => {
5488                        dlg.finished(false);
5489                        return Err(common::Error::MissingToken(e));
5490                    }
5491                },
5492            };
5493            request_value_reader
5494                .seek(std::io::SeekFrom::Start(0))
5495                .unwrap();
5496            let mut req_result = {
5497                let client = &self.hub.client;
5498                dlg.pre_request();
5499                let mut req_builder = hyper::Request::builder()
5500                    .method(hyper::Method::POST)
5501                    .uri(url.as_str())
5502                    .header(USER_AGENT, self.hub._user_agent.clone());
5503
5504                if let Some(token) = token.as_ref() {
5505                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5506                }
5507
5508                let request = req_builder
5509                    .header(CONTENT_TYPE, json_mime_type.to_string())
5510                    .header(CONTENT_LENGTH, request_size as u64)
5511                    .body(common::to_body(
5512                        request_value_reader.get_ref().clone().into(),
5513                    ));
5514
5515                client.request(request.unwrap()).await
5516            };
5517
5518            match req_result {
5519                Err(err) => {
5520                    if let common::Retry::After(d) = dlg.http_error(&err) {
5521                        sleep(d).await;
5522                        continue;
5523                    }
5524                    dlg.finished(false);
5525                    return Err(common::Error::HttpError(err));
5526                }
5527                Ok(res) => {
5528                    let (mut parts, body) = res.into_parts();
5529                    let mut body = common::Body::new(body);
5530                    if !parts.status.is_success() {
5531                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5532                        let error = serde_json::from_str(&common::to_string(&bytes));
5533                        let response = common::to_response(parts, bytes.into());
5534
5535                        if let common::Retry::After(d) =
5536                            dlg.http_failure(&response, error.as_ref().ok())
5537                        {
5538                            sleep(d).await;
5539                            continue;
5540                        }
5541
5542                        dlg.finished(false);
5543
5544                        return Err(match error {
5545                            Ok(value) => common::Error::BadRequest(value),
5546                            _ => common::Error::Failure(response),
5547                        });
5548                    }
5549                    let response = {
5550                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5551                        let encoded = common::to_string(&bytes);
5552                        match serde_json::from_str(&encoded) {
5553                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5554                            Err(error) => {
5555                                dlg.response_json_decode_error(&encoded, &error);
5556                                return Err(common::Error::JsonDecodeError(
5557                                    encoded.to_string(),
5558                                    error,
5559                                ));
5560                            }
5561                        }
5562                    };
5563
5564                    dlg.finished(true);
5565                    return Ok(response);
5566                }
5567            }
5568        }
5569    }
5570
5571    ///
5572    /// Sets the *request* property to the given value.
5573    ///
5574    /// Even though the property as already been set when instantiating this call,
5575    /// we provide this method for API completeness.
5576    pub fn request(
5577        mut self,
5578        new_value: GoogleDatastoreAdminV1ExportEntitiesRequest,
5579    ) -> ProjectExportCall<'a, C> {
5580        self._request = new_value;
5581        self
5582    }
5583    /// Required. Project ID against which to make the request.
5584    ///
5585    /// Sets the *project id* path property to the given value.
5586    ///
5587    /// Even though the property as already been set when instantiating this call,
5588    /// we provide this method for API completeness.
5589    pub fn project_id(mut self, new_value: &str) -> ProjectExportCall<'a, C> {
5590        self._project_id = new_value.to_string();
5591        self
5592    }
5593    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5594    /// while executing the actual API request.
5595    ///
5596    /// ````text
5597    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5598    /// ````
5599    ///
5600    /// Sets the *delegate* property to the given value.
5601    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectExportCall<'a, C> {
5602        self._delegate = Some(new_value);
5603        self
5604    }
5605
5606    /// Set any additional parameter of the query string used in the request.
5607    /// It should be used to set parameters which are not yet available through their own
5608    /// setters.
5609    ///
5610    /// Please note that this method must not be used to set any of the known parameters
5611    /// which have their own setter method. If done anyway, the request will fail.
5612    ///
5613    /// # Additional Parameters
5614    ///
5615    /// * *$.xgafv* (query-string) - V1 error format.
5616    /// * *access_token* (query-string) - OAuth access token.
5617    /// * *alt* (query-string) - Data format for response.
5618    /// * *callback* (query-string) - JSONP
5619    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5620    /// * *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.
5621    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5622    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5623    /// * *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.
5624    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5625    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5626    pub fn param<T>(mut self, name: T, value: T) -> ProjectExportCall<'a, C>
5627    where
5628        T: AsRef<str>,
5629    {
5630        self._additional_params
5631            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5632        self
5633    }
5634
5635    /// Identifies the authorization scope for the method you are building.
5636    ///
5637    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5638    /// [`Scope::CloudPlatform`].
5639    ///
5640    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5641    /// tokens for more than one scope.
5642    ///
5643    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5644    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5645    /// sufficient, a read-write scope will do as well.
5646    pub fn add_scope<St>(mut self, scope: St) -> ProjectExportCall<'a, C>
5647    where
5648        St: AsRef<str>,
5649    {
5650        self._scopes.insert(String::from(scope.as_ref()));
5651        self
5652    }
5653    /// Identifies the authorization scope(s) for the method you are building.
5654    ///
5655    /// See [`Self::add_scope()`] for details.
5656    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectExportCall<'a, C>
5657    where
5658        I: IntoIterator<Item = St>,
5659        St: AsRef<str>,
5660    {
5661        self._scopes
5662            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5663        self
5664    }
5665
5666    /// Removes all scopes, and no default scope will be used either.
5667    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5668    /// for details).
5669    pub fn clear_scopes(mut self) -> ProjectExportCall<'a, C> {
5670        self._scopes.clear();
5671        self
5672    }
5673}
5674
5675/// Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.
5676///
5677/// A builder for the *import* method supported by a *project* resource.
5678/// It is not used directly, but through a [`ProjectMethods`] instance.
5679///
5680/// # Example
5681///
5682/// Instantiate a resource method builder
5683///
5684/// ```test_harness,no_run
5685/// # extern crate hyper;
5686/// # extern crate hyper_rustls;
5687/// # extern crate google_datastore1 as datastore1;
5688/// use datastore1::api::GoogleDatastoreAdminV1ImportEntitiesRequest;
5689/// # async fn dox() {
5690/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5691///
5692/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5693/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5694/// #     secret,
5695/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5696/// # ).build().await.unwrap();
5697///
5698/// # let client = hyper_util::client::legacy::Client::builder(
5699/// #     hyper_util::rt::TokioExecutor::new()
5700/// # )
5701/// # .build(
5702/// #     hyper_rustls::HttpsConnectorBuilder::new()
5703/// #         .with_native_roots()
5704/// #         .unwrap()
5705/// #         .https_or_http()
5706/// #         .enable_http1()
5707/// #         .build()
5708/// # );
5709/// # let mut hub = Datastore::new(client, auth);
5710/// // As the method needs a request, you would usually fill it with the desired information
5711/// // into the respective structure. Some of the parts shown here might not be applicable !
5712/// // Values shown here are possibly random and not representative !
5713/// let mut req = GoogleDatastoreAdminV1ImportEntitiesRequest::default();
5714///
5715/// // You can configure optional parameters by calling the respective setters at will, and
5716/// // execute the final call using `doit()`.
5717/// // Values shown here are possibly random and not representative !
5718/// let result = hub.projects().import(req, "projectId")
5719///              .doit().await;
5720/// # }
5721/// ```
5722pub struct ProjectImportCall<'a, C>
5723where
5724    C: 'a,
5725{
5726    hub: &'a Datastore<C>,
5727    _request: GoogleDatastoreAdminV1ImportEntitiesRequest,
5728    _project_id: String,
5729    _delegate: Option<&'a mut dyn common::Delegate>,
5730    _additional_params: HashMap<String, String>,
5731    _scopes: BTreeSet<String>,
5732}
5733
5734impl<'a, C> common::CallBuilder for ProjectImportCall<'a, C> {}
5735
5736impl<'a, C> ProjectImportCall<'a, C>
5737where
5738    C: common::Connector,
5739{
5740    /// Perform the operation you have build so far.
5741    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
5742        use std::borrow::Cow;
5743        use std::io::{Read, Seek};
5744
5745        use common::{url::Params, ToParts};
5746        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5747
5748        let mut dd = common::DefaultDelegate;
5749        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5750        dlg.begin(common::MethodInfo {
5751            id: "datastore.projects.import",
5752            http_method: hyper::Method::POST,
5753        });
5754
5755        for &field in ["alt", "projectId"].iter() {
5756            if self._additional_params.contains_key(field) {
5757                dlg.finished(false);
5758                return Err(common::Error::FieldClash(field));
5759            }
5760        }
5761
5762        let mut params = Params::with_capacity(4 + self._additional_params.len());
5763        params.push("projectId", self._project_id);
5764
5765        params.extend(self._additional_params.iter());
5766
5767        params.push("alt", "json");
5768        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:import";
5769        if self._scopes.is_empty() {
5770            self._scopes
5771                .insert(Scope::CloudPlatform.as_ref().to_string());
5772        }
5773
5774        #[allow(clippy::single_element_loop)]
5775        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
5776            url = params.uri_replacement(url, param_name, find_this, false);
5777        }
5778        {
5779            let to_remove = ["projectId"];
5780            params.remove_params(&to_remove);
5781        }
5782
5783        let url = params.parse_with_url(&url);
5784
5785        let mut json_mime_type = mime::APPLICATION_JSON;
5786        let mut request_value_reader = {
5787            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5788            common::remove_json_null_values(&mut value);
5789            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5790            serde_json::to_writer(&mut dst, &value).unwrap();
5791            dst
5792        };
5793        let request_size = request_value_reader
5794            .seek(std::io::SeekFrom::End(0))
5795            .unwrap();
5796        request_value_reader
5797            .seek(std::io::SeekFrom::Start(0))
5798            .unwrap();
5799
5800        loop {
5801            let token = match self
5802                .hub
5803                .auth
5804                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5805                .await
5806            {
5807                Ok(token) => token,
5808                Err(e) => match dlg.token(e) {
5809                    Ok(token) => token,
5810                    Err(e) => {
5811                        dlg.finished(false);
5812                        return Err(common::Error::MissingToken(e));
5813                    }
5814                },
5815            };
5816            request_value_reader
5817                .seek(std::io::SeekFrom::Start(0))
5818                .unwrap();
5819            let mut req_result = {
5820                let client = &self.hub.client;
5821                dlg.pre_request();
5822                let mut req_builder = hyper::Request::builder()
5823                    .method(hyper::Method::POST)
5824                    .uri(url.as_str())
5825                    .header(USER_AGENT, self.hub._user_agent.clone());
5826
5827                if let Some(token) = token.as_ref() {
5828                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5829                }
5830
5831                let request = req_builder
5832                    .header(CONTENT_TYPE, json_mime_type.to_string())
5833                    .header(CONTENT_LENGTH, request_size as u64)
5834                    .body(common::to_body(
5835                        request_value_reader.get_ref().clone().into(),
5836                    ));
5837
5838                client.request(request.unwrap()).await
5839            };
5840
5841            match req_result {
5842                Err(err) => {
5843                    if let common::Retry::After(d) = dlg.http_error(&err) {
5844                        sleep(d).await;
5845                        continue;
5846                    }
5847                    dlg.finished(false);
5848                    return Err(common::Error::HttpError(err));
5849                }
5850                Ok(res) => {
5851                    let (mut parts, body) = res.into_parts();
5852                    let mut body = common::Body::new(body);
5853                    if !parts.status.is_success() {
5854                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5855                        let error = serde_json::from_str(&common::to_string(&bytes));
5856                        let response = common::to_response(parts, bytes.into());
5857
5858                        if let common::Retry::After(d) =
5859                            dlg.http_failure(&response, error.as_ref().ok())
5860                        {
5861                            sleep(d).await;
5862                            continue;
5863                        }
5864
5865                        dlg.finished(false);
5866
5867                        return Err(match error {
5868                            Ok(value) => common::Error::BadRequest(value),
5869                            _ => common::Error::Failure(response),
5870                        });
5871                    }
5872                    let response = {
5873                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5874                        let encoded = common::to_string(&bytes);
5875                        match serde_json::from_str(&encoded) {
5876                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5877                            Err(error) => {
5878                                dlg.response_json_decode_error(&encoded, &error);
5879                                return Err(common::Error::JsonDecodeError(
5880                                    encoded.to_string(),
5881                                    error,
5882                                ));
5883                            }
5884                        }
5885                    };
5886
5887                    dlg.finished(true);
5888                    return Ok(response);
5889                }
5890            }
5891        }
5892    }
5893
5894    ///
5895    /// Sets the *request* property to the given value.
5896    ///
5897    /// Even though the property as already been set when instantiating this call,
5898    /// we provide this method for API completeness.
5899    pub fn request(
5900        mut self,
5901        new_value: GoogleDatastoreAdminV1ImportEntitiesRequest,
5902    ) -> ProjectImportCall<'a, C> {
5903        self._request = new_value;
5904        self
5905    }
5906    /// Required. Project ID against which to make the request.
5907    ///
5908    /// Sets the *project id* path property to the given value.
5909    ///
5910    /// Even though the property as already been set when instantiating this call,
5911    /// we provide this method for API completeness.
5912    pub fn project_id(mut self, new_value: &str) -> ProjectImportCall<'a, C> {
5913        self._project_id = new_value.to_string();
5914        self
5915    }
5916    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5917    /// while executing the actual API request.
5918    ///
5919    /// ````text
5920    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5921    /// ````
5922    ///
5923    /// Sets the *delegate* property to the given value.
5924    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectImportCall<'a, C> {
5925        self._delegate = Some(new_value);
5926        self
5927    }
5928
5929    /// Set any additional parameter of the query string used in the request.
5930    /// It should be used to set parameters which are not yet available through their own
5931    /// setters.
5932    ///
5933    /// Please note that this method must not be used to set any of the known parameters
5934    /// which have their own setter method. If done anyway, the request will fail.
5935    ///
5936    /// # Additional Parameters
5937    ///
5938    /// * *$.xgafv* (query-string) - V1 error format.
5939    /// * *access_token* (query-string) - OAuth access token.
5940    /// * *alt* (query-string) - Data format for response.
5941    /// * *callback* (query-string) - JSONP
5942    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5943    /// * *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.
5944    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5945    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5946    /// * *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.
5947    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5948    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5949    pub fn param<T>(mut self, name: T, value: T) -> ProjectImportCall<'a, C>
5950    where
5951        T: AsRef<str>,
5952    {
5953        self._additional_params
5954            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5955        self
5956    }
5957
5958    /// Identifies the authorization scope for the method you are building.
5959    ///
5960    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5961    /// [`Scope::CloudPlatform`].
5962    ///
5963    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5964    /// tokens for more than one scope.
5965    ///
5966    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5967    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5968    /// sufficient, a read-write scope will do as well.
5969    pub fn add_scope<St>(mut self, scope: St) -> ProjectImportCall<'a, C>
5970    where
5971        St: AsRef<str>,
5972    {
5973        self._scopes.insert(String::from(scope.as_ref()));
5974        self
5975    }
5976    /// Identifies the authorization scope(s) for the method you are building.
5977    ///
5978    /// See [`Self::add_scope()`] for details.
5979    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectImportCall<'a, C>
5980    where
5981        I: IntoIterator<Item = St>,
5982        St: AsRef<str>,
5983    {
5984        self._scopes
5985            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5986        self
5987    }
5988
5989    /// Removes all scopes, and no default scope will be used either.
5990    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5991    /// for details).
5992    pub fn clear_scopes(mut self) -> ProjectImportCall<'a, C> {
5993        self._scopes.clear();
5994        self
5995    }
5996}
5997
5998/// Looks up entities by key.
5999///
6000/// A builder for the *lookup* method supported by a *project* resource.
6001/// It is not used directly, but through a [`ProjectMethods`] instance.
6002///
6003/// # Example
6004///
6005/// Instantiate a resource method builder
6006///
6007/// ```test_harness,no_run
6008/// # extern crate hyper;
6009/// # extern crate hyper_rustls;
6010/// # extern crate google_datastore1 as datastore1;
6011/// use datastore1::api::LookupRequest;
6012/// # async fn dox() {
6013/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6014///
6015/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6016/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6017/// #     secret,
6018/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6019/// # ).build().await.unwrap();
6020///
6021/// # let client = hyper_util::client::legacy::Client::builder(
6022/// #     hyper_util::rt::TokioExecutor::new()
6023/// # )
6024/// # .build(
6025/// #     hyper_rustls::HttpsConnectorBuilder::new()
6026/// #         .with_native_roots()
6027/// #         .unwrap()
6028/// #         .https_or_http()
6029/// #         .enable_http1()
6030/// #         .build()
6031/// # );
6032/// # let mut hub = Datastore::new(client, auth);
6033/// // As the method needs a request, you would usually fill it with the desired information
6034/// // into the respective structure. Some of the parts shown here might not be applicable !
6035/// // Values shown here are possibly random and not representative !
6036/// let mut req = LookupRequest::default();
6037///
6038/// // You can configure optional parameters by calling the respective setters at will, and
6039/// // execute the final call using `doit()`.
6040/// // Values shown here are possibly random and not representative !
6041/// let result = hub.projects().lookup(req, "projectId")
6042///              .doit().await;
6043/// # }
6044/// ```
6045pub struct ProjectLookupCall<'a, C>
6046where
6047    C: 'a,
6048{
6049    hub: &'a Datastore<C>,
6050    _request: LookupRequest,
6051    _project_id: String,
6052    _delegate: Option<&'a mut dyn common::Delegate>,
6053    _additional_params: HashMap<String, String>,
6054    _scopes: BTreeSet<String>,
6055}
6056
6057impl<'a, C> common::CallBuilder for ProjectLookupCall<'a, C> {}
6058
6059impl<'a, C> ProjectLookupCall<'a, C>
6060where
6061    C: common::Connector,
6062{
6063    /// Perform the operation you have build so far.
6064    pub async fn doit(mut self) -> common::Result<(common::Response, LookupResponse)> {
6065        use std::borrow::Cow;
6066        use std::io::{Read, Seek};
6067
6068        use common::{url::Params, ToParts};
6069        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6070
6071        let mut dd = common::DefaultDelegate;
6072        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6073        dlg.begin(common::MethodInfo {
6074            id: "datastore.projects.lookup",
6075            http_method: hyper::Method::POST,
6076        });
6077
6078        for &field in ["alt", "projectId"].iter() {
6079            if self._additional_params.contains_key(field) {
6080                dlg.finished(false);
6081                return Err(common::Error::FieldClash(field));
6082            }
6083        }
6084
6085        let mut params = Params::with_capacity(4 + self._additional_params.len());
6086        params.push("projectId", self._project_id);
6087
6088        params.extend(self._additional_params.iter());
6089
6090        params.push("alt", "json");
6091        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:lookup";
6092        if self._scopes.is_empty() {
6093            self._scopes
6094                .insert(Scope::CloudPlatform.as_ref().to_string());
6095        }
6096
6097        #[allow(clippy::single_element_loop)]
6098        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
6099            url = params.uri_replacement(url, param_name, find_this, false);
6100        }
6101        {
6102            let to_remove = ["projectId"];
6103            params.remove_params(&to_remove);
6104        }
6105
6106        let url = params.parse_with_url(&url);
6107
6108        let mut json_mime_type = mime::APPLICATION_JSON;
6109        let mut request_value_reader = {
6110            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6111            common::remove_json_null_values(&mut value);
6112            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6113            serde_json::to_writer(&mut dst, &value).unwrap();
6114            dst
6115        };
6116        let request_size = request_value_reader
6117            .seek(std::io::SeekFrom::End(0))
6118            .unwrap();
6119        request_value_reader
6120            .seek(std::io::SeekFrom::Start(0))
6121            .unwrap();
6122
6123        loop {
6124            let token = match self
6125                .hub
6126                .auth
6127                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6128                .await
6129            {
6130                Ok(token) => token,
6131                Err(e) => match dlg.token(e) {
6132                    Ok(token) => token,
6133                    Err(e) => {
6134                        dlg.finished(false);
6135                        return Err(common::Error::MissingToken(e));
6136                    }
6137                },
6138            };
6139            request_value_reader
6140                .seek(std::io::SeekFrom::Start(0))
6141                .unwrap();
6142            let mut req_result = {
6143                let client = &self.hub.client;
6144                dlg.pre_request();
6145                let mut req_builder = hyper::Request::builder()
6146                    .method(hyper::Method::POST)
6147                    .uri(url.as_str())
6148                    .header(USER_AGENT, self.hub._user_agent.clone());
6149
6150                if let Some(token) = token.as_ref() {
6151                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6152                }
6153
6154                let request = req_builder
6155                    .header(CONTENT_TYPE, json_mime_type.to_string())
6156                    .header(CONTENT_LENGTH, request_size as u64)
6157                    .body(common::to_body(
6158                        request_value_reader.get_ref().clone().into(),
6159                    ));
6160
6161                client.request(request.unwrap()).await
6162            };
6163
6164            match req_result {
6165                Err(err) => {
6166                    if let common::Retry::After(d) = dlg.http_error(&err) {
6167                        sleep(d).await;
6168                        continue;
6169                    }
6170                    dlg.finished(false);
6171                    return Err(common::Error::HttpError(err));
6172                }
6173                Ok(res) => {
6174                    let (mut parts, body) = res.into_parts();
6175                    let mut body = common::Body::new(body);
6176                    if !parts.status.is_success() {
6177                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6178                        let error = serde_json::from_str(&common::to_string(&bytes));
6179                        let response = common::to_response(parts, bytes.into());
6180
6181                        if let common::Retry::After(d) =
6182                            dlg.http_failure(&response, error.as_ref().ok())
6183                        {
6184                            sleep(d).await;
6185                            continue;
6186                        }
6187
6188                        dlg.finished(false);
6189
6190                        return Err(match error {
6191                            Ok(value) => common::Error::BadRequest(value),
6192                            _ => common::Error::Failure(response),
6193                        });
6194                    }
6195                    let response = {
6196                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6197                        let encoded = common::to_string(&bytes);
6198                        match serde_json::from_str(&encoded) {
6199                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6200                            Err(error) => {
6201                                dlg.response_json_decode_error(&encoded, &error);
6202                                return Err(common::Error::JsonDecodeError(
6203                                    encoded.to_string(),
6204                                    error,
6205                                ));
6206                            }
6207                        }
6208                    };
6209
6210                    dlg.finished(true);
6211                    return Ok(response);
6212                }
6213            }
6214        }
6215    }
6216
6217    ///
6218    /// Sets the *request* property to the given value.
6219    ///
6220    /// Even though the property as already been set when instantiating this call,
6221    /// we provide this method for API completeness.
6222    pub fn request(mut self, new_value: LookupRequest) -> ProjectLookupCall<'a, C> {
6223        self._request = new_value;
6224        self
6225    }
6226    /// Required. The ID of the project against which to make the request.
6227    ///
6228    /// Sets the *project id* path property to the given value.
6229    ///
6230    /// Even though the property as already been set when instantiating this call,
6231    /// we provide this method for API completeness.
6232    pub fn project_id(mut self, new_value: &str) -> ProjectLookupCall<'a, C> {
6233        self._project_id = new_value.to_string();
6234        self
6235    }
6236    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6237    /// while executing the actual API request.
6238    ///
6239    /// ````text
6240    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6241    /// ````
6242    ///
6243    /// Sets the *delegate* property to the given value.
6244    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectLookupCall<'a, C> {
6245        self._delegate = Some(new_value);
6246        self
6247    }
6248
6249    /// Set any additional parameter of the query string used in the request.
6250    /// It should be used to set parameters which are not yet available through their own
6251    /// setters.
6252    ///
6253    /// Please note that this method must not be used to set any of the known parameters
6254    /// which have their own setter method. If done anyway, the request will fail.
6255    ///
6256    /// # Additional Parameters
6257    ///
6258    /// * *$.xgafv* (query-string) - V1 error format.
6259    /// * *access_token* (query-string) - OAuth access token.
6260    /// * *alt* (query-string) - Data format for response.
6261    /// * *callback* (query-string) - JSONP
6262    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6263    /// * *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.
6264    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6265    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6266    /// * *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.
6267    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6268    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6269    pub fn param<T>(mut self, name: T, value: T) -> ProjectLookupCall<'a, C>
6270    where
6271        T: AsRef<str>,
6272    {
6273        self._additional_params
6274            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6275        self
6276    }
6277
6278    /// Identifies the authorization scope for the method you are building.
6279    ///
6280    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6281    /// [`Scope::CloudPlatform`].
6282    ///
6283    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6284    /// tokens for more than one scope.
6285    ///
6286    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6287    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6288    /// sufficient, a read-write scope will do as well.
6289    pub fn add_scope<St>(mut self, scope: St) -> ProjectLookupCall<'a, C>
6290    where
6291        St: AsRef<str>,
6292    {
6293        self._scopes.insert(String::from(scope.as_ref()));
6294        self
6295    }
6296    /// Identifies the authorization scope(s) for the method you are building.
6297    ///
6298    /// See [`Self::add_scope()`] for details.
6299    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLookupCall<'a, C>
6300    where
6301        I: IntoIterator<Item = St>,
6302        St: AsRef<str>,
6303    {
6304        self._scopes
6305            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6306        self
6307    }
6308
6309    /// Removes all scopes, and no default scope will be used either.
6310    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6311    /// for details).
6312    pub fn clear_scopes(mut self) -> ProjectLookupCall<'a, C> {
6313        self._scopes.clear();
6314        self
6315    }
6316}
6317
6318/// Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
6319///
6320/// A builder for the *reserveIds* method supported by a *project* resource.
6321/// It is not used directly, but through a [`ProjectMethods`] instance.
6322///
6323/// # Example
6324///
6325/// Instantiate a resource method builder
6326///
6327/// ```test_harness,no_run
6328/// # extern crate hyper;
6329/// # extern crate hyper_rustls;
6330/// # extern crate google_datastore1 as datastore1;
6331/// use datastore1::api::ReserveIdsRequest;
6332/// # async fn dox() {
6333/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6334///
6335/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6337/// #     secret,
6338/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6339/// # ).build().await.unwrap();
6340///
6341/// # let client = hyper_util::client::legacy::Client::builder(
6342/// #     hyper_util::rt::TokioExecutor::new()
6343/// # )
6344/// # .build(
6345/// #     hyper_rustls::HttpsConnectorBuilder::new()
6346/// #         .with_native_roots()
6347/// #         .unwrap()
6348/// #         .https_or_http()
6349/// #         .enable_http1()
6350/// #         .build()
6351/// # );
6352/// # let mut hub = Datastore::new(client, auth);
6353/// // As the method needs a request, you would usually fill it with the desired information
6354/// // into the respective structure. Some of the parts shown here might not be applicable !
6355/// // Values shown here are possibly random and not representative !
6356/// let mut req = ReserveIdsRequest::default();
6357///
6358/// // You can configure optional parameters by calling the respective setters at will, and
6359/// // execute the final call using `doit()`.
6360/// // Values shown here are possibly random and not representative !
6361/// let result = hub.projects().reserve_ids(req, "projectId")
6362///              .doit().await;
6363/// # }
6364/// ```
6365pub struct ProjectReserveIdCall<'a, C>
6366where
6367    C: 'a,
6368{
6369    hub: &'a Datastore<C>,
6370    _request: ReserveIdsRequest,
6371    _project_id: String,
6372    _delegate: Option<&'a mut dyn common::Delegate>,
6373    _additional_params: HashMap<String, String>,
6374    _scopes: BTreeSet<String>,
6375}
6376
6377impl<'a, C> common::CallBuilder for ProjectReserveIdCall<'a, C> {}
6378
6379impl<'a, C> ProjectReserveIdCall<'a, C>
6380where
6381    C: common::Connector,
6382{
6383    /// Perform the operation you have build so far.
6384    pub async fn doit(mut self) -> common::Result<(common::Response, ReserveIdsResponse)> {
6385        use std::borrow::Cow;
6386        use std::io::{Read, Seek};
6387
6388        use common::{url::Params, ToParts};
6389        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6390
6391        let mut dd = common::DefaultDelegate;
6392        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6393        dlg.begin(common::MethodInfo {
6394            id: "datastore.projects.reserveIds",
6395            http_method: hyper::Method::POST,
6396        });
6397
6398        for &field in ["alt", "projectId"].iter() {
6399            if self._additional_params.contains_key(field) {
6400                dlg.finished(false);
6401                return Err(common::Error::FieldClash(field));
6402            }
6403        }
6404
6405        let mut params = Params::with_capacity(4 + self._additional_params.len());
6406        params.push("projectId", self._project_id);
6407
6408        params.extend(self._additional_params.iter());
6409
6410        params.push("alt", "json");
6411        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:reserveIds";
6412        if self._scopes.is_empty() {
6413            self._scopes
6414                .insert(Scope::CloudPlatform.as_ref().to_string());
6415        }
6416
6417        #[allow(clippy::single_element_loop)]
6418        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
6419            url = params.uri_replacement(url, param_name, find_this, false);
6420        }
6421        {
6422            let to_remove = ["projectId"];
6423            params.remove_params(&to_remove);
6424        }
6425
6426        let url = params.parse_with_url(&url);
6427
6428        let mut json_mime_type = mime::APPLICATION_JSON;
6429        let mut request_value_reader = {
6430            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6431            common::remove_json_null_values(&mut value);
6432            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6433            serde_json::to_writer(&mut dst, &value).unwrap();
6434            dst
6435        };
6436        let request_size = request_value_reader
6437            .seek(std::io::SeekFrom::End(0))
6438            .unwrap();
6439        request_value_reader
6440            .seek(std::io::SeekFrom::Start(0))
6441            .unwrap();
6442
6443        loop {
6444            let token = match self
6445                .hub
6446                .auth
6447                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6448                .await
6449            {
6450                Ok(token) => token,
6451                Err(e) => match dlg.token(e) {
6452                    Ok(token) => token,
6453                    Err(e) => {
6454                        dlg.finished(false);
6455                        return Err(common::Error::MissingToken(e));
6456                    }
6457                },
6458            };
6459            request_value_reader
6460                .seek(std::io::SeekFrom::Start(0))
6461                .unwrap();
6462            let mut req_result = {
6463                let client = &self.hub.client;
6464                dlg.pre_request();
6465                let mut req_builder = hyper::Request::builder()
6466                    .method(hyper::Method::POST)
6467                    .uri(url.as_str())
6468                    .header(USER_AGENT, self.hub._user_agent.clone());
6469
6470                if let Some(token) = token.as_ref() {
6471                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6472                }
6473
6474                let request = req_builder
6475                    .header(CONTENT_TYPE, json_mime_type.to_string())
6476                    .header(CONTENT_LENGTH, request_size as u64)
6477                    .body(common::to_body(
6478                        request_value_reader.get_ref().clone().into(),
6479                    ));
6480
6481                client.request(request.unwrap()).await
6482            };
6483
6484            match req_result {
6485                Err(err) => {
6486                    if let common::Retry::After(d) = dlg.http_error(&err) {
6487                        sleep(d).await;
6488                        continue;
6489                    }
6490                    dlg.finished(false);
6491                    return Err(common::Error::HttpError(err));
6492                }
6493                Ok(res) => {
6494                    let (mut parts, body) = res.into_parts();
6495                    let mut body = common::Body::new(body);
6496                    if !parts.status.is_success() {
6497                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6498                        let error = serde_json::from_str(&common::to_string(&bytes));
6499                        let response = common::to_response(parts, bytes.into());
6500
6501                        if let common::Retry::After(d) =
6502                            dlg.http_failure(&response, error.as_ref().ok())
6503                        {
6504                            sleep(d).await;
6505                            continue;
6506                        }
6507
6508                        dlg.finished(false);
6509
6510                        return Err(match error {
6511                            Ok(value) => common::Error::BadRequest(value),
6512                            _ => common::Error::Failure(response),
6513                        });
6514                    }
6515                    let response = {
6516                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6517                        let encoded = common::to_string(&bytes);
6518                        match serde_json::from_str(&encoded) {
6519                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6520                            Err(error) => {
6521                                dlg.response_json_decode_error(&encoded, &error);
6522                                return Err(common::Error::JsonDecodeError(
6523                                    encoded.to_string(),
6524                                    error,
6525                                ));
6526                            }
6527                        }
6528                    };
6529
6530                    dlg.finished(true);
6531                    return Ok(response);
6532                }
6533            }
6534        }
6535    }
6536
6537    ///
6538    /// Sets the *request* property to the given value.
6539    ///
6540    /// Even though the property as already been set when instantiating this call,
6541    /// we provide this method for API completeness.
6542    pub fn request(mut self, new_value: ReserveIdsRequest) -> ProjectReserveIdCall<'a, C> {
6543        self._request = new_value;
6544        self
6545    }
6546    /// Required. The ID of the project against which to make the request.
6547    ///
6548    /// Sets the *project id* path property to the given value.
6549    ///
6550    /// Even though the property as already been set when instantiating this call,
6551    /// we provide this method for API completeness.
6552    pub fn project_id(mut self, new_value: &str) -> ProjectReserveIdCall<'a, C> {
6553        self._project_id = new_value.to_string();
6554        self
6555    }
6556    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6557    /// while executing the actual API request.
6558    ///
6559    /// ````text
6560    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6561    /// ````
6562    ///
6563    /// Sets the *delegate* property to the given value.
6564    pub fn delegate(
6565        mut self,
6566        new_value: &'a mut dyn common::Delegate,
6567    ) -> ProjectReserveIdCall<'a, C> {
6568        self._delegate = Some(new_value);
6569        self
6570    }
6571
6572    /// Set any additional parameter of the query string used in the request.
6573    /// It should be used to set parameters which are not yet available through their own
6574    /// setters.
6575    ///
6576    /// Please note that this method must not be used to set any of the known parameters
6577    /// which have their own setter method. If done anyway, the request will fail.
6578    ///
6579    /// # Additional Parameters
6580    ///
6581    /// * *$.xgafv* (query-string) - V1 error format.
6582    /// * *access_token* (query-string) - OAuth access token.
6583    /// * *alt* (query-string) - Data format for response.
6584    /// * *callback* (query-string) - JSONP
6585    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6586    /// * *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.
6587    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6588    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6589    /// * *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.
6590    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6591    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6592    pub fn param<T>(mut self, name: T, value: T) -> ProjectReserveIdCall<'a, C>
6593    where
6594        T: AsRef<str>,
6595    {
6596        self._additional_params
6597            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6598        self
6599    }
6600
6601    /// Identifies the authorization scope for the method you are building.
6602    ///
6603    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6604    /// [`Scope::CloudPlatform`].
6605    ///
6606    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6607    /// tokens for more than one scope.
6608    ///
6609    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6610    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6611    /// sufficient, a read-write scope will do as well.
6612    pub fn add_scope<St>(mut self, scope: St) -> ProjectReserveIdCall<'a, C>
6613    where
6614        St: AsRef<str>,
6615    {
6616        self._scopes.insert(String::from(scope.as_ref()));
6617        self
6618    }
6619    /// Identifies the authorization scope(s) for the method you are building.
6620    ///
6621    /// See [`Self::add_scope()`] for details.
6622    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectReserveIdCall<'a, C>
6623    where
6624        I: IntoIterator<Item = St>,
6625        St: AsRef<str>,
6626    {
6627        self._scopes
6628            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6629        self
6630    }
6631
6632    /// Removes all scopes, and no default scope will be used either.
6633    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6634    /// for details).
6635    pub fn clear_scopes(mut self) -> ProjectReserveIdCall<'a, C> {
6636        self._scopes.clear();
6637        self
6638    }
6639}
6640
6641/// Rolls back a transaction.
6642///
6643/// A builder for the *rollback* method supported by a *project* resource.
6644/// It is not used directly, but through a [`ProjectMethods`] instance.
6645///
6646/// # Example
6647///
6648/// Instantiate a resource method builder
6649///
6650/// ```test_harness,no_run
6651/// # extern crate hyper;
6652/// # extern crate hyper_rustls;
6653/// # extern crate google_datastore1 as datastore1;
6654/// use datastore1::api::RollbackRequest;
6655/// # async fn dox() {
6656/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6657///
6658/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6659/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6660/// #     secret,
6661/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6662/// # ).build().await.unwrap();
6663///
6664/// # let client = hyper_util::client::legacy::Client::builder(
6665/// #     hyper_util::rt::TokioExecutor::new()
6666/// # )
6667/// # .build(
6668/// #     hyper_rustls::HttpsConnectorBuilder::new()
6669/// #         .with_native_roots()
6670/// #         .unwrap()
6671/// #         .https_or_http()
6672/// #         .enable_http1()
6673/// #         .build()
6674/// # );
6675/// # let mut hub = Datastore::new(client, auth);
6676/// // As the method needs a request, you would usually fill it with the desired information
6677/// // into the respective structure. Some of the parts shown here might not be applicable !
6678/// // Values shown here are possibly random and not representative !
6679/// let mut req = RollbackRequest::default();
6680///
6681/// // You can configure optional parameters by calling the respective setters at will, and
6682/// // execute the final call using `doit()`.
6683/// // Values shown here are possibly random and not representative !
6684/// let result = hub.projects().rollback(req, "projectId")
6685///              .doit().await;
6686/// # }
6687/// ```
6688pub struct ProjectRollbackCall<'a, C>
6689where
6690    C: 'a,
6691{
6692    hub: &'a Datastore<C>,
6693    _request: RollbackRequest,
6694    _project_id: String,
6695    _delegate: Option<&'a mut dyn common::Delegate>,
6696    _additional_params: HashMap<String, String>,
6697    _scopes: BTreeSet<String>,
6698}
6699
6700impl<'a, C> common::CallBuilder for ProjectRollbackCall<'a, C> {}
6701
6702impl<'a, C> ProjectRollbackCall<'a, C>
6703where
6704    C: common::Connector,
6705{
6706    /// Perform the operation you have build so far.
6707    pub async fn doit(mut self) -> common::Result<(common::Response, RollbackResponse)> {
6708        use std::borrow::Cow;
6709        use std::io::{Read, Seek};
6710
6711        use common::{url::Params, ToParts};
6712        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6713
6714        let mut dd = common::DefaultDelegate;
6715        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6716        dlg.begin(common::MethodInfo {
6717            id: "datastore.projects.rollback",
6718            http_method: hyper::Method::POST,
6719        });
6720
6721        for &field in ["alt", "projectId"].iter() {
6722            if self._additional_params.contains_key(field) {
6723                dlg.finished(false);
6724                return Err(common::Error::FieldClash(field));
6725            }
6726        }
6727
6728        let mut params = Params::with_capacity(4 + self._additional_params.len());
6729        params.push("projectId", self._project_id);
6730
6731        params.extend(self._additional_params.iter());
6732
6733        params.push("alt", "json");
6734        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:rollback";
6735        if self._scopes.is_empty() {
6736            self._scopes
6737                .insert(Scope::CloudPlatform.as_ref().to_string());
6738        }
6739
6740        #[allow(clippy::single_element_loop)]
6741        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
6742            url = params.uri_replacement(url, param_name, find_this, false);
6743        }
6744        {
6745            let to_remove = ["projectId"];
6746            params.remove_params(&to_remove);
6747        }
6748
6749        let url = params.parse_with_url(&url);
6750
6751        let mut json_mime_type = mime::APPLICATION_JSON;
6752        let mut request_value_reader = {
6753            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6754            common::remove_json_null_values(&mut value);
6755            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6756            serde_json::to_writer(&mut dst, &value).unwrap();
6757            dst
6758        };
6759        let request_size = request_value_reader
6760            .seek(std::io::SeekFrom::End(0))
6761            .unwrap();
6762        request_value_reader
6763            .seek(std::io::SeekFrom::Start(0))
6764            .unwrap();
6765
6766        loop {
6767            let token = match self
6768                .hub
6769                .auth
6770                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6771                .await
6772            {
6773                Ok(token) => token,
6774                Err(e) => match dlg.token(e) {
6775                    Ok(token) => token,
6776                    Err(e) => {
6777                        dlg.finished(false);
6778                        return Err(common::Error::MissingToken(e));
6779                    }
6780                },
6781            };
6782            request_value_reader
6783                .seek(std::io::SeekFrom::Start(0))
6784                .unwrap();
6785            let mut req_result = {
6786                let client = &self.hub.client;
6787                dlg.pre_request();
6788                let mut req_builder = hyper::Request::builder()
6789                    .method(hyper::Method::POST)
6790                    .uri(url.as_str())
6791                    .header(USER_AGENT, self.hub._user_agent.clone());
6792
6793                if let Some(token) = token.as_ref() {
6794                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6795                }
6796
6797                let request = req_builder
6798                    .header(CONTENT_TYPE, json_mime_type.to_string())
6799                    .header(CONTENT_LENGTH, request_size as u64)
6800                    .body(common::to_body(
6801                        request_value_reader.get_ref().clone().into(),
6802                    ));
6803
6804                client.request(request.unwrap()).await
6805            };
6806
6807            match req_result {
6808                Err(err) => {
6809                    if let common::Retry::After(d) = dlg.http_error(&err) {
6810                        sleep(d).await;
6811                        continue;
6812                    }
6813                    dlg.finished(false);
6814                    return Err(common::Error::HttpError(err));
6815                }
6816                Ok(res) => {
6817                    let (mut parts, body) = res.into_parts();
6818                    let mut body = common::Body::new(body);
6819                    if !parts.status.is_success() {
6820                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6821                        let error = serde_json::from_str(&common::to_string(&bytes));
6822                        let response = common::to_response(parts, bytes.into());
6823
6824                        if let common::Retry::After(d) =
6825                            dlg.http_failure(&response, error.as_ref().ok())
6826                        {
6827                            sleep(d).await;
6828                            continue;
6829                        }
6830
6831                        dlg.finished(false);
6832
6833                        return Err(match error {
6834                            Ok(value) => common::Error::BadRequest(value),
6835                            _ => common::Error::Failure(response),
6836                        });
6837                    }
6838                    let response = {
6839                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6840                        let encoded = common::to_string(&bytes);
6841                        match serde_json::from_str(&encoded) {
6842                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6843                            Err(error) => {
6844                                dlg.response_json_decode_error(&encoded, &error);
6845                                return Err(common::Error::JsonDecodeError(
6846                                    encoded.to_string(),
6847                                    error,
6848                                ));
6849                            }
6850                        }
6851                    };
6852
6853                    dlg.finished(true);
6854                    return Ok(response);
6855                }
6856            }
6857        }
6858    }
6859
6860    ///
6861    /// Sets the *request* property to the given value.
6862    ///
6863    /// Even though the property as already been set when instantiating this call,
6864    /// we provide this method for API completeness.
6865    pub fn request(mut self, new_value: RollbackRequest) -> ProjectRollbackCall<'a, C> {
6866        self._request = new_value;
6867        self
6868    }
6869    /// Required. The ID of the project against which to make the request.
6870    ///
6871    /// Sets the *project id* path property to the given value.
6872    ///
6873    /// Even though the property as already been set when instantiating this call,
6874    /// we provide this method for API completeness.
6875    pub fn project_id(mut self, new_value: &str) -> ProjectRollbackCall<'a, C> {
6876        self._project_id = new_value.to_string();
6877        self
6878    }
6879    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6880    /// while executing the actual API request.
6881    ///
6882    /// ````text
6883    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6884    /// ````
6885    ///
6886    /// Sets the *delegate* property to the given value.
6887    pub fn delegate(
6888        mut self,
6889        new_value: &'a mut dyn common::Delegate,
6890    ) -> ProjectRollbackCall<'a, C> {
6891        self._delegate = Some(new_value);
6892        self
6893    }
6894
6895    /// Set any additional parameter of the query string used in the request.
6896    /// It should be used to set parameters which are not yet available through their own
6897    /// setters.
6898    ///
6899    /// Please note that this method must not be used to set any of the known parameters
6900    /// which have their own setter method. If done anyway, the request will fail.
6901    ///
6902    /// # Additional Parameters
6903    ///
6904    /// * *$.xgafv* (query-string) - V1 error format.
6905    /// * *access_token* (query-string) - OAuth access token.
6906    /// * *alt* (query-string) - Data format for response.
6907    /// * *callback* (query-string) - JSONP
6908    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6909    /// * *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.
6910    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6911    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6912    /// * *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.
6913    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6914    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6915    pub fn param<T>(mut self, name: T, value: T) -> ProjectRollbackCall<'a, C>
6916    where
6917        T: AsRef<str>,
6918    {
6919        self._additional_params
6920            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6921        self
6922    }
6923
6924    /// Identifies the authorization scope for the method you are building.
6925    ///
6926    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6927    /// [`Scope::CloudPlatform`].
6928    ///
6929    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6930    /// tokens for more than one scope.
6931    ///
6932    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6933    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6934    /// sufficient, a read-write scope will do as well.
6935    pub fn add_scope<St>(mut self, scope: St) -> ProjectRollbackCall<'a, C>
6936    where
6937        St: AsRef<str>,
6938    {
6939        self._scopes.insert(String::from(scope.as_ref()));
6940        self
6941    }
6942    /// Identifies the authorization scope(s) for the method you are building.
6943    ///
6944    /// See [`Self::add_scope()`] for details.
6945    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectRollbackCall<'a, C>
6946    where
6947        I: IntoIterator<Item = St>,
6948        St: AsRef<str>,
6949    {
6950        self._scopes
6951            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6952        self
6953    }
6954
6955    /// Removes all scopes, and no default scope will be used either.
6956    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6957    /// for details).
6958    pub fn clear_scopes(mut self) -> ProjectRollbackCall<'a, C> {
6959        self._scopes.clear();
6960        self
6961    }
6962}
6963
6964/// Runs an aggregation query.
6965///
6966/// A builder for the *runAggregationQuery* method supported by a *project* resource.
6967/// It is not used directly, but through a [`ProjectMethods`] instance.
6968///
6969/// # Example
6970///
6971/// Instantiate a resource method builder
6972///
6973/// ```test_harness,no_run
6974/// # extern crate hyper;
6975/// # extern crate hyper_rustls;
6976/// # extern crate google_datastore1 as datastore1;
6977/// use datastore1::api::RunAggregationQueryRequest;
6978/// # async fn dox() {
6979/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6980///
6981/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6982/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6983/// #     secret,
6984/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6985/// # ).build().await.unwrap();
6986///
6987/// # let client = hyper_util::client::legacy::Client::builder(
6988/// #     hyper_util::rt::TokioExecutor::new()
6989/// # )
6990/// # .build(
6991/// #     hyper_rustls::HttpsConnectorBuilder::new()
6992/// #         .with_native_roots()
6993/// #         .unwrap()
6994/// #         .https_or_http()
6995/// #         .enable_http1()
6996/// #         .build()
6997/// # );
6998/// # let mut hub = Datastore::new(client, auth);
6999/// // As the method needs a request, you would usually fill it with the desired information
7000/// // into the respective structure. Some of the parts shown here might not be applicable !
7001/// // Values shown here are possibly random and not representative !
7002/// let mut req = RunAggregationQueryRequest::default();
7003///
7004/// // You can configure optional parameters by calling the respective setters at will, and
7005/// // execute the final call using `doit()`.
7006/// // Values shown here are possibly random and not representative !
7007/// let result = hub.projects().run_aggregation_query(req, "projectId")
7008///              .doit().await;
7009/// # }
7010/// ```
7011pub struct ProjectRunAggregationQueryCall<'a, C>
7012where
7013    C: 'a,
7014{
7015    hub: &'a Datastore<C>,
7016    _request: RunAggregationQueryRequest,
7017    _project_id: String,
7018    _delegate: Option<&'a mut dyn common::Delegate>,
7019    _additional_params: HashMap<String, String>,
7020    _scopes: BTreeSet<String>,
7021}
7022
7023impl<'a, C> common::CallBuilder for ProjectRunAggregationQueryCall<'a, C> {}
7024
7025impl<'a, C> ProjectRunAggregationQueryCall<'a, C>
7026where
7027    C: common::Connector,
7028{
7029    /// Perform the operation you have build so far.
7030    pub async fn doit(mut self) -> common::Result<(common::Response, RunAggregationQueryResponse)> {
7031        use std::borrow::Cow;
7032        use std::io::{Read, Seek};
7033
7034        use common::{url::Params, ToParts};
7035        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7036
7037        let mut dd = common::DefaultDelegate;
7038        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7039        dlg.begin(common::MethodInfo {
7040            id: "datastore.projects.runAggregationQuery",
7041            http_method: hyper::Method::POST,
7042        });
7043
7044        for &field in ["alt", "projectId"].iter() {
7045            if self._additional_params.contains_key(field) {
7046                dlg.finished(false);
7047                return Err(common::Error::FieldClash(field));
7048            }
7049        }
7050
7051        let mut params = Params::with_capacity(4 + self._additional_params.len());
7052        params.push("projectId", self._project_id);
7053
7054        params.extend(self._additional_params.iter());
7055
7056        params.push("alt", "json");
7057        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:runAggregationQuery";
7058        if self._scopes.is_empty() {
7059            self._scopes
7060                .insert(Scope::CloudPlatform.as_ref().to_string());
7061        }
7062
7063        #[allow(clippy::single_element_loop)]
7064        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
7065            url = params.uri_replacement(url, param_name, find_this, false);
7066        }
7067        {
7068            let to_remove = ["projectId"];
7069            params.remove_params(&to_remove);
7070        }
7071
7072        let url = params.parse_with_url(&url);
7073
7074        let mut json_mime_type = mime::APPLICATION_JSON;
7075        let mut request_value_reader = {
7076            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7077            common::remove_json_null_values(&mut value);
7078            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7079            serde_json::to_writer(&mut dst, &value).unwrap();
7080            dst
7081        };
7082        let request_size = request_value_reader
7083            .seek(std::io::SeekFrom::End(0))
7084            .unwrap();
7085        request_value_reader
7086            .seek(std::io::SeekFrom::Start(0))
7087            .unwrap();
7088
7089        loop {
7090            let token = match self
7091                .hub
7092                .auth
7093                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7094                .await
7095            {
7096                Ok(token) => token,
7097                Err(e) => match dlg.token(e) {
7098                    Ok(token) => token,
7099                    Err(e) => {
7100                        dlg.finished(false);
7101                        return Err(common::Error::MissingToken(e));
7102                    }
7103                },
7104            };
7105            request_value_reader
7106                .seek(std::io::SeekFrom::Start(0))
7107                .unwrap();
7108            let mut req_result = {
7109                let client = &self.hub.client;
7110                dlg.pre_request();
7111                let mut req_builder = hyper::Request::builder()
7112                    .method(hyper::Method::POST)
7113                    .uri(url.as_str())
7114                    .header(USER_AGENT, self.hub._user_agent.clone());
7115
7116                if let Some(token) = token.as_ref() {
7117                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7118                }
7119
7120                let request = req_builder
7121                    .header(CONTENT_TYPE, json_mime_type.to_string())
7122                    .header(CONTENT_LENGTH, request_size as u64)
7123                    .body(common::to_body(
7124                        request_value_reader.get_ref().clone().into(),
7125                    ));
7126
7127                client.request(request.unwrap()).await
7128            };
7129
7130            match req_result {
7131                Err(err) => {
7132                    if let common::Retry::After(d) = dlg.http_error(&err) {
7133                        sleep(d).await;
7134                        continue;
7135                    }
7136                    dlg.finished(false);
7137                    return Err(common::Error::HttpError(err));
7138                }
7139                Ok(res) => {
7140                    let (mut parts, body) = res.into_parts();
7141                    let mut body = common::Body::new(body);
7142                    if !parts.status.is_success() {
7143                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7144                        let error = serde_json::from_str(&common::to_string(&bytes));
7145                        let response = common::to_response(parts, bytes.into());
7146
7147                        if let common::Retry::After(d) =
7148                            dlg.http_failure(&response, error.as_ref().ok())
7149                        {
7150                            sleep(d).await;
7151                            continue;
7152                        }
7153
7154                        dlg.finished(false);
7155
7156                        return Err(match error {
7157                            Ok(value) => common::Error::BadRequest(value),
7158                            _ => common::Error::Failure(response),
7159                        });
7160                    }
7161                    let response = {
7162                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7163                        let encoded = common::to_string(&bytes);
7164                        match serde_json::from_str(&encoded) {
7165                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7166                            Err(error) => {
7167                                dlg.response_json_decode_error(&encoded, &error);
7168                                return Err(common::Error::JsonDecodeError(
7169                                    encoded.to_string(),
7170                                    error,
7171                                ));
7172                            }
7173                        }
7174                    };
7175
7176                    dlg.finished(true);
7177                    return Ok(response);
7178                }
7179            }
7180        }
7181    }
7182
7183    ///
7184    /// Sets the *request* property to the given value.
7185    ///
7186    /// Even though the property as already been set when instantiating this call,
7187    /// we provide this method for API completeness.
7188    pub fn request(
7189        mut self,
7190        new_value: RunAggregationQueryRequest,
7191    ) -> ProjectRunAggregationQueryCall<'a, C> {
7192        self._request = new_value;
7193        self
7194    }
7195    /// Required. The ID of the project against which to make the request.
7196    ///
7197    /// Sets the *project id* path property to the given value.
7198    ///
7199    /// Even though the property as already been set when instantiating this call,
7200    /// we provide this method for API completeness.
7201    pub fn project_id(mut self, new_value: &str) -> ProjectRunAggregationQueryCall<'a, C> {
7202        self._project_id = new_value.to_string();
7203        self
7204    }
7205    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7206    /// while executing the actual API request.
7207    ///
7208    /// ````text
7209    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7210    /// ````
7211    ///
7212    /// Sets the *delegate* property to the given value.
7213    pub fn delegate(
7214        mut self,
7215        new_value: &'a mut dyn common::Delegate,
7216    ) -> ProjectRunAggregationQueryCall<'a, C> {
7217        self._delegate = Some(new_value);
7218        self
7219    }
7220
7221    /// Set any additional parameter of the query string used in the request.
7222    /// It should be used to set parameters which are not yet available through their own
7223    /// setters.
7224    ///
7225    /// Please note that this method must not be used to set any of the known parameters
7226    /// which have their own setter method. If done anyway, the request will fail.
7227    ///
7228    /// # Additional Parameters
7229    ///
7230    /// * *$.xgafv* (query-string) - V1 error format.
7231    /// * *access_token* (query-string) - OAuth access token.
7232    /// * *alt* (query-string) - Data format for response.
7233    /// * *callback* (query-string) - JSONP
7234    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7235    /// * *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.
7236    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7237    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7238    /// * *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.
7239    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7240    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7241    pub fn param<T>(mut self, name: T, value: T) -> ProjectRunAggregationQueryCall<'a, C>
7242    where
7243        T: AsRef<str>,
7244    {
7245        self._additional_params
7246            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7247        self
7248    }
7249
7250    /// Identifies the authorization scope for the method you are building.
7251    ///
7252    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7253    /// [`Scope::CloudPlatform`].
7254    ///
7255    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7256    /// tokens for more than one scope.
7257    ///
7258    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7259    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7260    /// sufficient, a read-write scope will do as well.
7261    pub fn add_scope<St>(mut self, scope: St) -> ProjectRunAggregationQueryCall<'a, C>
7262    where
7263        St: AsRef<str>,
7264    {
7265        self._scopes.insert(String::from(scope.as_ref()));
7266        self
7267    }
7268    /// Identifies the authorization scope(s) for the method you are building.
7269    ///
7270    /// See [`Self::add_scope()`] for details.
7271    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectRunAggregationQueryCall<'a, C>
7272    where
7273        I: IntoIterator<Item = St>,
7274        St: AsRef<str>,
7275    {
7276        self._scopes
7277            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7278        self
7279    }
7280
7281    /// Removes all scopes, and no default scope will be used either.
7282    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7283    /// for details).
7284    pub fn clear_scopes(mut self) -> ProjectRunAggregationQueryCall<'a, C> {
7285        self._scopes.clear();
7286        self
7287    }
7288}
7289
7290/// Queries for entities.
7291///
7292/// A builder for the *runQuery* method supported by a *project* resource.
7293/// It is not used directly, but through a [`ProjectMethods`] instance.
7294///
7295/// # Example
7296///
7297/// Instantiate a resource method builder
7298///
7299/// ```test_harness,no_run
7300/// # extern crate hyper;
7301/// # extern crate hyper_rustls;
7302/// # extern crate google_datastore1 as datastore1;
7303/// use datastore1::api::RunQueryRequest;
7304/// # async fn dox() {
7305/// # use datastore1::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7306///
7307/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7308/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7309/// #     secret,
7310/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7311/// # ).build().await.unwrap();
7312///
7313/// # let client = hyper_util::client::legacy::Client::builder(
7314/// #     hyper_util::rt::TokioExecutor::new()
7315/// # )
7316/// # .build(
7317/// #     hyper_rustls::HttpsConnectorBuilder::new()
7318/// #         .with_native_roots()
7319/// #         .unwrap()
7320/// #         .https_or_http()
7321/// #         .enable_http1()
7322/// #         .build()
7323/// # );
7324/// # let mut hub = Datastore::new(client, auth);
7325/// // As the method needs a request, you would usually fill it with the desired information
7326/// // into the respective structure. Some of the parts shown here might not be applicable !
7327/// // Values shown here are possibly random and not representative !
7328/// let mut req = RunQueryRequest::default();
7329///
7330/// // You can configure optional parameters by calling the respective setters at will, and
7331/// // execute the final call using `doit()`.
7332/// // Values shown here are possibly random and not representative !
7333/// let result = hub.projects().run_query(req, "projectId")
7334///              .doit().await;
7335/// # }
7336/// ```
7337pub struct ProjectRunQueryCall<'a, C>
7338where
7339    C: 'a,
7340{
7341    hub: &'a Datastore<C>,
7342    _request: RunQueryRequest,
7343    _project_id: String,
7344    _delegate: Option<&'a mut dyn common::Delegate>,
7345    _additional_params: HashMap<String, String>,
7346    _scopes: BTreeSet<String>,
7347}
7348
7349impl<'a, C> common::CallBuilder for ProjectRunQueryCall<'a, C> {}
7350
7351impl<'a, C> ProjectRunQueryCall<'a, C>
7352where
7353    C: common::Connector,
7354{
7355    /// Perform the operation you have build so far.
7356    pub async fn doit(mut self) -> common::Result<(common::Response, RunQueryResponse)> {
7357        use std::borrow::Cow;
7358        use std::io::{Read, Seek};
7359
7360        use common::{url::Params, ToParts};
7361        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7362
7363        let mut dd = common::DefaultDelegate;
7364        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7365        dlg.begin(common::MethodInfo {
7366            id: "datastore.projects.runQuery",
7367            http_method: hyper::Method::POST,
7368        });
7369
7370        for &field in ["alt", "projectId"].iter() {
7371            if self._additional_params.contains_key(field) {
7372                dlg.finished(false);
7373                return Err(common::Error::FieldClash(field));
7374            }
7375        }
7376
7377        let mut params = Params::with_capacity(4 + self._additional_params.len());
7378        params.push("projectId", self._project_id);
7379
7380        params.extend(self._additional_params.iter());
7381
7382        params.push("alt", "json");
7383        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:runQuery";
7384        if self._scopes.is_empty() {
7385            self._scopes
7386                .insert(Scope::CloudPlatform.as_ref().to_string());
7387        }
7388
7389        #[allow(clippy::single_element_loop)]
7390        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
7391            url = params.uri_replacement(url, param_name, find_this, false);
7392        }
7393        {
7394            let to_remove = ["projectId"];
7395            params.remove_params(&to_remove);
7396        }
7397
7398        let url = params.parse_with_url(&url);
7399
7400        let mut json_mime_type = mime::APPLICATION_JSON;
7401        let mut request_value_reader = {
7402            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7403            common::remove_json_null_values(&mut value);
7404            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7405            serde_json::to_writer(&mut dst, &value).unwrap();
7406            dst
7407        };
7408        let request_size = request_value_reader
7409            .seek(std::io::SeekFrom::End(0))
7410            .unwrap();
7411        request_value_reader
7412            .seek(std::io::SeekFrom::Start(0))
7413            .unwrap();
7414
7415        loop {
7416            let token = match self
7417                .hub
7418                .auth
7419                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7420                .await
7421            {
7422                Ok(token) => token,
7423                Err(e) => match dlg.token(e) {
7424                    Ok(token) => token,
7425                    Err(e) => {
7426                        dlg.finished(false);
7427                        return Err(common::Error::MissingToken(e));
7428                    }
7429                },
7430            };
7431            request_value_reader
7432                .seek(std::io::SeekFrom::Start(0))
7433                .unwrap();
7434            let mut req_result = {
7435                let client = &self.hub.client;
7436                dlg.pre_request();
7437                let mut req_builder = hyper::Request::builder()
7438                    .method(hyper::Method::POST)
7439                    .uri(url.as_str())
7440                    .header(USER_AGENT, self.hub._user_agent.clone());
7441
7442                if let Some(token) = token.as_ref() {
7443                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7444                }
7445
7446                let request = req_builder
7447                    .header(CONTENT_TYPE, json_mime_type.to_string())
7448                    .header(CONTENT_LENGTH, request_size as u64)
7449                    .body(common::to_body(
7450                        request_value_reader.get_ref().clone().into(),
7451                    ));
7452
7453                client.request(request.unwrap()).await
7454            };
7455
7456            match req_result {
7457                Err(err) => {
7458                    if let common::Retry::After(d) = dlg.http_error(&err) {
7459                        sleep(d).await;
7460                        continue;
7461                    }
7462                    dlg.finished(false);
7463                    return Err(common::Error::HttpError(err));
7464                }
7465                Ok(res) => {
7466                    let (mut parts, body) = res.into_parts();
7467                    let mut body = common::Body::new(body);
7468                    if !parts.status.is_success() {
7469                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7470                        let error = serde_json::from_str(&common::to_string(&bytes));
7471                        let response = common::to_response(parts, bytes.into());
7472
7473                        if let common::Retry::After(d) =
7474                            dlg.http_failure(&response, error.as_ref().ok())
7475                        {
7476                            sleep(d).await;
7477                            continue;
7478                        }
7479
7480                        dlg.finished(false);
7481
7482                        return Err(match error {
7483                            Ok(value) => common::Error::BadRequest(value),
7484                            _ => common::Error::Failure(response),
7485                        });
7486                    }
7487                    let response = {
7488                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7489                        let encoded = common::to_string(&bytes);
7490                        match serde_json::from_str(&encoded) {
7491                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7492                            Err(error) => {
7493                                dlg.response_json_decode_error(&encoded, &error);
7494                                return Err(common::Error::JsonDecodeError(
7495                                    encoded.to_string(),
7496                                    error,
7497                                ));
7498                            }
7499                        }
7500                    };
7501
7502                    dlg.finished(true);
7503                    return Ok(response);
7504                }
7505            }
7506        }
7507    }
7508
7509    ///
7510    /// Sets the *request* property to the given value.
7511    ///
7512    /// Even though the property as already been set when instantiating this call,
7513    /// we provide this method for API completeness.
7514    pub fn request(mut self, new_value: RunQueryRequest) -> ProjectRunQueryCall<'a, C> {
7515        self._request = new_value;
7516        self
7517    }
7518    /// Required. The ID of the project against which to make the request.
7519    ///
7520    /// Sets the *project id* path property to the given value.
7521    ///
7522    /// Even though the property as already been set when instantiating this call,
7523    /// we provide this method for API completeness.
7524    pub fn project_id(mut self, new_value: &str) -> ProjectRunQueryCall<'a, C> {
7525        self._project_id = new_value.to_string();
7526        self
7527    }
7528    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7529    /// while executing the actual API request.
7530    ///
7531    /// ````text
7532    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7533    /// ````
7534    ///
7535    /// Sets the *delegate* property to the given value.
7536    pub fn delegate(
7537        mut self,
7538        new_value: &'a mut dyn common::Delegate,
7539    ) -> ProjectRunQueryCall<'a, C> {
7540        self._delegate = Some(new_value);
7541        self
7542    }
7543
7544    /// Set any additional parameter of the query string used in the request.
7545    /// It should be used to set parameters which are not yet available through their own
7546    /// setters.
7547    ///
7548    /// Please note that this method must not be used to set any of the known parameters
7549    /// which have their own setter method. If done anyway, the request will fail.
7550    ///
7551    /// # Additional Parameters
7552    ///
7553    /// * *$.xgafv* (query-string) - V1 error format.
7554    /// * *access_token* (query-string) - OAuth access token.
7555    /// * *alt* (query-string) - Data format for response.
7556    /// * *callback* (query-string) - JSONP
7557    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7558    /// * *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.
7559    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7560    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7561    /// * *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.
7562    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7563    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7564    pub fn param<T>(mut self, name: T, value: T) -> ProjectRunQueryCall<'a, C>
7565    where
7566        T: AsRef<str>,
7567    {
7568        self._additional_params
7569            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7570        self
7571    }
7572
7573    /// Identifies the authorization scope for the method you are building.
7574    ///
7575    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7576    /// [`Scope::CloudPlatform`].
7577    ///
7578    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7579    /// tokens for more than one scope.
7580    ///
7581    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7582    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7583    /// sufficient, a read-write scope will do as well.
7584    pub fn add_scope<St>(mut self, scope: St) -> ProjectRunQueryCall<'a, C>
7585    where
7586        St: AsRef<str>,
7587    {
7588        self._scopes.insert(String::from(scope.as_ref()));
7589        self
7590    }
7591    /// Identifies the authorization scope(s) for the method you are building.
7592    ///
7593    /// See [`Self::add_scope()`] for details.
7594    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectRunQueryCall<'a, C>
7595    where
7596        I: IntoIterator<Item = St>,
7597        St: AsRef<str>,
7598    {
7599        self._scopes
7600            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7601        self
7602    }
7603
7604    /// Removes all scopes, and no default scope will be used either.
7605    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7606    /// for details).
7607    pub fn clear_scopes(mut self) -> ProjectRunQueryCall<'a, C> {
7608        self._scopes.clear();
7609        self
7610    }
7611}