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