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