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