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