Skip to main content

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