google_cloud_datafusion_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 data_fusion {
18    use crate::Result;
19
20    /// A builder for [DataFusion][crate::client::DataFusion].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_datafusion_v1::*;
25    /// # use builder::data_fusion::ClientBuilder;
26    /// # use client::DataFusion;
27    /// let builder : ClientBuilder = DataFusion::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://datafusion.googleapis.com")
30    ///     .build().await?;
31    /// # gax::client_builder::Result::<()>::Ok(()) });
32    /// ```
33    pub type ClientBuilder =
34        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36    pub(crate) mod client {
37        use super::super::super::client::DataFusion;
38        pub struct Factory;
39        impl gax::client_builder::internal::ClientFactory for Factory {
40            type Client = DataFusion;
41            type Credentials = gaxi::options::Credentials;
42            async fn build(
43                self,
44                config: gaxi::options::ClientConfig,
45            ) -> gax::client_builder::Result<Self::Client> {
46                Self::Client::new(config).await
47            }
48        }
49    }
50
51    /// Common implementation for [crate::client::DataFusion] request builders.
52    #[derive(Clone, Debug)]
53    pub(crate) struct RequestBuilder<R: std::default::Default> {
54        stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
55        request: R,
56        options: gax::options::RequestOptions,
57    }
58
59    impl<R> RequestBuilder<R>
60    where
61        R: std::default::Default,
62    {
63        pub(crate) fn new(
64            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: gax::options::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [DataFusion::list_available_versions][crate::client::DataFusion::list_available_versions] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_datafusion_v1::builder;
79    /// use builder::data_fusion::ListAvailableVersions;
80    /// # tokio_test::block_on(async {
81    /// use gax::paginator::ItemPaginator;
82    ///
83    /// let builder = prepare_request_builder();
84    /// let mut items = builder.by_item();
85    /// while let Some(result) = items.next().await {
86    ///   let item = result?;
87    /// }
88    /// # gax::Result::<()>::Ok(()) });
89    ///
90    /// fn prepare_request_builder() -> ListAvailableVersions {
91    ///   # panic!();
92    ///   // ... details omitted ...
93    /// }
94    /// ```
95    #[derive(Clone, Debug)]
96    pub struct ListAvailableVersions(RequestBuilder<crate::model::ListAvailableVersionsRequest>);
97
98    impl ListAvailableVersions {
99        pub(crate) fn new(
100            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
101        ) -> Self {
102            Self(RequestBuilder::new(stub))
103        }
104
105        /// Sets the full request, replacing any prior values.
106        pub fn with_request<V: Into<crate::model::ListAvailableVersionsRequest>>(
107            mut self,
108            v: V,
109        ) -> Self {
110            self.0.request = v.into();
111            self
112        }
113
114        /// Sets all the options, replacing any prior values.
115        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
116            self.0.options = v.into();
117            self
118        }
119
120        /// Sends the request.
121        pub async fn send(self) -> Result<crate::model::ListAvailableVersionsResponse> {
122            (*self.0.stub)
123                .list_available_versions(self.0.request, self.0.options)
124                .await
125                .map(gax::response::Response::into_body)
126        }
127
128        /// Streams each page in the collection.
129        pub fn by_page(
130            self,
131        ) -> impl gax::paginator::Paginator<crate::model::ListAvailableVersionsResponse, gax::error::Error>
132        {
133            use std::clone::Clone;
134            let token = self.0.request.page_token.clone();
135            let execute = move |token: String| {
136                let mut builder = self.clone();
137                builder.0.request = builder.0.request.set_page_token(token);
138                builder.send()
139            };
140            gax::paginator::internal::new_paginator(token, execute)
141        }
142
143        /// Streams each item in the collection.
144        pub fn by_item(
145            self,
146        ) -> impl gax::paginator::ItemPaginator<
147            crate::model::ListAvailableVersionsResponse,
148            gax::error::Error,
149        > {
150            use gax::paginator::Paginator;
151            self.by_page().items()
152        }
153
154        /// Sets the value of [parent][crate::model::ListAvailableVersionsRequest::parent].
155        ///
156        /// This is a **required** field for requests.
157        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
158            self.0.request.parent = v.into();
159            self
160        }
161
162        /// Sets the value of [page_size][crate::model::ListAvailableVersionsRequest::page_size].
163        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
164            self.0.request.page_size = v.into();
165            self
166        }
167
168        /// Sets the value of [page_token][crate::model::ListAvailableVersionsRequest::page_token].
169        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
170            self.0.request.page_token = v.into();
171            self
172        }
173
174        /// Sets the value of [latest_patch_only][crate::model::ListAvailableVersionsRequest::latest_patch_only].
175        pub fn set_latest_patch_only<T: Into<bool>>(mut self, v: T) -> Self {
176            self.0.request.latest_patch_only = v.into();
177            self
178        }
179    }
180
181    #[doc(hidden)]
182    impl gax::options::internal::RequestBuilder for ListAvailableVersions {
183        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
184            &mut self.0.options
185        }
186    }
187
188    /// The request builder for [DataFusion::list_instances][crate::client::DataFusion::list_instances] calls.
189    ///
190    /// # Example
191    /// ```no_run
192    /// # use google_cloud_datafusion_v1::builder;
193    /// use builder::data_fusion::ListInstances;
194    /// # tokio_test::block_on(async {
195    /// use gax::paginator::ItemPaginator;
196    ///
197    /// let builder = prepare_request_builder();
198    /// let mut items = builder.by_item();
199    /// while let Some(result) = items.next().await {
200    ///   let item = result?;
201    /// }
202    /// # gax::Result::<()>::Ok(()) });
203    ///
204    /// fn prepare_request_builder() -> ListInstances {
205    ///   # panic!();
206    ///   // ... details omitted ...
207    /// }
208    /// ```
209    #[derive(Clone, Debug)]
210    pub struct ListInstances(RequestBuilder<crate::model::ListInstancesRequest>);
211
212    impl ListInstances {
213        pub(crate) fn new(
214            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
215        ) -> Self {
216            Self(RequestBuilder::new(stub))
217        }
218
219        /// Sets the full request, replacing any prior values.
220        pub fn with_request<V: Into<crate::model::ListInstancesRequest>>(mut self, v: V) -> Self {
221            self.0.request = v.into();
222            self
223        }
224
225        /// Sets all the options, replacing any prior values.
226        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
227            self.0.options = v.into();
228            self
229        }
230
231        /// Sends the request.
232        pub async fn send(self) -> Result<crate::model::ListInstancesResponse> {
233            (*self.0.stub)
234                .list_instances(self.0.request, self.0.options)
235                .await
236                .map(gax::response::Response::into_body)
237        }
238
239        /// Streams each page in the collection.
240        pub fn by_page(
241            self,
242        ) -> impl gax::paginator::Paginator<crate::model::ListInstancesResponse, gax::error::Error>
243        {
244            use std::clone::Clone;
245            let token = self.0.request.page_token.clone();
246            let execute = move |token: String| {
247                let mut builder = self.clone();
248                builder.0.request = builder.0.request.set_page_token(token);
249                builder.send()
250            };
251            gax::paginator::internal::new_paginator(token, execute)
252        }
253
254        /// Streams each item in the collection.
255        pub fn by_item(
256            self,
257        ) -> impl gax::paginator::ItemPaginator<crate::model::ListInstancesResponse, gax::error::Error>
258        {
259            use gax::paginator::Paginator;
260            self.by_page().items()
261        }
262
263        /// Sets the value of [parent][crate::model::ListInstancesRequest::parent].
264        ///
265        /// This is a **required** field for requests.
266        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
267            self.0.request.parent = v.into();
268            self
269        }
270
271        /// Sets the value of [page_size][crate::model::ListInstancesRequest::page_size].
272        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
273            self.0.request.page_size = v.into();
274            self
275        }
276
277        /// Sets the value of [page_token][crate::model::ListInstancesRequest::page_token].
278        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
279            self.0.request.page_token = v.into();
280            self
281        }
282
283        /// Sets the value of [filter][crate::model::ListInstancesRequest::filter].
284        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
285            self.0.request.filter = v.into();
286            self
287        }
288
289        /// Sets the value of [order_by][crate::model::ListInstancesRequest::order_by].
290        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
291            self.0.request.order_by = v.into();
292            self
293        }
294    }
295
296    #[doc(hidden)]
297    impl gax::options::internal::RequestBuilder for ListInstances {
298        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
299            &mut self.0.options
300        }
301    }
302
303    /// The request builder for [DataFusion::get_instance][crate::client::DataFusion::get_instance] calls.
304    ///
305    /// # Example
306    /// ```no_run
307    /// # use google_cloud_datafusion_v1::builder;
308    /// use builder::data_fusion::GetInstance;
309    /// # tokio_test::block_on(async {
310    ///
311    /// let builder = prepare_request_builder();
312    /// let response = builder.send().await?;
313    /// # gax::Result::<()>::Ok(()) });
314    ///
315    /// fn prepare_request_builder() -> GetInstance {
316    ///   # panic!();
317    ///   // ... details omitted ...
318    /// }
319    /// ```
320    #[derive(Clone, Debug)]
321    pub struct GetInstance(RequestBuilder<crate::model::GetInstanceRequest>);
322
323    impl GetInstance {
324        pub(crate) fn new(
325            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
326        ) -> Self {
327            Self(RequestBuilder::new(stub))
328        }
329
330        /// Sets the full request, replacing any prior values.
331        pub fn with_request<V: Into<crate::model::GetInstanceRequest>>(mut self, v: V) -> Self {
332            self.0.request = v.into();
333            self
334        }
335
336        /// Sets all the options, replacing any prior values.
337        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
338            self.0.options = v.into();
339            self
340        }
341
342        /// Sends the request.
343        pub async fn send(self) -> Result<crate::model::Instance> {
344            (*self.0.stub)
345                .get_instance(self.0.request, self.0.options)
346                .await
347                .map(gax::response::Response::into_body)
348        }
349
350        /// Sets the value of [name][crate::model::GetInstanceRequest::name].
351        ///
352        /// This is a **required** field for requests.
353        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
354            self.0.request.name = v.into();
355            self
356        }
357    }
358
359    #[doc(hidden)]
360    impl gax::options::internal::RequestBuilder for GetInstance {
361        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
362            &mut self.0.options
363        }
364    }
365
366    /// The request builder for [DataFusion::create_instance][crate::client::DataFusion::create_instance] calls.
367    ///
368    /// # Example
369    /// ```no_run
370    /// # use google_cloud_datafusion_v1::builder;
371    /// use builder::data_fusion::CreateInstance;
372    /// # tokio_test::block_on(async {
373    /// use lro::Poller;
374    ///
375    /// let builder = prepare_request_builder();
376    /// let response = builder.poller().until_done().await?;
377    /// # gax::Result::<()>::Ok(()) });
378    ///
379    /// fn prepare_request_builder() -> CreateInstance {
380    ///   # panic!();
381    ///   // ... details omitted ...
382    /// }
383    /// ```
384    #[derive(Clone, Debug)]
385    pub struct CreateInstance(RequestBuilder<crate::model::CreateInstanceRequest>);
386
387    impl CreateInstance {
388        pub(crate) fn new(
389            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
390        ) -> Self {
391            Self(RequestBuilder::new(stub))
392        }
393
394        /// Sets the full request, replacing any prior values.
395        pub fn with_request<V: Into<crate::model::CreateInstanceRequest>>(mut self, v: V) -> Self {
396            self.0.request = v.into();
397            self
398        }
399
400        /// Sets all the options, replacing any prior values.
401        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
402            self.0.options = v.into();
403            self
404        }
405
406        /// Sends the request.
407        ///
408        /// # Long running operations
409        ///
410        /// This starts, but does not poll, a longrunning operation. More information
411        /// on [create_instance][crate::client::DataFusion::create_instance].
412        pub async fn send(self) -> Result<longrunning::model::Operation> {
413            (*self.0.stub)
414                .create_instance(self.0.request, self.0.options)
415                .await
416                .map(gax::response::Response::into_body)
417        }
418
419        /// Creates a [Poller][lro::Poller] to work with `create_instance`.
420        pub fn poller(
421            self,
422        ) -> impl lro::Poller<crate::model::Instance, crate::model::OperationMetadata> {
423            type Operation =
424                lro::internal::Operation<crate::model::Instance, crate::model::OperationMetadata>;
425            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
426            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
427
428            let stub = self.0.stub.clone();
429            let mut options = self.0.options.clone();
430            options.set_retry_policy(gax::retry_policy::NeverRetry);
431            let query = move |name| {
432                let stub = stub.clone();
433                let options = options.clone();
434                async {
435                    let op = GetOperation::new(stub)
436                        .set_name(name)
437                        .with_options(options)
438                        .send()
439                        .await?;
440                    Ok(Operation::new(op))
441                }
442            };
443
444            let start = move || async {
445                let op = self.send().await?;
446                Ok(Operation::new(op))
447            };
448
449            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
450        }
451
452        /// Sets the value of [parent][crate::model::CreateInstanceRequest::parent].
453        ///
454        /// This is a **required** field for requests.
455        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
456            self.0.request.parent = v.into();
457            self
458        }
459
460        /// Sets the value of [instance_id][crate::model::CreateInstanceRequest::instance_id].
461        ///
462        /// This is a **required** field for requests.
463        pub fn set_instance_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
464            self.0.request.instance_id = v.into();
465            self
466        }
467
468        /// Sets the value of [instance][crate::model::CreateInstanceRequest::instance].
469        pub fn set_instance<T>(mut self, v: T) -> Self
470        where
471            T: std::convert::Into<crate::model::Instance>,
472        {
473            self.0.request.instance = std::option::Option::Some(v.into());
474            self
475        }
476
477        /// Sets or clears the value of [instance][crate::model::CreateInstanceRequest::instance].
478        pub fn set_or_clear_instance<T>(mut self, v: std::option::Option<T>) -> Self
479        where
480            T: std::convert::Into<crate::model::Instance>,
481        {
482            self.0.request.instance = v.map(|x| x.into());
483            self
484        }
485    }
486
487    #[doc(hidden)]
488    impl gax::options::internal::RequestBuilder for CreateInstance {
489        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
490            &mut self.0.options
491        }
492    }
493
494    /// The request builder for [DataFusion::delete_instance][crate::client::DataFusion::delete_instance] calls.
495    ///
496    /// # Example
497    /// ```no_run
498    /// # use google_cloud_datafusion_v1::builder;
499    /// use builder::data_fusion::DeleteInstance;
500    /// # tokio_test::block_on(async {
501    /// use lro::Poller;
502    ///
503    /// let builder = prepare_request_builder();
504    /// let response = builder.poller().until_done().await?;
505    /// # gax::Result::<()>::Ok(()) });
506    ///
507    /// fn prepare_request_builder() -> DeleteInstance {
508    ///   # panic!();
509    ///   // ... details omitted ...
510    /// }
511    /// ```
512    #[derive(Clone, Debug)]
513    pub struct DeleteInstance(RequestBuilder<crate::model::DeleteInstanceRequest>);
514
515    impl DeleteInstance {
516        pub(crate) fn new(
517            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
518        ) -> Self {
519            Self(RequestBuilder::new(stub))
520        }
521
522        /// Sets the full request, replacing any prior values.
523        pub fn with_request<V: Into<crate::model::DeleteInstanceRequest>>(mut self, v: V) -> Self {
524            self.0.request = v.into();
525            self
526        }
527
528        /// Sets all the options, replacing any prior values.
529        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
530            self.0.options = v.into();
531            self
532        }
533
534        /// Sends the request.
535        ///
536        /// # Long running operations
537        ///
538        /// This starts, but does not poll, a longrunning operation. More information
539        /// on [delete_instance][crate::client::DataFusion::delete_instance].
540        pub async fn send(self) -> Result<longrunning::model::Operation> {
541            (*self.0.stub)
542                .delete_instance(self.0.request, self.0.options)
543                .await
544                .map(gax::response::Response::into_body)
545        }
546
547        /// Creates a [Poller][lro::Poller] to work with `delete_instance`.
548        pub fn poller(self) -> impl lro::Poller<(), crate::model::OperationMetadata> {
549            type Operation = lro::internal::Operation<wkt::Empty, crate::model::OperationMetadata>;
550            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
551            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
552
553            let stub = self.0.stub.clone();
554            let mut options = self.0.options.clone();
555            options.set_retry_policy(gax::retry_policy::NeverRetry);
556            let query = move |name| {
557                let stub = stub.clone();
558                let options = options.clone();
559                async {
560                    let op = GetOperation::new(stub)
561                        .set_name(name)
562                        .with_options(options)
563                        .send()
564                        .await?;
565                    Ok(Operation::new(op))
566                }
567            };
568
569            let start = move || async {
570                let op = self.send().await?;
571                Ok(Operation::new(op))
572            };
573
574            lro::internal::new_unit_response_poller(
575                polling_error_policy,
576                polling_backoff_policy,
577                start,
578                query,
579            )
580        }
581
582        /// Sets the value of [name][crate::model::DeleteInstanceRequest::name].
583        ///
584        /// This is a **required** field for requests.
585        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
586            self.0.request.name = v.into();
587            self
588        }
589    }
590
591    #[doc(hidden)]
592    impl gax::options::internal::RequestBuilder for DeleteInstance {
593        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
594            &mut self.0.options
595        }
596    }
597
598    /// The request builder for [DataFusion::update_instance][crate::client::DataFusion::update_instance] calls.
599    ///
600    /// # Example
601    /// ```no_run
602    /// # use google_cloud_datafusion_v1::builder;
603    /// use builder::data_fusion::UpdateInstance;
604    /// # tokio_test::block_on(async {
605    /// use lro::Poller;
606    ///
607    /// let builder = prepare_request_builder();
608    /// let response = builder.poller().until_done().await?;
609    /// # gax::Result::<()>::Ok(()) });
610    ///
611    /// fn prepare_request_builder() -> UpdateInstance {
612    ///   # panic!();
613    ///   // ... details omitted ...
614    /// }
615    /// ```
616    #[derive(Clone, Debug)]
617    pub struct UpdateInstance(RequestBuilder<crate::model::UpdateInstanceRequest>);
618
619    impl UpdateInstance {
620        pub(crate) fn new(
621            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
622        ) -> Self {
623            Self(RequestBuilder::new(stub))
624        }
625
626        /// Sets the full request, replacing any prior values.
627        pub fn with_request<V: Into<crate::model::UpdateInstanceRequest>>(mut self, v: V) -> Self {
628            self.0.request = v.into();
629            self
630        }
631
632        /// Sets all the options, replacing any prior values.
633        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
634            self.0.options = v.into();
635            self
636        }
637
638        /// Sends the request.
639        ///
640        /// # Long running operations
641        ///
642        /// This starts, but does not poll, a longrunning operation. More information
643        /// on [update_instance][crate::client::DataFusion::update_instance].
644        pub async fn send(self) -> Result<longrunning::model::Operation> {
645            (*self.0.stub)
646                .update_instance(self.0.request, self.0.options)
647                .await
648                .map(gax::response::Response::into_body)
649        }
650
651        /// Creates a [Poller][lro::Poller] to work with `update_instance`.
652        pub fn poller(
653            self,
654        ) -> impl lro::Poller<crate::model::Instance, crate::model::OperationMetadata> {
655            type Operation =
656                lro::internal::Operation<crate::model::Instance, crate::model::OperationMetadata>;
657            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
658            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
659
660            let stub = self.0.stub.clone();
661            let mut options = self.0.options.clone();
662            options.set_retry_policy(gax::retry_policy::NeverRetry);
663            let query = move |name| {
664                let stub = stub.clone();
665                let options = options.clone();
666                async {
667                    let op = GetOperation::new(stub)
668                        .set_name(name)
669                        .with_options(options)
670                        .send()
671                        .await?;
672                    Ok(Operation::new(op))
673                }
674            };
675
676            let start = move || async {
677                let op = self.send().await?;
678                Ok(Operation::new(op))
679            };
680
681            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
682        }
683
684        /// Sets the value of [instance][crate::model::UpdateInstanceRequest::instance].
685        ///
686        /// This is a **required** field for requests.
687        pub fn set_instance<T>(mut self, v: T) -> Self
688        where
689            T: std::convert::Into<crate::model::Instance>,
690        {
691            self.0.request.instance = std::option::Option::Some(v.into());
692            self
693        }
694
695        /// Sets or clears the value of [instance][crate::model::UpdateInstanceRequest::instance].
696        ///
697        /// This is a **required** field for requests.
698        pub fn set_or_clear_instance<T>(mut self, v: std::option::Option<T>) -> Self
699        where
700            T: std::convert::Into<crate::model::Instance>,
701        {
702            self.0.request.instance = v.map(|x| x.into());
703            self
704        }
705
706        /// Sets the value of [update_mask][crate::model::UpdateInstanceRequest::update_mask].
707        pub fn set_update_mask<T>(mut self, v: T) -> Self
708        where
709            T: std::convert::Into<wkt::FieldMask>,
710        {
711            self.0.request.update_mask = std::option::Option::Some(v.into());
712            self
713        }
714
715        /// Sets or clears the value of [update_mask][crate::model::UpdateInstanceRequest::update_mask].
716        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
717        where
718            T: std::convert::Into<wkt::FieldMask>,
719        {
720            self.0.request.update_mask = v.map(|x| x.into());
721            self
722        }
723    }
724
725    #[doc(hidden)]
726    impl gax::options::internal::RequestBuilder for UpdateInstance {
727        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
728            &mut self.0.options
729        }
730    }
731
732    /// The request builder for [DataFusion::restart_instance][crate::client::DataFusion::restart_instance] calls.
733    ///
734    /// # Example
735    /// ```no_run
736    /// # use google_cloud_datafusion_v1::builder;
737    /// use builder::data_fusion::RestartInstance;
738    /// # tokio_test::block_on(async {
739    /// use lro::Poller;
740    ///
741    /// let builder = prepare_request_builder();
742    /// let response = builder.poller().until_done().await?;
743    /// # gax::Result::<()>::Ok(()) });
744    ///
745    /// fn prepare_request_builder() -> RestartInstance {
746    ///   # panic!();
747    ///   // ... details omitted ...
748    /// }
749    /// ```
750    #[derive(Clone, Debug)]
751    pub struct RestartInstance(RequestBuilder<crate::model::RestartInstanceRequest>);
752
753    impl RestartInstance {
754        pub(crate) fn new(
755            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
756        ) -> Self {
757            Self(RequestBuilder::new(stub))
758        }
759
760        /// Sets the full request, replacing any prior values.
761        pub fn with_request<V: Into<crate::model::RestartInstanceRequest>>(mut self, v: V) -> Self {
762            self.0.request = v.into();
763            self
764        }
765
766        /// Sets all the options, replacing any prior values.
767        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
768            self.0.options = v.into();
769            self
770        }
771
772        /// Sends the request.
773        ///
774        /// # Long running operations
775        ///
776        /// This starts, but does not poll, a longrunning operation. More information
777        /// on [restart_instance][crate::client::DataFusion::restart_instance].
778        pub async fn send(self) -> Result<longrunning::model::Operation> {
779            (*self.0.stub)
780                .restart_instance(self.0.request, self.0.options)
781                .await
782                .map(gax::response::Response::into_body)
783        }
784
785        /// Creates a [Poller][lro::Poller] to work with `restart_instance`.
786        pub fn poller(
787            self,
788        ) -> impl lro::Poller<crate::model::Instance, crate::model::OperationMetadata> {
789            type Operation =
790                lro::internal::Operation<crate::model::Instance, crate::model::OperationMetadata>;
791            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
792            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
793
794            let stub = self.0.stub.clone();
795            let mut options = self.0.options.clone();
796            options.set_retry_policy(gax::retry_policy::NeverRetry);
797            let query = move |name| {
798                let stub = stub.clone();
799                let options = options.clone();
800                async {
801                    let op = GetOperation::new(stub)
802                        .set_name(name)
803                        .with_options(options)
804                        .send()
805                        .await?;
806                    Ok(Operation::new(op))
807                }
808            };
809
810            let start = move || async {
811                let op = self.send().await?;
812                Ok(Operation::new(op))
813            };
814
815            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
816        }
817
818        /// Sets the value of [name][crate::model::RestartInstanceRequest::name].
819        ///
820        /// This is a **required** field for requests.
821        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
822            self.0.request.name = v.into();
823            self
824        }
825    }
826
827    #[doc(hidden)]
828    impl gax::options::internal::RequestBuilder for RestartInstance {
829        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
830            &mut self.0.options
831        }
832    }
833
834    /// The request builder for [DataFusion::list_operations][crate::client::DataFusion::list_operations] calls.
835    ///
836    /// # Example
837    /// ```no_run
838    /// # use google_cloud_datafusion_v1::builder;
839    /// use builder::data_fusion::ListOperations;
840    /// # tokio_test::block_on(async {
841    /// use gax::paginator::ItemPaginator;
842    ///
843    /// let builder = prepare_request_builder();
844    /// let mut items = builder.by_item();
845    /// while let Some(result) = items.next().await {
846    ///   let item = result?;
847    /// }
848    /// # gax::Result::<()>::Ok(()) });
849    ///
850    /// fn prepare_request_builder() -> ListOperations {
851    ///   # panic!();
852    ///   // ... details omitted ...
853    /// }
854    /// ```
855    #[derive(Clone, Debug)]
856    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);
857
858    impl ListOperations {
859        pub(crate) fn new(
860            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
861        ) -> Self {
862            Self(RequestBuilder::new(stub))
863        }
864
865        /// Sets the full request, replacing any prior values.
866        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
867            mut self,
868            v: V,
869        ) -> Self {
870            self.0.request = v.into();
871            self
872        }
873
874        /// Sets all the options, replacing any prior values.
875        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
876            self.0.options = v.into();
877            self
878        }
879
880        /// Sends the request.
881        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
882            (*self.0.stub)
883                .list_operations(self.0.request, self.0.options)
884                .await
885                .map(gax::response::Response::into_body)
886        }
887
888        /// Streams each page in the collection.
889        pub fn by_page(
890            self,
891        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
892        {
893            use std::clone::Clone;
894            let token = self.0.request.page_token.clone();
895            let execute = move |token: String| {
896                let mut builder = self.clone();
897                builder.0.request = builder.0.request.set_page_token(token);
898                builder.send()
899            };
900            gax::paginator::internal::new_paginator(token, execute)
901        }
902
903        /// Streams each item in the collection.
904        pub fn by_item(
905            self,
906        ) -> impl gax::paginator::ItemPaginator<
907            longrunning::model::ListOperationsResponse,
908            gax::error::Error,
909        > {
910            use gax::paginator::Paginator;
911            self.by_page().items()
912        }
913
914        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
915        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
916            self.0.request.name = v.into();
917            self
918        }
919
920        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
921        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
922            self.0.request.filter = v.into();
923            self
924        }
925
926        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
927        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
928            self.0.request.page_size = v.into();
929            self
930        }
931
932        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
933        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
934            self.0.request.page_token = v.into();
935            self
936        }
937
938        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
939        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
940            self.0.request.return_partial_success = v.into();
941            self
942        }
943    }
944
945    #[doc(hidden)]
946    impl gax::options::internal::RequestBuilder for ListOperations {
947        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
948            &mut self.0.options
949        }
950    }
951
952    /// The request builder for [DataFusion::get_operation][crate::client::DataFusion::get_operation] calls.
953    ///
954    /// # Example
955    /// ```no_run
956    /// # use google_cloud_datafusion_v1::builder;
957    /// use builder::data_fusion::GetOperation;
958    /// # tokio_test::block_on(async {
959    ///
960    /// let builder = prepare_request_builder();
961    /// let response = builder.send().await?;
962    /// # gax::Result::<()>::Ok(()) });
963    ///
964    /// fn prepare_request_builder() -> GetOperation {
965    ///   # panic!();
966    ///   // ... details omitted ...
967    /// }
968    /// ```
969    #[derive(Clone, Debug)]
970    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);
971
972    impl GetOperation {
973        pub(crate) fn new(
974            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
975        ) -> Self {
976            Self(RequestBuilder::new(stub))
977        }
978
979        /// Sets the full request, replacing any prior values.
980        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
981            mut self,
982            v: V,
983        ) -> Self {
984            self.0.request = v.into();
985            self
986        }
987
988        /// Sets all the options, replacing any prior values.
989        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
990            self.0.options = v.into();
991            self
992        }
993
994        /// Sends the request.
995        pub async fn send(self) -> Result<longrunning::model::Operation> {
996            (*self.0.stub)
997                .get_operation(self.0.request, self.0.options)
998                .await
999                .map(gax::response::Response::into_body)
1000        }
1001
1002        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
1003        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1004            self.0.request.name = v.into();
1005            self
1006        }
1007    }
1008
1009    #[doc(hidden)]
1010    impl gax::options::internal::RequestBuilder for GetOperation {
1011        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1012            &mut self.0.options
1013        }
1014    }
1015
1016    /// The request builder for [DataFusion::delete_operation][crate::client::DataFusion::delete_operation] calls.
1017    ///
1018    /// # Example
1019    /// ```no_run
1020    /// # use google_cloud_datafusion_v1::builder;
1021    /// use builder::data_fusion::DeleteOperation;
1022    /// # tokio_test::block_on(async {
1023    ///
1024    /// let builder = prepare_request_builder();
1025    /// let response = builder.send().await?;
1026    /// # gax::Result::<()>::Ok(()) });
1027    ///
1028    /// fn prepare_request_builder() -> DeleteOperation {
1029    ///   # panic!();
1030    ///   // ... details omitted ...
1031    /// }
1032    /// ```
1033    #[derive(Clone, Debug)]
1034    pub struct DeleteOperation(RequestBuilder<longrunning::model::DeleteOperationRequest>);
1035
1036    impl DeleteOperation {
1037        pub(crate) fn new(
1038            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
1039        ) -> Self {
1040            Self(RequestBuilder::new(stub))
1041        }
1042
1043        /// Sets the full request, replacing any prior values.
1044        pub fn with_request<V: Into<longrunning::model::DeleteOperationRequest>>(
1045            mut self,
1046            v: V,
1047        ) -> Self {
1048            self.0.request = v.into();
1049            self
1050        }
1051
1052        /// Sets all the options, replacing any prior values.
1053        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1054            self.0.options = v.into();
1055            self
1056        }
1057
1058        /// Sends the request.
1059        pub async fn send(self) -> Result<()> {
1060            (*self.0.stub)
1061                .delete_operation(self.0.request, self.0.options)
1062                .await
1063                .map(gax::response::Response::into_body)
1064        }
1065
1066        /// Sets the value of [name][longrunning::model::DeleteOperationRequest::name].
1067        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1068            self.0.request.name = v.into();
1069            self
1070        }
1071    }
1072
1073    #[doc(hidden)]
1074    impl gax::options::internal::RequestBuilder for DeleteOperation {
1075        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1076            &mut self.0.options
1077        }
1078    }
1079
1080    /// The request builder for [DataFusion::cancel_operation][crate::client::DataFusion::cancel_operation] calls.
1081    ///
1082    /// # Example
1083    /// ```no_run
1084    /// # use google_cloud_datafusion_v1::builder;
1085    /// use builder::data_fusion::CancelOperation;
1086    /// # tokio_test::block_on(async {
1087    ///
1088    /// let builder = prepare_request_builder();
1089    /// let response = builder.send().await?;
1090    /// # gax::Result::<()>::Ok(()) });
1091    ///
1092    /// fn prepare_request_builder() -> CancelOperation {
1093    ///   # panic!();
1094    ///   // ... details omitted ...
1095    /// }
1096    /// ```
1097    #[derive(Clone, Debug)]
1098    pub struct CancelOperation(RequestBuilder<longrunning::model::CancelOperationRequest>);
1099
1100    impl CancelOperation {
1101        pub(crate) fn new(
1102            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataFusion>,
1103        ) -> Self {
1104            Self(RequestBuilder::new(stub))
1105        }
1106
1107        /// Sets the full request, replacing any prior values.
1108        pub fn with_request<V: Into<longrunning::model::CancelOperationRequest>>(
1109            mut self,
1110            v: V,
1111        ) -> Self {
1112            self.0.request = v.into();
1113            self
1114        }
1115
1116        /// Sets all the options, replacing any prior values.
1117        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1118            self.0.options = v.into();
1119            self
1120        }
1121
1122        /// Sends the request.
1123        pub async fn send(self) -> Result<()> {
1124            (*self.0.stub)
1125                .cancel_operation(self.0.request, self.0.options)
1126                .await
1127                .map(gax::response::Response::into_body)
1128        }
1129
1130        /// Sets the value of [name][longrunning::model::CancelOperationRequest::name].
1131        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1132            self.0.request.name = v.into();
1133            self
1134        }
1135    }
1136
1137    #[doc(hidden)]
1138    impl gax::options::internal::RequestBuilder for CancelOperation {
1139        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1140            &mut self.0.options
1141        }
1142    }
1143}