google_cloud_spanner_admin_database_v1/builder.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17pub mod database_admin {
18 use crate::Result;
19
20 /// A builder for [DatabaseAdmin][crate::client::DatabaseAdmin].
21 ///
22 /// ```
23 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24 /// # use google_cloud_spanner_admin_database_v1::*;
25 /// # use builder::database_admin::ClientBuilder;
26 /// # use client::DatabaseAdmin;
27 /// let builder : ClientBuilder = DatabaseAdmin::builder();
28 /// let client = builder
29 /// .with_endpoint("https://spanner.googleapis.com")
30 /// .build().await?;
31 /// # Ok(()) }
32 /// ```
33 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
34
35 pub(crate) mod client {
36 use super::super::super::client::DatabaseAdmin;
37 pub struct Factory;
38 impl crate::ClientFactory for Factory {
39 type Client = DatabaseAdmin;
40 type Credentials = gaxi::options::Credentials;
41 async fn build(
42 self,
43 config: gaxi::options::ClientConfig,
44 ) -> crate::ClientBuilderResult<Self::Client> {
45 Self::Client::new(config).await
46 }
47 }
48 }
49
50 /// Common implementation for [crate::client::DatabaseAdmin] request builders.
51 #[derive(Clone, Debug)]
52 pub(crate) struct RequestBuilder<R: std::default::Default> {
53 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
54 request: R,
55 options: crate::RequestOptions,
56 }
57
58 impl<R> RequestBuilder<R>
59 where
60 R: std::default::Default,
61 {
62 pub(crate) fn new(
63 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
64 ) -> Self {
65 Self {
66 stub,
67 request: R::default(),
68 options: crate::RequestOptions::default(),
69 }
70 }
71 }
72
73 /// The request builder for [DatabaseAdmin::list_databases][crate::client::DatabaseAdmin::list_databases] calls.
74 ///
75 /// # Example
76 /// ```
77 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::ListDatabases;
78 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
79 /// use google_cloud_gax::paginator::ItemPaginator;
80 ///
81 /// let builder = prepare_request_builder();
82 /// let mut items = builder.by_item();
83 /// while let Some(result) = items.next().await {
84 /// let item = result?;
85 /// }
86 /// # Ok(()) }
87 ///
88 /// fn prepare_request_builder() -> ListDatabases {
89 /// # panic!();
90 /// // ... details omitted ...
91 /// }
92 /// ```
93 #[derive(Clone, Debug)]
94 pub struct ListDatabases(RequestBuilder<crate::model::ListDatabasesRequest>);
95
96 impl ListDatabases {
97 pub(crate) fn new(
98 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
99 ) -> Self {
100 Self(RequestBuilder::new(stub))
101 }
102
103 /// Sets the full request, replacing any prior values.
104 pub fn with_request<V: Into<crate::model::ListDatabasesRequest>>(mut self, v: V) -> Self {
105 self.0.request = v.into();
106 self
107 }
108
109 /// Sets all the options, replacing any prior values.
110 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
111 self.0.options = v.into();
112 self
113 }
114
115 /// Sends the request.
116 pub async fn send(self) -> Result<crate::model::ListDatabasesResponse> {
117 (*self.0.stub)
118 .list_databases(self.0.request, self.0.options)
119 .await
120 .map(crate::Response::into_body)
121 }
122
123 /// Streams each page in the collection.
124 pub fn by_page(
125 self,
126 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListDatabasesResponse, crate::Error>
127 {
128 use std::clone::Clone;
129 let token = self.0.request.page_token.clone();
130 let execute = move |token: String| {
131 let mut builder = self.clone();
132 builder.0.request = builder.0.request.set_page_token(token);
133 builder.send()
134 };
135 google_cloud_gax::paginator::internal::new_paginator(token, execute)
136 }
137
138 /// Streams each item in the collection.
139 pub fn by_item(
140 self,
141 ) -> impl google_cloud_gax::paginator::ItemPaginator<
142 crate::model::ListDatabasesResponse,
143 crate::Error,
144 > {
145 use google_cloud_gax::paginator::Paginator;
146 self.by_page().items()
147 }
148
149 /// Sets the value of [parent][crate::model::ListDatabasesRequest::parent].
150 ///
151 /// This is a **required** field for requests.
152 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
153 self.0.request.parent = v.into();
154 self
155 }
156
157 /// Sets the value of [page_size][crate::model::ListDatabasesRequest::page_size].
158 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
159 self.0.request.page_size = v.into();
160 self
161 }
162
163 /// Sets the value of [page_token][crate::model::ListDatabasesRequest::page_token].
164 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
165 self.0.request.page_token = v.into();
166 self
167 }
168 }
169
170 #[doc(hidden)]
171 impl crate::RequestBuilder for ListDatabases {
172 fn request_options(&mut self) -> &mut crate::RequestOptions {
173 &mut self.0.options
174 }
175 }
176
177 /// The request builder for [DatabaseAdmin::create_database][crate::client::DatabaseAdmin::create_database] calls.
178 ///
179 /// # Example
180 /// ```
181 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::CreateDatabase;
182 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
183 /// use google_cloud_lro::Poller;
184 ///
185 /// let builder = prepare_request_builder();
186 /// let response = builder.poller().until_done().await?;
187 /// # Ok(()) }
188 ///
189 /// fn prepare_request_builder() -> CreateDatabase {
190 /// # panic!();
191 /// // ... details omitted ...
192 /// }
193 /// ```
194 #[derive(Clone, Debug)]
195 pub struct CreateDatabase(RequestBuilder<crate::model::CreateDatabaseRequest>);
196
197 impl CreateDatabase {
198 pub(crate) fn new(
199 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
200 ) -> Self {
201 Self(RequestBuilder::new(stub))
202 }
203
204 /// Sets the full request, replacing any prior values.
205 pub fn with_request<V: Into<crate::model::CreateDatabaseRequest>>(mut self, v: V) -> Self {
206 self.0.request = v.into();
207 self
208 }
209
210 /// Sets all the options, replacing any prior values.
211 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
212 self.0.options = v.into();
213 self
214 }
215
216 /// Sends the request.
217 ///
218 /// # Long running operations
219 ///
220 /// This starts, but does not poll, a longrunning operation. More information
221 /// on [create_database][crate::client::DatabaseAdmin::create_database].
222 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
223 (*self.0.stub)
224 .create_database(self.0.request, self.0.options)
225 .await
226 .map(crate::Response::into_body)
227 }
228
229 /// Creates a [Poller][google_cloud_lro::Poller] to work with `create_database`.
230 pub fn poller(
231 self,
232 ) -> impl google_cloud_lro::Poller<crate::model::Database, crate::model::CreateDatabaseMetadata>
233 {
234 type Operation = google_cloud_lro::internal::Operation<
235 crate::model::Database,
236 crate::model::CreateDatabaseMetadata,
237 >;
238 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
239 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
240
241 let stub = self.0.stub.clone();
242 let mut options = self.0.options.clone();
243 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
244 let query = move |name| {
245 let stub = stub.clone();
246 let options = options.clone();
247 async {
248 let op = GetOperation::new(stub)
249 .set_name(name)
250 .with_options(options)
251 .send()
252 .await?;
253 Ok(Operation::new(op))
254 }
255 };
256
257 let start = move || async {
258 let op = self.send().await?;
259 Ok(Operation::new(op))
260 };
261
262 google_cloud_lro::internal::new_poller(
263 polling_error_policy,
264 polling_backoff_policy,
265 start,
266 query,
267 )
268 }
269
270 /// Sets the value of [parent][crate::model::CreateDatabaseRequest::parent].
271 ///
272 /// This is a **required** field for requests.
273 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
274 self.0.request.parent = v.into();
275 self
276 }
277
278 /// Sets the value of [create_statement][crate::model::CreateDatabaseRequest::create_statement].
279 ///
280 /// This is a **required** field for requests.
281 pub fn set_create_statement<T: Into<std::string::String>>(mut self, v: T) -> Self {
282 self.0.request.create_statement = v.into();
283 self
284 }
285
286 /// Sets the value of [extra_statements][crate::model::CreateDatabaseRequest::extra_statements].
287 pub fn set_extra_statements<T, V>(mut self, v: T) -> Self
288 where
289 T: std::iter::IntoIterator<Item = V>,
290 V: std::convert::Into<std::string::String>,
291 {
292 use std::iter::Iterator;
293 self.0.request.extra_statements = v.into_iter().map(|i| i.into()).collect();
294 self
295 }
296
297 /// Sets the value of [encryption_config][crate::model::CreateDatabaseRequest::encryption_config].
298 pub fn set_encryption_config<T>(mut self, v: T) -> Self
299 where
300 T: std::convert::Into<crate::model::EncryptionConfig>,
301 {
302 self.0.request.encryption_config = std::option::Option::Some(v.into());
303 self
304 }
305
306 /// Sets or clears the value of [encryption_config][crate::model::CreateDatabaseRequest::encryption_config].
307 pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
308 where
309 T: std::convert::Into<crate::model::EncryptionConfig>,
310 {
311 self.0.request.encryption_config = v.map(|x| x.into());
312 self
313 }
314
315 /// Sets the value of [database_dialect][crate::model::CreateDatabaseRequest::database_dialect].
316 pub fn set_database_dialect<T: Into<crate::model::DatabaseDialect>>(
317 mut self,
318 v: T,
319 ) -> Self {
320 self.0.request.database_dialect = v.into();
321 self
322 }
323
324 /// Sets the value of [proto_descriptors][crate::model::CreateDatabaseRequest::proto_descriptors].
325 pub fn set_proto_descriptors<T: Into<::bytes::Bytes>>(mut self, v: T) -> Self {
326 self.0.request.proto_descriptors = v.into();
327 self
328 }
329 }
330
331 #[doc(hidden)]
332 impl crate::RequestBuilder for CreateDatabase {
333 fn request_options(&mut self) -> &mut crate::RequestOptions {
334 &mut self.0.options
335 }
336 }
337
338 /// The request builder for [DatabaseAdmin::get_database][crate::client::DatabaseAdmin::get_database] calls.
339 ///
340 /// # Example
341 /// ```
342 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::GetDatabase;
343 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
344 ///
345 /// let builder = prepare_request_builder();
346 /// let response = builder.send().await?;
347 /// # Ok(()) }
348 ///
349 /// fn prepare_request_builder() -> GetDatabase {
350 /// # panic!();
351 /// // ... details omitted ...
352 /// }
353 /// ```
354 #[derive(Clone, Debug)]
355 pub struct GetDatabase(RequestBuilder<crate::model::GetDatabaseRequest>);
356
357 impl GetDatabase {
358 pub(crate) fn new(
359 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
360 ) -> Self {
361 Self(RequestBuilder::new(stub))
362 }
363
364 /// Sets the full request, replacing any prior values.
365 pub fn with_request<V: Into<crate::model::GetDatabaseRequest>>(mut self, v: V) -> Self {
366 self.0.request = v.into();
367 self
368 }
369
370 /// Sets all the options, replacing any prior values.
371 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
372 self.0.options = v.into();
373 self
374 }
375
376 /// Sends the request.
377 pub async fn send(self) -> Result<crate::model::Database> {
378 (*self.0.stub)
379 .get_database(self.0.request, self.0.options)
380 .await
381 .map(crate::Response::into_body)
382 }
383
384 /// Sets the value of [name][crate::model::GetDatabaseRequest::name].
385 ///
386 /// This is a **required** field for requests.
387 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
388 self.0.request.name = v.into();
389 self
390 }
391 }
392
393 #[doc(hidden)]
394 impl crate::RequestBuilder for GetDatabase {
395 fn request_options(&mut self) -> &mut crate::RequestOptions {
396 &mut self.0.options
397 }
398 }
399
400 /// The request builder for [DatabaseAdmin::update_database][crate::client::DatabaseAdmin::update_database] calls.
401 ///
402 /// # Example
403 /// ```
404 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::UpdateDatabase;
405 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
406 /// use google_cloud_lro::Poller;
407 ///
408 /// let builder = prepare_request_builder();
409 /// let response = builder.poller().until_done().await?;
410 /// # Ok(()) }
411 ///
412 /// fn prepare_request_builder() -> UpdateDatabase {
413 /// # panic!();
414 /// // ... details omitted ...
415 /// }
416 /// ```
417 #[derive(Clone, Debug)]
418 pub struct UpdateDatabase(RequestBuilder<crate::model::UpdateDatabaseRequest>);
419
420 impl UpdateDatabase {
421 pub(crate) fn new(
422 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
423 ) -> Self {
424 Self(RequestBuilder::new(stub))
425 }
426
427 /// Sets the full request, replacing any prior values.
428 pub fn with_request<V: Into<crate::model::UpdateDatabaseRequest>>(mut self, v: V) -> Self {
429 self.0.request = v.into();
430 self
431 }
432
433 /// Sets all the options, replacing any prior values.
434 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
435 self.0.options = v.into();
436 self
437 }
438
439 /// Sends the request.
440 ///
441 /// # Long running operations
442 ///
443 /// This starts, but does not poll, a longrunning operation. More information
444 /// on [update_database][crate::client::DatabaseAdmin::update_database].
445 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
446 (*self.0.stub)
447 .update_database(self.0.request, self.0.options)
448 .await
449 .map(crate::Response::into_body)
450 }
451
452 /// Creates a [Poller][google_cloud_lro::Poller] to work with `update_database`.
453 pub fn poller(
454 self,
455 ) -> impl google_cloud_lro::Poller<crate::model::Database, crate::model::UpdateDatabaseMetadata>
456 {
457 type Operation = google_cloud_lro::internal::Operation<
458 crate::model::Database,
459 crate::model::UpdateDatabaseMetadata,
460 >;
461 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
462 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
463
464 let stub = self.0.stub.clone();
465 let mut options = self.0.options.clone();
466 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
467 let query = move |name| {
468 let stub = stub.clone();
469 let options = options.clone();
470 async {
471 let op = GetOperation::new(stub)
472 .set_name(name)
473 .with_options(options)
474 .send()
475 .await?;
476 Ok(Operation::new(op))
477 }
478 };
479
480 let start = move || async {
481 let op = self.send().await?;
482 Ok(Operation::new(op))
483 };
484
485 google_cloud_lro::internal::new_poller(
486 polling_error_policy,
487 polling_backoff_policy,
488 start,
489 query,
490 )
491 }
492
493 /// Sets the value of [database][crate::model::UpdateDatabaseRequest::database].
494 ///
495 /// This is a **required** field for requests.
496 pub fn set_database<T>(mut self, v: T) -> Self
497 where
498 T: std::convert::Into<crate::model::Database>,
499 {
500 self.0.request.database = std::option::Option::Some(v.into());
501 self
502 }
503
504 /// Sets or clears the value of [database][crate::model::UpdateDatabaseRequest::database].
505 ///
506 /// This is a **required** field for requests.
507 pub fn set_or_clear_database<T>(mut self, v: std::option::Option<T>) -> Self
508 where
509 T: std::convert::Into<crate::model::Database>,
510 {
511 self.0.request.database = v.map(|x| x.into());
512 self
513 }
514
515 /// Sets the value of [update_mask][crate::model::UpdateDatabaseRequest::update_mask].
516 ///
517 /// This is a **required** field for requests.
518 pub fn set_update_mask<T>(mut self, v: T) -> Self
519 where
520 T: std::convert::Into<wkt::FieldMask>,
521 {
522 self.0.request.update_mask = std::option::Option::Some(v.into());
523 self
524 }
525
526 /// Sets or clears the value of [update_mask][crate::model::UpdateDatabaseRequest::update_mask].
527 ///
528 /// This is a **required** field for requests.
529 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
530 where
531 T: std::convert::Into<wkt::FieldMask>,
532 {
533 self.0.request.update_mask = v.map(|x| x.into());
534 self
535 }
536 }
537
538 #[doc(hidden)]
539 impl crate::RequestBuilder for UpdateDatabase {
540 fn request_options(&mut self) -> &mut crate::RequestOptions {
541 &mut self.0.options
542 }
543 }
544
545 /// The request builder for [DatabaseAdmin::update_database_ddl][crate::client::DatabaseAdmin::update_database_ddl] calls.
546 ///
547 /// # Example
548 /// ```
549 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::UpdateDatabaseDdl;
550 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
551 /// use google_cloud_lro::Poller;
552 ///
553 /// let builder = prepare_request_builder();
554 /// let response = builder.poller().until_done().await?;
555 /// # Ok(()) }
556 ///
557 /// fn prepare_request_builder() -> UpdateDatabaseDdl {
558 /// # panic!();
559 /// // ... details omitted ...
560 /// }
561 /// ```
562 #[derive(Clone, Debug)]
563 pub struct UpdateDatabaseDdl(RequestBuilder<crate::model::UpdateDatabaseDdlRequest>);
564
565 impl UpdateDatabaseDdl {
566 pub(crate) fn new(
567 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
568 ) -> Self {
569 Self(RequestBuilder::new(stub))
570 }
571
572 /// Sets the full request, replacing any prior values.
573 pub fn with_request<V: Into<crate::model::UpdateDatabaseDdlRequest>>(
574 mut self,
575 v: V,
576 ) -> Self {
577 self.0.request = v.into();
578 self
579 }
580
581 /// Sets all the options, replacing any prior values.
582 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
583 self.0.options = v.into();
584 self
585 }
586
587 /// Sends the request.
588 ///
589 /// # Long running operations
590 ///
591 /// This starts, but does not poll, a longrunning operation. More information
592 /// on [update_database_ddl][crate::client::DatabaseAdmin::update_database_ddl].
593 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
594 (*self.0.stub)
595 .update_database_ddl(self.0.request, self.0.options)
596 .await
597 .map(crate::Response::into_body)
598 }
599
600 /// Creates a [Poller][google_cloud_lro::Poller] to work with `update_database_ddl`.
601 pub fn poller(
602 self,
603 ) -> impl google_cloud_lro::Poller<(), crate::model::UpdateDatabaseDdlMetadata> {
604 type Operation = google_cloud_lro::internal::Operation<
605 wkt::Empty,
606 crate::model::UpdateDatabaseDdlMetadata,
607 >;
608 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
609 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
610
611 let stub = self.0.stub.clone();
612 let mut options = self.0.options.clone();
613 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
614 let query = move |name| {
615 let stub = stub.clone();
616 let options = options.clone();
617 async {
618 let op = GetOperation::new(stub)
619 .set_name(name)
620 .with_options(options)
621 .send()
622 .await?;
623 Ok(Operation::new(op))
624 }
625 };
626
627 let start = move || async {
628 let op = self.send().await?;
629 Ok(Operation::new(op))
630 };
631
632 google_cloud_lro::internal::new_unit_response_poller(
633 polling_error_policy,
634 polling_backoff_policy,
635 start,
636 query,
637 )
638 }
639
640 /// Sets the value of [database][crate::model::UpdateDatabaseDdlRequest::database].
641 ///
642 /// This is a **required** field for requests.
643 pub fn set_database<T: Into<std::string::String>>(mut self, v: T) -> Self {
644 self.0.request.database = v.into();
645 self
646 }
647
648 /// Sets the value of [statements][crate::model::UpdateDatabaseDdlRequest::statements].
649 ///
650 /// This is a **required** field for requests.
651 pub fn set_statements<T, V>(mut self, v: T) -> Self
652 where
653 T: std::iter::IntoIterator<Item = V>,
654 V: std::convert::Into<std::string::String>,
655 {
656 use std::iter::Iterator;
657 self.0.request.statements = v.into_iter().map(|i| i.into()).collect();
658 self
659 }
660
661 /// Sets the value of [operation_id][crate::model::UpdateDatabaseDdlRequest::operation_id].
662 pub fn set_operation_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
663 self.0.request.operation_id = v.into();
664 self
665 }
666
667 /// Sets the value of [proto_descriptors][crate::model::UpdateDatabaseDdlRequest::proto_descriptors].
668 pub fn set_proto_descriptors<T: Into<::bytes::Bytes>>(mut self, v: T) -> Self {
669 self.0.request.proto_descriptors = v.into();
670 self
671 }
672
673 /// Sets the value of [throughput_mode][crate::model::UpdateDatabaseDdlRequest::throughput_mode].
674 pub fn set_throughput_mode<T: Into<bool>>(mut self, v: T) -> Self {
675 self.0.request.throughput_mode = v.into();
676 self
677 }
678 }
679
680 #[doc(hidden)]
681 impl crate::RequestBuilder for UpdateDatabaseDdl {
682 fn request_options(&mut self) -> &mut crate::RequestOptions {
683 &mut self.0.options
684 }
685 }
686
687 /// The request builder for [DatabaseAdmin::drop_database][crate::client::DatabaseAdmin::drop_database] calls.
688 ///
689 /// # Example
690 /// ```
691 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::DropDatabase;
692 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
693 ///
694 /// let builder = prepare_request_builder();
695 /// let response = builder.send().await?;
696 /// # Ok(()) }
697 ///
698 /// fn prepare_request_builder() -> DropDatabase {
699 /// # panic!();
700 /// // ... details omitted ...
701 /// }
702 /// ```
703 #[derive(Clone, Debug)]
704 pub struct DropDatabase(RequestBuilder<crate::model::DropDatabaseRequest>);
705
706 impl DropDatabase {
707 pub(crate) fn new(
708 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
709 ) -> Self {
710 Self(RequestBuilder::new(stub))
711 }
712
713 /// Sets the full request, replacing any prior values.
714 pub fn with_request<V: Into<crate::model::DropDatabaseRequest>>(mut self, v: V) -> Self {
715 self.0.request = v.into();
716 self
717 }
718
719 /// Sets all the options, replacing any prior values.
720 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
721 self.0.options = v.into();
722 self
723 }
724
725 /// Sends the request.
726 pub async fn send(self) -> Result<()> {
727 (*self.0.stub)
728 .drop_database(self.0.request, self.0.options)
729 .await
730 .map(crate::Response::into_body)
731 }
732
733 /// Sets the value of [database][crate::model::DropDatabaseRequest::database].
734 ///
735 /// This is a **required** field for requests.
736 pub fn set_database<T: Into<std::string::String>>(mut self, v: T) -> Self {
737 self.0.request.database = v.into();
738 self
739 }
740 }
741
742 #[doc(hidden)]
743 impl crate::RequestBuilder for DropDatabase {
744 fn request_options(&mut self) -> &mut crate::RequestOptions {
745 &mut self.0.options
746 }
747 }
748
749 /// The request builder for [DatabaseAdmin::get_database_ddl][crate::client::DatabaseAdmin::get_database_ddl] calls.
750 ///
751 /// # Example
752 /// ```
753 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::GetDatabaseDdl;
754 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
755 ///
756 /// let builder = prepare_request_builder();
757 /// let response = builder.send().await?;
758 /// # Ok(()) }
759 ///
760 /// fn prepare_request_builder() -> GetDatabaseDdl {
761 /// # panic!();
762 /// // ... details omitted ...
763 /// }
764 /// ```
765 #[derive(Clone, Debug)]
766 pub struct GetDatabaseDdl(RequestBuilder<crate::model::GetDatabaseDdlRequest>);
767
768 impl GetDatabaseDdl {
769 pub(crate) fn new(
770 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
771 ) -> Self {
772 Self(RequestBuilder::new(stub))
773 }
774
775 /// Sets the full request, replacing any prior values.
776 pub fn with_request<V: Into<crate::model::GetDatabaseDdlRequest>>(mut self, v: V) -> Self {
777 self.0.request = v.into();
778 self
779 }
780
781 /// Sets all the options, replacing any prior values.
782 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
783 self.0.options = v.into();
784 self
785 }
786
787 /// Sends the request.
788 pub async fn send(self) -> Result<crate::model::GetDatabaseDdlResponse> {
789 (*self.0.stub)
790 .get_database_ddl(self.0.request, self.0.options)
791 .await
792 .map(crate::Response::into_body)
793 }
794
795 /// Sets the value of [database][crate::model::GetDatabaseDdlRequest::database].
796 ///
797 /// This is a **required** field for requests.
798 pub fn set_database<T: Into<std::string::String>>(mut self, v: T) -> Self {
799 self.0.request.database = v.into();
800 self
801 }
802 }
803
804 #[doc(hidden)]
805 impl crate::RequestBuilder for GetDatabaseDdl {
806 fn request_options(&mut self) -> &mut crate::RequestOptions {
807 &mut self.0.options
808 }
809 }
810
811 /// The request builder for [DatabaseAdmin::set_iam_policy][crate::client::DatabaseAdmin::set_iam_policy] calls.
812 ///
813 /// # Example
814 /// ```
815 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::SetIamPolicy;
816 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
817 ///
818 /// let builder = prepare_request_builder();
819 /// let response = builder.send().await?;
820 /// # Ok(()) }
821 ///
822 /// fn prepare_request_builder() -> SetIamPolicy {
823 /// # panic!();
824 /// // ... details omitted ...
825 /// }
826 /// ```
827 #[derive(Clone, Debug)]
828 pub struct SetIamPolicy(RequestBuilder<google_cloud_iam_v1::model::SetIamPolicyRequest>);
829
830 impl SetIamPolicy {
831 pub(crate) fn new(
832 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
833 ) -> Self {
834 Self(RequestBuilder::new(stub))
835 }
836
837 /// Sets the full request, replacing any prior values.
838 pub fn with_request<V: Into<google_cloud_iam_v1::model::SetIamPolicyRequest>>(
839 mut self,
840 v: V,
841 ) -> Self {
842 self.0.request = v.into();
843 self
844 }
845
846 /// Sets all the options, replacing any prior values.
847 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
848 self.0.options = v.into();
849 self
850 }
851
852 /// Sends the request.
853 pub async fn send(self) -> Result<google_cloud_iam_v1::model::Policy> {
854 (*self.0.stub)
855 .set_iam_policy(self.0.request, self.0.options)
856 .await
857 .map(crate::Response::into_body)
858 }
859
860 /// Sets the value of [resource][google_cloud_iam_v1::model::SetIamPolicyRequest::resource].
861 ///
862 /// This is a **required** field for requests.
863 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
864 self.0.request.resource = v.into();
865 self
866 }
867
868 /// Sets the value of [policy][google_cloud_iam_v1::model::SetIamPolicyRequest::policy].
869 ///
870 /// This is a **required** field for requests.
871 pub fn set_policy<T>(mut self, v: T) -> Self
872 where
873 T: std::convert::Into<google_cloud_iam_v1::model::Policy>,
874 {
875 self.0.request.policy = std::option::Option::Some(v.into());
876 self
877 }
878
879 /// Sets or clears the value of [policy][google_cloud_iam_v1::model::SetIamPolicyRequest::policy].
880 ///
881 /// This is a **required** field for requests.
882 pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
883 where
884 T: std::convert::Into<google_cloud_iam_v1::model::Policy>,
885 {
886 self.0.request.policy = v.map(|x| x.into());
887 self
888 }
889
890 /// Sets the value of [update_mask][google_cloud_iam_v1::model::SetIamPolicyRequest::update_mask].
891 pub fn set_update_mask<T>(mut self, v: T) -> Self
892 where
893 T: std::convert::Into<wkt::FieldMask>,
894 {
895 self.0.request.update_mask = std::option::Option::Some(v.into());
896 self
897 }
898
899 /// Sets or clears the value of [update_mask][google_cloud_iam_v1::model::SetIamPolicyRequest::update_mask].
900 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
901 where
902 T: std::convert::Into<wkt::FieldMask>,
903 {
904 self.0.request.update_mask = v.map(|x| x.into());
905 self
906 }
907 }
908
909 #[doc(hidden)]
910 impl crate::RequestBuilder for SetIamPolicy {
911 fn request_options(&mut self) -> &mut crate::RequestOptions {
912 &mut self.0.options
913 }
914 }
915
916 /// The request builder for [DatabaseAdmin::get_iam_policy][crate::client::DatabaseAdmin::get_iam_policy] calls.
917 ///
918 /// # Example
919 /// ```
920 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::GetIamPolicy;
921 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
922 ///
923 /// let builder = prepare_request_builder();
924 /// let response = builder.send().await?;
925 /// # Ok(()) }
926 ///
927 /// fn prepare_request_builder() -> GetIamPolicy {
928 /// # panic!();
929 /// // ... details omitted ...
930 /// }
931 /// ```
932 #[derive(Clone, Debug)]
933 pub struct GetIamPolicy(RequestBuilder<google_cloud_iam_v1::model::GetIamPolicyRequest>);
934
935 impl GetIamPolicy {
936 pub(crate) fn new(
937 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
938 ) -> Self {
939 Self(RequestBuilder::new(stub))
940 }
941
942 /// Sets the full request, replacing any prior values.
943 pub fn with_request<V: Into<google_cloud_iam_v1::model::GetIamPolicyRequest>>(
944 mut self,
945 v: V,
946 ) -> Self {
947 self.0.request = v.into();
948 self
949 }
950
951 /// Sets all the options, replacing any prior values.
952 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
953 self.0.options = v.into();
954 self
955 }
956
957 /// Sends the request.
958 pub async fn send(self) -> Result<google_cloud_iam_v1::model::Policy> {
959 (*self.0.stub)
960 .get_iam_policy(self.0.request, self.0.options)
961 .await
962 .map(crate::Response::into_body)
963 }
964
965 /// Sets the value of [resource][google_cloud_iam_v1::model::GetIamPolicyRequest::resource].
966 ///
967 /// This is a **required** field for requests.
968 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
969 self.0.request.resource = v.into();
970 self
971 }
972
973 /// Sets the value of [options][google_cloud_iam_v1::model::GetIamPolicyRequest::options].
974 pub fn set_options<T>(mut self, v: T) -> Self
975 where
976 T: std::convert::Into<google_cloud_iam_v1::model::GetPolicyOptions>,
977 {
978 self.0.request.options = std::option::Option::Some(v.into());
979 self
980 }
981
982 /// Sets or clears the value of [options][google_cloud_iam_v1::model::GetIamPolicyRequest::options].
983 pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
984 where
985 T: std::convert::Into<google_cloud_iam_v1::model::GetPolicyOptions>,
986 {
987 self.0.request.options = v.map(|x| x.into());
988 self
989 }
990 }
991
992 #[doc(hidden)]
993 impl crate::RequestBuilder for GetIamPolicy {
994 fn request_options(&mut self) -> &mut crate::RequestOptions {
995 &mut self.0.options
996 }
997 }
998
999 /// The request builder for [DatabaseAdmin::test_iam_permissions][crate::client::DatabaseAdmin::test_iam_permissions] calls.
1000 ///
1001 /// # Example
1002 /// ```
1003 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::TestIamPermissions;
1004 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1005 ///
1006 /// let builder = prepare_request_builder();
1007 /// let response = builder.send().await?;
1008 /// # Ok(()) }
1009 ///
1010 /// fn prepare_request_builder() -> TestIamPermissions {
1011 /// # panic!();
1012 /// // ... details omitted ...
1013 /// }
1014 /// ```
1015 #[derive(Clone, Debug)]
1016 pub struct TestIamPermissions(
1017 RequestBuilder<google_cloud_iam_v1::model::TestIamPermissionsRequest>,
1018 );
1019
1020 impl TestIamPermissions {
1021 pub(crate) fn new(
1022 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1023 ) -> Self {
1024 Self(RequestBuilder::new(stub))
1025 }
1026
1027 /// Sets the full request, replacing any prior values.
1028 pub fn with_request<V: Into<google_cloud_iam_v1::model::TestIamPermissionsRequest>>(
1029 mut self,
1030 v: V,
1031 ) -> Self {
1032 self.0.request = v.into();
1033 self
1034 }
1035
1036 /// Sets all the options, replacing any prior values.
1037 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1038 self.0.options = v.into();
1039 self
1040 }
1041
1042 /// Sends the request.
1043 pub async fn send(self) -> Result<google_cloud_iam_v1::model::TestIamPermissionsResponse> {
1044 (*self.0.stub)
1045 .test_iam_permissions(self.0.request, self.0.options)
1046 .await
1047 .map(crate::Response::into_body)
1048 }
1049
1050 /// Sets the value of [resource][google_cloud_iam_v1::model::TestIamPermissionsRequest::resource].
1051 ///
1052 /// This is a **required** field for requests.
1053 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
1054 self.0.request.resource = v.into();
1055 self
1056 }
1057
1058 /// Sets the value of [permissions][google_cloud_iam_v1::model::TestIamPermissionsRequest::permissions].
1059 ///
1060 /// This is a **required** field for requests.
1061 pub fn set_permissions<T, V>(mut self, v: T) -> Self
1062 where
1063 T: std::iter::IntoIterator<Item = V>,
1064 V: std::convert::Into<std::string::String>,
1065 {
1066 use std::iter::Iterator;
1067 self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
1068 self
1069 }
1070 }
1071
1072 #[doc(hidden)]
1073 impl crate::RequestBuilder for TestIamPermissions {
1074 fn request_options(&mut self) -> &mut crate::RequestOptions {
1075 &mut self.0.options
1076 }
1077 }
1078
1079 /// The request builder for [DatabaseAdmin::create_backup][crate::client::DatabaseAdmin::create_backup] calls.
1080 ///
1081 /// # Example
1082 /// ```
1083 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::CreateBackup;
1084 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1085 /// use google_cloud_lro::Poller;
1086 ///
1087 /// let builder = prepare_request_builder();
1088 /// let response = builder.poller().until_done().await?;
1089 /// # Ok(()) }
1090 ///
1091 /// fn prepare_request_builder() -> CreateBackup {
1092 /// # panic!();
1093 /// // ... details omitted ...
1094 /// }
1095 /// ```
1096 #[derive(Clone, Debug)]
1097 pub struct CreateBackup(RequestBuilder<crate::model::CreateBackupRequest>);
1098
1099 impl CreateBackup {
1100 pub(crate) fn new(
1101 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1102 ) -> Self {
1103 Self(RequestBuilder::new(stub))
1104 }
1105
1106 /// Sets the full request, replacing any prior values.
1107 pub fn with_request<V: Into<crate::model::CreateBackupRequest>>(mut self, v: V) -> Self {
1108 self.0.request = v.into();
1109 self
1110 }
1111
1112 /// Sets all the options, replacing any prior values.
1113 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1114 self.0.options = v.into();
1115 self
1116 }
1117
1118 /// Sends the request.
1119 ///
1120 /// # Long running operations
1121 ///
1122 /// This starts, but does not poll, a longrunning operation. More information
1123 /// on [create_backup][crate::client::DatabaseAdmin::create_backup].
1124 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1125 (*self.0.stub)
1126 .create_backup(self.0.request, self.0.options)
1127 .await
1128 .map(crate::Response::into_body)
1129 }
1130
1131 /// Creates a [Poller][google_cloud_lro::Poller] to work with `create_backup`.
1132 pub fn poller(
1133 self,
1134 ) -> impl google_cloud_lro::Poller<crate::model::Backup, crate::model::CreateBackupMetadata>
1135 {
1136 type Operation = google_cloud_lro::internal::Operation<
1137 crate::model::Backup,
1138 crate::model::CreateBackupMetadata,
1139 >;
1140 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1141 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1142
1143 let stub = self.0.stub.clone();
1144 let mut options = self.0.options.clone();
1145 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1146 let query = move |name| {
1147 let stub = stub.clone();
1148 let options = options.clone();
1149 async {
1150 let op = GetOperation::new(stub)
1151 .set_name(name)
1152 .with_options(options)
1153 .send()
1154 .await?;
1155 Ok(Operation::new(op))
1156 }
1157 };
1158
1159 let start = move || async {
1160 let op = self.send().await?;
1161 Ok(Operation::new(op))
1162 };
1163
1164 google_cloud_lro::internal::new_poller(
1165 polling_error_policy,
1166 polling_backoff_policy,
1167 start,
1168 query,
1169 )
1170 }
1171
1172 /// Sets the value of [parent][crate::model::CreateBackupRequest::parent].
1173 ///
1174 /// This is a **required** field for requests.
1175 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1176 self.0.request.parent = v.into();
1177 self
1178 }
1179
1180 /// Sets the value of [backup_id][crate::model::CreateBackupRequest::backup_id].
1181 ///
1182 /// This is a **required** field for requests.
1183 pub fn set_backup_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1184 self.0.request.backup_id = v.into();
1185 self
1186 }
1187
1188 /// Sets the value of [backup][crate::model::CreateBackupRequest::backup].
1189 ///
1190 /// This is a **required** field for requests.
1191 pub fn set_backup<T>(mut self, v: T) -> Self
1192 where
1193 T: std::convert::Into<crate::model::Backup>,
1194 {
1195 self.0.request.backup = std::option::Option::Some(v.into());
1196 self
1197 }
1198
1199 /// Sets or clears the value of [backup][crate::model::CreateBackupRequest::backup].
1200 ///
1201 /// This is a **required** field for requests.
1202 pub fn set_or_clear_backup<T>(mut self, v: std::option::Option<T>) -> Self
1203 where
1204 T: std::convert::Into<crate::model::Backup>,
1205 {
1206 self.0.request.backup = v.map(|x| x.into());
1207 self
1208 }
1209
1210 /// Sets the value of [encryption_config][crate::model::CreateBackupRequest::encryption_config].
1211 pub fn set_encryption_config<T>(mut self, v: T) -> Self
1212 where
1213 T: std::convert::Into<crate::model::CreateBackupEncryptionConfig>,
1214 {
1215 self.0.request.encryption_config = std::option::Option::Some(v.into());
1216 self
1217 }
1218
1219 /// Sets or clears the value of [encryption_config][crate::model::CreateBackupRequest::encryption_config].
1220 pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
1221 where
1222 T: std::convert::Into<crate::model::CreateBackupEncryptionConfig>,
1223 {
1224 self.0.request.encryption_config = v.map(|x| x.into());
1225 self
1226 }
1227 }
1228
1229 #[doc(hidden)]
1230 impl crate::RequestBuilder for CreateBackup {
1231 fn request_options(&mut self) -> &mut crate::RequestOptions {
1232 &mut self.0.options
1233 }
1234 }
1235
1236 /// The request builder for [DatabaseAdmin::copy_backup][crate::client::DatabaseAdmin::copy_backup] calls.
1237 ///
1238 /// # Example
1239 /// ```
1240 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::CopyBackup;
1241 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1242 /// use google_cloud_lro::Poller;
1243 ///
1244 /// let builder = prepare_request_builder();
1245 /// let response = builder.poller().until_done().await?;
1246 /// # Ok(()) }
1247 ///
1248 /// fn prepare_request_builder() -> CopyBackup {
1249 /// # panic!();
1250 /// // ... details omitted ...
1251 /// }
1252 /// ```
1253 #[derive(Clone, Debug)]
1254 pub struct CopyBackup(RequestBuilder<crate::model::CopyBackupRequest>);
1255
1256 impl CopyBackup {
1257 pub(crate) fn new(
1258 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1259 ) -> Self {
1260 Self(RequestBuilder::new(stub))
1261 }
1262
1263 /// Sets the full request, replacing any prior values.
1264 pub fn with_request<V: Into<crate::model::CopyBackupRequest>>(mut self, v: V) -> Self {
1265 self.0.request = v.into();
1266 self
1267 }
1268
1269 /// Sets all the options, replacing any prior values.
1270 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1271 self.0.options = v.into();
1272 self
1273 }
1274
1275 /// Sends the request.
1276 ///
1277 /// # Long running operations
1278 ///
1279 /// This starts, but does not poll, a longrunning operation. More information
1280 /// on [copy_backup][crate::client::DatabaseAdmin::copy_backup].
1281 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1282 (*self.0.stub)
1283 .copy_backup(self.0.request, self.0.options)
1284 .await
1285 .map(crate::Response::into_body)
1286 }
1287
1288 /// Creates a [Poller][google_cloud_lro::Poller] to work with `copy_backup`.
1289 pub fn poller(
1290 self,
1291 ) -> impl google_cloud_lro::Poller<crate::model::Backup, crate::model::CopyBackupMetadata>
1292 {
1293 type Operation = google_cloud_lro::internal::Operation<
1294 crate::model::Backup,
1295 crate::model::CopyBackupMetadata,
1296 >;
1297 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1298 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1299
1300 let stub = self.0.stub.clone();
1301 let mut options = self.0.options.clone();
1302 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1303 let query = move |name| {
1304 let stub = stub.clone();
1305 let options = options.clone();
1306 async {
1307 let op = GetOperation::new(stub)
1308 .set_name(name)
1309 .with_options(options)
1310 .send()
1311 .await?;
1312 Ok(Operation::new(op))
1313 }
1314 };
1315
1316 let start = move || async {
1317 let op = self.send().await?;
1318 Ok(Operation::new(op))
1319 };
1320
1321 google_cloud_lro::internal::new_poller(
1322 polling_error_policy,
1323 polling_backoff_policy,
1324 start,
1325 query,
1326 )
1327 }
1328
1329 /// Sets the value of [parent][crate::model::CopyBackupRequest::parent].
1330 ///
1331 /// This is a **required** field for requests.
1332 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1333 self.0.request.parent = v.into();
1334 self
1335 }
1336
1337 /// Sets the value of [backup_id][crate::model::CopyBackupRequest::backup_id].
1338 ///
1339 /// This is a **required** field for requests.
1340 pub fn set_backup_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1341 self.0.request.backup_id = v.into();
1342 self
1343 }
1344
1345 /// Sets the value of [source_backup][crate::model::CopyBackupRequest::source_backup].
1346 ///
1347 /// This is a **required** field for requests.
1348 pub fn set_source_backup<T: Into<std::string::String>>(mut self, v: T) -> Self {
1349 self.0.request.source_backup = v.into();
1350 self
1351 }
1352
1353 /// Sets the value of [expire_time][crate::model::CopyBackupRequest::expire_time].
1354 ///
1355 /// This is a **required** field for requests.
1356 pub fn set_expire_time<T>(mut self, v: T) -> Self
1357 where
1358 T: std::convert::Into<wkt::Timestamp>,
1359 {
1360 self.0.request.expire_time = std::option::Option::Some(v.into());
1361 self
1362 }
1363
1364 /// Sets or clears the value of [expire_time][crate::model::CopyBackupRequest::expire_time].
1365 ///
1366 /// This is a **required** field for requests.
1367 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
1368 where
1369 T: std::convert::Into<wkt::Timestamp>,
1370 {
1371 self.0.request.expire_time = v.map(|x| x.into());
1372 self
1373 }
1374
1375 /// Sets the value of [encryption_config][crate::model::CopyBackupRequest::encryption_config].
1376 pub fn set_encryption_config<T>(mut self, v: T) -> Self
1377 where
1378 T: std::convert::Into<crate::model::CopyBackupEncryptionConfig>,
1379 {
1380 self.0.request.encryption_config = std::option::Option::Some(v.into());
1381 self
1382 }
1383
1384 /// Sets or clears the value of [encryption_config][crate::model::CopyBackupRequest::encryption_config].
1385 pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
1386 where
1387 T: std::convert::Into<crate::model::CopyBackupEncryptionConfig>,
1388 {
1389 self.0.request.encryption_config = v.map(|x| x.into());
1390 self
1391 }
1392 }
1393
1394 #[doc(hidden)]
1395 impl crate::RequestBuilder for CopyBackup {
1396 fn request_options(&mut self) -> &mut crate::RequestOptions {
1397 &mut self.0.options
1398 }
1399 }
1400
1401 /// The request builder for [DatabaseAdmin::get_backup][crate::client::DatabaseAdmin::get_backup] calls.
1402 ///
1403 /// # Example
1404 /// ```
1405 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::GetBackup;
1406 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1407 ///
1408 /// let builder = prepare_request_builder();
1409 /// let response = builder.send().await?;
1410 /// # Ok(()) }
1411 ///
1412 /// fn prepare_request_builder() -> GetBackup {
1413 /// # panic!();
1414 /// // ... details omitted ...
1415 /// }
1416 /// ```
1417 #[derive(Clone, Debug)]
1418 pub struct GetBackup(RequestBuilder<crate::model::GetBackupRequest>);
1419
1420 impl GetBackup {
1421 pub(crate) fn new(
1422 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1423 ) -> Self {
1424 Self(RequestBuilder::new(stub))
1425 }
1426
1427 /// Sets the full request, replacing any prior values.
1428 pub fn with_request<V: Into<crate::model::GetBackupRequest>>(mut self, v: V) -> Self {
1429 self.0.request = v.into();
1430 self
1431 }
1432
1433 /// Sets all the options, replacing any prior values.
1434 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1435 self.0.options = v.into();
1436 self
1437 }
1438
1439 /// Sends the request.
1440 pub async fn send(self) -> Result<crate::model::Backup> {
1441 (*self.0.stub)
1442 .get_backup(self.0.request, self.0.options)
1443 .await
1444 .map(crate::Response::into_body)
1445 }
1446
1447 /// Sets the value of [name][crate::model::GetBackupRequest::name].
1448 ///
1449 /// This is a **required** field for requests.
1450 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1451 self.0.request.name = v.into();
1452 self
1453 }
1454 }
1455
1456 #[doc(hidden)]
1457 impl crate::RequestBuilder for GetBackup {
1458 fn request_options(&mut self) -> &mut crate::RequestOptions {
1459 &mut self.0.options
1460 }
1461 }
1462
1463 /// The request builder for [DatabaseAdmin::update_backup][crate::client::DatabaseAdmin::update_backup] calls.
1464 ///
1465 /// # Example
1466 /// ```
1467 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::UpdateBackup;
1468 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1469 ///
1470 /// let builder = prepare_request_builder();
1471 /// let response = builder.send().await?;
1472 /// # Ok(()) }
1473 ///
1474 /// fn prepare_request_builder() -> UpdateBackup {
1475 /// # panic!();
1476 /// // ... details omitted ...
1477 /// }
1478 /// ```
1479 #[derive(Clone, Debug)]
1480 pub struct UpdateBackup(RequestBuilder<crate::model::UpdateBackupRequest>);
1481
1482 impl UpdateBackup {
1483 pub(crate) fn new(
1484 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1485 ) -> Self {
1486 Self(RequestBuilder::new(stub))
1487 }
1488
1489 /// Sets the full request, replacing any prior values.
1490 pub fn with_request<V: Into<crate::model::UpdateBackupRequest>>(mut self, v: V) -> Self {
1491 self.0.request = v.into();
1492 self
1493 }
1494
1495 /// Sets all the options, replacing any prior values.
1496 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1497 self.0.options = v.into();
1498 self
1499 }
1500
1501 /// Sends the request.
1502 pub async fn send(self) -> Result<crate::model::Backup> {
1503 (*self.0.stub)
1504 .update_backup(self.0.request, self.0.options)
1505 .await
1506 .map(crate::Response::into_body)
1507 }
1508
1509 /// Sets the value of [backup][crate::model::UpdateBackupRequest::backup].
1510 ///
1511 /// This is a **required** field for requests.
1512 pub fn set_backup<T>(mut self, v: T) -> Self
1513 where
1514 T: std::convert::Into<crate::model::Backup>,
1515 {
1516 self.0.request.backup = std::option::Option::Some(v.into());
1517 self
1518 }
1519
1520 /// Sets or clears the value of [backup][crate::model::UpdateBackupRequest::backup].
1521 ///
1522 /// This is a **required** field for requests.
1523 pub fn set_or_clear_backup<T>(mut self, v: std::option::Option<T>) -> Self
1524 where
1525 T: std::convert::Into<crate::model::Backup>,
1526 {
1527 self.0.request.backup = v.map(|x| x.into());
1528 self
1529 }
1530
1531 /// Sets the value of [update_mask][crate::model::UpdateBackupRequest::update_mask].
1532 ///
1533 /// This is a **required** field for requests.
1534 pub fn set_update_mask<T>(mut self, v: T) -> Self
1535 where
1536 T: std::convert::Into<wkt::FieldMask>,
1537 {
1538 self.0.request.update_mask = std::option::Option::Some(v.into());
1539 self
1540 }
1541
1542 /// Sets or clears the value of [update_mask][crate::model::UpdateBackupRequest::update_mask].
1543 ///
1544 /// This is a **required** field for requests.
1545 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
1546 where
1547 T: std::convert::Into<wkt::FieldMask>,
1548 {
1549 self.0.request.update_mask = v.map(|x| x.into());
1550 self
1551 }
1552 }
1553
1554 #[doc(hidden)]
1555 impl crate::RequestBuilder for UpdateBackup {
1556 fn request_options(&mut self) -> &mut crate::RequestOptions {
1557 &mut self.0.options
1558 }
1559 }
1560
1561 /// The request builder for [DatabaseAdmin::delete_backup][crate::client::DatabaseAdmin::delete_backup] calls.
1562 ///
1563 /// # Example
1564 /// ```
1565 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::DeleteBackup;
1566 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1567 ///
1568 /// let builder = prepare_request_builder();
1569 /// let response = builder.send().await?;
1570 /// # Ok(()) }
1571 ///
1572 /// fn prepare_request_builder() -> DeleteBackup {
1573 /// # panic!();
1574 /// // ... details omitted ...
1575 /// }
1576 /// ```
1577 #[derive(Clone, Debug)]
1578 pub struct DeleteBackup(RequestBuilder<crate::model::DeleteBackupRequest>);
1579
1580 impl DeleteBackup {
1581 pub(crate) fn new(
1582 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1583 ) -> Self {
1584 Self(RequestBuilder::new(stub))
1585 }
1586
1587 /// Sets the full request, replacing any prior values.
1588 pub fn with_request<V: Into<crate::model::DeleteBackupRequest>>(mut self, v: V) -> Self {
1589 self.0.request = v.into();
1590 self
1591 }
1592
1593 /// Sets all the options, replacing any prior values.
1594 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1595 self.0.options = v.into();
1596 self
1597 }
1598
1599 /// Sends the request.
1600 pub async fn send(self) -> Result<()> {
1601 (*self.0.stub)
1602 .delete_backup(self.0.request, self.0.options)
1603 .await
1604 .map(crate::Response::into_body)
1605 }
1606
1607 /// Sets the value of [name][crate::model::DeleteBackupRequest::name].
1608 ///
1609 /// This is a **required** field for requests.
1610 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1611 self.0.request.name = v.into();
1612 self
1613 }
1614 }
1615
1616 #[doc(hidden)]
1617 impl crate::RequestBuilder for DeleteBackup {
1618 fn request_options(&mut self) -> &mut crate::RequestOptions {
1619 &mut self.0.options
1620 }
1621 }
1622
1623 /// The request builder for [DatabaseAdmin::list_backups][crate::client::DatabaseAdmin::list_backups] calls.
1624 ///
1625 /// # Example
1626 /// ```
1627 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::ListBackups;
1628 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1629 /// use google_cloud_gax::paginator::ItemPaginator;
1630 ///
1631 /// let builder = prepare_request_builder();
1632 /// let mut items = builder.by_item();
1633 /// while let Some(result) = items.next().await {
1634 /// let item = result?;
1635 /// }
1636 /// # Ok(()) }
1637 ///
1638 /// fn prepare_request_builder() -> ListBackups {
1639 /// # panic!();
1640 /// // ... details omitted ...
1641 /// }
1642 /// ```
1643 #[derive(Clone, Debug)]
1644 pub struct ListBackups(RequestBuilder<crate::model::ListBackupsRequest>);
1645
1646 impl ListBackups {
1647 pub(crate) fn new(
1648 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1649 ) -> Self {
1650 Self(RequestBuilder::new(stub))
1651 }
1652
1653 /// Sets the full request, replacing any prior values.
1654 pub fn with_request<V: Into<crate::model::ListBackupsRequest>>(mut self, v: V) -> Self {
1655 self.0.request = v.into();
1656 self
1657 }
1658
1659 /// Sets all the options, replacing any prior values.
1660 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1661 self.0.options = v.into();
1662 self
1663 }
1664
1665 /// Sends the request.
1666 pub async fn send(self) -> Result<crate::model::ListBackupsResponse> {
1667 (*self.0.stub)
1668 .list_backups(self.0.request, self.0.options)
1669 .await
1670 .map(crate::Response::into_body)
1671 }
1672
1673 /// Streams each page in the collection.
1674 pub fn by_page(
1675 self,
1676 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListBackupsResponse, crate::Error>
1677 {
1678 use std::clone::Clone;
1679 let token = self.0.request.page_token.clone();
1680 let execute = move |token: String| {
1681 let mut builder = self.clone();
1682 builder.0.request = builder.0.request.set_page_token(token);
1683 builder.send()
1684 };
1685 google_cloud_gax::paginator::internal::new_paginator(token, execute)
1686 }
1687
1688 /// Streams each item in the collection.
1689 pub fn by_item(
1690 self,
1691 ) -> impl google_cloud_gax::paginator::ItemPaginator<
1692 crate::model::ListBackupsResponse,
1693 crate::Error,
1694 > {
1695 use google_cloud_gax::paginator::Paginator;
1696 self.by_page().items()
1697 }
1698
1699 /// Sets the value of [parent][crate::model::ListBackupsRequest::parent].
1700 ///
1701 /// This is a **required** field for requests.
1702 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1703 self.0.request.parent = v.into();
1704 self
1705 }
1706
1707 /// Sets the value of [filter][crate::model::ListBackupsRequest::filter].
1708 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1709 self.0.request.filter = v.into();
1710 self
1711 }
1712
1713 /// Sets the value of [page_size][crate::model::ListBackupsRequest::page_size].
1714 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1715 self.0.request.page_size = v.into();
1716 self
1717 }
1718
1719 /// Sets the value of [page_token][crate::model::ListBackupsRequest::page_token].
1720 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1721 self.0.request.page_token = v.into();
1722 self
1723 }
1724 }
1725
1726 #[doc(hidden)]
1727 impl crate::RequestBuilder for ListBackups {
1728 fn request_options(&mut self) -> &mut crate::RequestOptions {
1729 &mut self.0.options
1730 }
1731 }
1732
1733 /// The request builder for [DatabaseAdmin::restore_database][crate::client::DatabaseAdmin::restore_database] calls.
1734 ///
1735 /// # Example
1736 /// ```
1737 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::RestoreDatabase;
1738 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1739 /// use google_cloud_lro::Poller;
1740 ///
1741 /// let builder = prepare_request_builder();
1742 /// let response = builder.poller().until_done().await?;
1743 /// # Ok(()) }
1744 ///
1745 /// fn prepare_request_builder() -> RestoreDatabase {
1746 /// # panic!();
1747 /// // ... details omitted ...
1748 /// }
1749 /// ```
1750 #[derive(Clone, Debug)]
1751 pub struct RestoreDatabase(RequestBuilder<crate::model::RestoreDatabaseRequest>);
1752
1753 impl RestoreDatabase {
1754 pub(crate) fn new(
1755 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1756 ) -> Self {
1757 Self(RequestBuilder::new(stub))
1758 }
1759
1760 /// Sets the full request, replacing any prior values.
1761 pub fn with_request<V: Into<crate::model::RestoreDatabaseRequest>>(mut self, v: V) -> Self {
1762 self.0.request = v.into();
1763 self
1764 }
1765
1766 /// Sets all the options, replacing any prior values.
1767 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1768 self.0.options = v.into();
1769 self
1770 }
1771
1772 /// Sends the request.
1773 ///
1774 /// # Long running operations
1775 ///
1776 /// This starts, but does not poll, a longrunning operation. More information
1777 /// on [restore_database][crate::client::DatabaseAdmin::restore_database].
1778 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1779 (*self.0.stub)
1780 .restore_database(self.0.request, self.0.options)
1781 .await
1782 .map(crate::Response::into_body)
1783 }
1784
1785 /// Creates a [Poller][google_cloud_lro::Poller] to work with `restore_database`.
1786 pub fn poller(
1787 self,
1788 ) -> impl google_cloud_lro::Poller<crate::model::Database, crate::model::RestoreDatabaseMetadata>
1789 {
1790 type Operation = google_cloud_lro::internal::Operation<
1791 crate::model::Database,
1792 crate::model::RestoreDatabaseMetadata,
1793 >;
1794 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1795 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1796
1797 let stub = self.0.stub.clone();
1798 let mut options = self.0.options.clone();
1799 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1800 let query = move |name| {
1801 let stub = stub.clone();
1802 let options = options.clone();
1803 async {
1804 let op = GetOperation::new(stub)
1805 .set_name(name)
1806 .with_options(options)
1807 .send()
1808 .await?;
1809 Ok(Operation::new(op))
1810 }
1811 };
1812
1813 let start = move || async {
1814 let op = self.send().await?;
1815 Ok(Operation::new(op))
1816 };
1817
1818 google_cloud_lro::internal::new_poller(
1819 polling_error_policy,
1820 polling_backoff_policy,
1821 start,
1822 query,
1823 )
1824 }
1825
1826 /// Sets the value of [parent][crate::model::RestoreDatabaseRequest::parent].
1827 ///
1828 /// This is a **required** field for requests.
1829 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1830 self.0.request.parent = v.into();
1831 self
1832 }
1833
1834 /// Sets the value of [database_id][crate::model::RestoreDatabaseRequest::database_id].
1835 ///
1836 /// This is a **required** field for requests.
1837 pub fn set_database_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1838 self.0.request.database_id = v.into();
1839 self
1840 }
1841
1842 /// Sets the value of [encryption_config][crate::model::RestoreDatabaseRequest::encryption_config].
1843 pub fn set_encryption_config<T>(mut self, v: T) -> Self
1844 where
1845 T: std::convert::Into<crate::model::RestoreDatabaseEncryptionConfig>,
1846 {
1847 self.0.request.encryption_config = std::option::Option::Some(v.into());
1848 self
1849 }
1850
1851 /// Sets or clears the value of [encryption_config][crate::model::RestoreDatabaseRequest::encryption_config].
1852 pub fn set_or_clear_encryption_config<T>(mut self, v: std::option::Option<T>) -> Self
1853 where
1854 T: std::convert::Into<crate::model::RestoreDatabaseEncryptionConfig>,
1855 {
1856 self.0.request.encryption_config = v.map(|x| x.into());
1857 self
1858 }
1859
1860 /// Sets the value of [source][crate::model::RestoreDatabaseRequest::source].
1861 ///
1862 /// Note that all the setters affecting `source` are
1863 /// mutually exclusive.
1864 pub fn set_source<T: Into<Option<crate::model::restore_database_request::Source>>>(
1865 mut self,
1866 v: T,
1867 ) -> Self {
1868 self.0.request.source = v.into();
1869 self
1870 }
1871
1872 /// Sets the value of [source][crate::model::RestoreDatabaseRequest::source]
1873 /// to hold a `Backup`.
1874 ///
1875 /// Note that all the setters affecting `source` are
1876 /// mutually exclusive.
1877 pub fn set_backup<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1878 self.0.request = self.0.request.set_backup(v);
1879 self
1880 }
1881 }
1882
1883 #[doc(hidden)]
1884 impl crate::RequestBuilder for RestoreDatabase {
1885 fn request_options(&mut self) -> &mut crate::RequestOptions {
1886 &mut self.0.options
1887 }
1888 }
1889
1890 /// The request builder for [DatabaseAdmin::list_database_operations][crate::client::DatabaseAdmin::list_database_operations] calls.
1891 ///
1892 /// # Example
1893 /// ```
1894 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::ListDatabaseOperations;
1895 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
1896 /// use google_cloud_gax::paginator::ItemPaginator;
1897 ///
1898 /// let builder = prepare_request_builder();
1899 /// let mut items = builder.by_item();
1900 /// while let Some(result) = items.next().await {
1901 /// let item = result?;
1902 /// }
1903 /// # Ok(()) }
1904 ///
1905 /// fn prepare_request_builder() -> ListDatabaseOperations {
1906 /// # panic!();
1907 /// // ... details omitted ...
1908 /// }
1909 /// ```
1910 #[derive(Clone, Debug)]
1911 pub struct ListDatabaseOperations(RequestBuilder<crate::model::ListDatabaseOperationsRequest>);
1912
1913 impl ListDatabaseOperations {
1914 pub(crate) fn new(
1915 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
1916 ) -> Self {
1917 Self(RequestBuilder::new(stub))
1918 }
1919
1920 /// Sets the full request, replacing any prior values.
1921 pub fn with_request<V: Into<crate::model::ListDatabaseOperationsRequest>>(
1922 mut self,
1923 v: V,
1924 ) -> Self {
1925 self.0.request = v.into();
1926 self
1927 }
1928
1929 /// Sets all the options, replacing any prior values.
1930 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1931 self.0.options = v.into();
1932 self
1933 }
1934
1935 /// Sends the request.
1936 pub async fn send(self) -> Result<crate::model::ListDatabaseOperationsResponse> {
1937 (*self.0.stub)
1938 .list_database_operations(self.0.request, self.0.options)
1939 .await
1940 .map(crate::Response::into_body)
1941 }
1942
1943 /// Streams each page in the collection.
1944 pub fn by_page(
1945 self,
1946 ) -> impl google_cloud_gax::paginator::Paginator<
1947 crate::model::ListDatabaseOperationsResponse,
1948 crate::Error,
1949 > {
1950 use std::clone::Clone;
1951 let token = self.0.request.page_token.clone();
1952 let execute = move |token: String| {
1953 let mut builder = self.clone();
1954 builder.0.request = builder.0.request.set_page_token(token);
1955 builder.send()
1956 };
1957 google_cloud_gax::paginator::internal::new_paginator(token, execute)
1958 }
1959
1960 /// Streams each item in the collection.
1961 pub fn by_item(
1962 self,
1963 ) -> impl google_cloud_gax::paginator::ItemPaginator<
1964 crate::model::ListDatabaseOperationsResponse,
1965 crate::Error,
1966 > {
1967 use google_cloud_gax::paginator::Paginator;
1968 self.by_page().items()
1969 }
1970
1971 /// Sets the value of [parent][crate::model::ListDatabaseOperationsRequest::parent].
1972 ///
1973 /// This is a **required** field for requests.
1974 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1975 self.0.request.parent = v.into();
1976 self
1977 }
1978
1979 /// Sets the value of [filter][crate::model::ListDatabaseOperationsRequest::filter].
1980 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1981 self.0.request.filter = v.into();
1982 self
1983 }
1984
1985 /// Sets the value of [page_size][crate::model::ListDatabaseOperationsRequest::page_size].
1986 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1987 self.0.request.page_size = v.into();
1988 self
1989 }
1990
1991 /// Sets the value of [page_token][crate::model::ListDatabaseOperationsRequest::page_token].
1992 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1993 self.0.request.page_token = v.into();
1994 self
1995 }
1996 }
1997
1998 #[doc(hidden)]
1999 impl crate::RequestBuilder for ListDatabaseOperations {
2000 fn request_options(&mut self) -> &mut crate::RequestOptions {
2001 &mut self.0.options
2002 }
2003 }
2004
2005 /// The request builder for [DatabaseAdmin::list_backup_operations][crate::client::DatabaseAdmin::list_backup_operations] calls.
2006 ///
2007 /// # Example
2008 /// ```
2009 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::ListBackupOperations;
2010 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2011 /// use google_cloud_gax::paginator::ItemPaginator;
2012 ///
2013 /// let builder = prepare_request_builder();
2014 /// let mut items = builder.by_item();
2015 /// while let Some(result) = items.next().await {
2016 /// let item = result?;
2017 /// }
2018 /// # Ok(()) }
2019 ///
2020 /// fn prepare_request_builder() -> ListBackupOperations {
2021 /// # panic!();
2022 /// // ... details omitted ...
2023 /// }
2024 /// ```
2025 #[derive(Clone, Debug)]
2026 pub struct ListBackupOperations(RequestBuilder<crate::model::ListBackupOperationsRequest>);
2027
2028 impl ListBackupOperations {
2029 pub(crate) fn new(
2030 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2031 ) -> Self {
2032 Self(RequestBuilder::new(stub))
2033 }
2034
2035 /// Sets the full request, replacing any prior values.
2036 pub fn with_request<V: Into<crate::model::ListBackupOperationsRequest>>(
2037 mut self,
2038 v: V,
2039 ) -> Self {
2040 self.0.request = v.into();
2041 self
2042 }
2043
2044 /// Sets all the options, replacing any prior values.
2045 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2046 self.0.options = v.into();
2047 self
2048 }
2049
2050 /// Sends the request.
2051 pub async fn send(self) -> Result<crate::model::ListBackupOperationsResponse> {
2052 (*self.0.stub)
2053 .list_backup_operations(self.0.request, self.0.options)
2054 .await
2055 .map(crate::Response::into_body)
2056 }
2057
2058 /// Streams each page in the collection.
2059 pub fn by_page(
2060 self,
2061 ) -> impl google_cloud_gax::paginator::Paginator<
2062 crate::model::ListBackupOperationsResponse,
2063 crate::Error,
2064 > {
2065 use std::clone::Clone;
2066 let token = self.0.request.page_token.clone();
2067 let execute = move |token: String| {
2068 let mut builder = self.clone();
2069 builder.0.request = builder.0.request.set_page_token(token);
2070 builder.send()
2071 };
2072 google_cloud_gax::paginator::internal::new_paginator(token, execute)
2073 }
2074
2075 /// Streams each item in the collection.
2076 pub fn by_item(
2077 self,
2078 ) -> impl google_cloud_gax::paginator::ItemPaginator<
2079 crate::model::ListBackupOperationsResponse,
2080 crate::Error,
2081 > {
2082 use google_cloud_gax::paginator::Paginator;
2083 self.by_page().items()
2084 }
2085
2086 /// Sets the value of [parent][crate::model::ListBackupOperationsRequest::parent].
2087 ///
2088 /// This is a **required** field for requests.
2089 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
2090 self.0.request.parent = v.into();
2091 self
2092 }
2093
2094 /// Sets the value of [filter][crate::model::ListBackupOperationsRequest::filter].
2095 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
2096 self.0.request.filter = v.into();
2097 self
2098 }
2099
2100 /// Sets the value of [page_size][crate::model::ListBackupOperationsRequest::page_size].
2101 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
2102 self.0.request.page_size = v.into();
2103 self
2104 }
2105
2106 /// Sets the value of [page_token][crate::model::ListBackupOperationsRequest::page_token].
2107 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
2108 self.0.request.page_token = v.into();
2109 self
2110 }
2111 }
2112
2113 #[doc(hidden)]
2114 impl crate::RequestBuilder for ListBackupOperations {
2115 fn request_options(&mut self) -> &mut crate::RequestOptions {
2116 &mut self.0.options
2117 }
2118 }
2119
2120 /// The request builder for [DatabaseAdmin::list_database_roles][crate::client::DatabaseAdmin::list_database_roles] calls.
2121 ///
2122 /// # Example
2123 /// ```
2124 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::ListDatabaseRoles;
2125 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2126 /// use google_cloud_gax::paginator::ItemPaginator;
2127 ///
2128 /// let builder = prepare_request_builder();
2129 /// let mut items = builder.by_item();
2130 /// while let Some(result) = items.next().await {
2131 /// let item = result?;
2132 /// }
2133 /// # Ok(()) }
2134 ///
2135 /// fn prepare_request_builder() -> ListDatabaseRoles {
2136 /// # panic!();
2137 /// // ... details omitted ...
2138 /// }
2139 /// ```
2140 #[derive(Clone, Debug)]
2141 pub struct ListDatabaseRoles(RequestBuilder<crate::model::ListDatabaseRolesRequest>);
2142
2143 impl ListDatabaseRoles {
2144 pub(crate) fn new(
2145 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2146 ) -> Self {
2147 Self(RequestBuilder::new(stub))
2148 }
2149
2150 /// Sets the full request, replacing any prior values.
2151 pub fn with_request<V: Into<crate::model::ListDatabaseRolesRequest>>(
2152 mut self,
2153 v: V,
2154 ) -> Self {
2155 self.0.request = v.into();
2156 self
2157 }
2158
2159 /// Sets all the options, replacing any prior values.
2160 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2161 self.0.options = v.into();
2162 self
2163 }
2164
2165 /// Sends the request.
2166 pub async fn send(self) -> Result<crate::model::ListDatabaseRolesResponse> {
2167 (*self.0.stub)
2168 .list_database_roles(self.0.request, self.0.options)
2169 .await
2170 .map(crate::Response::into_body)
2171 }
2172
2173 /// Streams each page in the collection.
2174 pub fn by_page(
2175 self,
2176 ) -> impl google_cloud_gax::paginator::Paginator<
2177 crate::model::ListDatabaseRolesResponse,
2178 crate::Error,
2179 > {
2180 use std::clone::Clone;
2181 let token = self.0.request.page_token.clone();
2182 let execute = move |token: String| {
2183 let mut builder = self.clone();
2184 builder.0.request = builder.0.request.set_page_token(token);
2185 builder.send()
2186 };
2187 google_cloud_gax::paginator::internal::new_paginator(token, execute)
2188 }
2189
2190 /// Streams each item in the collection.
2191 pub fn by_item(
2192 self,
2193 ) -> impl google_cloud_gax::paginator::ItemPaginator<
2194 crate::model::ListDatabaseRolesResponse,
2195 crate::Error,
2196 > {
2197 use google_cloud_gax::paginator::Paginator;
2198 self.by_page().items()
2199 }
2200
2201 /// Sets the value of [parent][crate::model::ListDatabaseRolesRequest::parent].
2202 ///
2203 /// This is a **required** field for requests.
2204 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
2205 self.0.request.parent = v.into();
2206 self
2207 }
2208
2209 /// Sets the value of [page_size][crate::model::ListDatabaseRolesRequest::page_size].
2210 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
2211 self.0.request.page_size = v.into();
2212 self
2213 }
2214
2215 /// Sets the value of [page_token][crate::model::ListDatabaseRolesRequest::page_token].
2216 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
2217 self.0.request.page_token = v.into();
2218 self
2219 }
2220 }
2221
2222 #[doc(hidden)]
2223 impl crate::RequestBuilder for ListDatabaseRoles {
2224 fn request_options(&mut self) -> &mut crate::RequestOptions {
2225 &mut self.0.options
2226 }
2227 }
2228
2229 /// The request builder for [DatabaseAdmin::add_split_points][crate::client::DatabaseAdmin::add_split_points] calls.
2230 ///
2231 /// # Example
2232 /// ```
2233 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::AddSplitPoints;
2234 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2235 ///
2236 /// let builder = prepare_request_builder();
2237 /// let response = builder.send().await?;
2238 /// # Ok(()) }
2239 ///
2240 /// fn prepare_request_builder() -> AddSplitPoints {
2241 /// # panic!();
2242 /// // ... details omitted ...
2243 /// }
2244 /// ```
2245 #[derive(Clone, Debug)]
2246 pub struct AddSplitPoints(RequestBuilder<crate::model::AddSplitPointsRequest>);
2247
2248 impl AddSplitPoints {
2249 pub(crate) fn new(
2250 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2251 ) -> Self {
2252 Self(RequestBuilder::new(stub))
2253 }
2254
2255 /// Sets the full request, replacing any prior values.
2256 pub fn with_request<V: Into<crate::model::AddSplitPointsRequest>>(mut self, v: V) -> Self {
2257 self.0.request = v.into();
2258 self
2259 }
2260
2261 /// Sets all the options, replacing any prior values.
2262 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2263 self.0.options = v.into();
2264 self
2265 }
2266
2267 /// Sends the request.
2268 pub async fn send(self) -> Result<crate::model::AddSplitPointsResponse> {
2269 (*self.0.stub)
2270 .add_split_points(self.0.request, self.0.options)
2271 .await
2272 .map(crate::Response::into_body)
2273 }
2274
2275 /// Sets the value of [database][crate::model::AddSplitPointsRequest::database].
2276 ///
2277 /// This is a **required** field for requests.
2278 pub fn set_database<T: Into<std::string::String>>(mut self, v: T) -> Self {
2279 self.0.request.database = v.into();
2280 self
2281 }
2282
2283 /// Sets the value of [split_points][crate::model::AddSplitPointsRequest::split_points].
2284 ///
2285 /// This is a **required** field for requests.
2286 pub fn set_split_points<T, V>(mut self, v: T) -> Self
2287 where
2288 T: std::iter::IntoIterator<Item = V>,
2289 V: std::convert::Into<crate::model::SplitPoints>,
2290 {
2291 use std::iter::Iterator;
2292 self.0.request.split_points = v.into_iter().map(|i| i.into()).collect();
2293 self
2294 }
2295
2296 /// Sets the value of [initiator][crate::model::AddSplitPointsRequest::initiator].
2297 pub fn set_initiator<T: Into<std::string::String>>(mut self, v: T) -> Self {
2298 self.0.request.initiator = v.into();
2299 self
2300 }
2301 }
2302
2303 #[doc(hidden)]
2304 impl crate::RequestBuilder for AddSplitPoints {
2305 fn request_options(&mut self) -> &mut crate::RequestOptions {
2306 &mut self.0.options
2307 }
2308 }
2309
2310 /// The request builder for [DatabaseAdmin::create_backup_schedule][crate::client::DatabaseAdmin::create_backup_schedule] calls.
2311 ///
2312 /// # Example
2313 /// ```
2314 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::CreateBackupSchedule;
2315 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2316 ///
2317 /// let builder = prepare_request_builder();
2318 /// let response = builder.send().await?;
2319 /// # Ok(()) }
2320 ///
2321 /// fn prepare_request_builder() -> CreateBackupSchedule {
2322 /// # panic!();
2323 /// // ... details omitted ...
2324 /// }
2325 /// ```
2326 #[derive(Clone, Debug)]
2327 pub struct CreateBackupSchedule(RequestBuilder<crate::model::CreateBackupScheduleRequest>);
2328
2329 impl CreateBackupSchedule {
2330 pub(crate) fn new(
2331 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2332 ) -> Self {
2333 Self(RequestBuilder::new(stub))
2334 }
2335
2336 /// Sets the full request, replacing any prior values.
2337 pub fn with_request<V: Into<crate::model::CreateBackupScheduleRequest>>(
2338 mut self,
2339 v: V,
2340 ) -> Self {
2341 self.0.request = v.into();
2342 self
2343 }
2344
2345 /// Sets all the options, replacing any prior values.
2346 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2347 self.0.options = v.into();
2348 self
2349 }
2350
2351 /// Sends the request.
2352 pub async fn send(self) -> Result<crate::model::BackupSchedule> {
2353 (*self.0.stub)
2354 .create_backup_schedule(self.0.request, self.0.options)
2355 .await
2356 .map(crate::Response::into_body)
2357 }
2358
2359 /// Sets the value of [parent][crate::model::CreateBackupScheduleRequest::parent].
2360 ///
2361 /// This is a **required** field for requests.
2362 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
2363 self.0.request.parent = v.into();
2364 self
2365 }
2366
2367 /// Sets the value of [backup_schedule_id][crate::model::CreateBackupScheduleRequest::backup_schedule_id].
2368 ///
2369 /// This is a **required** field for requests.
2370 pub fn set_backup_schedule_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
2371 self.0.request.backup_schedule_id = v.into();
2372 self
2373 }
2374
2375 /// Sets the value of [backup_schedule][crate::model::CreateBackupScheduleRequest::backup_schedule].
2376 ///
2377 /// This is a **required** field for requests.
2378 pub fn set_backup_schedule<T>(mut self, v: T) -> Self
2379 where
2380 T: std::convert::Into<crate::model::BackupSchedule>,
2381 {
2382 self.0.request.backup_schedule = std::option::Option::Some(v.into());
2383 self
2384 }
2385
2386 /// Sets or clears the value of [backup_schedule][crate::model::CreateBackupScheduleRequest::backup_schedule].
2387 ///
2388 /// This is a **required** field for requests.
2389 pub fn set_or_clear_backup_schedule<T>(mut self, v: std::option::Option<T>) -> Self
2390 where
2391 T: std::convert::Into<crate::model::BackupSchedule>,
2392 {
2393 self.0.request.backup_schedule = v.map(|x| x.into());
2394 self
2395 }
2396 }
2397
2398 #[doc(hidden)]
2399 impl crate::RequestBuilder for CreateBackupSchedule {
2400 fn request_options(&mut self) -> &mut crate::RequestOptions {
2401 &mut self.0.options
2402 }
2403 }
2404
2405 /// The request builder for [DatabaseAdmin::get_backup_schedule][crate::client::DatabaseAdmin::get_backup_schedule] calls.
2406 ///
2407 /// # Example
2408 /// ```
2409 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::GetBackupSchedule;
2410 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2411 ///
2412 /// let builder = prepare_request_builder();
2413 /// let response = builder.send().await?;
2414 /// # Ok(()) }
2415 ///
2416 /// fn prepare_request_builder() -> GetBackupSchedule {
2417 /// # panic!();
2418 /// // ... details omitted ...
2419 /// }
2420 /// ```
2421 #[derive(Clone, Debug)]
2422 pub struct GetBackupSchedule(RequestBuilder<crate::model::GetBackupScheduleRequest>);
2423
2424 impl GetBackupSchedule {
2425 pub(crate) fn new(
2426 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2427 ) -> Self {
2428 Self(RequestBuilder::new(stub))
2429 }
2430
2431 /// Sets the full request, replacing any prior values.
2432 pub fn with_request<V: Into<crate::model::GetBackupScheduleRequest>>(
2433 mut self,
2434 v: V,
2435 ) -> Self {
2436 self.0.request = v.into();
2437 self
2438 }
2439
2440 /// Sets all the options, replacing any prior values.
2441 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2442 self.0.options = v.into();
2443 self
2444 }
2445
2446 /// Sends the request.
2447 pub async fn send(self) -> Result<crate::model::BackupSchedule> {
2448 (*self.0.stub)
2449 .get_backup_schedule(self.0.request, self.0.options)
2450 .await
2451 .map(crate::Response::into_body)
2452 }
2453
2454 /// Sets the value of [name][crate::model::GetBackupScheduleRequest::name].
2455 ///
2456 /// This is a **required** field for requests.
2457 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2458 self.0.request.name = v.into();
2459 self
2460 }
2461 }
2462
2463 #[doc(hidden)]
2464 impl crate::RequestBuilder for GetBackupSchedule {
2465 fn request_options(&mut self) -> &mut crate::RequestOptions {
2466 &mut self.0.options
2467 }
2468 }
2469
2470 /// The request builder for [DatabaseAdmin::update_backup_schedule][crate::client::DatabaseAdmin::update_backup_schedule] calls.
2471 ///
2472 /// # Example
2473 /// ```
2474 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::UpdateBackupSchedule;
2475 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2476 ///
2477 /// let builder = prepare_request_builder();
2478 /// let response = builder.send().await?;
2479 /// # Ok(()) }
2480 ///
2481 /// fn prepare_request_builder() -> UpdateBackupSchedule {
2482 /// # panic!();
2483 /// // ... details omitted ...
2484 /// }
2485 /// ```
2486 #[derive(Clone, Debug)]
2487 pub struct UpdateBackupSchedule(RequestBuilder<crate::model::UpdateBackupScheduleRequest>);
2488
2489 impl UpdateBackupSchedule {
2490 pub(crate) fn new(
2491 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2492 ) -> Self {
2493 Self(RequestBuilder::new(stub))
2494 }
2495
2496 /// Sets the full request, replacing any prior values.
2497 pub fn with_request<V: Into<crate::model::UpdateBackupScheduleRequest>>(
2498 mut self,
2499 v: V,
2500 ) -> Self {
2501 self.0.request = v.into();
2502 self
2503 }
2504
2505 /// Sets all the options, replacing any prior values.
2506 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2507 self.0.options = v.into();
2508 self
2509 }
2510
2511 /// Sends the request.
2512 pub async fn send(self) -> Result<crate::model::BackupSchedule> {
2513 (*self.0.stub)
2514 .update_backup_schedule(self.0.request, self.0.options)
2515 .await
2516 .map(crate::Response::into_body)
2517 }
2518
2519 /// Sets the value of [backup_schedule][crate::model::UpdateBackupScheduleRequest::backup_schedule].
2520 ///
2521 /// This is a **required** field for requests.
2522 pub fn set_backup_schedule<T>(mut self, v: T) -> Self
2523 where
2524 T: std::convert::Into<crate::model::BackupSchedule>,
2525 {
2526 self.0.request.backup_schedule = std::option::Option::Some(v.into());
2527 self
2528 }
2529
2530 /// Sets or clears the value of [backup_schedule][crate::model::UpdateBackupScheduleRequest::backup_schedule].
2531 ///
2532 /// This is a **required** field for requests.
2533 pub fn set_or_clear_backup_schedule<T>(mut self, v: std::option::Option<T>) -> Self
2534 where
2535 T: std::convert::Into<crate::model::BackupSchedule>,
2536 {
2537 self.0.request.backup_schedule = v.map(|x| x.into());
2538 self
2539 }
2540
2541 /// Sets the value of [update_mask][crate::model::UpdateBackupScheduleRequest::update_mask].
2542 ///
2543 /// This is a **required** field for requests.
2544 pub fn set_update_mask<T>(mut self, v: T) -> Self
2545 where
2546 T: std::convert::Into<wkt::FieldMask>,
2547 {
2548 self.0.request.update_mask = std::option::Option::Some(v.into());
2549 self
2550 }
2551
2552 /// Sets or clears the value of [update_mask][crate::model::UpdateBackupScheduleRequest::update_mask].
2553 ///
2554 /// This is a **required** field for requests.
2555 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
2556 where
2557 T: std::convert::Into<wkt::FieldMask>,
2558 {
2559 self.0.request.update_mask = v.map(|x| x.into());
2560 self
2561 }
2562 }
2563
2564 #[doc(hidden)]
2565 impl crate::RequestBuilder for UpdateBackupSchedule {
2566 fn request_options(&mut self) -> &mut crate::RequestOptions {
2567 &mut self.0.options
2568 }
2569 }
2570
2571 /// The request builder for [DatabaseAdmin::delete_backup_schedule][crate::client::DatabaseAdmin::delete_backup_schedule] calls.
2572 ///
2573 /// # Example
2574 /// ```
2575 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::DeleteBackupSchedule;
2576 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2577 ///
2578 /// let builder = prepare_request_builder();
2579 /// let response = builder.send().await?;
2580 /// # Ok(()) }
2581 ///
2582 /// fn prepare_request_builder() -> DeleteBackupSchedule {
2583 /// # panic!();
2584 /// // ... details omitted ...
2585 /// }
2586 /// ```
2587 #[derive(Clone, Debug)]
2588 pub struct DeleteBackupSchedule(RequestBuilder<crate::model::DeleteBackupScheduleRequest>);
2589
2590 impl DeleteBackupSchedule {
2591 pub(crate) fn new(
2592 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2593 ) -> Self {
2594 Self(RequestBuilder::new(stub))
2595 }
2596
2597 /// Sets the full request, replacing any prior values.
2598 pub fn with_request<V: Into<crate::model::DeleteBackupScheduleRequest>>(
2599 mut self,
2600 v: V,
2601 ) -> Self {
2602 self.0.request = v.into();
2603 self
2604 }
2605
2606 /// Sets all the options, replacing any prior values.
2607 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2608 self.0.options = v.into();
2609 self
2610 }
2611
2612 /// Sends the request.
2613 pub async fn send(self) -> Result<()> {
2614 (*self.0.stub)
2615 .delete_backup_schedule(self.0.request, self.0.options)
2616 .await
2617 .map(crate::Response::into_body)
2618 }
2619
2620 /// Sets the value of [name][crate::model::DeleteBackupScheduleRequest::name].
2621 ///
2622 /// This is a **required** field for requests.
2623 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2624 self.0.request.name = v.into();
2625 self
2626 }
2627 }
2628
2629 #[doc(hidden)]
2630 impl crate::RequestBuilder for DeleteBackupSchedule {
2631 fn request_options(&mut self) -> &mut crate::RequestOptions {
2632 &mut self.0.options
2633 }
2634 }
2635
2636 /// The request builder for [DatabaseAdmin::list_backup_schedules][crate::client::DatabaseAdmin::list_backup_schedules] calls.
2637 ///
2638 /// # Example
2639 /// ```
2640 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::ListBackupSchedules;
2641 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2642 /// use google_cloud_gax::paginator::ItemPaginator;
2643 ///
2644 /// let builder = prepare_request_builder();
2645 /// let mut items = builder.by_item();
2646 /// while let Some(result) = items.next().await {
2647 /// let item = result?;
2648 /// }
2649 /// # Ok(()) }
2650 ///
2651 /// fn prepare_request_builder() -> ListBackupSchedules {
2652 /// # panic!();
2653 /// // ... details omitted ...
2654 /// }
2655 /// ```
2656 #[derive(Clone, Debug)]
2657 pub struct ListBackupSchedules(RequestBuilder<crate::model::ListBackupSchedulesRequest>);
2658
2659 impl ListBackupSchedules {
2660 pub(crate) fn new(
2661 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2662 ) -> Self {
2663 Self(RequestBuilder::new(stub))
2664 }
2665
2666 /// Sets the full request, replacing any prior values.
2667 pub fn with_request<V: Into<crate::model::ListBackupSchedulesRequest>>(
2668 mut self,
2669 v: V,
2670 ) -> Self {
2671 self.0.request = v.into();
2672 self
2673 }
2674
2675 /// Sets all the options, replacing any prior values.
2676 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2677 self.0.options = v.into();
2678 self
2679 }
2680
2681 /// Sends the request.
2682 pub async fn send(self) -> Result<crate::model::ListBackupSchedulesResponse> {
2683 (*self.0.stub)
2684 .list_backup_schedules(self.0.request, self.0.options)
2685 .await
2686 .map(crate::Response::into_body)
2687 }
2688
2689 /// Streams each page in the collection.
2690 pub fn by_page(
2691 self,
2692 ) -> impl google_cloud_gax::paginator::Paginator<
2693 crate::model::ListBackupSchedulesResponse,
2694 crate::Error,
2695 > {
2696 use std::clone::Clone;
2697 let token = self.0.request.page_token.clone();
2698 let execute = move |token: String| {
2699 let mut builder = self.clone();
2700 builder.0.request = builder.0.request.set_page_token(token);
2701 builder.send()
2702 };
2703 google_cloud_gax::paginator::internal::new_paginator(token, execute)
2704 }
2705
2706 /// Streams each item in the collection.
2707 pub fn by_item(
2708 self,
2709 ) -> impl google_cloud_gax::paginator::ItemPaginator<
2710 crate::model::ListBackupSchedulesResponse,
2711 crate::Error,
2712 > {
2713 use google_cloud_gax::paginator::Paginator;
2714 self.by_page().items()
2715 }
2716
2717 /// Sets the value of [parent][crate::model::ListBackupSchedulesRequest::parent].
2718 ///
2719 /// This is a **required** field for requests.
2720 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
2721 self.0.request.parent = v.into();
2722 self
2723 }
2724
2725 /// Sets the value of [page_size][crate::model::ListBackupSchedulesRequest::page_size].
2726 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
2727 self.0.request.page_size = v.into();
2728 self
2729 }
2730
2731 /// Sets the value of [page_token][crate::model::ListBackupSchedulesRequest::page_token].
2732 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
2733 self.0.request.page_token = v.into();
2734 self
2735 }
2736 }
2737
2738 #[doc(hidden)]
2739 impl crate::RequestBuilder for ListBackupSchedules {
2740 fn request_options(&mut self) -> &mut crate::RequestOptions {
2741 &mut self.0.options
2742 }
2743 }
2744
2745 /// The request builder for [DatabaseAdmin::list_operations][crate::client::DatabaseAdmin::list_operations] calls.
2746 ///
2747 /// # Example
2748 /// ```
2749 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::ListOperations;
2750 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2751 /// use google_cloud_gax::paginator::ItemPaginator;
2752 ///
2753 /// let builder = prepare_request_builder();
2754 /// let mut items = builder.by_item();
2755 /// while let Some(result) = items.next().await {
2756 /// let item = result?;
2757 /// }
2758 /// # Ok(()) }
2759 ///
2760 /// fn prepare_request_builder() -> ListOperations {
2761 /// # panic!();
2762 /// // ... details omitted ...
2763 /// }
2764 /// ```
2765 #[derive(Clone, Debug)]
2766 pub struct ListOperations(
2767 RequestBuilder<google_cloud_longrunning::model::ListOperationsRequest>,
2768 );
2769
2770 impl ListOperations {
2771 pub(crate) fn new(
2772 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2773 ) -> Self {
2774 Self(RequestBuilder::new(stub))
2775 }
2776
2777 /// Sets the full request, replacing any prior values.
2778 pub fn with_request<V: Into<google_cloud_longrunning::model::ListOperationsRequest>>(
2779 mut self,
2780 v: V,
2781 ) -> Self {
2782 self.0.request = v.into();
2783 self
2784 }
2785
2786 /// Sets all the options, replacing any prior values.
2787 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2788 self.0.options = v.into();
2789 self
2790 }
2791
2792 /// Sends the request.
2793 pub async fn send(self) -> Result<google_cloud_longrunning::model::ListOperationsResponse> {
2794 (*self.0.stub)
2795 .list_operations(self.0.request, self.0.options)
2796 .await
2797 .map(crate::Response::into_body)
2798 }
2799
2800 /// Streams each page in the collection.
2801 pub fn by_page(
2802 self,
2803 ) -> impl google_cloud_gax::paginator::Paginator<
2804 google_cloud_longrunning::model::ListOperationsResponse,
2805 crate::Error,
2806 > {
2807 use std::clone::Clone;
2808 let token = self.0.request.page_token.clone();
2809 let execute = move |token: String| {
2810 let mut builder = self.clone();
2811 builder.0.request = builder.0.request.set_page_token(token);
2812 builder.send()
2813 };
2814 google_cloud_gax::paginator::internal::new_paginator(token, execute)
2815 }
2816
2817 /// Streams each item in the collection.
2818 pub fn by_item(
2819 self,
2820 ) -> impl google_cloud_gax::paginator::ItemPaginator<
2821 google_cloud_longrunning::model::ListOperationsResponse,
2822 crate::Error,
2823 > {
2824 use google_cloud_gax::paginator::Paginator;
2825 self.by_page().items()
2826 }
2827
2828 /// Sets the value of [name][google_cloud_longrunning::model::ListOperationsRequest::name].
2829 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2830 self.0.request.name = v.into();
2831 self
2832 }
2833
2834 /// Sets the value of [filter][google_cloud_longrunning::model::ListOperationsRequest::filter].
2835 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
2836 self.0.request.filter = v.into();
2837 self
2838 }
2839
2840 /// Sets the value of [page_size][google_cloud_longrunning::model::ListOperationsRequest::page_size].
2841 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
2842 self.0.request.page_size = v.into();
2843 self
2844 }
2845
2846 /// Sets the value of [page_token][google_cloud_longrunning::model::ListOperationsRequest::page_token].
2847 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
2848 self.0.request.page_token = v.into();
2849 self
2850 }
2851
2852 /// Sets the value of [return_partial_success][google_cloud_longrunning::model::ListOperationsRequest::return_partial_success].
2853 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
2854 self.0.request.return_partial_success = v.into();
2855 self
2856 }
2857 }
2858
2859 #[doc(hidden)]
2860 impl crate::RequestBuilder for ListOperations {
2861 fn request_options(&mut self) -> &mut crate::RequestOptions {
2862 &mut self.0.options
2863 }
2864 }
2865
2866 /// The request builder for [DatabaseAdmin::get_operation][crate::client::DatabaseAdmin::get_operation] calls.
2867 ///
2868 /// # Example
2869 /// ```
2870 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::GetOperation;
2871 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2872 ///
2873 /// let builder = prepare_request_builder();
2874 /// let response = builder.send().await?;
2875 /// # Ok(()) }
2876 ///
2877 /// fn prepare_request_builder() -> GetOperation {
2878 /// # panic!();
2879 /// // ... details omitted ...
2880 /// }
2881 /// ```
2882 #[derive(Clone, Debug)]
2883 pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
2884
2885 impl GetOperation {
2886 pub(crate) fn new(
2887 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2888 ) -> Self {
2889 Self(RequestBuilder::new(stub))
2890 }
2891
2892 /// Sets the full request, replacing any prior values.
2893 pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
2894 mut self,
2895 v: V,
2896 ) -> Self {
2897 self.0.request = v.into();
2898 self
2899 }
2900
2901 /// Sets all the options, replacing any prior values.
2902 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2903 self.0.options = v.into();
2904 self
2905 }
2906
2907 /// Sends the request.
2908 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
2909 (*self.0.stub)
2910 .get_operation(self.0.request, self.0.options)
2911 .await
2912 .map(crate::Response::into_body)
2913 }
2914
2915 /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
2916 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2917 self.0.request.name = v.into();
2918 self
2919 }
2920 }
2921
2922 #[doc(hidden)]
2923 impl crate::RequestBuilder for GetOperation {
2924 fn request_options(&mut self) -> &mut crate::RequestOptions {
2925 &mut self.0.options
2926 }
2927 }
2928
2929 /// The request builder for [DatabaseAdmin::delete_operation][crate::client::DatabaseAdmin::delete_operation] calls.
2930 ///
2931 /// # Example
2932 /// ```
2933 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::DeleteOperation;
2934 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
2935 ///
2936 /// let builder = prepare_request_builder();
2937 /// let response = builder.send().await?;
2938 /// # Ok(()) }
2939 ///
2940 /// fn prepare_request_builder() -> DeleteOperation {
2941 /// # panic!();
2942 /// // ... details omitted ...
2943 /// }
2944 /// ```
2945 #[derive(Clone, Debug)]
2946 pub struct DeleteOperation(
2947 RequestBuilder<google_cloud_longrunning::model::DeleteOperationRequest>,
2948 );
2949
2950 impl DeleteOperation {
2951 pub(crate) fn new(
2952 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
2953 ) -> Self {
2954 Self(RequestBuilder::new(stub))
2955 }
2956
2957 /// Sets the full request, replacing any prior values.
2958 pub fn with_request<V: Into<google_cloud_longrunning::model::DeleteOperationRequest>>(
2959 mut self,
2960 v: V,
2961 ) -> Self {
2962 self.0.request = v.into();
2963 self
2964 }
2965
2966 /// Sets all the options, replacing any prior values.
2967 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2968 self.0.options = v.into();
2969 self
2970 }
2971
2972 /// Sends the request.
2973 pub async fn send(self) -> Result<()> {
2974 (*self.0.stub)
2975 .delete_operation(self.0.request, self.0.options)
2976 .await
2977 .map(crate::Response::into_body)
2978 }
2979
2980 /// Sets the value of [name][google_cloud_longrunning::model::DeleteOperationRequest::name].
2981 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2982 self.0.request.name = v.into();
2983 self
2984 }
2985 }
2986
2987 #[doc(hidden)]
2988 impl crate::RequestBuilder for DeleteOperation {
2989 fn request_options(&mut self) -> &mut crate::RequestOptions {
2990 &mut self.0.options
2991 }
2992 }
2993
2994 /// The request builder for [DatabaseAdmin::cancel_operation][crate::client::DatabaseAdmin::cancel_operation] calls.
2995 ///
2996 /// # Example
2997 /// ```
2998 /// # use google_cloud_spanner_admin_database_v1::builder::database_admin::CancelOperation;
2999 /// # async fn sample() -> google_cloud_spanner_admin_database_v1::Result<()> {
3000 ///
3001 /// let builder = prepare_request_builder();
3002 /// let response = builder.send().await?;
3003 /// # Ok(()) }
3004 ///
3005 /// fn prepare_request_builder() -> CancelOperation {
3006 /// # panic!();
3007 /// // ... details omitted ...
3008 /// }
3009 /// ```
3010 #[derive(Clone, Debug)]
3011 pub struct CancelOperation(
3012 RequestBuilder<google_cloud_longrunning::model::CancelOperationRequest>,
3013 );
3014
3015 impl CancelOperation {
3016 pub(crate) fn new(
3017 stub: std::sync::Arc<dyn super::super::stub::dynamic::DatabaseAdmin>,
3018 ) -> Self {
3019 Self(RequestBuilder::new(stub))
3020 }
3021
3022 /// Sets the full request, replacing any prior values.
3023 pub fn with_request<V: Into<google_cloud_longrunning::model::CancelOperationRequest>>(
3024 mut self,
3025 v: V,
3026 ) -> Self {
3027 self.0.request = v.into();
3028 self
3029 }
3030
3031 /// Sets all the options, replacing any prior values.
3032 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
3033 self.0.options = v.into();
3034 self
3035 }
3036
3037 /// Sends the request.
3038 pub async fn send(self) -> Result<()> {
3039 (*self.0.stub)
3040 .cancel_operation(self.0.request, self.0.options)
3041 .await
3042 .map(crate::Response::into_body)
3043 }
3044
3045 /// Sets the value of [name][google_cloud_longrunning::model::CancelOperationRequest::name].
3046 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
3047 self.0.request.name = v.into();
3048 self
3049 }
3050 }
3051
3052 #[doc(hidden)]
3053 impl crate::RequestBuilder for CancelOperation {
3054 fn request_options(&mut self) -> &mut crate::RequestOptions {
3055 &mut self.0.options
3056 }
3057 }
3058}