google_cloud_bigquery_datapolicies_v2/
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_policy_service {
18    use crate::Result;
19
20    /// A builder for [DataPolicyService][crate::client::DataPolicyService].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_bigquery_datapolicies_v2::*;
25    /// # use builder::data_policy_service::ClientBuilder;
26    /// # use client::DataPolicyService;
27    /// let builder : ClientBuilder = DataPolicyService::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://bigquerydatapolicy.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::DataPolicyService;
38        pub struct Factory;
39        impl gax::client_builder::internal::ClientFactory for Factory {
40            type Client = DataPolicyService;
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::DataPolicyService] 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::DataPolicyService>,
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::DataPolicyService>,
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 [DataPolicyService::create_data_policy][crate::client::DataPolicyService::create_data_policy] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_bigquery_datapolicies_v2::builder;
79    /// use builder::data_policy_service::CreateDataPolicy;
80    /// # tokio_test::block_on(async {
81    ///
82    /// let builder = prepare_request_builder();
83    /// let response = builder.send().await?;
84    /// # gax::Result::<()>::Ok(()) });
85    ///
86    /// fn prepare_request_builder() -> CreateDataPolicy {
87    ///   # panic!();
88    ///   // ... details omitted ...
89    /// }
90    /// ```
91    #[derive(Clone, Debug)]
92    pub struct CreateDataPolicy(RequestBuilder<crate::model::CreateDataPolicyRequest>);
93
94    impl CreateDataPolicy {
95        pub(crate) fn new(
96            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
97        ) -> Self {
98            Self(RequestBuilder::new(stub))
99        }
100
101        /// Sets the full request, replacing any prior values.
102        pub fn with_request<V: Into<crate::model::CreateDataPolicyRequest>>(
103            mut self,
104            v: V,
105        ) -> Self {
106            self.0.request = v.into();
107            self
108        }
109
110        /// Sets all the options, replacing any prior values.
111        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
112            self.0.options = v.into();
113            self
114        }
115
116        /// Sends the request.
117        pub async fn send(self) -> Result<crate::model::DataPolicy> {
118            (*self.0.stub)
119                .create_data_policy(self.0.request, self.0.options)
120                .await
121                .map(gax::response::Response::into_body)
122        }
123
124        /// Sets the value of [parent][crate::model::CreateDataPolicyRequest::parent].
125        ///
126        /// This is a **required** field for requests.
127        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
128            self.0.request.parent = v.into();
129            self
130        }
131
132        /// Sets the value of [data_policy_id][crate::model::CreateDataPolicyRequest::data_policy_id].
133        ///
134        /// This is a **required** field for requests.
135        pub fn set_data_policy_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
136            self.0.request.data_policy_id = v.into();
137            self
138        }
139
140        /// Sets the value of [data_policy][crate::model::CreateDataPolicyRequest::data_policy].
141        ///
142        /// This is a **required** field for requests.
143        pub fn set_data_policy<T>(mut self, v: T) -> Self
144        where
145            T: std::convert::Into<crate::model::DataPolicy>,
146        {
147            self.0.request.data_policy = std::option::Option::Some(v.into());
148            self
149        }
150
151        /// Sets or clears the value of [data_policy][crate::model::CreateDataPolicyRequest::data_policy].
152        ///
153        /// This is a **required** field for requests.
154        pub fn set_or_clear_data_policy<T>(mut self, v: std::option::Option<T>) -> Self
155        where
156            T: std::convert::Into<crate::model::DataPolicy>,
157        {
158            self.0.request.data_policy = v.map(|x| x.into());
159            self
160        }
161    }
162
163    #[doc(hidden)]
164    impl gax::options::internal::RequestBuilder for CreateDataPolicy {
165        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
166            &mut self.0.options
167        }
168    }
169
170    /// The request builder for [DataPolicyService::add_grantees][crate::client::DataPolicyService::add_grantees] calls.
171    ///
172    /// # Example
173    /// ```no_run
174    /// # use google_cloud_bigquery_datapolicies_v2::builder;
175    /// use builder::data_policy_service::AddGrantees;
176    /// # tokio_test::block_on(async {
177    ///
178    /// let builder = prepare_request_builder();
179    /// let response = builder.send().await?;
180    /// # gax::Result::<()>::Ok(()) });
181    ///
182    /// fn prepare_request_builder() -> AddGrantees {
183    ///   # panic!();
184    ///   // ... details omitted ...
185    /// }
186    /// ```
187    #[derive(Clone, Debug)]
188    pub struct AddGrantees(RequestBuilder<crate::model::AddGranteesRequest>);
189
190    impl AddGrantees {
191        pub(crate) fn new(
192            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
193        ) -> Self {
194            Self(RequestBuilder::new(stub))
195        }
196
197        /// Sets the full request, replacing any prior values.
198        pub fn with_request<V: Into<crate::model::AddGranteesRequest>>(mut self, v: V) -> Self {
199            self.0.request = v.into();
200            self
201        }
202
203        /// Sets all the options, replacing any prior values.
204        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
205            self.0.options = v.into();
206            self
207        }
208
209        /// Sends the request.
210        pub async fn send(self) -> Result<crate::model::DataPolicy> {
211            (*self.0.stub)
212                .add_grantees(self.0.request, self.0.options)
213                .await
214                .map(gax::response::Response::into_body)
215        }
216
217        /// Sets the value of [data_policy][crate::model::AddGranteesRequest::data_policy].
218        ///
219        /// This is a **required** field for requests.
220        pub fn set_data_policy<T: Into<std::string::String>>(mut self, v: T) -> Self {
221            self.0.request.data_policy = v.into();
222            self
223        }
224
225        /// Sets the value of [grantees][crate::model::AddGranteesRequest::grantees].
226        ///
227        /// This is a **required** field for requests.
228        pub fn set_grantees<T, V>(mut self, v: T) -> Self
229        where
230            T: std::iter::IntoIterator<Item = V>,
231            V: std::convert::Into<std::string::String>,
232        {
233            use std::iter::Iterator;
234            self.0.request.grantees = v.into_iter().map(|i| i.into()).collect();
235            self
236        }
237    }
238
239    #[doc(hidden)]
240    impl gax::options::internal::RequestBuilder for AddGrantees {
241        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
242            &mut self.0.options
243        }
244    }
245
246    /// The request builder for [DataPolicyService::remove_grantees][crate::client::DataPolicyService::remove_grantees] calls.
247    ///
248    /// # Example
249    /// ```no_run
250    /// # use google_cloud_bigquery_datapolicies_v2::builder;
251    /// use builder::data_policy_service::RemoveGrantees;
252    /// # tokio_test::block_on(async {
253    ///
254    /// let builder = prepare_request_builder();
255    /// let response = builder.send().await?;
256    /// # gax::Result::<()>::Ok(()) });
257    ///
258    /// fn prepare_request_builder() -> RemoveGrantees {
259    ///   # panic!();
260    ///   // ... details omitted ...
261    /// }
262    /// ```
263    #[derive(Clone, Debug)]
264    pub struct RemoveGrantees(RequestBuilder<crate::model::RemoveGranteesRequest>);
265
266    impl RemoveGrantees {
267        pub(crate) fn new(
268            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
269        ) -> Self {
270            Self(RequestBuilder::new(stub))
271        }
272
273        /// Sets the full request, replacing any prior values.
274        pub fn with_request<V: Into<crate::model::RemoveGranteesRequest>>(mut self, v: V) -> Self {
275            self.0.request = v.into();
276            self
277        }
278
279        /// Sets all the options, replacing any prior values.
280        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
281            self.0.options = v.into();
282            self
283        }
284
285        /// Sends the request.
286        pub async fn send(self) -> Result<crate::model::DataPolicy> {
287            (*self.0.stub)
288                .remove_grantees(self.0.request, self.0.options)
289                .await
290                .map(gax::response::Response::into_body)
291        }
292
293        /// Sets the value of [data_policy][crate::model::RemoveGranteesRequest::data_policy].
294        ///
295        /// This is a **required** field for requests.
296        pub fn set_data_policy<T: Into<std::string::String>>(mut self, v: T) -> Self {
297            self.0.request.data_policy = v.into();
298            self
299        }
300
301        /// Sets the value of [grantees][crate::model::RemoveGranteesRequest::grantees].
302        ///
303        /// This is a **required** field for requests.
304        pub fn set_grantees<T, V>(mut self, v: T) -> Self
305        where
306            T: std::iter::IntoIterator<Item = V>,
307            V: std::convert::Into<std::string::String>,
308        {
309            use std::iter::Iterator;
310            self.0.request.grantees = v.into_iter().map(|i| i.into()).collect();
311            self
312        }
313    }
314
315    #[doc(hidden)]
316    impl gax::options::internal::RequestBuilder for RemoveGrantees {
317        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
318            &mut self.0.options
319        }
320    }
321
322    /// The request builder for [DataPolicyService::update_data_policy][crate::client::DataPolicyService::update_data_policy] calls.
323    ///
324    /// # Example
325    /// ```no_run
326    /// # use google_cloud_bigquery_datapolicies_v2::builder;
327    /// use builder::data_policy_service::UpdateDataPolicy;
328    /// # tokio_test::block_on(async {
329    ///
330    /// let builder = prepare_request_builder();
331    /// let response = builder.send().await?;
332    /// # gax::Result::<()>::Ok(()) });
333    ///
334    /// fn prepare_request_builder() -> UpdateDataPolicy {
335    ///   # panic!();
336    ///   // ... details omitted ...
337    /// }
338    /// ```
339    #[derive(Clone, Debug)]
340    pub struct UpdateDataPolicy(RequestBuilder<crate::model::UpdateDataPolicyRequest>);
341
342    impl UpdateDataPolicy {
343        pub(crate) fn new(
344            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
345        ) -> Self {
346            Self(RequestBuilder::new(stub))
347        }
348
349        /// Sets the full request, replacing any prior values.
350        pub fn with_request<V: Into<crate::model::UpdateDataPolicyRequest>>(
351            mut self,
352            v: V,
353        ) -> Self {
354            self.0.request = v.into();
355            self
356        }
357
358        /// Sets all the options, replacing any prior values.
359        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
360            self.0.options = v.into();
361            self
362        }
363
364        /// Sends the request.
365        pub async fn send(self) -> Result<crate::model::DataPolicy> {
366            (*self.0.stub)
367                .update_data_policy(self.0.request, self.0.options)
368                .await
369                .map(gax::response::Response::into_body)
370        }
371
372        /// Sets the value of [data_policy][crate::model::UpdateDataPolicyRequest::data_policy].
373        ///
374        /// This is a **required** field for requests.
375        pub fn set_data_policy<T>(mut self, v: T) -> Self
376        where
377            T: std::convert::Into<crate::model::DataPolicy>,
378        {
379            self.0.request.data_policy = std::option::Option::Some(v.into());
380            self
381        }
382
383        /// Sets or clears the value of [data_policy][crate::model::UpdateDataPolicyRequest::data_policy].
384        ///
385        /// This is a **required** field for requests.
386        pub fn set_or_clear_data_policy<T>(mut self, v: std::option::Option<T>) -> Self
387        where
388            T: std::convert::Into<crate::model::DataPolicy>,
389        {
390            self.0.request.data_policy = v.map(|x| x.into());
391            self
392        }
393
394        /// Sets the value of [update_mask][crate::model::UpdateDataPolicyRequest::update_mask].
395        pub fn set_update_mask<T>(mut self, v: T) -> Self
396        where
397            T: std::convert::Into<wkt::FieldMask>,
398        {
399            self.0.request.update_mask = std::option::Option::Some(v.into());
400            self
401        }
402
403        /// Sets or clears the value of [update_mask][crate::model::UpdateDataPolicyRequest::update_mask].
404        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
405        where
406            T: std::convert::Into<wkt::FieldMask>,
407        {
408            self.0.request.update_mask = v.map(|x| x.into());
409            self
410        }
411
412        /// Sets the value of [allow_missing][crate::model::UpdateDataPolicyRequest::allow_missing].
413        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
414            self.0.request.allow_missing = v.into();
415            self
416        }
417    }
418
419    #[doc(hidden)]
420    impl gax::options::internal::RequestBuilder for UpdateDataPolicy {
421        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
422            &mut self.0.options
423        }
424    }
425
426    /// The request builder for [DataPolicyService::delete_data_policy][crate::client::DataPolicyService::delete_data_policy] calls.
427    ///
428    /// # Example
429    /// ```no_run
430    /// # use google_cloud_bigquery_datapolicies_v2::builder;
431    /// use builder::data_policy_service::DeleteDataPolicy;
432    /// # tokio_test::block_on(async {
433    ///
434    /// let builder = prepare_request_builder();
435    /// let response = builder.send().await?;
436    /// # gax::Result::<()>::Ok(()) });
437    ///
438    /// fn prepare_request_builder() -> DeleteDataPolicy {
439    ///   # panic!();
440    ///   // ... details omitted ...
441    /// }
442    /// ```
443    #[derive(Clone, Debug)]
444    pub struct DeleteDataPolicy(RequestBuilder<crate::model::DeleteDataPolicyRequest>);
445
446    impl DeleteDataPolicy {
447        pub(crate) fn new(
448            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
449        ) -> Self {
450            Self(RequestBuilder::new(stub))
451        }
452
453        /// Sets the full request, replacing any prior values.
454        pub fn with_request<V: Into<crate::model::DeleteDataPolicyRequest>>(
455            mut self,
456            v: V,
457        ) -> Self {
458            self.0.request = v.into();
459            self
460        }
461
462        /// Sets all the options, replacing any prior values.
463        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
464            self.0.options = v.into();
465            self
466        }
467
468        /// Sends the request.
469        pub async fn send(self) -> Result<()> {
470            (*self.0.stub)
471                .delete_data_policy(self.0.request, self.0.options)
472                .await
473                .map(gax::response::Response::into_body)
474        }
475
476        /// Sets the value of [name][crate::model::DeleteDataPolicyRequest::name].
477        ///
478        /// This is a **required** field for requests.
479        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
480            self.0.request.name = v.into();
481            self
482        }
483    }
484
485    #[doc(hidden)]
486    impl gax::options::internal::RequestBuilder for DeleteDataPolicy {
487        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
488            &mut self.0.options
489        }
490    }
491
492    /// The request builder for [DataPolicyService::get_data_policy][crate::client::DataPolicyService::get_data_policy] calls.
493    ///
494    /// # Example
495    /// ```no_run
496    /// # use google_cloud_bigquery_datapolicies_v2::builder;
497    /// use builder::data_policy_service::GetDataPolicy;
498    /// # tokio_test::block_on(async {
499    ///
500    /// let builder = prepare_request_builder();
501    /// let response = builder.send().await?;
502    /// # gax::Result::<()>::Ok(()) });
503    ///
504    /// fn prepare_request_builder() -> GetDataPolicy {
505    ///   # panic!();
506    ///   // ... details omitted ...
507    /// }
508    /// ```
509    #[derive(Clone, Debug)]
510    pub struct GetDataPolicy(RequestBuilder<crate::model::GetDataPolicyRequest>);
511
512    impl GetDataPolicy {
513        pub(crate) fn new(
514            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
515        ) -> Self {
516            Self(RequestBuilder::new(stub))
517        }
518
519        /// Sets the full request, replacing any prior values.
520        pub fn with_request<V: Into<crate::model::GetDataPolicyRequest>>(mut self, v: V) -> Self {
521            self.0.request = v.into();
522            self
523        }
524
525        /// Sets all the options, replacing any prior values.
526        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
527            self.0.options = v.into();
528            self
529        }
530
531        /// Sends the request.
532        pub async fn send(self) -> Result<crate::model::DataPolicy> {
533            (*self.0.stub)
534                .get_data_policy(self.0.request, self.0.options)
535                .await
536                .map(gax::response::Response::into_body)
537        }
538
539        /// Sets the value of [name][crate::model::GetDataPolicyRequest::name].
540        ///
541        /// This is a **required** field for requests.
542        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
543            self.0.request.name = v.into();
544            self
545        }
546    }
547
548    #[doc(hidden)]
549    impl gax::options::internal::RequestBuilder for GetDataPolicy {
550        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
551            &mut self.0.options
552        }
553    }
554
555    /// The request builder for [DataPolicyService::list_data_policies][crate::client::DataPolicyService::list_data_policies] calls.
556    ///
557    /// # Example
558    /// ```no_run
559    /// # use google_cloud_bigquery_datapolicies_v2::builder;
560    /// use builder::data_policy_service::ListDataPolicies;
561    /// # tokio_test::block_on(async {
562    /// use gax::paginator::ItemPaginator;
563    ///
564    /// let builder = prepare_request_builder();
565    /// let mut items = builder.by_item();
566    /// while let Some(result) = items.next().await {
567    ///   let item = result?;
568    /// }
569    /// # gax::Result::<()>::Ok(()) });
570    ///
571    /// fn prepare_request_builder() -> ListDataPolicies {
572    ///   # panic!();
573    ///   // ... details omitted ...
574    /// }
575    /// ```
576    #[derive(Clone, Debug)]
577    pub struct ListDataPolicies(RequestBuilder<crate::model::ListDataPoliciesRequest>);
578
579    impl ListDataPolicies {
580        pub(crate) fn new(
581            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
582        ) -> Self {
583            Self(RequestBuilder::new(stub))
584        }
585
586        /// Sets the full request, replacing any prior values.
587        pub fn with_request<V: Into<crate::model::ListDataPoliciesRequest>>(
588            mut self,
589            v: V,
590        ) -> Self {
591            self.0.request = v.into();
592            self
593        }
594
595        /// Sets all the options, replacing any prior values.
596        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
597            self.0.options = v.into();
598            self
599        }
600
601        /// Sends the request.
602        pub async fn send(self) -> Result<crate::model::ListDataPoliciesResponse> {
603            (*self.0.stub)
604                .list_data_policies(self.0.request, self.0.options)
605                .await
606                .map(gax::response::Response::into_body)
607        }
608
609        /// Streams each page in the collection.
610        pub fn by_page(
611            self,
612        ) -> impl gax::paginator::Paginator<crate::model::ListDataPoliciesResponse, gax::error::Error>
613        {
614            use std::clone::Clone;
615            let token = self.0.request.page_token.clone();
616            let execute = move |token: String| {
617                let mut builder = self.clone();
618                builder.0.request = builder.0.request.set_page_token(token);
619                builder.send()
620            };
621            gax::paginator::internal::new_paginator(token, execute)
622        }
623
624        /// Streams each item in the collection.
625        pub fn by_item(
626            self,
627        ) -> impl gax::paginator::ItemPaginator<crate::model::ListDataPoliciesResponse, gax::error::Error>
628        {
629            use gax::paginator::Paginator;
630            self.by_page().items()
631        }
632
633        /// Sets the value of [parent][crate::model::ListDataPoliciesRequest::parent].
634        ///
635        /// This is a **required** field for requests.
636        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
637            self.0.request.parent = v.into();
638            self
639        }
640
641        /// Sets the value of [page_size][crate::model::ListDataPoliciesRequest::page_size].
642        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
643            self.0.request.page_size = v.into();
644            self
645        }
646
647        /// Sets the value of [page_token][crate::model::ListDataPoliciesRequest::page_token].
648        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
649            self.0.request.page_token = v.into();
650            self
651        }
652
653        /// Sets the value of [filter][crate::model::ListDataPoliciesRequest::filter].
654        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
655            self.0.request.filter = v.into();
656            self
657        }
658    }
659
660    #[doc(hidden)]
661    impl gax::options::internal::RequestBuilder for ListDataPolicies {
662        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
663            &mut self.0.options
664        }
665    }
666
667    /// The request builder for [DataPolicyService::get_iam_policy][crate::client::DataPolicyService::get_iam_policy] calls.
668    ///
669    /// # Example
670    /// ```no_run
671    /// # use google_cloud_bigquery_datapolicies_v2::builder;
672    /// use builder::data_policy_service::GetIamPolicy;
673    /// # tokio_test::block_on(async {
674    ///
675    /// let builder = prepare_request_builder();
676    /// let response = builder.send().await?;
677    /// # gax::Result::<()>::Ok(()) });
678    ///
679    /// fn prepare_request_builder() -> GetIamPolicy {
680    ///   # panic!();
681    ///   // ... details omitted ...
682    /// }
683    /// ```
684    #[derive(Clone, Debug)]
685    pub struct GetIamPolicy(RequestBuilder<iam_v1::model::GetIamPolicyRequest>);
686
687    impl GetIamPolicy {
688        pub(crate) fn new(
689            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
690        ) -> Self {
691            Self(RequestBuilder::new(stub))
692        }
693
694        /// Sets the full request, replacing any prior values.
695        pub fn with_request<V: Into<iam_v1::model::GetIamPolicyRequest>>(mut self, v: V) -> Self {
696            self.0.request = v.into();
697            self
698        }
699
700        /// Sets all the options, replacing any prior values.
701        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
702            self.0.options = v.into();
703            self
704        }
705
706        /// Sends the request.
707        pub async fn send(self) -> Result<iam_v1::model::Policy> {
708            (*self.0.stub)
709                .get_iam_policy(self.0.request, self.0.options)
710                .await
711                .map(gax::response::Response::into_body)
712        }
713
714        /// Sets the value of [resource][iam_v1::model::GetIamPolicyRequest::resource].
715        ///
716        /// This is a **required** field for requests.
717        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
718            self.0.request.resource = v.into();
719            self
720        }
721
722        /// Sets the value of [options][iam_v1::model::GetIamPolicyRequest::options].
723        pub fn set_options<T>(mut self, v: T) -> Self
724        where
725            T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
726        {
727            self.0.request.options = std::option::Option::Some(v.into());
728            self
729        }
730
731        /// Sets or clears the value of [options][iam_v1::model::GetIamPolicyRequest::options].
732        pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
733        where
734            T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
735        {
736            self.0.request.options = v.map(|x| x.into());
737            self
738        }
739    }
740
741    #[doc(hidden)]
742    impl gax::options::internal::RequestBuilder for GetIamPolicy {
743        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
744            &mut self.0.options
745        }
746    }
747
748    /// The request builder for [DataPolicyService::set_iam_policy][crate::client::DataPolicyService::set_iam_policy] calls.
749    ///
750    /// # Example
751    /// ```no_run
752    /// # use google_cloud_bigquery_datapolicies_v2::builder;
753    /// use builder::data_policy_service::SetIamPolicy;
754    /// # tokio_test::block_on(async {
755    ///
756    /// let builder = prepare_request_builder();
757    /// let response = builder.send().await?;
758    /// # gax::Result::<()>::Ok(()) });
759    ///
760    /// fn prepare_request_builder() -> SetIamPolicy {
761    ///   # panic!();
762    ///   // ... details omitted ...
763    /// }
764    /// ```
765    #[derive(Clone, Debug)]
766    pub struct SetIamPolicy(RequestBuilder<iam_v1::model::SetIamPolicyRequest>);
767
768    impl SetIamPolicy {
769        pub(crate) fn new(
770            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
771        ) -> Self {
772            Self(RequestBuilder::new(stub))
773        }
774
775        /// Sets the full request, replacing any prior values.
776        pub fn with_request<V: Into<iam_v1::model::SetIamPolicyRequest>>(mut self, v: V) -> Self {
777            self.0.request = v.into();
778            self
779        }
780
781        /// Sets all the options, replacing any prior values.
782        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
783            self.0.options = v.into();
784            self
785        }
786
787        /// Sends the request.
788        pub async fn send(self) -> Result<iam_v1::model::Policy> {
789            (*self.0.stub)
790                .set_iam_policy(self.0.request, self.0.options)
791                .await
792                .map(gax::response::Response::into_body)
793        }
794
795        /// Sets the value of [resource][iam_v1::model::SetIamPolicyRequest::resource].
796        ///
797        /// This is a **required** field for requests.
798        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
799            self.0.request.resource = v.into();
800            self
801        }
802
803        /// Sets the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
804        ///
805        /// This is a **required** field for requests.
806        pub fn set_policy<T>(mut self, v: T) -> Self
807        where
808            T: std::convert::Into<iam_v1::model::Policy>,
809        {
810            self.0.request.policy = std::option::Option::Some(v.into());
811            self
812        }
813
814        /// Sets or clears the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
815        ///
816        /// This is a **required** field for requests.
817        pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
818        where
819            T: std::convert::Into<iam_v1::model::Policy>,
820        {
821            self.0.request.policy = v.map(|x| x.into());
822            self
823        }
824
825        /// Sets the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
826        pub fn set_update_mask<T>(mut self, v: T) -> Self
827        where
828            T: std::convert::Into<wkt::FieldMask>,
829        {
830            self.0.request.update_mask = std::option::Option::Some(v.into());
831            self
832        }
833
834        /// Sets or clears the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
835        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
836        where
837            T: std::convert::Into<wkt::FieldMask>,
838        {
839            self.0.request.update_mask = v.map(|x| x.into());
840            self
841        }
842    }
843
844    #[doc(hidden)]
845    impl gax::options::internal::RequestBuilder for SetIamPolicy {
846        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
847            &mut self.0.options
848        }
849    }
850
851    /// The request builder for [DataPolicyService::test_iam_permissions][crate::client::DataPolicyService::test_iam_permissions] calls.
852    ///
853    /// # Example
854    /// ```no_run
855    /// # use google_cloud_bigquery_datapolicies_v2::builder;
856    /// use builder::data_policy_service::TestIamPermissions;
857    /// # tokio_test::block_on(async {
858    ///
859    /// let builder = prepare_request_builder();
860    /// let response = builder.send().await?;
861    /// # gax::Result::<()>::Ok(()) });
862    ///
863    /// fn prepare_request_builder() -> TestIamPermissions {
864    ///   # panic!();
865    ///   // ... details omitted ...
866    /// }
867    /// ```
868    #[derive(Clone, Debug)]
869    pub struct TestIamPermissions(RequestBuilder<iam_v1::model::TestIamPermissionsRequest>);
870
871    impl TestIamPermissions {
872        pub(crate) fn new(
873            stub: std::sync::Arc<dyn super::super::stub::dynamic::DataPolicyService>,
874        ) -> Self {
875            Self(RequestBuilder::new(stub))
876        }
877
878        /// Sets the full request, replacing any prior values.
879        pub fn with_request<V: Into<iam_v1::model::TestIamPermissionsRequest>>(
880            mut self,
881            v: V,
882        ) -> Self {
883            self.0.request = v.into();
884            self
885        }
886
887        /// Sets all the options, replacing any prior values.
888        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
889            self.0.options = v.into();
890            self
891        }
892
893        /// Sends the request.
894        pub async fn send(self) -> Result<iam_v1::model::TestIamPermissionsResponse> {
895            (*self.0.stub)
896                .test_iam_permissions(self.0.request, self.0.options)
897                .await
898                .map(gax::response::Response::into_body)
899        }
900
901        /// Sets the value of [resource][iam_v1::model::TestIamPermissionsRequest::resource].
902        ///
903        /// This is a **required** field for requests.
904        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
905            self.0.request.resource = v.into();
906            self
907        }
908
909        /// Sets the value of [permissions][iam_v1::model::TestIamPermissionsRequest::permissions].
910        ///
911        /// This is a **required** field for requests.
912        pub fn set_permissions<T, V>(mut self, v: T) -> Self
913        where
914            T: std::iter::IntoIterator<Item = V>,
915            V: std::convert::Into<std::string::String>,
916        {
917            use std::iter::Iterator;
918            self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
919            self
920        }
921    }
922
923    #[doc(hidden)]
924    impl gax::options::internal::RequestBuilder for TestIamPermissions {
925        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
926            &mut self.0.options
927        }
928    }
929}