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