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