google_datastore1_beta3/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_beta3 as datastore1_beta3;
53/// use datastore1_beta3::api::RunQueryRequest;
54/// use datastore1_beta3::{Result, Error};
55/// # async fn dox() {
56/// use datastore1_beta3::{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 = RunQueryRequest::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().run_query(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 /// Required. A list of keys with incomplete key paths for which to allocate IDs. No key may be reserved/read-only.
253 pub keys: Option<Vec<Key>>,
254}
255
256impl common::RequestValue for AllocateIdsRequest {}
257
258/// The response for Datastore.AllocateIds.
259///
260/// # Activities
261///
262/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
263/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
264///
265/// * [allocate ids projects](ProjectAllocateIdCall) (response)
266#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
267#[serde_with::serde_as]
268#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
269pub struct AllocateIdsResponse {
270 /// The keys specified in the request (in the same order), each with its key path completed with a newly allocated ID.
271 pub keys: Option<Vec<Key>>,
272}
273
274impl common::ResponseResult for AllocateIdsResponse {}
275
276/// An array value.
277///
278/// This type is not used in any activity, and only used as *part* of another schema.
279///
280#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
281#[serde_with::serde_as]
282#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
283pub struct ArrayValue {
284 /// 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'.
285 pub values: Option<Vec<Value>>,
286}
287
288impl common::Part for ArrayValue {}
289
290/// 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.
291///
292/// This type is not used in any activity, and only used as *part* of another schema.
293///
294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
295#[serde_with::serde_as]
296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
297pub struct Avg {
298 /// The property to aggregate on.
299 pub property: Option<PropertyReference>,
300}
301
302impl common::Part for Avg {}
303
304/// The request for Datastore.BeginTransaction.
305///
306/// # Activities
307///
308/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
309/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
310///
311/// * [begin transaction projects](ProjectBeginTransactionCall) (request)
312#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
313#[serde_with::serde_as]
314#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
315pub struct BeginTransactionRequest {
316 /// Options for a new transaction.
317 #[serde(rename = "transactionOptions")]
318 pub transaction_options: Option<TransactionOptions>,
319}
320
321impl common::RequestValue for BeginTransactionRequest {}
322
323/// The response for Datastore.BeginTransaction.
324///
325/// # Activities
326///
327/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
328/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
329///
330/// * [begin transaction projects](ProjectBeginTransactionCall) (response)
331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
332#[serde_with::serde_as]
333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
334pub struct BeginTransactionResponse {
335 /// The transaction identifier (always present).
336 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
337 pub transaction: Option<Vec<u8>>,
338}
339
340impl common::ResponseResult for BeginTransactionResponse {}
341
342/// The request for Datastore.Commit.
343///
344/// # Activities
345///
346/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
347/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
348///
349/// * [commit projects](ProjectCommitCall) (request)
350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
351#[serde_with::serde_as]
352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
353pub struct CommitRequest {
354 /// The type of commit to perform. Defaults to `TRANSACTIONAL`.
355 pub mode: Option<String>,
356 /// 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.
357 pub mutations: Option<Vec<Mutation>>,
358 /// The identifier of the transaction associated with the commit. A transaction identifier is returned by a call to Datastore.BeginTransaction.
359 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
360 pub transaction: Option<Vec<u8>>,
361}
362
363impl common::RequestValue for CommitRequest {}
364
365/// The response for Datastore.Commit.
366///
367/// # Activities
368///
369/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
370/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
371///
372/// * [commit projects](ProjectCommitCall) (response)
373#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
374#[serde_with::serde_as]
375#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
376pub struct CommitResponse {
377 /// The transaction commit timestamp. Not set for non-transactional commits.
378 #[serde(rename = "commitTime")]
379 pub commit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
380 /// The number of index entries updated during the commit, or zero if none were updated.
381 #[serde(rename = "indexUpdates")]
382 pub index_updates: Option<i32>,
383 /// The result of performing the mutations. The i-th mutation result corresponds to the i-th mutation in the request.
384 #[serde(rename = "mutationResults")]
385 pub mutation_results: Option<Vec<MutationResult>>,
386}
387
388impl common::ResponseResult for CommitResponse {}
389
390/// A filter that merges multiple other filters using the given operator.
391///
392/// This type is not used in any activity, and only used as *part* of another schema.
393///
394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
395#[serde_with::serde_as]
396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
397pub struct CompositeFilter {
398 /// The list of filters to combine. Requires: * At least one filter is present.
399 pub filters: Option<Vec<Filter>>,
400 /// The operator for combining multiple filters.
401 pub op: Option<String>,
402}
403
404impl common::Part for CompositeFilter {}
405
406/// Count of entities that match the query. The `COUNT(*)` aggregation function operates on the entire entity so it does not require a field reference.
407///
408/// This type is not used in any activity, and only used as *part* of another schema.
409///
410#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
411#[serde_with::serde_as]
412#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
413pub struct Count {
414 /// 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.
415 #[serde(rename = "upTo")]
416 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
417 pub up_to: Option<i64>,
418}
419
420impl common::Part for Count {}
421
422/// A Datastore data object. Must not exceed 1 MiB - 4 bytes.
423///
424/// This type is not used in any activity, and only used as *part* of another schema.
425///
426#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
427#[serde_with::serde_as]
428#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
429pub struct Entity {
430 /// 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.
431 pub key: Option<Key>,
432 /// 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.
433 pub properties: Option<HashMap<String, Value>>,
434}
435
436impl common::Part for Entity {}
437
438/// The result of fetching an entity from Datastore.
439///
440/// This type is not used in any activity, and only used as *part* of another schema.
441///
442#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
443#[serde_with::serde_as]
444#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
445pub struct EntityResult {
446 /// 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.
447 #[serde(rename = "createTime")]
448 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
449 /// A cursor that points to the position after the result entity. Set only when the `EntityResult` is part of a `QueryResultBatch` message.
450 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
451 pub cursor: Option<Vec<u8>>,
452 /// The resulting entity.
453 pub entity: Option<Entity>,
454 /// 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.
455 #[serde(rename = "updateTime")]
456 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
457 /// 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.
458 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
459 pub version: Option<i64>,
460}
461
462impl common::Part for EntityResult {}
463
464/// Execution statistics for the query.
465///
466/// This type is not used in any activity, and only used as *part* of another schema.
467///
468#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
469#[serde_with::serde_as]
470#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
471pub struct ExecutionStats {
472 /// 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" } }
473 #[serde(rename = "debugStats")]
474 pub debug_stats: Option<HashMap<String, serde_json::Value>>,
475 /// Total time to execute the query in the backend.
476 #[serde(rename = "executionDuration")]
477 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
478 pub execution_duration: Option<chrono::Duration>,
479 /// Total billable read operations.
480 #[serde(rename = "readOperations")]
481 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
482 pub read_operations: Option<i64>,
483 /// Total number of results returned, including documents, projections, aggregation results, keys.
484 #[serde(rename = "resultsReturned")]
485 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
486 pub results_returned: Option<i64>,
487}
488
489impl common::Part for ExecutionStats {}
490
491/// Explain metrics for the query.
492///
493/// This type is not used in any activity, and only used as *part* of another schema.
494///
495#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
496#[serde_with::serde_as]
497#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
498pub struct ExplainMetrics {
499 /// Aggregated stats from the execution of the query. Only present when ExplainOptions.analyze is set to true.
500 #[serde(rename = "executionStats")]
501 pub execution_stats: Option<ExecutionStats>,
502 /// Planning phase information for the query.
503 #[serde(rename = "planSummary")]
504 pub plan_summary: Option<PlanSummary>,
505}
506
507impl common::Part for ExplainMetrics {}
508
509/// Explain options for the query.
510///
511/// This type is not used in any activity, and only used as *part* of another schema.
512///
513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
514#[serde_with::serde_as]
515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
516pub struct ExplainOptions {
517 /// 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.
518 pub analyze: Option<bool>,
519}
520
521impl common::Part for ExplainOptions {}
522
523/// A holder for any type of filter.
524///
525/// This type is not used in any activity, and only used as *part* of another schema.
526///
527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
528#[serde_with::serde_as]
529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
530pub struct Filter {
531 /// A composite filter.
532 #[serde(rename = "compositeFilter")]
533 pub composite_filter: Option<CompositeFilter>,
534 /// A filter on a property.
535 #[serde(rename = "propertyFilter")]
536 pub property_filter: Option<PropertyFilter>,
537}
538
539impl common::Part for Filter {}
540
541/// A [GQL query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
542///
543/// This type is not used in any activity, and only used as *part* of another schema.
544///
545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
546#[serde_with::serde_as]
547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
548pub struct GqlQuery {
549 /// 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.
550 #[serde(rename = "allowLiterals")]
551 pub allow_literals: Option<bool>,
552 /// 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 `""`.
553 #[serde(rename = "namedBindings")]
554 pub named_bindings: Option<HashMap<String, GqlQueryParameter>>,
555 /// 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.
556 #[serde(rename = "positionalBindings")]
557 pub positional_bindings: Option<Vec<GqlQueryParameter>>,
558 /// A string of the format described [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
559 #[serde(rename = "queryString")]
560 pub query_string: Option<String>,
561}
562
563impl common::Part for GqlQuery {}
564
565/// A binding parameter for a GQL query.
566///
567/// This type is not used in any activity, and only used as *part* of another schema.
568///
569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
570#[serde_with::serde_as]
571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
572pub struct GqlQueryParameter {
573 /// A query cursor. Query cursors are returned in query result batches.
574 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
575 pub cursor: Option<Vec<u8>>,
576 /// A value parameter.
577 pub value: Option<Value>,
578}
579
580impl common::Part for GqlQueryParameter {}
581
582/// 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.
583///
584/// This type is not used in any activity, and only used as *part* of another schema.
585///
586#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
587#[serde_with::serde_as]
588#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
589pub struct Key {
590 /// Entities are partitioned into subsets, currently identified by a project ID and namespace ID. Queries are scoped to a single partition.
591 #[serde(rename = "partitionId")]
592 pub partition_id: Option<PartitionId>,
593 /// 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.
594 pub path: Option<Vec<PathElement>>,
595}
596
597impl common::Part for Key {}
598
599/// A representation of a kind.
600///
601/// This type is not used in any activity, and only used as *part* of another schema.
602///
603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
604#[serde_with::serde_as]
605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
606pub struct KindExpression {
607 /// The name of the kind.
608 pub name: Option<String>,
609}
610
611impl common::Part for KindExpression {}
612
613/// 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.
614///
615/// This type is not used in any activity, and only used as *part* of another schema.
616///
617#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
618#[serde_with::serde_as]
619#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
620pub struct LatLng {
621 /// The latitude in degrees. It must be in the range [-90.0, +90.0].
622 pub latitude: Option<f64>,
623 /// The longitude in degrees. It must be in the range [-180.0, +180.0].
624 pub longitude: Option<f64>,
625}
626
627impl common::Part for LatLng {}
628
629/// The request for Datastore.Lookup.
630///
631/// # Activities
632///
633/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
634/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
635///
636/// * [lookup projects](ProjectLookupCall) (request)
637#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
638#[serde_with::serde_as]
639#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
640pub struct LookupRequest {
641 /// Required. Keys of entities to look up.
642 pub keys: Option<Vec<Key>>,
643 /// 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.
644 #[serde(rename = "propertyMask")]
645 pub property_mask: Option<PropertyMask>,
646 /// The options for this lookup request.
647 #[serde(rename = "readOptions")]
648 pub read_options: Option<ReadOptions>,
649}
650
651impl common::RequestValue for LookupRequest {}
652
653/// The response for Datastore.Lookup.
654///
655/// # Activities
656///
657/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
658/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
659///
660/// * [lookup projects](ProjectLookupCall) (response)
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct LookupResponse {
665 /// 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.
666 pub deferred: Option<Vec<Key>>,
667 /// 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.
668 pub found: Option<Vec<EntityResult>>,
669 /// 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.
670 pub missing: Option<Vec<EntityResult>>,
671 /// The time at which these entities were read or found missing.
672 #[serde(rename = "readTime")]
673 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
674}
675
676impl common::ResponseResult for LookupResponse {}
677
678/// A mutation to apply to an entity.
679///
680/// This type is not used in any activity, and only used as *part* of another schema.
681///
682#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
683#[serde_with::serde_as]
684#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
685pub struct Mutation {
686 /// 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.
687 #[serde(rename = "baseVersion")]
688 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
689 pub base_version: Option<i64>,
690 /// 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.
691 pub delete: Option<Key>,
692 /// The entity to insert. The entity must not already exist. The entity key's final path element may be incomplete.
693 pub insert: Option<Entity>,
694 /// 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.
695 #[serde(rename = "propertyMask")]
696 pub property_mask: Option<PropertyMask>,
697 /// The entity to update. The entity must already exist. Must have a complete key path.
698 pub update: Option<Entity>,
699 /// 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.
700 #[serde(rename = "updateTime")]
701 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
702 /// The entity to upsert. The entity may or may not already exist. The entity key's final path element may be incomplete.
703 pub upsert: Option<Entity>,
704}
705
706impl common::Part for Mutation {}
707
708/// The result of applying a mutation.
709///
710/// This type is not used in any activity, and only used as *part* of another schema.
711///
712#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
713#[serde_with::serde_as]
714#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
715pub struct MutationResult {
716 /// Whether a conflict was detected for this mutation. Always false when a conflict detection strategy field is not set in the mutation.
717 #[serde(rename = "conflictDetected")]
718 pub conflict_detected: Option<bool>,
719 /// The create time of the entity. This field will not be set after a 'delete'.
720 #[serde(rename = "createTime")]
721 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
722 /// The automatically allocated key. Set only when the mutation allocated a key.
723 pub key: Option<Key>,
724 /// 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'.
725 #[serde(rename = "updateTime")]
726 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
727 /// 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.
728 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
729 pub version: Option<i64>,
730}
731
732impl common::Part for MutationResult {}
733
734/// 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.
735///
736/// This type is not used in any activity, and only used as *part* of another schema.
737///
738#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
739#[serde_with::serde_as]
740#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
741pub struct PartitionId {
742 /// If not empty, the ID of the namespace to which the entities belong.
743 #[serde(rename = "namespaceId")]
744 pub namespace_id: Option<String>,
745 /// The ID of the project to which the entities belong.
746 #[serde(rename = "projectId")]
747 pub project_id: Option<String>,
748}
749
750impl common::Part for PartitionId {}
751
752/// 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.
753///
754/// This type is not used in any activity, and only used as *part* of another schema.
755///
756#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
757#[serde_with::serde_as]
758#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
759pub struct PathElement {
760 /// 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.
761 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
762 pub id: Option<i64>,
763 /// 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.
764 pub kind: Option<String>,
765 /// 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.
766 pub name: Option<String>,
767}
768
769impl common::Part for PathElement {}
770
771/// Planning phase information for the query.
772///
773/// This type is not used in any activity, and only used as *part* of another schema.
774///
775#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
776#[serde_with::serde_as]
777#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
778pub struct PlanSummary {
779 /// The indexes selected for the query. For example: [ {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} ]
780 #[serde(rename = "indexesUsed")]
781 pub indexes_used: Option<Vec<HashMap<String, serde_json::Value>>>,
782}
783
784impl common::Part for PlanSummary {}
785
786/// A representation of a property in a projection.
787///
788/// This type is not used in any activity, and only used as *part* of another schema.
789///
790#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
791#[serde_with::serde_as]
792#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
793pub struct Projection {
794 /// The property to project.
795 pub property: Option<PropertyReference>,
796}
797
798impl common::Part for Projection {}
799
800/// A filter on a specific property.
801///
802/// This type is not used in any activity, and only used as *part* of another schema.
803///
804#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
805#[serde_with::serde_as]
806#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
807pub struct PropertyFilter {
808 /// The operator to filter by.
809 pub op: Option<String>,
810 /// The property to filter by.
811 pub property: Option<PropertyReference>,
812 /// The value to compare the property to.
813 pub value: Option<Value>,
814}
815
816impl common::Part for PropertyFilter {}
817
818/// The set of arbitrarily nested property paths used to restrict an operation to only a subset of properties in an entity.
819///
820/// This type is not used in any activity, and only used as *part* of another schema.
821///
822#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
823#[serde_with::serde_as]
824#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
825pub struct PropertyMask {
826 /// 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.
827 pub paths: Option<Vec<String>>,
828}
829
830impl common::Part for PropertyMask {}
831
832/// The desired order for a specific property.
833///
834/// This type is not used in any activity, and only used as *part* of another schema.
835///
836#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
837#[serde_with::serde_as]
838#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
839pub struct PropertyOrder {
840 /// The direction to order by. Defaults to `ASCENDING`.
841 pub direction: Option<String>,
842 /// The property to order by.
843 pub property: Option<PropertyReference>,
844}
845
846impl common::Part for PropertyOrder {}
847
848/// A reference to a property relative to the kind expressions.
849///
850/// This type is not used in any activity, and only used as *part* of another schema.
851///
852#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
853#[serde_with::serde_as]
854#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
855pub struct PropertyReference {
856 /// A reference to a property. Requires: * MUST be a dot-delimited (`.`) string of segments, where each segment conforms to entity property name limitations.
857 pub name: Option<String>,
858}
859
860impl common::Part for PropertyReference {}
861
862/// A query for entities.
863///
864/// This type is not used in any activity, and only used as *part* of another schema.
865///
866#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
867#[serde_with::serde_as]
868#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
869pub struct Query {
870 /// 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`.
871 #[serde(rename = "distinctOn")]
872 pub distinct_on: Option<Vec<PropertyReference>>,
873 /// 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).
874 #[serde(rename = "endCursor")]
875 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
876 pub end_cursor: Option<Vec<u8>>,
877 /// The filter to apply.
878 pub filter: Option<Filter>,
879 /// The kinds to query (if empty, returns entities of all kinds). Currently at most 1 kind may be specified.
880 pub kind: Option<Vec<KindExpression>>,
881 /// The maximum number of results to return. Applies after all other constraints. Optional. Unspecified is interpreted as no limit. Must be >= 0 if specified.
882 pub limit: Option<i32>,
883 /// The number of results to skip. Applies before limit, but after all other constraints. Optional. Must be >= 0 if specified.
884 pub offset: Option<i32>,
885 /// The order to apply to the query results (if empty, order is unspecified).
886 pub order: Option<Vec<PropertyOrder>>,
887 /// The projection to return. Defaults to returning all properties.
888 pub projection: Option<Vec<Projection>>,
889 /// 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).
890 #[serde(rename = "startCursor")]
891 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
892 pub start_cursor: Option<Vec<u8>>,
893}
894
895impl common::Part for Query {}
896
897/// A batch of results produced by a query.
898///
899/// This type is not used in any activity, and only used as *part* of another schema.
900///
901#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
902#[serde_with::serde_as]
903#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
904pub struct QueryResultBatch {
905 /// A cursor that points to the position after the last result in the batch.
906 #[serde(rename = "endCursor")]
907 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
908 pub end_cursor: Option<Vec<u8>>,
909 /// The result type for every entity in `entity_results`.
910 #[serde(rename = "entityResultType")]
911 pub entity_result_type: Option<String>,
912 /// The results for this batch.
913 #[serde(rename = "entityResults")]
914 pub entity_results: Option<Vec<EntityResult>>,
915 /// The state of the query after the current batch.
916 #[serde(rename = "moreResults")]
917 pub more_results: Option<String>,
918 /// 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.
919 #[serde(rename = "readTime")]
920 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
921 /// A cursor that points to the position after the last skipped result. Will be set when `skipped_results` != 0.
922 #[serde(rename = "skippedCursor")]
923 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
924 pub skipped_cursor: Option<Vec<u8>>,
925 /// The number of results skipped, typically because of an offset.
926 #[serde(rename = "skippedResults")]
927 pub skipped_results: Option<i32>,
928 /// 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.
929 #[serde(rename = "snapshotVersion")]
930 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
931 pub snapshot_version: Option<i64>,
932}
933
934impl common::Part for QueryResultBatch {}
935
936/// Options specific to read-only transactions.
937///
938/// This type is not used in any activity, and only used as *part* of another schema.
939///
940#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
941#[serde_with::serde_as]
942#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
943pub struct ReadOnly {
944 /// 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.
945 #[serde(rename = "readTime")]
946 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
947}
948
949impl common::Part for ReadOnly {}
950
951/// The options shared by read requests.
952///
953/// This type is not used in any activity, and only used as *part* of another schema.
954///
955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
956#[serde_with::serde_as]
957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
958pub struct ReadOptions {
959 /// The non-transactional read consistency to use.
960 #[serde(rename = "readConsistency")]
961 pub read_consistency: Option<String>,
962 /// 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.
963 #[serde(rename = "readTime")]
964 pub read_time: Option<chrono::DateTime<chrono::offset::Utc>>,
965 /// The identifier of the transaction in which to read. A transaction identifier is returned by a call to Datastore.BeginTransaction.
966 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
967 pub transaction: Option<Vec<u8>>,
968}
969
970impl common::Part for ReadOptions {}
971
972/// Options specific to read / write transactions.
973///
974/// This type is not used in any activity, and only used as *part* of another schema.
975///
976#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
977#[serde_with::serde_as]
978#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
979pub struct ReadWrite {
980 /// The transaction identifier of the transaction being retried.
981 #[serde(rename = "previousTransaction")]
982 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
983 pub previous_transaction: Option<Vec<u8>>,
984}
985
986impl common::Part for ReadWrite {}
987
988/// The request for Datastore.ReserveIds.
989///
990/// # Activities
991///
992/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
993/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
994///
995/// * [reserve ids projects](ProjectReserveIdCall) (request)
996#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
997#[serde_with::serde_as]
998#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
999pub struct ReserveIdsRequest {
1000 /// The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
1001 #[serde(rename = "databaseId")]
1002 pub database_id: Option<String>,
1003 /// Required. A list of keys with complete key paths whose numeric IDs should not be auto-allocated.
1004 pub keys: Option<Vec<Key>>,
1005}
1006
1007impl common::RequestValue for ReserveIdsRequest {}
1008
1009/// The response for Datastore.ReserveIds.
1010///
1011/// # Activities
1012///
1013/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1014/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1015///
1016/// * [reserve ids projects](ProjectReserveIdCall) (response)
1017#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1018#[serde_with::serde_as]
1019#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1020pub struct ReserveIdsResponse {
1021 _never_set: Option<bool>,
1022}
1023
1024impl common::ResponseResult for ReserveIdsResponse {}
1025
1026/// The request for Datastore.Rollback.
1027///
1028/// # Activities
1029///
1030/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1031/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1032///
1033/// * [rollback projects](ProjectRollbackCall) (request)
1034#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1035#[serde_with::serde_as]
1036#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1037pub struct RollbackRequest {
1038 /// Required. The transaction identifier, returned by a call to Datastore.BeginTransaction.
1039 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1040 pub transaction: Option<Vec<u8>>,
1041}
1042
1043impl common::RequestValue for RollbackRequest {}
1044
1045/// The response for Datastore.Rollback. (an empty message).
1046///
1047/// # Activities
1048///
1049/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1050/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1051///
1052/// * [rollback projects](ProjectRollbackCall) (response)
1053#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1054#[serde_with::serde_as]
1055#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1056pub struct RollbackResponse {
1057 _never_set: Option<bool>,
1058}
1059
1060impl common::ResponseResult for RollbackResponse {}
1061
1062/// The request for Datastore.RunAggregationQuery.
1063///
1064/// # Activities
1065///
1066/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1067/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1068///
1069/// * [run aggregation query projects](ProjectRunAggregationQueryCall) (request)
1070#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1071#[serde_with::serde_as]
1072#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1073pub struct RunAggregationQueryRequest {
1074 /// The query to run.
1075 #[serde(rename = "aggregationQuery")]
1076 pub aggregation_query: Option<AggregationQuery>,
1077 /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
1078 #[serde(rename = "explainOptions")]
1079 pub explain_options: Option<ExplainOptions>,
1080 /// The GQL query to run. This query must be an aggregation query.
1081 #[serde(rename = "gqlQuery")]
1082 pub gql_query: Option<GqlQuery>,
1083 /// 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.
1084 #[serde(rename = "partitionId")]
1085 pub partition_id: Option<PartitionId>,
1086 /// The options for this query.
1087 #[serde(rename = "readOptions")]
1088 pub read_options: Option<ReadOptions>,
1089}
1090
1091impl common::RequestValue for RunAggregationQueryRequest {}
1092
1093/// The response for Datastore.RunAggregationQuery.
1094///
1095/// # Activities
1096///
1097/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1098/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1099///
1100/// * [run aggregation query projects](ProjectRunAggregationQueryCall) (response)
1101#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1102#[serde_with::serde_as]
1103#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1104pub struct RunAggregationQueryResponse {
1105 /// A batch of aggregation results. Always present.
1106 pub batch: Option<AggregationResultBatch>,
1107 /// 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.
1108 #[serde(rename = "explainMetrics")]
1109 pub explain_metrics: Option<ExplainMetrics>,
1110 /// The parsed form of the `GqlQuery` from the request, if it was set.
1111 pub query: Option<AggregationQuery>,
1112}
1113
1114impl common::ResponseResult for RunAggregationQueryResponse {}
1115
1116/// The request for Datastore.RunQuery.
1117///
1118/// # Activities
1119///
1120/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1121/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1122///
1123/// * [run query projects](ProjectRunQueryCall) (request)
1124#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1125#[serde_with::serde_as]
1126#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1127pub struct RunQueryRequest {
1128 /// Optional. Explain options for the query. If set, additional query statistics will be returned. If not, only query results will be returned.
1129 #[serde(rename = "explainOptions")]
1130 pub explain_options: Option<ExplainOptions>,
1131 /// The GQL query to run. This query must be a non-aggregation query.
1132 #[serde(rename = "gqlQuery")]
1133 pub gql_query: Option<GqlQuery>,
1134 /// 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.
1135 #[serde(rename = "partitionId")]
1136 pub partition_id: Option<PartitionId>,
1137 /// The properties to return. This field must not be set for a projection query. See LookupRequest.property_mask.
1138 #[serde(rename = "propertyMask")]
1139 pub property_mask: Option<PropertyMask>,
1140 /// The query to run.
1141 pub query: Option<Query>,
1142 /// The options for this query.
1143 #[serde(rename = "readOptions")]
1144 pub read_options: Option<ReadOptions>,
1145}
1146
1147impl common::RequestValue for RunQueryRequest {}
1148
1149/// The response for Datastore.RunQuery.
1150///
1151/// # Activities
1152///
1153/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1154/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1155///
1156/// * [run query projects](ProjectRunQueryCall) (response)
1157#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1158#[serde_with::serde_as]
1159#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1160pub struct RunQueryResponse {
1161 /// A batch of query results (always present).
1162 pub batch: Option<QueryResultBatch>,
1163 /// 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.
1164 #[serde(rename = "explainMetrics")]
1165 pub explain_metrics: Option<ExplainMetrics>,
1166 /// The parsed form of the `GqlQuery` from the request, if it was set.
1167 pub query: Option<Query>,
1168}
1169
1170impl common::ResponseResult for RunQueryResponse {}
1171
1172/// 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.
1173///
1174/// This type is not used in any activity, and only used as *part* of another schema.
1175///
1176#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1177#[serde_with::serde_as]
1178#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1179pub struct Sum {
1180 /// The property to aggregate on.
1181 pub property: Option<PropertyReference>,
1182}
1183
1184impl common::Part for Sum {}
1185
1186/// 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.
1187///
1188/// This type is not used in any activity, and only used as *part* of another schema.
1189///
1190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1191#[serde_with::serde_as]
1192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1193pub struct TransactionOptions {
1194 /// The transaction should only allow reads.
1195 #[serde(rename = "readOnly")]
1196 pub read_only: Option<ReadOnly>,
1197 /// The transaction should allow both reads and writes.
1198 #[serde(rename = "readWrite")]
1199 pub read_write: Option<ReadWrite>,
1200}
1201
1202impl common::Part for TransactionOptions {}
1203
1204/// A message that can hold any of the supported value types and associated metadata.
1205///
1206/// This type is not used in any activity, and only used as *part* of another schema.
1207///
1208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1209#[serde_with::serde_as]
1210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1211pub struct Value {
1212 /// 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`.
1213 #[serde(rename = "arrayValue")]
1214 pub array_value: Option<ArrayValue>,
1215 /// 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.
1216 #[serde(rename = "blobValue")]
1217 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1218 pub blob_value: Option<Vec<u8>>,
1219 /// A boolean value.
1220 #[serde(rename = "booleanValue")]
1221 pub boolean_value: Option<bool>,
1222 /// A double value.
1223 #[serde(rename = "doubleValue")]
1224 pub double_value: Option<f64>,
1225 /// An entity value. - May have no key. - May have a key with an incomplete key path. - May have a reserved/read-only key.
1226 #[serde(rename = "entityValue")]
1227 pub entity_value: Option<Entity>,
1228 /// If the value should be excluded from all indexes including those defined explicitly.
1229 #[serde(rename = "excludeFromIndexes")]
1230 pub exclude_from_indexes: Option<bool>,
1231 /// A geo point value representing a point on the surface of Earth.
1232 #[serde(rename = "geoPointValue")]
1233 pub geo_point_value: Option<LatLng>,
1234 /// An integer value.
1235 #[serde(rename = "integerValue")]
1236 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1237 pub integer_value: Option<i64>,
1238 /// A key value.
1239 #[serde(rename = "keyValue")]
1240 pub key_value: Option<Key>,
1241 /// The `meaning` field should only be populated for backwards compatibility.
1242 pub meaning: Option<i32>,
1243 /// A null value.
1244 #[serde(rename = "nullValue")]
1245 pub null_value: Option<String>,
1246 /// 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.
1247 #[serde(rename = "stringValue")]
1248 pub string_value: Option<String>,
1249 /// A timestamp value. When stored in the Datastore, precise only to microseconds; any additional precision is rounded down.
1250 #[serde(rename = "timestampValue")]
1251 pub timestamp_value: Option<chrono::DateTime<chrono::offset::Utc>>,
1252}
1253
1254impl common::Part for Value {}
1255
1256// ###################
1257// MethodBuilders ###
1258// #################
1259
1260/// A builder providing access to all methods supported on *project* resources.
1261/// It is not used directly, but through the [`Datastore`] hub.
1262///
1263/// # Example
1264///
1265/// Instantiate a resource builder
1266///
1267/// ```test_harness,no_run
1268/// extern crate hyper;
1269/// extern crate hyper_rustls;
1270/// extern crate google_datastore1_beta3 as datastore1_beta3;
1271///
1272/// # async fn dox() {
1273/// use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1274///
1275/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1276/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1277/// secret,
1278/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1279/// ).build().await.unwrap();
1280///
1281/// let client = hyper_util::client::legacy::Client::builder(
1282/// hyper_util::rt::TokioExecutor::new()
1283/// )
1284/// .build(
1285/// hyper_rustls::HttpsConnectorBuilder::new()
1286/// .with_native_roots()
1287/// .unwrap()
1288/// .https_or_http()
1289/// .enable_http1()
1290/// .build()
1291/// );
1292/// let mut hub = Datastore::new(client, auth);
1293/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1294/// // like `allocate_ids(...)`, `begin_transaction(...)`, `commit(...)`, `lookup(...)`, `reserve_ids(...)`, `rollback(...)`, `run_aggregation_query(...)` and `run_query(...)`
1295/// // to build up your call.
1296/// let rb = hub.projects();
1297/// # }
1298/// ```
1299pub struct ProjectMethods<'a, C>
1300where
1301 C: 'a,
1302{
1303 hub: &'a Datastore<C>,
1304}
1305
1306impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1307
1308impl<'a, C> ProjectMethods<'a, C> {
1309 /// Create a builder to help you perform the following task:
1310 ///
1311 /// Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
1312 ///
1313 /// # Arguments
1314 ///
1315 /// * `request` - No description provided.
1316 /// * `projectId` - Required. The ID of the project against which to make the request.
1317 pub fn allocate_ids(
1318 &self,
1319 request: AllocateIdsRequest,
1320 project_id: &str,
1321 ) -> ProjectAllocateIdCall<'a, C> {
1322 ProjectAllocateIdCall {
1323 hub: self.hub,
1324 _request: request,
1325 _project_id: project_id.to_string(),
1326 _delegate: Default::default(),
1327 _additional_params: Default::default(),
1328 _scopes: Default::default(),
1329 }
1330 }
1331
1332 /// Create a builder to help you perform the following task:
1333 ///
1334 /// Begins a new transaction.
1335 ///
1336 /// # Arguments
1337 ///
1338 /// * `request` - No description provided.
1339 /// * `projectId` - Required. The ID of the project against which to make the request.
1340 pub fn begin_transaction(
1341 &self,
1342 request: BeginTransactionRequest,
1343 project_id: &str,
1344 ) -> ProjectBeginTransactionCall<'a, C> {
1345 ProjectBeginTransactionCall {
1346 hub: self.hub,
1347 _request: request,
1348 _project_id: project_id.to_string(),
1349 _delegate: Default::default(),
1350 _additional_params: Default::default(),
1351 _scopes: Default::default(),
1352 }
1353 }
1354
1355 /// Create a builder to help you perform the following task:
1356 ///
1357 /// Commits a transaction, optionally creating, deleting or modifying some entities.
1358 ///
1359 /// # Arguments
1360 ///
1361 /// * `request` - No description provided.
1362 /// * `projectId` - Required. The ID of the project against which to make the request.
1363 pub fn commit(&self, request: CommitRequest, project_id: &str) -> ProjectCommitCall<'a, C> {
1364 ProjectCommitCall {
1365 hub: self.hub,
1366 _request: request,
1367 _project_id: project_id.to_string(),
1368 _delegate: Default::default(),
1369 _additional_params: Default::default(),
1370 _scopes: Default::default(),
1371 }
1372 }
1373
1374 /// Create a builder to help you perform the following task:
1375 ///
1376 /// Looks up entities by key.
1377 ///
1378 /// # Arguments
1379 ///
1380 /// * `request` - No description provided.
1381 /// * `projectId` - Required. The ID of the project against which to make the request.
1382 pub fn lookup(&self, request: LookupRequest, project_id: &str) -> ProjectLookupCall<'a, C> {
1383 ProjectLookupCall {
1384 hub: self.hub,
1385 _request: request,
1386 _project_id: project_id.to_string(),
1387 _delegate: Default::default(),
1388 _additional_params: Default::default(),
1389 _scopes: Default::default(),
1390 }
1391 }
1392
1393 /// Create a builder to help you perform the following task:
1394 ///
1395 /// Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
1396 ///
1397 /// # Arguments
1398 ///
1399 /// * `request` - No description provided.
1400 /// * `projectId` - Required. The ID of the project against which to make the request.
1401 pub fn reserve_ids(
1402 &self,
1403 request: ReserveIdsRequest,
1404 project_id: &str,
1405 ) -> ProjectReserveIdCall<'a, C> {
1406 ProjectReserveIdCall {
1407 hub: self.hub,
1408 _request: request,
1409 _project_id: project_id.to_string(),
1410 _delegate: Default::default(),
1411 _additional_params: Default::default(),
1412 _scopes: Default::default(),
1413 }
1414 }
1415
1416 /// Create a builder to help you perform the following task:
1417 ///
1418 /// Rolls back a transaction.
1419 ///
1420 /// # Arguments
1421 ///
1422 /// * `request` - No description provided.
1423 /// * `projectId` - Required. The ID of the project against which to make the request.
1424 pub fn rollback(
1425 &self,
1426 request: RollbackRequest,
1427 project_id: &str,
1428 ) -> ProjectRollbackCall<'a, C> {
1429 ProjectRollbackCall {
1430 hub: self.hub,
1431 _request: request,
1432 _project_id: project_id.to_string(),
1433 _delegate: Default::default(),
1434 _additional_params: Default::default(),
1435 _scopes: Default::default(),
1436 }
1437 }
1438
1439 /// Create a builder to help you perform the following task:
1440 ///
1441 /// Runs an aggregation query.
1442 ///
1443 /// # Arguments
1444 ///
1445 /// * `request` - No description provided.
1446 /// * `projectId` - Required. The ID of the project against which to make the request.
1447 pub fn run_aggregation_query(
1448 &self,
1449 request: RunAggregationQueryRequest,
1450 project_id: &str,
1451 ) -> ProjectRunAggregationQueryCall<'a, C> {
1452 ProjectRunAggregationQueryCall {
1453 hub: self.hub,
1454 _request: request,
1455 _project_id: project_id.to_string(),
1456 _delegate: Default::default(),
1457 _additional_params: Default::default(),
1458 _scopes: Default::default(),
1459 }
1460 }
1461
1462 /// Create a builder to help you perform the following task:
1463 ///
1464 /// Queries for entities.
1465 ///
1466 /// # Arguments
1467 ///
1468 /// * `request` - No description provided.
1469 /// * `projectId` - Required. The ID of the project against which to make the request.
1470 pub fn run_query(
1471 &self,
1472 request: RunQueryRequest,
1473 project_id: &str,
1474 ) -> ProjectRunQueryCall<'a, C> {
1475 ProjectRunQueryCall {
1476 hub: self.hub,
1477 _request: request,
1478 _project_id: project_id.to_string(),
1479 _delegate: Default::default(),
1480 _additional_params: Default::default(),
1481 _scopes: Default::default(),
1482 }
1483 }
1484}
1485
1486// ###################
1487// CallBuilders ###
1488// #################
1489
1490/// Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
1491///
1492/// A builder for the *allocateIds* method supported by a *project* resource.
1493/// It is not used directly, but through a [`ProjectMethods`] instance.
1494///
1495/// # Example
1496///
1497/// Instantiate a resource method builder
1498///
1499/// ```test_harness,no_run
1500/// # extern crate hyper;
1501/// # extern crate hyper_rustls;
1502/// # extern crate google_datastore1_beta3 as datastore1_beta3;
1503/// use datastore1_beta3::api::AllocateIdsRequest;
1504/// # async fn dox() {
1505/// # use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1506///
1507/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1508/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1509/// # secret,
1510/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1511/// # ).build().await.unwrap();
1512///
1513/// # let client = hyper_util::client::legacy::Client::builder(
1514/// # hyper_util::rt::TokioExecutor::new()
1515/// # )
1516/// # .build(
1517/// # hyper_rustls::HttpsConnectorBuilder::new()
1518/// # .with_native_roots()
1519/// # .unwrap()
1520/// # .https_or_http()
1521/// # .enable_http1()
1522/// # .build()
1523/// # );
1524/// # let mut hub = Datastore::new(client, auth);
1525/// // As the method needs a request, you would usually fill it with the desired information
1526/// // into the respective structure. Some of the parts shown here might not be applicable !
1527/// // Values shown here are possibly random and not representative !
1528/// let mut req = AllocateIdsRequest::default();
1529///
1530/// // You can configure optional parameters by calling the respective setters at will, and
1531/// // execute the final call using `doit()`.
1532/// // Values shown here are possibly random and not representative !
1533/// let result = hub.projects().allocate_ids(req, "projectId")
1534/// .doit().await;
1535/// # }
1536/// ```
1537pub struct ProjectAllocateIdCall<'a, C>
1538where
1539 C: 'a,
1540{
1541 hub: &'a Datastore<C>,
1542 _request: AllocateIdsRequest,
1543 _project_id: String,
1544 _delegate: Option<&'a mut dyn common::Delegate>,
1545 _additional_params: HashMap<String, String>,
1546 _scopes: BTreeSet<String>,
1547}
1548
1549impl<'a, C> common::CallBuilder for ProjectAllocateIdCall<'a, C> {}
1550
1551impl<'a, C> ProjectAllocateIdCall<'a, C>
1552where
1553 C: common::Connector,
1554{
1555 /// Perform the operation you have build so far.
1556 pub async fn doit(mut self) -> common::Result<(common::Response, AllocateIdsResponse)> {
1557 use std::borrow::Cow;
1558 use std::io::{Read, Seek};
1559
1560 use common::{url::Params, ToParts};
1561 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1562
1563 let mut dd = common::DefaultDelegate;
1564 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1565 dlg.begin(common::MethodInfo {
1566 id: "datastore.projects.allocateIds",
1567 http_method: hyper::Method::POST,
1568 });
1569
1570 for &field in ["alt", "projectId"].iter() {
1571 if self._additional_params.contains_key(field) {
1572 dlg.finished(false);
1573 return Err(common::Error::FieldClash(field));
1574 }
1575 }
1576
1577 let mut params = Params::with_capacity(4 + self._additional_params.len());
1578 params.push("projectId", self._project_id);
1579
1580 params.extend(self._additional_params.iter());
1581
1582 params.push("alt", "json");
1583 let mut url = self.hub._base_url.clone() + "v1beta3/projects/{projectId}:allocateIds";
1584 if self._scopes.is_empty() {
1585 self._scopes
1586 .insert(Scope::CloudPlatform.as_ref().to_string());
1587 }
1588
1589 #[allow(clippy::single_element_loop)]
1590 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
1591 url = params.uri_replacement(url, param_name, find_this, false);
1592 }
1593 {
1594 let to_remove = ["projectId"];
1595 params.remove_params(&to_remove);
1596 }
1597
1598 let url = params.parse_with_url(&url);
1599
1600 let mut json_mime_type = mime::APPLICATION_JSON;
1601 let mut request_value_reader = {
1602 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1603 common::remove_json_null_values(&mut value);
1604 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1605 serde_json::to_writer(&mut dst, &value).unwrap();
1606 dst
1607 };
1608 let request_size = request_value_reader
1609 .seek(std::io::SeekFrom::End(0))
1610 .unwrap();
1611 request_value_reader
1612 .seek(std::io::SeekFrom::Start(0))
1613 .unwrap();
1614
1615 loop {
1616 let token = match self
1617 .hub
1618 .auth
1619 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1620 .await
1621 {
1622 Ok(token) => token,
1623 Err(e) => match dlg.token(e) {
1624 Ok(token) => token,
1625 Err(e) => {
1626 dlg.finished(false);
1627 return Err(common::Error::MissingToken(e));
1628 }
1629 },
1630 };
1631 request_value_reader
1632 .seek(std::io::SeekFrom::Start(0))
1633 .unwrap();
1634 let mut req_result = {
1635 let client = &self.hub.client;
1636 dlg.pre_request();
1637 let mut req_builder = hyper::Request::builder()
1638 .method(hyper::Method::POST)
1639 .uri(url.as_str())
1640 .header(USER_AGENT, self.hub._user_agent.clone());
1641
1642 if let Some(token) = token.as_ref() {
1643 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1644 }
1645
1646 let request = req_builder
1647 .header(CONTENT_TYPE, json_mime_type.to_string())
1648 .header(CONTENT_LENGTH, request_size as u64)
1649 .body(common::to_body(
1650 request_value_reader.get_ref().clone().into(),
1651 ));
1652
1653 client.request(request.unwrap()).await
1654 };
1655
1656 match req_result {
1657 Err(err) => {
1658 if let common::Retry::After(d) = dlg.http_error(&err) {
1659 sleep(d).await;
1660 continue;
1661 }
1662 dlg.finished(false);
1663 return Err(common::Error::HttpError(err));
1664 }
1665 Ok(res) => {
1666 let (mut parts, body) = res.into_parts();
1667 let mut body = common::Body::new(body);
1668 if !parts.status.is_success() {
1669 let bytes = common::to_bytes(body).await.unwrap_or_default();
1670 let error = serde_json::from_str(&common::to_string(&bytes));
1671 let response = common::to_response(parts, bytes.into());
1672
1673 if let common::Retry::After(d) =
1674 dlg.http_failure(&response, error.as_ref().ok())
1675 {
1676 sleep(d).await;
1677 continue;
1678 }
1679
1680 dlg.finished(false);
1681
1682 return Err(match error {
1683 Ok(value) => common::Error::BadRequest(value),
1684 _ => common::Error::Failure(response),
1685 });
1686 }
1687 let response = {
1688 let bytes = common::to_bytes(body).await.unwrap_or_default();
1689 let encoded = common::to_string(&bytes);
1690 match serde_json::from_str(&encoded) {
1691 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1692 Err(error) => {
1693 dlg.response_json_decode_error(&encoded, &error);
1694 return Err(common::Error::JsonDecodeError(
1695 encoded.to_string(),
1696 error,
1697 ));
1698 }
1699 }
1700 };
1701
1702 dlg.finished(true);
1703 return Ok(response);
1704 }
1705 }
1706 }
1707 }
1708
1709 ///
1710 /// Sets the *request* property to the given value.
1711 ///
1712 /// Even though the property as already been set when instantiating this call,
1713 /// we provide this method for API completeness.
1714 pub fn request(mut self, new_value: AllocateIdsRequest) -> ProjectAllocateIdCall<'a, C> {
1715 self._request = new_value;
1716 self
1717 }
1718 /// Required. The ID of the project against which to make the request.
1719 ///
1720 /// Sets the *project id* path property to the given value.
1721 ///
1722 /// Even though the property as already been set when instantiating this call,
1723 /// we provide this method for API completeness.
1724 pub fn project_id(mut self, new_value: &str) -> ProjectAllocateIdCall<'a, C> {
1725 self._project_id = new_value.to_string();
1726 self
1727 }
1728 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1729 /// while executing the actual API request.
1730 ///
1731 /// ````text
1732 /// It should be used to handle progress information, and to implement a certain level of resilience.
1733 /// ````
1734 ///
1735 /// Sets the *delegate* property to the given value.
1736 pub fn delegate(
1737 mut self,
1738 new_value: &'a mut dyn common::Delegate,
1739 ) -> ProjectAllocateIdCall<'a, C> {
1740 self._delegate = Some(new_value);
1741 self
1742 }
1743
1744 /// Set any additional parameter of the query string used in the request.
1745 /// It should be used to set parameters which are not yet available through their own
1746 /// setters.
1747 ///
1748 /// Please note that this method must not be used to set any of the known parameters
1749 /// which have their own setter method. If done anyway, the request will fail.
1750 ///
1751 /// # Additional Parameters
1752 ///
1753 /// * *$.xgafv* (query-string) - V1 error format.
1754 /// * *access_token* (query-string) - OAuth access token.
1755 /// * *alt* (query-string) - Data format for response.
1756 /// * *callback* (query-string) - JSONP
1757 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1758 /// * *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.
1759 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1760 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1761 /// * *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.
1762 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1763 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1764 pub fn param<T>(mut self, name: T, value: T) -> ProjectAllocateIdCall<'a, C>
1765 where
1766 T: AsRef<str>,
1767 {
1768 self._additional_params
1769 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1770 self
1771 }
1772
1773 /// Identifies the authorization scope for the method you are building.
1774 ///
1775 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1776 /// [`Scope::CloudPlatform`].
1777 ///
1778 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1779 /// tokens for more than one scope.
1780 ///
1781 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1782 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1783 /// sufficient, a read-write scope will do as well.
1784 pub fn add_scope<St>(mut self, scope: St) -> ProjectAllocateIdCall<'a, C>
1785 where
1786 St: AsRef<str>,
1787 {
1788 self._scopes.insert(String::from(scope.as_ref()));
1789 self
1790 }
1791 /// Identifies the authorization scope(s) for the method you are building.
1792 ///
1793 /// See [`Self::add_scope()`] for details.
1794 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAllocateIdCall<'a, C>
1795 where
1796 I: IntoIterator<Item = St>,
1797 St: AsRef<str>,
1798 {
1799 self._scopes
1800 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1801 self
1802 }
1803
1804 /// Removes all scopes, and no default scope will be used either.
1805 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1806 /// for details).
1807 pub fn clear_scopes(mut self) -> ProjectAllocateIdCall<'a, C> {
1808 self._scopes.clear();
1809 self
1810 }
1811}
1812
1813/// Begins a new transaction.
1814///
1815/// A builder for the *beginTransaction* method supported by a *project* resource.
1816/// It is not used directly, but through a [`ProjectMethods`] instance.
1817///
1818/// # Example
1819///
1820/// Instantiate a resource method builder
1821///
1822/// ```test_harness,no_run
1823/// # extern crate hyper;
1824/// # extern crate hyper_rustls;
1825/// # extern crate google_datastore1_beta3 as datastore1_beta3;
1826/// use datastore1_beta3::api::BeginTransactionRequest;
1827/// # async fn dox() {
1828/// # use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1829///
1830/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1831/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1832/// # secret,
1833/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1834/// # ).build().await.unwrap();
1835///
1836/// # let client = hyper_util::client::legacy::Client::builder(
1837/// # hyper_util::rt::TokioExecutor::new()
1838/// # )
1839/// # .build(
1840/// # hyper_rustls::HttpsConnectorBuilder::new()
1841/// # .with_native_roots()
1842/// # .unwrap()
1843/// # .https_or_http()
1844/// # .enable_http1()
1845/// # .build()
1846/// # );
1847/// # let mut hub = Datastore::new(client, auth);
1848/// // As the method needs a request, you would usually fill it with the desired information
1849/// // into the respective structure. Some of the parts shown here might not be applicable !
1850/// // Values shown here are possibly random and not representative !
1851/// let mut req = BeginTransactionRequest::default();
1852///
1853/// // You can configure optional parameters by calling the respective setters at will, and
1854/// // execute the final call using `doit()`.
1855/// // Values shown here are possibly random and not representative !
1856/// let result = hub.projects().begin_transaction(req, "projectId")
1857/// .doit().await;
1858/// # }
1859/// ```
1860pub struct ProjectBeginTransactionCall<'a, C>
1861where
1862 C: 'a,
1863{
1864 hub: &'a Datastore<C>,
1865 _request: BeginTransactionRequest,
1866 _project_id: String,
1867 _delegate: Option<&'a mut dyn common::Delegate>,
1868 _additional_params: HashMap<String, String>,
1869 _scopes: BTreeSet<String>,
1870}
1871
1872impl<'a, C> common::CallBuilder for ProjectBeginTransactionCall<'a, C> {}
1873
1874impl<'a, C> ProjectBeginTransactionCall<'a, C>
1875where
1876 C: common::Connector,
1877{
1878 /// Perform the operation you have build so far.
1879 pub async fn doit(mut self) -> common::Result<(common::Response, BeginTransactionResponse)> {
1880 use std::borrow::Cow;
1881 use std::io::{Read, Seek};
1882
1883 use common::{url::Params, ToParts};
1884 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1885
1886 let mut dd = common::DefaultDelegate;
1887 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1888 dlg.begin(common::MethodInfo {
1889 id: "datastore.projects.beginTransaction",
1890 http_method: hyper::Method::POST,
1891 });
1892
1893 for &field in ["alt", "projectId"].iter() {
1894 if self._additional_params.contains_key(field) {
1895 dlg.finished(false);
1896 return Err(common::Error::FieldClash(field));
1897 }
1898 }
1899
1900 let mut params = Params::with_capacity(4 + self._additional_params.len());
1901 params.push("projectId", self._project_id);
1902
1903 params.extend(self._additional_params.iter());
1904
1905 params.push("alt", "json");
1906 let mut url = self.hub._base_url.clone() + "v1beta3/projects/{projectId}:beginTransaction";
1907 if self._scopes.is_empty() {
1908 self._scopes
1909 .insert(Scope::CloudPlatform.as_ref().to_string());
1910 }
1911
1912 #[allow(clippy::single_element_loop)]
1913 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
1914 url = params.uri_replacement(url, param_name, find_this, false);
1915 }
1916 {
1917 let to_remove = ["projectId"];
1918 params.remove_params(&to_remove);
1919 }
1920
1921 let url = params.parse_with_url(&url);
1922
1923 let mut json_mime_type = mime::APPLICATION_JSON;
1924 let mut request_value_reader = {
1925 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1926 common::remove_json_null_values(&mut value);
1927 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1928 serde_json::to_writer(&mut dst, &value).unwrap();
1929 dst
1930 };
1931 let request_size = request_value_reader
1932 .seek(std::io::SeekFrom::End(0))
1933 .unwrap();
1934 request_value_reader
1935 .seek(std::io::SeekFrom::Start(0))
1936 .unwrap();
1937
1938 loop {
1939 let token = match self
1940 .hub
1941 .auth
1942 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1943 .await
1944 {
1945 Ok(token) => token,
1946 Err(e) => match dlg.token(e) {
1947 Ok(token) => token,
1948 Err(e) => {
1949 dlg.finished(false);
1950 return Err(common::Error::MissingToken(e));
1951 }
1952 },
1953 };
1954 request_value_reader
1955 .seek(std::io::SeekFrom::Start(0))
1956 .unwrap();
1957 let mut req_result = {
1958 let client = &self.hub.client;
1959 dlg.pre_request();
1960 let mut req_builder = hyper::Request::builder()
1961 .method(hyper::Method::POST)
1962 .uri(url.as_str())
1963 .header(USER_AGENT, self.hub._user_agent.clone());
1964
1965 if let Some(token) = token.as_ref() {
1966 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1967 }
1968
1969 let request = req_builder
1970 .header(CONTENT_TYPE, json_mime_type.to_string())
1971 .header(CONTENT_LENGTH, request_size as u64)
1972 .body(common::to_body(
1973 request_value_reader.get_ref().clone().into(),
1974 ));
1975
1976 client.request(request.unwrap()).await
1977 };
1978
1979 match req_result {
1980 Err(err) => {
1981 if let common::Retry::After(d) = dlg.http_error(&err) {
1982 sleep(d).await;
1983 continue;
1984 }
1985 dlg.finished(false);
1986 return Err(common::Error::HttpError(err));
1987 }
1988 Ok(res) => {
1989 let (mut parts, body) = res.into_parts();
1990 let mut body = common::Body::new(body);
1991 if !parts.status.is_success() {
1992 let bytes = common::to_bytes(body).await.unwrap_or_default();
1993 let error = serde_json::from_str(&common::to_string(&bytes));
1994 let response = common::to_response(parts, bytes.into());
1995
1996 if let common::Retry::After(d) =
1997 dlg.http_failure(&response, error.as_ref().ok())
1998 {
1999 sleep(d).await;
2000 continue;
2001 }
2002
2003 dlg.finished(false);
2004
2005 return Err(match error {
2006 Ok(value) => common::Error::BadRequest(value),
2007 _ => common::Error::Failure(response),
2008 });
2009 }
2010 let response = {
2011 let bytes = common::to_bytes(body).await.unwrap_or_default();
2012 let encoded = common::to_string(&bytes);
2013 match serde_json::from_str(&encoded) {
2014 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2015 Err(error) => {
2016 dlg.response_json_decode_error(&encoded, &error);
2017 return Err(common::Error::JsonDecodeError(
2018 encoded.to_string(),
2019 error,
2020 ));
2021 }
2022 }
2023 };
2024
2025 dlg.finished(true);
2026 return Ok(response);
2027 }
2028 }
2029 }
2030 }
2031
2032 ///
2033 /// Sets the *request* property to the given value.
2034 ///
2035 /// Even though the property as already been set when instantiating this call,
2036 /// we provide this method for API completeness.
2037 pub fn request(
2038 mut self,
2039 new_value: BeginTransactionRequest,
2040 ) -> ProjectBeginTransactionCall<'a, C> {
2041 self._request = new_value;
2042 self
2043 }
2044 /// Required. The ID of the project against which to make the request.
2045 ///
2046 /// Sets the *project id* path property to the given value.
2047 ///
2048 /// Even though the property as already been set when instantiating this call,
2049 /// we provide this method for API completeness.
2050 pub fn project_id(mut self, new_value: &str) -> ProjectBeginTransactionCall<'a, C> {
2051 self._project_id = new_value.to_string();
2052 self
2053 }
2054 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2055 /// while executing the actual API request.
2056 ///
2057 /// ````text
2058 /// It should be used to handle progress information, and to implement a certain level of resilience.
2059 /// ````
2060 ///
2061 /// Sets the *delegate* property to the given value.
2062 pub fn delegate(
2063 mut self,
2064 new_value: &'a mut dyn common::Delegate,
2065 ) -> ProjectBeginTransactionCall<'a, C> {
2066 self._delegate = Some(new_value);
2067 self
2068 }
2069
2070 /// Set any additional parameter of the query string used in the request.
2071 /// It should be used to set parameters which are not yet available through their own
2072 /// setters.
2073 ///
2074 /// Please note that this method must not be used to set any of the known parameters
2075 /// which have their own setter method. If done anyway, the request will fail.
2076 ///
2077 /// # Additional Parameters
2078 ///
2079 /// * *$.xgafv* (query-string) - V1 error format.
2080 /// * *access_token* (query-string) - OAuth access token.
2081 /// * *alt* (query-string) - Data format for response.
2082 /// * *callback* (query-string) - JSONP
2083 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2084 /// * *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.
2085 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2086 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2087 /// * *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.
2088 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2089 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2090 pub fn param<T>(mut self, name: T, value: T) -> ProjectBeginTransactionCall<'a, C>
2091 where
2092 T: AsRef<str>,
2093 {
2094 self._additional_params
2095 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2096 self
2097 }
2098
2099 /// Identifies the authorization scope for the method you are building.
2100 ///
2101 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2102 /// [`Scope::CloudPlatform`].
2103 ///
2104 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2105 /// tokens for more than one scope.
2106 ///
2107 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2108 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2109 /// sufficient, a read-write scope will do as well.
2110 pub fn add_scope<St>(mut self, scope: St) -> ProjectBeginTransactionCall<'a, C>
2111 where
2112 St: AsRef<str>,
2113 {
2114 self._scopes.insert(String::from(scope.as_ref()));
2115 self
2116 }
2117 /// Identifies the authorization scope(s) for the method you are building.
2118 ///
2119 /// See [`Self::add_scope()`] for details.
2120 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBeginTransactionCall<'a, C>
2121 where
2122 I: IntoIterator<Item = St>,
2123 St: AsRef<str>,
2124 {
2125 self._scopes
2126 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2127 self
2128 }
2129
2130 /// Removes all scopes, and no default scope will be used either.
2131 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2132 /// for details).
2133 pub fn clear_scopes(mut self) -> ProjectBeginTransactionCall<'a, C> {
2134 self._scopes.clear();
2135 self
2136 }
2137}
2138
2139/// Commits a transaction, optionally creating, deleting or modifying some entities.
2140///
2141/// A builder for the *commit* method supported by a *project* resource.
2142/// It is not used directly, but through a [`ProjectMethods`] instance.
2143///
2144/// # Example
2145///
2146/// Instantiate a resource method builder
2147///
2148/// ```test_harness,no_run
2149/// # extern crate hyper;
2150/// # extern crate hyper_rustls;
2151/// # extern crate google_datastore1_beta3 as datastore1_beta3;
2152/// use datastore1_beta3::api::CommitRequest;
2153/// # async fn dox() {
2154/// # use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2155///
2156/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2157/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2158/// # secret,
2159/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2160/// # ).build().await.unwrap();
2161///
2162/// # let client = hyper_util::client::legacy::Client::builder(
2163/// # hyper_util::rt::TokioExecutor::new()
2164/// # )
2165/// # .build(
2166/// # hyper_rustls::HttpsConnectorBuilder::new()
2167/// # .with_native_roots()
2168/// # .unwrap()
2169/// # .https_or_http()
2170/// # .enable_http1()
2171/// # .build()
2172/// # );
2173/// # let mut hub = Datastore::new(client, auth);
2174/// // As the method needs a request, you would usually fill it with the desired information
2175/// // into the respective structure. Some of the parts shown here might not be applicable !
2176/// // Values shown here are possibly random and not representative !
2177/// let mut req = CommitRequest::default();
2178///
2179/// // You can configure optional parameters by calling the respective setters at will, and
2180/// // execute the final call using `doit()`.
2181/// // Values shown here are possibly random and not representative !
2182/// let result = hub.projects().commit(req, "projectId")
2183/// .doit().await;
2184/// # }
2185/// ```
2186pub struct ProjectCommitCall<'a, C>
2187where
2188 C: 'a,
2189{
2190 hub: &'a Datastore<C>,
2191 _request: CommitRequest,
2192 _project_id: String,
2193 _delegate: Option<&'a mut dyn common::Delegate>,
2194 _additional_params: HashMap<String, String>,
2195 _scopes: BTreeSet<String>,
2196}
2197
2198impl<'a, C> common::CallBuilder for ProjectCommitCall<'a, C> {}
2199
2200impl<'a, C> ProjectCommitCall<'a, C>
2201where
2202 C: common::Connector,
2203{
2204 /// Perform the operation you have build so far.
2205 pub async fn doit(mut self) -> common::Result<(common::Response, CommitResponse)> {
2206 use std::borrow::Cow;
2207 use std::io::{Read, Seek};
2208
2209 use common::{url::Params, ToParts};
2210 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2211
2212 let mut dd = common::DefaultDelegate;
2213 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2214 dlg.begin(common::MethodInfo {
2215 id: "datastore.projects.commit",
2216 http_method: hyper::Method::POST,
2217 });
2218
2219 for &field in ["alt", "projectId"].iter() {
2220 if self._additional_params.contains_key(field) {
2221 dlg.finished(false);
2222 return Err(common::Error::FieldClash(field));
2223 }
2224 }
2225
2226 let mut params = Params::with_capacity(4 + self._additional_params.len());
2227 params.push("projectId", self._project_id);
2228
2229 params.extend(self._additional_params.iter());
2230
2231 params.push("alt", "json");
2232 let mut url = self.hub._base_url.clone() + "v1beta3/projects/{projectId}:commit";
2233 if self._scopes.is_empty() {
2234 self._scopes
2235 .insert(Scope::CloudPlatform.as_ref().to_string());
2236 }
2237
2238 #[allow(clippy::single_element_loop)]
2239 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
2240 url = params.uri_replacement(url, param_name, find_this, false);
2241 }
2242 {
2243 let to_remove = ["projectId"];
2244 params.remove_params(&to_remove);
2245 }
2246
2247 let url = params.parse_with_url(&url);
2248
2249 let mut json_mime_type = mime::APPLICATION_JSON;
2250 let mut request_value_reader = {
2251 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2252 common::remove_json_null_values(&mut value);
2253 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2254 serde_json::to_writer(&mut dst, &value).unwrap();
2255 dst
2256 };
2257 let request_size = request_value_reader
2258 .seek(std::io::SeekFrom::End(0))
2259 .unwrap();
2260 request_value_reader
2261 .seek(std::io::SeekFrom::Start(0))
2262 .unwrap();
2263
2264 loop {
2265 let token = match self
2266 .hub
2267 .auth
2268 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2269 .await
2270 {
2271 Ok(token) => token,
2272 Err(e) => match dlg.token(e) {
2273 Ok(token) => token,
2274 Err(e) => {
2275 dlg.finished(false);
2276 return Err(common::Error::MissingToken(e));
2277 }
2278 },
2279 };
2280 request_value_reader
2281 .seek(std::io::SeekFrom::Start(0))
2282 .unwrap();
2283 let mut req_result = {
2284 let client = &self.hub.client;
2285 dlg.pre_request();
2286 let mut req_builder = hyper::Request::builder()
2287 .method(hyper::Method::POST)
2288 .uri(url.as_str())
2289 .header(USER_AGENT, self.hub._user_agent.clone());
2290
2291 if let Some(token) = token.as_ref() {
2292 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2293 }
2294
2295 let request = req_builder
2296 .header(CONTENT_TYPE, json_mime_type.to_string())
2297 .header(CONTENT_LENGTH, request_size as u64)
2298 .body(common::to_body(
2299 request_value_reader.get_ref().clone().into(),
2300 ));
2301
2302 client.request(request.unwrap()).await
2303 };
2304
2305 match req_result {
2306 Err(err) => {
2307 if let common::Retry::After(d) = dlg.http_error(&err) {
2308 sleep(d).await;
2309 continue;
2310 }
2311 dlg.finished(false);
2312 return Err(common::Error::HttpError(err));
2313 }
2314 Ok(res) => {
2315 let (mut parts, body) = res.into_parts();
2316 let mut body = common::Body::new(body);
2317 if !parts.status.is_success() {
2318 let bytes = common::to_bytes(body).await.unwrap_or_default();
2319 let error = serde_json::from_str(&common::to_string(&bytes));
2320 let response = common::to_response(parts, bytes.into());
2321
2322 if let common::Retry::After(d) =
2323 dlg.http_failure(&response, error.as_ref().ok())
2324 {
2325 sleep(d).await;
2326 continue;
2327 }
2328
2329 dlg.finished(false);
2330
2331 return Err(match error {
2332 Ok(value) => common::Error::BadRequest(value),
2333 _ => common::Error::Failure(response),
2334 });
2335 }
2336 let response = {
2337 let bytes = common::to_bytes(body).await.unwrap_or_default();
2338 let encoded = common::to_string(&bytes);
2339 match serde_json::from_str(&encoded) {
2340 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2341 Err(error) => {
2342 dlg.response_json_decode_error(&encoded, &error);
2343 return Err(common::Error::JsonDecodeError(
2344 encoded.to_string(),
2345 error,
2346 ));
2347 }
2348 }
2349 };
2350
2351 dlg.finished(true);
2352 return Ok(response);
2353 }
2354 }
2355 }
2356 }
2357
2358 ///
2359 /// Sets the *request* property to the given value.
2360 ///
2361 /// Even though the property as already been set when instantiating this call,
2362 /// we provide this method for API completeness.
2363 pub fn request(mut self, new_value: CommitRequest) -> ProjectCommitCall<'a, C> {
2364 self._request = new_value;
2365 self
2366 }
2367 /// Required. The ID of the project against which to make the request.
2368 ///
2369 /// Sets the *project id* path property to the given value.
2370 ///
2371 /// Even though the property as already been set when instantiating this call,
2372 /// we provide this method for API completeness.
2373 pub fn project_id(mut self, new_value: &str) -> ProjectCommitCall<'a, C> {
2374 self._project_id = new_value.to_string();
2375 self
2376 }
2377 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2378 /// while executing the actual API request.
2379 ///
2380 /// ````text
2381 /// It should be used to handle progress information, and to implement a certain level of resilience.
2382 /// ````
2383 ///
2384 /// Sets the *delegate* property to the given value.
2385 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectCommitCall<'a, C> {
2386 self._delegate = Some(new_value);
2387 self
2388 }
2389
2390 /// Set any additional parameter of the query string used in the request.
2391 /// It should be used to set parameters which are not yet available through their own
2392 /// setters.
2393 ///
2394 /// Please note that this method must not be used to set any of the known parameters
2395 /// which have their own setter method. If done anyway, the request will fail.
2396 ///
2397 /// # Additional Parameters
2398 ///
2399 /// * *$.xgafv* (query-string) - V1 error format.
2400 /// * *access_token* (query-string) - OAuth access token.
2401 /// * *alt* (query-string) - Data format for response.
2402 /// * *callback* (query-string) - JSONP
2403 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2404 /// * *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.
2405 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2406 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2407 /// * *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.
2408 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2409 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2410 pub fn param<T>(mut self, name: T, value: T) -> ProjectCommitCall<'a, C>
2411 where
2412 T: AsRef<str>,
2413 {
2414 self._additional_params
2415 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2416 self
2417 }
2418
2419 /// Identifies the authorization scope for the method you are building.
2420 ///
2421 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2422 /// [`Scope::CloudPlatform`].
2423 ///
2424 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2425 /// tokens for more than one scope.
2426 ///
2427 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2428 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2429 /// sufficient, a read-write scope will do as well.
2430 pub fn add_scope<St>(mut self, scope: St) -> ProjectCommitCall<'a, C>
2431 where
2432 St: AsRef<str>,
2433 {
2434 self._scopes.insert(String::from(scope.as_ref()));
2435 self
2436 }
2437 /// Identifies the authorization scope(s) for the method you are building.
2438 ///
2439 /// See [`Self::add_scope()`] for details.
2440 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectCommitCall<'a, C>
2441 where
2442 I: IntoIterator<Item = St>,
2443 St: AsRef<str>,
2444 {
2445 self._scopes
2446 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2447 self
2448 }
2449
2450 /// Removes all scopes, and no default scope will be used either.
2451 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2452 /// for details).
2453 pub fn clear_scopes(mut self) -> ProjectCommitCall<'a, C> {
2454 self._scopes.clear();
2455 self
2456 }
2457}
2458
2459/// Looks up entities by key.
2460///
2461/// A builder for the *lookup* method supported by a *project* resource.
2462/// It is not used directly, but through a [`ProjectMethods`] instance.
2463///
2464/// # Example
2465///
2466/// Instantiate a resource method builder
2467///
2468/// ```test_harness,no_run
2469/// # extern crate hyper;
2470/// # extern crate hyper_rustls;
2471/// # extern crate google_datastore1_beta3 as datastore1_beta3;
2472/// use datastore1_beta3::api::LookupRequest;
2473/// # async fn dox() {
2474/// # use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2475///
2476/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2477/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2478/// # secret,
2479/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2480/// # ).build().await.unwrap();
2481///
2482/// # let client = hyper_util::client::legacy::Client::builder(
2483/// # hyper_util::rt::TokioExecutor::new()
2484/// # )
2485/// # .build(
2486/// # hyper_rustls::HttpsConnectorBuilder::new()
2487/// # .with_native_roots()
2488/// # .unwrap()
2489/// # .https_or_http()
2490/// # .enable_http1()
2491/// # .build()
2492/// # );
2493/// # let mut hub = Datastore::new(client, auth);
2494/// // As the method needs a request, you would usually fill it with the desired information
2495/// // into the respective structure. Some of the parts shown here might not be applicable !
2496/// // Values shown here are possibly random and not representative !
2497/// let mut req = LookupRequest::default();
2498///
2499/// // You can configure optional parameters by calling the respective setters at will, and
2500/// // execute the final call using `doit()`.
2501/// // Values shown here are possibly random and not representative !
2502/// let result = hub.projects().lookup(req, "projectId")
2503/// .doit().await;
2504/// # }
2505/// ```
2506pub struct ProjectLookupCall<'a, C>
2507where
2508 C: 'a,
2509{
2510 hub: &'a Datastore<C>,
2511 _request: LookupRequest,
2512 _project_id: String,
2513 _delegate: Option<&'a mut dyn common::Delegate>,
2514 _additional_params: HashMap<String, String>,
2515 _scopes: BTreeSet<String>,
2516}
2517
2518impl<'a, C> common::CallBuilder for ProjectLookupCall<'a, C> {}
2519
2520impl<'a, C> ProjectLookupCall<'a, C>
2521where
2522 C: common::Connector,
2523{
2524 /// Perform the operation you have build so far.
2525 pub async fn doit(mut self) -> common::Result<(common::Response, LookupResponse)> {
2526 use std::borrow::Cow;
2527 use std::io::{Read, Seek};
2528
2529 use common::{url::Params, ToParts};
2530 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2531
2532 let mut dd = common::DefaultDelegate;
2533 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2534 dlg.begin(common::MethodInfo {
2535 id: "datastore.projects.lookup",
2536 http_method: hyper::Method::POST,
2537 });
2538
2539 for &field in ["alt", "projectId"].iter() {
2540 if self._additional_params.contains_key(field) {
2541 dlg.finished(false);
2542 return Err(common::Error::FieldClash(field));
2543 }
2544 }
2545
2546 let mut params = Params::with_capacity(4 + self._additional_params.len());
2547 params.push("projectId", self._project_id);
2548
2549 params.extend(self._additional_params.iter());
2550
2551 params.push("alt", "json");
2552 let mut url = self.hub._base_url.clone() + "v1beta3/projects/{projectId}:lookup";
2553 if self._scopes.is_empty() {
2554 self._scopes
2555 .insert(Scope::CloudPlatform.as_ref().to_string());
2556 }
2557
2558 #[allow(clippy::single_element_loop)]
2559 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
2560 url = params.uri_replacement(url, param_name, find_this, false);
2561 }
2562 {
2563 let to_remove = ["projectId"];
2564 params.remove_params(&to_remove);
2565 }
2566
2567 let url = params.parse_with_url(&url);
2568
2569 let mut json_mime_type = mime::APPLICATION_JSON;
2570 let mut request_value_reader = {
2571 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2572 common::remove_json_null_values(&mut value);
2573 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2574 serde_json::to_writer(&mut dst, &value).unwrap();
2575 dst
2576 };
2577 let request_size = request_value_reader
2578 .seek(std::io::SeekFrom::End(0))
2579 .unwrap();
2580 request_value_reader
2581 .seek(std::io::SeekFrom::Start(0))
2582 .unwrap();
2583
2584 loop {
2585 let token = match self
2586 .hub
2587 .auth
2588 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2589 .await
2590 {
2591 Ok(token) => token,
2592 Err(e) => match dlg.token(e) {
2593 Ok(token) => token,
2594 Err(e) => {
2595 dlg.finished(false);
2596 return Err(common::Error::MissingToken(e));
2597 }
2598 },
2599 };
2600 request_value_reader
2601 .seek(std::io::SeekFrom::Start(0))
2602 .unwrap();
2603 let mut req_result = {
2604 let client = &self.hub.client;
2605 dlg.pre_request();
2606 let mut req_builder = hyper::Request::builder()
2607 .method(hyper::Method::POST)
2608 .uri(url.as_str())
2609 .header(USER_AGENT, self.hub._user_agent.clone());
2610
2611 if let Some(token) = token.as_ref() {
2612 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2613 }
2614
2615 let request = req_builder
2616 .header(CONTENT_TYPE, json_mime_type.to_string())
2617 .header(CONTENT_LENGTH, request_size as u64)
2618 .body(common::to_body(
2619 request_value_reader.get_ref().clone().into(),
2620 ));
2621
2622 client.request(request.unwrap()).await
2623 };
2624
2625 match req_result {
2626 Err(err) => {
2627 if let common::Retry::After(d) = dlg.http_error(&err) {
2628 sleep(d).await;
2629 continue;
2630 }
2631 dlg.finished(false);
2632 return Err(common::Error::HttpError(err));
2633 }
2634 Ok(res) => {
2635 let (mut parts, body) = res.into_parts();
2636 let mut body = common::Body::new(body);
2637 if !parts.status.is_success() {
2638 let bytes = common::to_bytes(body).await.unwrap_or_default();
2639 let error = serde_json::from_str(&common::to_string(&bytes));
2640 let response = common::to_response(parts, bytes.into());
2641
2642 if let common::Retry::After(d) =
2643 dlg.http_failure(&response, error.as_ref().ok())
2644 {
2645 sleep(d).await;
2646 continue;
2647 }
2648
2649 dlg.finished(false);
2650
2651 return Err(match error {
2652 Ok(value) => common::Error::BadRequest(value),
2653 _ => common::Error::Failure(response),
2654 });
2655 }
2656 let response = {
2657 let bytes = common::to_bytes(body).await.unwrap_or_default();
2658 let encoded = common::to_string(&bytes);
2659 match serde_json::from_str(&encoded) {
2660 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2661 Err(error) => {
2662 dlg.response_json_decode_error(&encoded, &error);
2663 return Err(common::Error::JsonDecodeError(
2664 encoded.to_string(),
2665 error,
2666 ));
2667 }
2668 }
2669 };
2670
2671 dlg.finished(true);
2672 return Ok(response);
2673 }
2674 }
2675 }
2676 }
2677
2678 ///
2679 /// Sets the *request* property to the given value.
2680 ///
2681 /// Even though the property as already been set when instantiating this call,
2682 /// we provide this method for API completeness.
2683 pub fn request(mut self, new_value: LookupRequest) -> ProjectLookupCall<'a, C> {
2684 self._request = new_value;
2685 self
2686 }
2687 /// Required. The ID of the project against which to make the request.
2688 ///
2689 /// Sets the *project id* path property to the given value.
2690 ///
2691 /// Even though the property as already been set when instantiating this call,
2692 /// we provide this method for API completeness.
2693 pub fn project_id(mut self, new_value: &str) -> ProjectLookupCall<'a, C> {
2694 self._project_id = new_value.to_string();
2695 self
2696 }
2697 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2698 /// while executing the actual API request.
2699 ///
2700 /// ````text
2701 /// It should be used to handle progress information, and to implement a certain level of resilience.
2702 /// ````
2703 ///
2704 /// Sets the *delegate* property to the given value.
2705 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectLookupCall<'a, C> {
2706 self._delegate = Some(new_value);
2707 self
2708 }
2709
2710 /// Set any additional parameter of the query string used in the request.
2711 /// It should be used to set parameters which are not yet available through their own
2712 /// setters.
2713 ///
2714 /// Please note that this method must not be used to set any of the known parameters
2715 /// which have their own setter method. If done anyway, the request will fail.
2716 ///
2717 /// # Additional Parameters
2718 ///
2719 /// * *$.xgafv* (query-string) - V1 error format.
2720 /// * *access_token* (query-string) - OAuth access token.
2721 /// * *alt* (query-string) - Data format for response.
2722 /// * *callback* (query-string) - JSONP
2723 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2724 /// * *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.
2725 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2726 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2727 /// * *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.
2728 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2729 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2730 pub fn param<T>(mut self, name: T, value: T) -> ProjectLookupCall<'a, C>
2731 where
2732 T: AsRef<str>,
2733 {
2734 self._additional_params
2735 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2736 self
2737 }
2738
2739 /// Identifies the authorization scope for the method you are building.
2740 ///
2741 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2742 /// [`Scope::CloudPlatform`].
2743 ///
2744 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2745 /// tokens for more than one scope.
2746 ///
2747 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2748 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2749 /// sufficient, a read-write scope will do as well.
2750 pub fn add_scope<St>(mut self, scope: St) -> ProjectLookupCall<'a, C>
2751 where
2752 St: AsRef<str>,
2753 {
2754 self._scopes.insert(String::from(scope.as_ref()));
2755 self
2756 }
2757 /// Identifies the authorization scope(s) for the method you are building.
2758 ///
2759 /// See [`Self::add_scope()`] for details.
2760 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLookupCall<'a, C>
2761 where
2762 I: IntoIterator<Item = St>,
2763 St: AsRef<str>,
2764 {
2765 self._scopes
2766 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2767 self
2768 }
2769
2770 /// Removes all scopes, and no default scope will be used either.
2771 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2772 /// for details).
2773 pub fn clear_scopes(mut self) -> ProjectLookupCall<'a, C> {
2774 self._scopes.clear();
2775 self
2776 }
2777}
2778
2779/// Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
2780///
2781/// A builder for the *reserveIds* method supported by a *project* resource.
2782/// It is not used directly, but through a [`ProjectMethods`] instance.
2783///
2784/// # Example
2785///
2786/// Instantiate a resource method builder
2787///
2788/// ```test_harness,no_run
2789/// # extern crate hyper;
2790/// # extern crate hyper_rustls;
2791/// # extern crate google_datastore1_beta3 as datastore1_beta3;
2792/// use datastore1_beta3::api::ReserveIdsRequest;
2793/// # async fn dox() {
2794/// # use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2795///
2796/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2797/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2798/// # secret,
2799/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2800/// # ).build().await.unwrap();
2801///
2802/// # let client = hyper_util::client::legacy::Client::builder(
2803/// # hyper_util::rt::TokioExecutor::new()
2804/// # )
2805/// # .build(
2806/// # hyper_rustls::HttpsConnectorBuilder::new()
2807/// # .with_native_roots()
2808/// # .unwrap()
2809/// # .https_or_http()
2810/// # .enable_http1()
2811/// # .build()
2812/// # );
2813/// # let mut hub = Datastore::new(client, auth);
2814/// // As the method needs a request, you would usually fill it with the desired information
2815/// // into the respective structure. Some of the parts shown here might not be applicable !
2816/// // Values shown here are possibly random and not representative !
2817/// let mut req = ReserveIdsRequest::default();
2818///
2819/// // You can configure optional parameters by calling the respective setters at will, and
2820/// // execute the final call using `doit()`.
2821/// // Values shown here are possibly random and not representative !
2822/// let result = hub.projects().reserve_ids(req, "projectId")
2823/// .doit().await;
2824/// # }
2825/// ```
2826pub struct ProjectReserveIdCall<'a, C>
2827where
2828 C: 'a,
2829{
2830 hub: &'a Datastore<C>,
2831 _request: ReserveIdsRequest,
2832 _project_id: String,
2833 _delegate: Option<&'a mut dyn common::Delegate>,
2834 _additional_params: HashMap<String, String>,
2835 _scopes: BTreeSet<String>,
2836}
2837
2838impl<'a, C> common::CallBuilder for ProjectReserveIdCall<'a, C> {}
2839
2840impl<'a, C> ProjectReserveIdCall<'a, C>
2841where
2842 C: common::Connector,
2843{
2844 /// Perform the operation you have build so far.
2845 pub async fn doit(mut self) -> common::Result<(common::Response, ReserveIdsResponse)> {
2846 use std::borrow::Cow;
2847 use std::io::{Read, Seek};
2848
2849 use common::{url::Params, ToParts};
2850 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2851
2852 let mut dd = common::DefaultDelegate;
2853 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2854 dlg.begin(common::MethodInfo {
2855 id: "datastore.projects.reserveIds",
2856 http_method: hyper::Method::POST,
2857 });
2858
2859 for &field in ["alt", "projectId"].iter() {
2860 if self._additional_params.contains_key(field) {
2861 dlg.finished(false);
2862 return Err(common::Error::FieldClash(field));
2863 }
2864 }
2865
2866 let mut params = Params::with_capacity(4 + self._additional_params.len());
2867 params.push("projectId", self._project_id);
2868
2869 params.extend(self._additional_params.iter());
2870
2871 params.push("alt", "json");
2872 let mut url = self.hub._base_url.clone() + "v1beta3/projects/{projectId}:reserveIds";
2873 if self._scopes.is_empty() {
2874 self._scopes
2875 .insert(Scope::CloudPlatform.as_ref().to_string());
2876 }
2877
2878 #[allow(clippy::single_element_loop)]
2879 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
2880 url = params.uri_replacement(url, param_name, find_this, false);
2881 }
2882 {
2883 let to_remove = ["projectId"];
2884 params.remove_params(&to_remove);
2885 }
2886
2887 let url = params.parse_with_url(&url);
2888
2889 let mut json_mime_type = mime::APPLICATION_JSON;
2890 let mut request_value_reader = {
2891 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2892 common::remove_json_null_values(&mut value);
2893 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2894 serde_json::to_writer(&mut dst, &value).unwrap();
2895 dst
2896 };
2897 let request_size = request_value_reader
2898 .seek(std::io::SeekFrom::End(0))
2899 .unwrap();
2900 request_value_reader
2901 .seek(std::io::SeekFrom::Start(0))
2902 .unwrap();
2903
2904 loop {
2905 let token = match self
2906 .hub
2907 .auth
2908 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2909 .await
2910 {
2911 Ok(token) => token,
2912 Err(e) => match dlg.token(e) {
2913 Ok(token) => token,
2914 Err(e) => {
2915 dlg.finished(false);
2916 return Err(common::Error::MissingToken(e));
2917 }
2918 },
2919 };
2920 request_value_reader
2921 .seek(std::io::SeekFrom::Start(0))
2922 .unwrap();
2923 let mut req_result = {
2924 let client = &self.hub.client;
2925 dlg.pre_request();
2926 let mut req_builder = hyper::Request::builder()
2927 .method(hyper::Method::POST)
2928 .uri(url.as_str())
2929 .header(USER_AGENT, self.hub._user_agent.clone());
2930
2931 if let Some(token) = token.as_ref() {
2932 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2933 }
2934
2935 let request = req_builder
2936 .header(CONTENT_TYPE, json_mime_type.to_string())
2937 .header(CONTENT_LENGTH, request_size as u64)
2938 .body(common::to_body(
2939 request_value_reader.get_ref().clone().into(),
2940 ));
2941
2942 client.request(request.unwrap()).await
2943 };
2944
2945 match req_result {
2946 Err(err) => {
2947 if let common::Retry::After(d) = dlg.http_error(&err) {
2948 sleep(d).await;
2949 continue;
2950 }
2951 dlg.finished(false);
2952 return Err(common::Error::HttpError(err));
2953 }
2954 Ok(res) => {
2955 let (mut parts, body) = res.into_parts();
2956 let mut body = common::Body::new(body);
2957 if !parts.status.is_success() {
2958 let bytes = common::to_bytes(body).await.unwrap_or_default();
2959 let error = serde_json::from_str(&common::to_string(&bytes));
2960 let response = common::to_response(parts, bytes.into());
2961
2962 if let common::Retry::After(d) =
2963 dlg.http_failure(&response, error.as_ref().ok())
2964 {
2965 sleep(d).await;
2966 continue;
2967 }
2968
2969 dlg.finished(false);
2970
2971 return Err(match error {
2972 Ok(value) => common::Error::BadRequest(value),
2973 _ => common::Error::Failure(response),
2974 });
2975 }
2976 let response = {
2977 let bytes = common::to_bytes(body).await.unwrap_or_default();
2978 let encoded = common::to_string(&bytes);
2979 match serde_json::from_str(&encoded) {
2980 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2981 Err(error) => {
2982 dlg.response_json_decode_error(&encoded, &error);
2983 return Err(common::Error::JsonDecodeError(
2984 encoded.to_string(),
2985 error,
2986 ));
2987 }
2988 }
2989 };
2990
2991 dlg.finished(true);
2992 return Ok(response);
2993 }
2994 }
2995 }
2996 }
2997
2998 ///
2999 /// Sets the *request* property to the given value.
3000 ///
3001 /// Even though the property as already been set when instantiating this call,
3002 /// we provide this method for API completeness.
3003 pub fn request(mut self, new_value: ReserveIdsRequest) -> ProjectReserveIdCall<'a, C> {
3004 self._request = new_value;
3005 self
3006 }
3007 /// Required. The ID of the project against which to make the request.
3008 ///
3009 /// Sets the *project id* path property to the given value.
3010 ///
3011 /// Even though the property as already been set when instantiating this call,
3012 /// we provide this method for API completeness.
3013 pub fn project_id(mut self, new_value: &str) -> ProjectReserveIdCall<'a, C> {
3014 self._project_id = new_value.to_string();
3015 self
3016 }
3017 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3018 /// while executing the actual API request.
3019 ///
3020 /// ````text
3021 /// It should be used to handle progress information, and to implement a certain level of resilience.
3022 /// ````
3023 ///
3024 /// Sets the *delegate* property to the given value.
3025 pub fn delegate(
3026 mut self,
3027 new_value: &'a mut dyn common::Delegate,
3028 ) -> ProjectReserveIdCall<'a, C> {
3029 self._delegate = Some(new_value);
3030 self
3031 }
3032
3033 /// Set any additional parameter of the query string used in the request.
3034 /// It should be used to set parameters which are not yet available through their own
3035 /// setters.
3036 ///
3037 /// Please note that this method must not be used to set any of the known parameters
3038 /// which have their own setter method. If done anyway, the request will fail.
3039 ///
3040 /// # Additional Parameters
3041 ///
3042 /// * *$.xgafv* (query-string) - V1 error format.
3043 /// * *access_token* (query-string) - OAuth access token.
3044 /// * *alt* (query-string) - Data format for response.
3045 /// * *callback* (query-string) - JSONP
3046 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3047 /// * *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.
3048 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3049 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3050 /// * *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.
3051 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3052 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3053 pub fn param<T>(mut self, name: T, value: T) -> ProjectReserveIdCall<'a, C>
3054 where
3055 T: AsRef<str>,
3056 {
3057 self._additional_params
3058 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3059 self
3060 }
3061
3062 /// Identifies the authorization scope for the method you are building.
3063 ///
3064 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3065 /// [`Scope::CloudPlatform`].
3066 ///
3067 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3068 /// tokens for more than one scope.
3069 ///
3070 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3071 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3072 /// sufficient, a read-write scope will do as well.
3073 pub fn add_scope<St>(mut self, scope: St) -> ProjectReserveIdCall<'a, C>
3074 where
3075 St: AsRef<str>,
3076 {
3077 self._scopes.insert(String::from(scope.as_ref()));
3078 self
3079 }
3080 /// Identifies the authorization scope(s) for the method you are building.
3081 ///
3082 /// See [`Self::add_scope()`] for details.
3083 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectReserveIdCall<'a, C>
3084 where
3085 I: IntoIterator<Item = St>,
3086 St: AsRef<str>,
3087 {
3088 self._scopes
3089 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3090 self
3091 }
3092
3093 /// Removes all scopes, and no default scope will be used either.
3094 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3095 /// for details).
3096 pub fn clear_scopes(mut self) -> ProjectReserveIdCall<'a, C> {
3097 self._scopes.clear();
3098 self
3099 }
3100}
3101
3102/// Rolls back a transaction.
3103///
3104/// A builder for the *rollback* method supported by a *project* resource.
3105/// It is not used directly, but through a [`ProjectMethods`] instance.
3106///
3107/// # Example
3108///
3109/// Instantiate a resource method builder
3110///
3111/// ```test_harness,no_run
3112/// # extern crate hyper;
3113/// # extern crate hyper_rustls;
3114/// # extern crate google_datastore1_beta3 as datastore1_beta3;
3115/// use datastore1_beta3::api::RollbackRequest;
3116/// # async fn dox() {
3117/// # use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3118///
3119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3120/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3121/// # secret,
3122/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3123/// # ).build().await.unwrap();
3124///
3125/// # let client = hyper_util::client::legacy::Client::builder(
3126/// # hyper_util::rt::TokioExecutor::new()
3127/// # )
3128/// # .build(
3129/// # hyper_rustls::HttpsConnectorBuilder::new()
3130/// # .with_native_roots()
3131/// # .unwrap()
3132/// # .https_or_http()
3133/// # .enable_http1()
3134/// # .build()
3135/// # );
3136/// # let mut hub = Datastore::new(client, auth);
3137/// // As the method needs a request, you would usually fill it with the desired information
3138/// // into the respective structure. Some of the parts shown here might not be applicable !
3139/// // Values shown here are possibly random and not representative !
3140/// let mut req = RollbackRequest::default();
3141///
3142/// // You can configure optional parameters by calling the respective setters at will, and
3143/// // execute the final call using `doit()`.
3144/// // Values shown here are possibly random and not representative !
3145/// let result = hub.projects().rollback(req, "projectId")
3146/// .doit().await;
3147/// # }
3148/// ```
3149pub struct ProjectRollbackCall<'a, C>
3150where
3151 C: 'a,
3152{
3153 hub: &'a Datastore<C>,
3154 _request: RollbackRequest,
3155 _project_id: String,
3156 _delegate: Option<&'a mut dyn common::Delegate>,
3157 _additional_params: HashMap<String, String>,
3158 _scopes: BTreeSet<String>,
3159}
3160
3161impl<'a, C> common::CallBuilder for ProjectRollbackCall<'a, C> {}
3162
3163impl<'a, C> ProjectRollbackCall<'a, C>
3164where
3165 C: common::Connector,
3166{
3167 /// Perform the operation you have build so far.
3168 pub async fn doit(mut self) -> common::Result<(common::Response, RollbackResponse)> {
3169 use std::borrow::Cow;
3170 use std::io::{Read, Seek};
3171
3172 use common::{url::Params, ToParts};
3173 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3174
3175 let mut dd = common::DefaultDelegate;
3176 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3177 dlg.begin(common::MethodInfo {
3178 id: "datastore.projects.rollback",
3179 http_method: hyper::Method::POST,
3180 });
3181
3182 for &field in ["alt", "projectId"].iter() {
3183 if self._additional_params.contains_key(field) {
3184 dlg.finished(false);
3185 return Err(common::Error::FieldClash(field));
3186 }
3187 }
3188
3189 let mut params = Params::with_capacity(4 + self._additional_params.len());
3190 params.push("projectId", self._project_id);
3191
3192 params.extend(self._additional_params.iter());
3193
3194 params.push("alt", "json");
3195 let mut url = self.hub._base_url.clone() + "v1beta3/projects/{projectId}:rollback";
3196 if self._scopes.is_empty() {
3197 self._scopes
3198 .insert(Scope::CloudPlatform.as_ref().to_string());
3199 }
3200
3201 #[allow(clippy::single_element_loop)]
3202 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
3203 url = params.uri_replacement(url, param_name, find_this, false);
3204 }
3205 {
3206 let to_remove = ["projectId"];
3207 params.remove_params(&to_remove);
3208 }
3209
3210 let url = params.parse_with_url(&url);
3211
3212 let mut json_mime_type = mime::APPLICATION_JSON;
3213 let mut request_value_reader = {
3214 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3215 common::remove_json_null_values(&mut value);
3216 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3217 serde_json::to_writer(&mut dst, &value).unwrap();
3218 dst
3219 };
3220 let request_size = request_value_reader
3221 .seek(std::io::SeekFrom::End(0))
3222 .unwrap();
3223 request_value_reader
3224 .seek(std::io::SeekFrom::Start(0))
3225 .unwrap();
3226
3227 loop {
3228 let token = match self
3229 .hub
3230 .auth
3231 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3232 .await
3233 {
3234 Ok(token) => token,
3235 Err(e) => match dlg.token(e) {
3236 Ok(token) => token,
3237 Err(e) => {
3238 dlg.finished(false);
3239 return Err(common::Error::MissingToken(e));
3240 }
3241 },
3242 };
3243 request_value_reader
3244 .seek(std::io::SeekFrom::Start(0))
3245 .unwrap();
3246 let mut req_result = {
3247 let client = &self.hub.client;
3248 dlg.pre_request();
3249 let mut req_builder = hyper::Request::builder()
3250 .method(hyper::Method::POST)
3251 .uri(url.as_str())
3252 .header(USER_AGENT, self.hub._user_agent.clone());
3253
3254 if let Some(token) = token.as_ref() {
3255 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3256 }
3257
3258 let request = req_builder
3259 .header(CONTENT_TYPE, json_mime_type.to_string())
3260 .header(CONTENT_LENGTH, request_size as u64)
3261 .body(common::to_body(
3262 request_value_reader.get_ref().clone().into(),
3263 ));
3264
3265 client.request(request.unwrap()).await
3266 };
3267
3268 match req_result {
3269 Err(err) => {
3270 if let common::Retry::After(d) = dlg.http_error(&err) {
3271 sleep(d).await;
3272 continue;
3273 }
3274 dlg.finished(false);
3275 return Err(common::Error::HttpError(err));
3276 }
3277 Ok(res) => {
3278 let (mut parts, body) = res.into_parts();
3279 let mut body = common::Body::new(body);
3280 if !parts.status.is_success() {
3281 let bytes = common::to_bytes(body).await.unwrap_or_default();
3282 let error = serde_json::from_str(&common::to_string(&bytes));
3283 let response = common::to_response(parts, bytes.into());
3284
3285 if let common::Retry::After(d) =
3286 dlg.http_failure(&response, error.as_ref().ok())
3287 {
3288 sleep(d).await;
3289 continue;
3290 }
3291
3292 dlg.finished(false);
3293
3294 return Err(match error {
3295 Ok(value) => common::Error::BadRequest(value),
3296 _ => common::Error::Failure(response),
3297 });
3298 }
3299 let response = {
3300 let bytes = common::to_bytes(body).await.unwrap_or_default();
3301 let encoded = common::to_string(&bytes);
3302 match serde_json::from_str(&encoded) {
3303 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3304 Err(error) => {
3305 dlg.response_json_decode_error(&encoded, &error);
3306 return Err(common::Error::JsonDecodeError(
3307 encoded.to_string(),
3308 error,
3309 ));
3310 }
3311 }
3312 };
3313
3314 dlg.finished(true);
3315 return Ok(response);
3316 }
3317 }
3318 }
3319 }
3320
3321 ///
3322 /// Sets the *request* property to the given value.
3323 ///
3324 /// Even though the property as already been set when instantiating this call,
3325 /// we provide this method for API completeness.
3326 pub fn request(mut self, new_value: RollbackRequest) -> ProjectRollbackCall<'a, C> {
3327 self._request = new_value;
3328 self
3329 }
3330 /// Required. The ID of the project against which to make the request.
3331 ///
3332 /// Sets the *project id* path property to the given value.
3333 ///
3334 /// Even though the property as already been set when instantiating this call,
3335 /// we provide this method for API completeness.
3336 pub fn project_id(mut self, new_value: &str) -> ProjectRollbackCall<'a, C> {
3337 self._project_id = new_value.to_string();
3338 self
3339 }
3340 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3341 /// while executing the actual API request.
3342 ///
3343 /// ````text
3344 /// It should be used to handle progress information, and to implement a certain level of resilience.
3345 /// ````
3346 ///
3347 /// Sets the *delegate* property to the given value.
3348 pub fn delegate(
3349 mut self,
3350 new_value: &'a mut dyn common::Delegate,
3351 ) -> ProjectRollbackCall<'a, C> {
3352 self._delegate = Some(new_value);
3353 self
3354 }
3355
3356 /// Set any additional parameter of the query string used in the request.
3357 /// It should be used to set parameters which are not yet available through their own
3358 /// setters.
3359 ///
3360 /// Please note that this method must not be used to set any of the known parameters
3361 /// which have their own setter method. If done anyway, the request will fail.
3362 ///
3363 /// # Additional Parameters
3364 ///
3365 /// * *$.xgafv* (query-string) - V1 error format.
3366 /// * *access_token* (query-string) - OAuth access token.
3367 /// * *alt* (query-string) - Data format for response.
3368 /// * *callback* (query-string) - JSONP
3369 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3370 /// * *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.
3371 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3372 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3373 /// * *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.
3374 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3375 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3376 pub fn param<T>(mut self, name: T, value: T) -> ProjectRollbackCall<'a, C>
3377 where
3378 T: AsRef<str>,
3379 {
3380 self._additional_params
3381 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3382 self
3383 }
3384
3385 /// Identifies the authorization scope for the method you are building.
3386 ///
3387 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3388 /// [`Scope::CloudPlatform`].
3389 ///
3390 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3391 /// tokens for more than one scope.
3392 ///
3393 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3394 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3395 /// sufficient, a read-write scope will do as well.
3396 pub fn add_scope<St>(mut self, scope: St) -> ProjectRollbackCall<'a, C>
3397 where
3398 St: AsRef<str>,
3399 {
3400 self._scopes.insert(String::from(scope.as_ref()));
3401 self
3402 }
3403 /// Identifies the authorization scope(s) for the method you are building.
3404 ///
3405 /// See [`Self::add_scope()`] for details.
3406 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectRollbackCall<'a, C>
3407 where
3408 I: IntoIterator<Item = St>,
3409 St: AsRef<str>,
3410 {
3411 self._scopes
3412 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3413 self
3414 }
3415
3416 /// Removes all scopes, and no default scope will be used either.
3417 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3418 /// for details).
3419 pub fn clear_scopes(mut self) -> ProjectRollbackCall<'a, C> {
3420 self._scopes.clear();
3421 self
3422 }
3423}
3424
3425/// Runs an aggregation query.
3426///
3427/// A builder for the *runAggregationQuery* method supported by a *project* resource.
3428/// It is not used directly, but through a [`ProjectMethods`] instance.
3429///
3430/// # Example
3431///
3432/// Instantiate a resource method builder
3433///
3434/// ```test_harness,no_run
3435/// # extern crate hyper;
3436/// # extern crate hyper_rustls;
3437/// # extern crate google_datastore1_beta3 as datastore1_beta3;
3438/// use datastore1_beta3::api::RunAggregationQueryRequest;
3439/// # async fn dox() {
3440/// # use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3441///
3442/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3443/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3444/// # secret,
3445/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3446/// # ).build().await.unwrap();
3447///
3448/// # let client = hyper_util::client::legacy::Client::builder(
3449/// # hyper_util::rt::TokioExecutor::new()
3450/// # )
3451/// # .build(
3452/// # hyper_rustls::HttpsConnectorBuilder::new()
3453/// # .with_native_roots()
3454/// # .unwrap()
3455/// # .https_or_http()
3456/// # .enable_http1()
3457/// # .build()
3458/// # );
3459/// # let mut hub = Datastore::new(client, auth);
3460/// // As the method needs a request, you would usually fill it with the desired information
3461/// // into the respective structure. Some of the parts shown here might not be applicable !
3462/// // Values shown here are possibly random and not representative !
3463/// let mut req = RunAggregationQueryRequest::default();
3464///
3465/// // You can configure optional parameters by calling the respective setters at will, and
3466/// // execute the final call using `doit()`.
3467/// // Values shown here are possibly random and not representative !
3468/// let result = hub.projects().run_aggregation_query(req, "projectId")
3469/// .doit().await;
3470/// # }
3471/// ```
3472pub struct ProjectRunAggregationQueryCall<'a, C>
3473where
3474 C: 'a,
3475{
3476 hub: &'a Datastore<C>,
3477 _request: RunAggregationQueryRequest,
3478 _project_id: String,
3479 _delegate: Option<&'a mut dyn common::Delegate>,
3480 _additional_params: HashMap<String, String>,
3481 _scopes: BTreeSet<String>,
3482}
3483
3484impl<'a, C> common::CallBuilder for ProjectRunAggregationQueryCall<'a, C> {}
3485
3486impl<'a, C> ProjectRunAggregationQueryCall<'a, C>
3487where
3488 C: common::Connector,
3489{
3490 /// Perform the operation you have build so far.
3491 pub async fn doit(mut self) -> common::Result<(common::Response, RunAggregationQueryResponse)> {
3492 use std::borrow::Cow;
3493 use std::io::{Read, Seek};
3494
3495 use common::{url::Params, ToParts};
3496 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3497
3498 let mut dd = common::DefaultDelegate;
3499 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3500 dlg.begin(common::MethodInfo {
3501 id: "datastore.projects.runAggregationQuery",
3502 http_method: hyper::Method::POST,
3503 });
3504
3505 for &field in ["alt", "projectId"].iter() {
3506 if self._additional_params.contains_key(field) {
3507 dlg.finished(false);
3508 return Err(common::Error::FieldClash(field));
3509 }
3510 }
3511
3512 let mut params = Params::with_capacity(4 + self._additional_params.len());
3513 params.push("projectId", self._project_id);
3514
3515 params.extend(self._additional_params.iter());
3516
3517 params.push("alt", "json");
3518 let mut url =
3519 self.hub._base_url.clone() + "v1beta3/projects/{projectId}:runAggregationQuery";
3520 if self._scopes.is_empty() {
3521 self._scopes
3522 .insert(Scope::CloudPlatform.as_ref().to_string());
3523 }
3524
3525 #[allow(clippy::single_element_loop)]
3526 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
3527 url = params.uri_replacement(url, param_name, find_this, false);
3528 }
3529 {
3530 let to_remove = ["projectId"];
3531 params.remove_params(&to_remove);
3532 }
3533
3534 let url = params.parse_with_url(&url);
3535
3536 let mut json_mime_type = mime::APPLICATION_JSON;
3537 let mut request_value_reader = {
3538 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3539 common::remove_json_null_values(&mut value);
3540 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3541 serde_json::to_writer(&mut dst, &value).unwrap();
3542 dst
3543 };
3544 let request_size = request_value_reader
3545 .seek(std::io::SeekFrom::End(0))
3546 .unwrap();
3547 request_value_reader
3548 .seek(std::io::SeekFrom::Start(0))
3549 .unwrap();
3550
3551 loop {
3552 let token = match self
3553 .hub
3554 .auth
3555 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3556 .await
3557 {
3558 Ok(token) => token,
3559 Err(e) => match dlg.token(e) {
3560 Ok(token) => token,
3561 Err(e) => {
3562 dlg.finished(false);
3563 return Err(common::Error::MissingToken(e));
3564 }
3565 },
3566 };
3567 request_value_reader
3568 .seek(std::io::SeekFrom::Start(0))
3569 .unwrap();
3570 let mut req_result = {
3571 let client = &self.hub.client;
3572 dlg.pre_request();
3573 let mut req_builder = hyper::Request::builder()
3574 .method(hyper::Method::POST)
3575 .uri(url.as_str())
3576 .header(USER_AGENT, self.hub._user_agent.clone());
3577
3578 if let Some(token) = token.as_ref() {
3579 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3580 }
3581
3582 let request = req_builder
3583 .header(CONTENT_TYPE, json_mime_type.to_string())
3584 .header(CONTENT_LENGTH, request_size as u64)
3585 .body(common::to_body(
3586 request_value_reader.get_ref().clone().into(),
3587 ));
3588
3589 client.request(request.unwrap()).await
3590 };
3591
3592 match req_result {
3593 Err(err) => {
3594 if let common::Retry::After(d) = dlg.http_error(&err) {
3595 sleep(d).await;
3596 continue;
3597 }
3598 dlg.finished(false);
3599 return Err(common::Error::HttpError(err));
3600 }
3601 Ok(res) => {
3602 let (mut parts, body) = res.into_parts();
3603 let mut body = common::Body::new(body);
3604 if !parts.status.is_success() {
3605 let bytes = common::to_bytes(body).await.unwrap_or_default();
3606 let error = serde_json::from_str(&common::to_string(&bytes));
3607 let response = common::to_response(parts, bytes.into());
3608
3609 if let common::Retry::After(d) =
3610 dlg.http_failure(&response, error.as_ref().ok())
3611 {
3612 sleep(d).await;
3613 continue;
3614 }
3615
3616 dlg.finished(false);
3617
3618 return Err(match error {
3619 Ok(value) => common::Error::BadRequest(value),
3620 _ => common::Error::Failure(response),
3621 });
3622 }
3623 let response = {
3624 let bytes = common::to_bytes(body).await.unwrap_or_default();
3625 let encoded = common::to_string(&bytes);
3626 match serde_json::from_str(&encoded) {
3627 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3628 Err(error) => {
3629 dlg.response_json_decode_error(&encoded, &error);
3630 return Err(common::Error::JsonDecodeError(
3631 encoded.to_string(),
3632 error,
3633 ));
3634 }
3635 }
3636 };
3637
3638 dlg.finished(true);
3639 return Ok(response);
3640 }
3641 }
3642 }
3643 }
3644
3645 ///
3646 /// Sets the *request* property to the given value.
3647 ///
3648 /// Even though the property as already been set when instantiating this call,
3649 /// we provide this method for API completeness.
3650 pub fn request(
3651 mut self,
3652 new_value: RunAggregationQueryRequest,
3653 ) -> ProjectRunAggregationQueryCall<'a, C> {
3654 self._request = new_value;
3655 self
3656 }
3657 /// Required. The ID of the project against which to make the request.
3658 ///
3659 /// Sets the *project id* path property to the given value.
3660 ///
3661 /// Even though the property as already been set when instantiating this call,
3662 /// we provide this method for API completeness.
3663 pub fn project_id(mut self, new_value: &str) -> ProjectRunAggregationQueryCall<'a, C> {
3664 self._project_id = new_value.to_string();
3665 self
3666 }
3667 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3668 /// while executing the actual API request.
3669 ///
3670 /// ````text
3671 /// It should be used to handle progress information, and to implement a certain level of resilience.
3672 /// ````
3673 ///
3674 /// Sets the *delegate* property to the given value.
3675 pub fn delegate(
3676 mut self,
3677 new_value: &'a mut dyn common::Delegate,
3678 ) -> ProjectRunAggregationQueryCall<'a, C> {
3679 self._delegate = Some(new_value);
3680 self
3681 }
3682
3683 /// Set any additional parameter of the query string used in the request.
3684 /// It should be used to set parameters which are not yet available through their own
3685 /// setters.
3686 ///
3687 /// Please note that this method must not be used to set any of the known parameters
3688 /// which have their own setter method. If done anyway, the request will fail.
3689 ///
3690 /// # Additional Parameters
3691 ///
3692 /// * *$.xgafv* (query-string) - V1 error format.
3693 /// * *access_token* (query-string) - OAuth access token.
3694 /// * *alt* (query-string) - Data format for response.
3695 /// * *callback* (query-string) - JSONP
3696 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3697 /// * *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.
3698 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3699 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3700 /// * *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.
3701 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3702 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3703 pub fn param<T>(mut self, name: T, value: T) -> ProjectRunAggregationQueryCall<'a, C>
3704 where
3705 T: AsRef<str>,
3706 {
3707 self._additional_params
3708 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3709 self
3710 }
3711
3712 /// Identifies the authorization scope for the method you are building.
3713 ///
3714 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3715 /// [`Scope::CloudPlatform`].
3716 ///
3717 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3718 /// tokens for more than one scope.
3719 ///
3720 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3721 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3722 /// sufficient, a read-write scope will do as well.
3723 pub fn add_scope<St>(mut self, scope: St) -> ProjectRunAggregationQueryCall<'a, C>
3724 where
3725 St: AsRef<str>,
3726 {
3727 self._scopes.insert(String::from(scope.as_ref()));
3728 self
3729 }
3730 /// Identifies the authorization scope(s) for the method you are building.
3731 ///
3732 /// See [`Self::add_scope()`] for details.
3733 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectRunAggregationQueryCall<'a, C>
3734 where
3735 I: IntoIterator<Item = St>,
3736 St: AsRef<str>,
3737 {
3738 self._scopes
3739 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3740 self
3741 }
3742
3743 /// Removes all scopes, and no default scope will be used either.
3744 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3745 /// for details).
3746 pub fn clear_scopes(mut self) -> ProjectRunAggregationQueryCall<'a, C> {
3747 self._scopes.clear();
3748 self
3749 }
3750}
3751
3752/// Queries for entities.
3753///
3754/// A builder for the *runQuery* method supported by a *project* resource.
3755/// It is not used directly, but through a [`ProjectMethods`] instance.
3756///
3757/// # Example
3758///
3759/// Instantiate a resource method builder
3760///
3761/// ```test_harness,no_run
3762/// # extern crate hyper;
3763/// # extern crate hyper_rustls;
3764/// # extern crate google_datastore1_beta3 as datastore1_beta3;
3765/// use datastore1_beta3::api::RunQueryRequest;
3766/// # async fn dox() {
3767/// # use datastore1_beta3::{Datastore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3768///
3769/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3770/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3771/// # secret,
3772/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3773/// # ).build().await.unwrap();
3774///
3775/// # let client = hyper_util::client::legacy::Client::builder(
3776/// # hyper_util::rt::TokioExecutor::new()
3777/// # )
3778/// # .build(
3779/// # hyper_rustls::HttpsConnectorBuilder::new()
3780/// # .with_native_roots()
3781/// # .unwrap()
3782/// # .https_or_http()
3783/// # .enable_http1()
3784/// # .build()
3785/// # );
3786/// # let mut hub = Datastore::new(client, auth);
3787/// // As the method needs a request, you would usually fill it with the desired information
3788/// // into the respective structure. Some of the parts shown here might not be applicable !
3789/// // Values shown here are possibly random and not representative !
3790/// let mut req = RunQueryRequest::default();
3791///
3792/// // You can configure optional parameters by calling the respective setters at will, and
3793/// // execute the final call using `doit()`.
3794/// // Values shown here are possibly random and not representative !
3795/// let result = hub.projects().run_query(req, "projectId")
3796/// .doit().await;
3797/// # }
3798/// ```
3799pub struct ProjectRunQueryCall<'a, C>
3800where
3801 C: 'a,
3802{
3803 hub: &'a Datastore<C>,
3804 _request: RunQueryRequest,
3805 _project_id: String,
3806 _delegate: Option<&'a mut dyn common::Delegate>,
3807 _additional_params: HashMap<String, String>,
3808 _scopes: BTreeSet<String>,
3809}
3810
3811impl<'a, C> common::CallBuilder for ProjectRunQueryCall<'a, C> {}
3812
3813impl<'a, C> ProjectRunQueryCall<'a, C>
3814where
3815 C: common::Connector,
3816{
3817 /// Perform the operation you have build so far.
3818 pub async fn doit(mut self) -> common::Result<(common::Response, RunQueryResponse)> {
3819 use std::borrow::Cow;
3820 use std::io::{Read, Seek};
3821
3822 use common::{url::Params, ToParts};
3823 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3824
3825 let mut dd = common::DefaultDelegate;
3826 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3827 dlg.begin(common::MethodInfo {
3828 id: "datastore.projects.runQuery",
3829 http_method: hyper::Method::POST,
3830 });
3831
3832 for &field in ["alt", "projectId"].iter() {
3833 if self._additional_params.contains_key(field) {
3834 dlg.finished(false);
3835 return Err(common::Error::FieldClash(field));
3836 }
3837 }
3838
3839 let mut params = Params::with_capacity(4 + self._additional_params.len());
3840 params.push("projectId", self._project_id);
3841
3842 params.extend(self._additional_params.iter());
3843
3844 params.push("alt", "json");
3845 let mut url = self.hub._base_url.clone() + "v1beta3/projects/{projectId}:runQuery";
3846 if self._scopes.is_empty() {
3847 self._scopes
3848 .insert(Scope::CloudPlatform.as_ref().to_string());
3849 }
3850
3851 #[allow(clippy::single_element_loop)]
3852 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
3853 url = params.uri_replacement(url, param_name, find_this, false);
3854 }
3855 {
3856 let to_remove = ["projectId"];
3857 params.remove_params(&to_remove);
3858 }
3859
3860 let url = params.parse_with_url(&url);
3861
3862 let mut json_mime_type = mime::APPLICATION_JSON;
3863 let mut request_value_reader = {
3864 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3865 common::remove_json_null_values(&mut value);
3866 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3867 serde_json::to_writer(&mut dst, &value).unwrap();
3868 dst
3869 };
3870 let request_size = request_value_reader
3871 .seek(std::io::SeekFrom::End(0))
3872 .unwrap();
3873 request_value_reader
3874 .seek(std::io::SeekFrom::Start(0))
3875 .unwrap();
3876
3877 loop {
3878 let token = match self
3879 .hub
3880 .auth
3881 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3882 .await
3883 {
3884 Ok(token) => token,
3885 Err(e) => match dlg.token(e) {
3886 Ok(token) => token,
3887 Err(e) => {
3888 dlg.finished(false);
3889 return Err(common::Error::MissingToken(e));
3890 }
3891 },
3892 };
3893 request_value_reader
3894 .seek(std::io::SeekFrom::Start(0))
3895 .unwrap();
3896 let mut req_result = {
3897 let client = &self.hub.client;
3898 dlg.pre_request();
3899 let mut req_builder = hyper::Request::builder()
3900 .method(hyper::Method::POST)
3901 .uri(url.as_str())
3902 .header(USER_AGENT, self.hub._user_agent.clone());
3903
3904 if let Some(token) = token.as_ref() {
3905 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3906 }
3907
3908 let request = req_builder
3909 .header(CONTENT_TYPE, json_mime_type.to_string())
3910 .header(CONTENT_LENGTH, request_size as u64)
3911 .body(common::to_body(
3912 request_value_reader.get_ref().clone().into(),
3913 ));
3914
3915 client.request(request.unwrap()).await
3916 };
3917
3918 match req_result {
3919 Err(err) => {
3920 if let common::Retry::After(d) = dlg.http_error(&err) {
3921 sleep(d).await;
3922 continue;
3923 }
3924 dlg.finished(false);
3925 return Err(common::Error::HttpError(err));
3926 }
3927 Ok(res) => {
3928 let (mut parts, body) = res.into_parts();
3929 let mut body = common::Body::new(body);
3930 if !parts.status.is_success() {
3931 let bytes = common::to_bytes(body).await.unwrap_or_default();
3932 let error = serde_json::from_str(&common::to_string(&bytes));
3933 let response = common::to_response(parts, bytes.into());
3934
3935 if let common::Retry::After(d) =
3936 dlg.http_failure(&response, error.as_ref().ok())
3937 {
3938 sleep(d).await;
3939 continue;
3940 }
3941
3942 dlg.finished(false);
3943
3944 return Err(match error {
3945 Ok(value) => common::Error::BadRequest(value),
3946 _ => common::Error::Failure(response),
3947 });
3948 }
3949 let response = {
3950 let bytes = common::to_bytes(body).await.unwrap_or_default();
3951 let encoded = common::to_string(&bytes);
3952 match serde_json::from_str(&encoded) {
3953 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3954 Err(error) => {
3955 dlg.response_json_decode_error(&encoded, &error);
3956 return Err(common::Error::JsonDecodeError(
3957 encoded.to_string(),
3958 error,
3959 ));
3960 }
3961 }
3962 };
3963
3964 dlg.finished(true);
3965 return Ok(response);
3966 }
3967 }
3968 }
3969 }
3970
3971 ///
3972 /// Sets the *request* property to the given value.
3973 ///
3974 /// Even though the property as already been set when instantiating this call,
3975 /// we provide this method for API completeness.
3976 pub fn request(mut self, new_value: RunQueryRequest) -> ProjectRunQueryCall<'a, C> {
3977 self._request = new_value;
3978 self
3979 }
3980 /// Required. The ID of the project against which to make the request.
3981 ///
3982 /// Sets the *project id* path property to the given value.
3983 ///
3984 /// Even though the property as already been set when instantiating this call,
3985 /// we provide this method for API completeness.
3986 pub fn project_id(mut self, new_value: &str) -> ProjectRunQueryCall<'a, C> {
3987 self._project_id = new_value.to_string();
3988 self
3989 }
3990 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3991 /// while executing the actual API request.
3992 ///
3993 /// ````text
3994 /// It should be used to handle progress information, and to implement a certain level of resilience.
3995 /// ````
3996 ///
3997 /// Sets the *delegate* property to the given value.
3998 pub fn delegate(
3999 mut self,
4000 new_value: &'a mut dyn common::Delegate,
4001 ) -> ProjectRunQueryCall<'a, C> {
4002 self._delegate = Some(new_value);
4003 self
4004 }
4005
4006 /// Set any additional parameter of the query string used in the request.
4007 /// It should be used to set parameters which are not yet available through their own
4008 /// setters.
4009 ///
4010 /// Please note that this method must not be used to set any of the known parameters
4011 /// which have their own setter method. If done anyway, the request will fail.
4012 ///
4013 /// # Additional Parameters
4014 ///
4015 /// * *$.xgafv* (query-string) - V1 error format.
4016 /// * *access_token* (query-string) - OAuth access token.
4017 /// * *alt* (query-string) - Data format for response.
4018 /// * *callback* (query-string) - JSONP
4019 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4020 /// * *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.
4021 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4022 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4023 /// * *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.
4024 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4025 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4026 pub fn param<T>(mut self, name: T, value: T) -> ProjectRunQueryCall<'a, C>
4027 where
4028 T: AsRef<str>,
4029 {
4030 self._additional_params
4031 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4032 self
4033 }
4034
4035 /// Identifies the authorization scope for the method you are building.
4036 ///
4037 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4038 /// [`Scope::CloudPlatform`].
4039 ///
4040 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4041 /// tokens for more than one scope.
4042 ///
4043 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4044 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4045 /// sufficient, a read-write scope will do as well.
4046 pub fn add_scope<St>(mut self, scope: St) -> ProjectRunQueryCall<'a, C>
4047 where
4048 St: AsRef<str>,
4049 {
4050 self._scopes.insert(String::from(scope.as_ref()));
4051 self
4052 }
4053 /// Identifies the authorization scope(s) for the method you are building.
4054 ///
4055 /// See [`Self::add_scope()`] for details.
4056 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectRunQueryCall<'a, C>
4057 where
4058 I: IntoIterator<Item = St>,
4059 St: AsRef<str>,
4060 {
4061 self._scopes
4062 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4063 self
4064 }
4065
4066 /// Removes all scopes, and no default scope will be used either.
4067 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4068 /// for details).
4069 pub fn clear_scopes(mut self) -> ProjectRunQueryCall<'a, C> {
4070 self._scopes.clear();
4071 self
4072 }
4073}