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