Skip to main content

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