google_cloud_binaryauthorization_v1/
builders.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    use std::sync::Arc;
20
21    /// Common implementation for [crate::client::BinauthzManagementServiceV1] request builders.
22    #[derive(Clone, Debug)]
23    pub struct RequestBuilder<R: std::default::Default> {
24        stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
25        request: R,
26        options: gax::options::RequestOptions,
27    }
28
29    impl<R> RequestBuilder<R>
30    where
31        R: std::default::Default,
32    {
33        pub(crate) fn new(
34            stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
35        ) -> Self {
36            Self {
37                stub,
38                request: R::default(),
39                options: gax::options::RequestOptions::default(),
40            }
41        }
42    }
43
44    /// The request builder for a BinauthzManagementServiceV1::get_policy call.
45    #[derive(Clone, Debug)]
46    pub struct GetPolicy(RequestBuilder<crate::model::GetPolicyRequest>);
47
48    impl GetPolicy {
49        pub(crate) fn new(
50            stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
51        ) -> Self {
52            Self(RequestBuilder::new(stub))
53        }
54
55        /// Sets the full request, replacing any prior values.
56        pub fn with_request<V: Into<crate::model::GetPolicyRequest>>(mut self, v: V) -> Self {
57            self.0.request = v.into();
58            self
59        }
60
61        /// Sets all the options, replacing any prior values.
62        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
63            self.0.options = v.into();
64            self
65        }
66
67        /// Sends the request.
68        pub async fn send(self) -> Result<crate::model::Policy> {
69            (*self.0.stub)
70                .get_policy(self.0.request, self.0.options)
71                .await
72        }
73
74        /// Sets the value of [name][crate::model::GetPolicyRequest::name].
75        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
76            self.0.request.name = v.into();
77            self
78        }
79    }
80
81    impl gax::options::RequestBuilder for GetPolicy {
82        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
83            &mut self.0.options
84        }
85    }
86
87    /// The request builder for a BinauthzManagementServiceV1::update_policy call.
88    #[derive(Clone, Debug)]
89    pub struct UpdatePolicy(RequestBuilder<crate::model::UpdatePolicyRequest>);
90
91    impl UpdatePolicy {
92        pub(crate) fn new(
93            stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
94        ) -> Self {
95            Self(RequestBuilder::new(stub))
96        }
97
98        /// Sets the full request, replacing any prior values.
99        pub fn with_request<V: Into<crate::model::UpdatePolicyRequest>>(mut self, v: V) -> Self {
100            self.0.request = v.into();
101            self
102        }
103
104        /// Sets all the options, replacing any prior values.
105        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
106            self.0.options = v.into();
107            self
108        }
109
110        /// Sends the request.
111        pub async fn send(self) -> Result<crate::model::Policy> {
112            (*self.0.stub)
113                .update_policy(self.0.request, self.0.options)
114                .await
115        }
116
117        /// Sets the value of [policy][crate::model::UpdatePolicyRequest::policy].
118        pub fn set_policy<T: Into<std::option::Option<crate::model::Policy>>>(
119            mut self,
120            v: T,
121        ) -> Self {
122            self.0.request.policy = v.into();
123            self
124        }
125    }
126
127    impl gax::options::RequestBuilder for UpdatePolicy {
128        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
129            &mut self.0.options
130        }
131    }
132
133    /// The request builder for a BinauthzManagementServiceV1::create_attestor call.
134    #[derive(Clone, Debug)]
135    pub struct CreateAttestor(RequestBuilder<crate::model::CreateAttestorRequest>);
136
137    impl CreateAttestor {
138        pub(crate) fn new(
139            stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
140        ) -> Self {
141            Self(RequestBuilder::new(stub))
142        }
143
144        /// Sets the full request, replacing any prior values.
145        pub fn with_request<V: Into<crate::model::CreateAttestorRequest>>(mut self, v: V) -> Self {
146            self.0.request = v.into();
147            self
148        }
149
150        /// Sets all the options, replacing any prior values.
151        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
152            self.0.options = v.into();
153            self
154        }
155
156        /// Sends the request.
157        pub async fn send(self) -> Result<crate::model::Attestor> {
158            (*self.0.stub)
159                .create_attestor(self.0.request, self.0.options)
160                .await
161        }
162
163        /// Sets the value of [parent][crate::model::CreateAttestorRequest::parent].
164        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
165            self.0.request.parent = v.into();
166            self
167        }
168
169        /// Sets the value of [attestor_id][crate::model::CreateAttestorRequest::attestor_id].
170        pub fn set_attestor_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
171            self.0.request.attestor_id = v.into();
172            self
173        }
174
175        /// Sets the value of [attestor][crate::model::CreateAttestorRequest::attestor].
176        pub fn set_attestor<T: Into<std::option::Option<crate::model::Attestor>>>(
177            mut self,
178            v: T,
179        ) -> Self {
180            self.0.request.attestor = v.into();
181            self
182        }
183    }
184
185    impl gax::options::RequestBuilder for CreateAttestor {
186        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
187            &mut self.0.options
188        }
189    }
190
191    /// The request builder for a BinauthzManagementServiceV1::get_attestor call.
192    #[derive(Clone, Debug)]
193    pub struct GetAttestor(RequestBuilder<crate::model::GetAttestorRequest>);
194
195    impl GetAttestor {
196        pub(crate) fn new(
197            stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
198        ) -> Self {
199            Self(RequestBuilder::new(stub))
200        }
201
202        /// Sets the full request, replacing any prior values.
203        pub fn with_request<V: Into<crate::model::GetAttestorRequest>>(mut self, v: V) -> Self {
204            self.0.request = v.into();
205            self
206        }
207
208        /// Sets all the options, replacing any prior values.
209        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
210            self.0.options = v.into();
211            self
212        }
213
214        /// Sends the request.
215        pub async fn send(self) -> Result<crate::model::Attestor> {
216            (*self.0.stub)
217                .get_attestor(self.0.request, self.0.options)
218                .await
219        }
220
221        /// Sets the value of [name][crate::model::GetAttestorRequest::name].
222        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
223            self.0.request.name = v.into();
224            self
225        }
226    }
227
228    impl gax::options::RequestBuilder for GetAttestor {
229        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
230            &mut self.0.options
231        }
232    }
233
234    /// The request builder for a BinauthzManagementServiceV1::update_attestor call.
235    #[derive(Clone, Debug)]
236    pub struct UpdateAttestor(RequestBuilder<crate::model::UpdateAttestorRequest>);
237
238    impl UpdateAttestor {
239        pub(crate) fn new(
240            stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
241        ) -> Self {
242            Self(RequestBuilder::new(stub))
243        }
244
245        /// Sets the full request, replacing any prior values.
246        pub fn with_request<V: Into<crate::model::UpdateAttestorRequest>>(mut self, v: V) -> Self {
247            self.0.request = v.into();
248            self
249        }
250
251        /// Sets all the options, replacing any prior values.
252        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
253            self.0.options = v.into();
254            self
255        }
256
257        /// Sends the request.
258        pub async fn send(self) -> Result<crate::model::Attestor> {
259            (*self.0.stub)
260                .update_attestor(self.0.request, self.0.options)
261                .await
262        }
263
264        /// Sets the value of [attestor][crate::model::UpdateAttestorRequest::attestor].
265        pub fn set_attestor<T: Into<std::option::Option<crate::model::Attestor>>>(
266            mut self,
267            v: T,
268        ) -> Self {
269            self.0.request.attestor = v.into();
270            self
271        }
272    }
273
274    impl gax::options::RequestBuilder for UpdateAttestor {
275        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
276            &mut self.0.options
277        }
278    }
279
280    /// The request builder for a BinauthzManagementServiceV1::list_attestors call.
281    #[derive(Clone, Debug)]
282    pub struct ListAttestors(RequestBuilder<crate::model::ListAttestorsRequest>);
283
284    impl ListAttestors {
285        pub(crate) fn new(
286            stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
287        ) -> Self {
288            Self(RequestBuilder::new(stub))
289        }
290
291        /// Sets the full request, replacing any prior values.
292        pub fn with_request<V: Into<crate::model::ListAttestorsRequest>>(mut self, v: V) -> Self {
293            self.0.request = v.into();
294            self
295        }
296
297        /// Sets all the options, replacing any prior values.
298        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
299            self.0.options = v.into();
300            self
301        }
302
303        /// Sends the request.
304        pub async fn send(self) -> Result<crate::model::ListAttestorsResponse> {
305            (*self.0.stub)
306                .list_attestors(self.0.request, self.0.options)
307                .await
308        }
309
310        /// Streams the responses back.
311        #[cfg(feature = "unstable-stream")]
312        pub async fn stream(
313            self,
314        ) -> gax::paginator::Paginator<crate::model::ListAttestorsResponse, gax::error::Error>
315        {
316            let token = gax::paginator::extract_token(&self.0.request.page_token);
317            let execute = move |token: String| {
318                let mut builder = self.clone();
319                builder.0.request = builder.0.request.set_page_token(token);
320                builder.send()
321            };
322            gax::paginator::Paginator::new(token, execute)
323        }
324
325        /// Sets the value of [parent][crate::model::ListAttestorsRequest::parent].
326        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
327            self.0.request.parent = v.into();
328            self
329        }
330
331        /// Sets the value of [page_size][crate::model::ListAttestorsRequest::page_size].
332        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
333            self.0.request.page_size = v.into();
334            self
335        }
336
337        /// Sets the value of [page_token][crate::model::ListAttestorsRequest::page_token].
338        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
339            self.0.request.page_token = v.into();
340            self
341        }
342    }
343
344    impl gax::options::RequestBuilder for ListAttestors {
345        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
346            &mut self.0.options
347        }
348    }
349
350    /// The request builder for a BinauthzManagementServiceV1::delete_attestor call.
351    #[derive(Clone, Debug)]
352    pub struct DeleteAttestor(RequestBuilder<crate::model::DeleteAttestorRequest>);
353
354    impl DeleteAttestor {
355        pub(crate) fn new(
356            stub: Arc<dyn crate::stubs::dynamic::BinauthzManagementServiceV1>,
357        ) -> Self {
358            Self(RequestBuilder::new(stub))
359        }
360
361        /// Sets the full request, replacing any prior values.
362        pub fn with_request<V: Into<crate::model::DeleteAttestorRequest>>(mut self, v: V) -> Self {
363            self.0.request = v.into();
364            self
365        }
366
367        /// Sets all the options, replacing any prior values.
368        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
369            self.0.options = v.into();
370            self
371        }
372
373        /// Sends the request.
374        pub async fn send(self) -> Result<wkt::Empty> {
375            (*self.0.stub)
376                .delete_attestor(self.0.request, self.0.options)
377                .await
378        }
379
380        /// Sets the value of [name][crate::model::DeleteAttestorRequest::name].
381        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
382            self.0.request.name = v.into();
383            self
384        }
385    }
386
387    impl gax::options::RequestBuilder for DeleteAttestor {
388        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
389            &mut self.0.options
390        }
391    }
392}
393
394pub mod system_policy_v_1 {
395    use crate::Result;
396    use std::sync::Arc;
397
398    /// Common implementation for [crate::client::SystemPolicyV1] request builders.
399    #[derive(Clone, Debug)]
400    pub struct RequestBuilder<R: std::default::Default> {
401        stub: Arc<dyn crate::stubs::dynamic::SystemPolicyV1>,
402        request: R,
403        options: gax::options::RequestOptions,
404    }
405
406    impl<R> RequestBuilder<R>
407    where
408        R: std::default::Default,
409    {
410        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::SystemPolicyV1>) -> Self {
411            Self {
412                stub,
413                request: R::default(),
414                options: gax::options::RequestOptions::default(),
415            }
416        }
417    }
418
419    /// The request builder for a SystemPolicyV1::get_system_policy call.
420    #[derive(Clone, Debug)]
421    pub struct GetSystemPolicy(RequestBuilder<crate::model::GetSystemPolicyRequest>);
422
423    impl GetSystemPolicy {
424        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::SystemPolicyV1>) -> Self {
425            Self(RequestBuilder::new(stub))
426        }
427
428        /// Sets the full request, replacing any prior values.
429        pub fn with_request<V: Into<crate::model::GetSystemPolicyRequest>>(mut self, v: V) -> Self {
430            self.0.request = v.into();
431            self
432        }
433
434        /// Sets all the options, replacing any prior values.
435        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
436            self.0.options = v.into();
437            self
438        }
439
440        /// Sends the request.
441        pub async fn send(self) -> Result<crate::model::Policy> {
442            (*self.0.stub)
443                .get_system_policy(self.0.request, self.0.options)
444                .await
445        }
446
447        /// Sets the value of [name][crate::model::GetSystemPolicyRequest::name].
448        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
449            self.0.request.name = v.into();
450            self
451        }
452    }
453
454    impl gax::options::RequestBuilder for GetSystemPolicy {
455        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
456            &mut self.0.options
457        }
458    }
459}
460
461pub mod validation_helper_v_1 {
462    use crate::Result;
463    use std::sync::Arc;
464
465    /// Common implementation for [crate::client::ValidationHelperV1] request builders.
466    #[derive(Clone, Debug)]
467    pub struct RequestBuilder<R: std::default::Default> {
468        stub: Arc<dyn crate::stubs::dynamic::ValidationHelperV1>,
469        request: R,
470        options: gax::options::RequestOptions,
471    }
472
473    impl<R> RequestBuilder<R>
474    where
475        R: std::default::Default,
476    {
477        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ValidationHelperV1>) -> Self {
478            Self {
479                stub,
480                request: R::default(),
481                options: gax::options::RequestOptions::default(),
482            }
483        }
484    }
485
486    /// The request builder for a ValidationHelperV1::validate_attestation_occurrence call.
487    #[derive(Clone, Debug)]
488    pub struct ValidateAttestationOccurrence(
489        RequestBuilder<crate::model::ValidateAttestationOccurrenceRequest>,
490    );
491
492    impl ValidateAttestationOccurrence {
493        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ValidationHelperV1>) -> Self {
494            Self(RequestBuilder::new(stub))
495        }
496
497        /// Sets the full request, replacing any prior values.
498        pub fn with_request<V: Into<crate::model::ValidateAttestationOccurrenceRequest>>(
499            mut self,
500            v: V,
501        ) -> Self {
502            self.0.request = v.into();
503            self
504        }
505
506        /// Sets all the options, replacing any prior values.
507        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
508            self.0.options = v.into();
509            self
510        }
511
512        /// Sends the request.
513        pub async fn send(self) -> Result<crate::model::ValidateAttestationOccurrenceResponse> {
514            (*self.0.stub)
515                .validate_attestation_occurrence(self.0.request, self.0.options)
516                .await
517        }
518
519        /// Sets the value of [attestor][crate::model::ValidateAttestationOccurrenceRequest::attestor].
520        pub fn set_attestor<T: Into<std::string::String>>(mut self, v: T) -> Self {
521            self.0.request.attestor = v.into();
522            self
523        }
524
525        /// Sets the value of [attestation][crate::model::ValidateAttestationOccurrenceRequest::attestation].
526        pub fn set_attestation<
527            T: Into<std::option::Option<grafeas::model::AttestationOccurrence>>,
528        >(
529            mut self,
530            v: T,
531        ) -> Self {
532            self.0.request.attestation = v.into();
533            self
534        }
535
536        /// Sets the value of [occurrence_note][crate::model::ValidateAttestationOccurrenceRequest::occurrence_note].
537        pub fn set_occurrence_note<T: Into<std::string::String>>(mut self, v: T) -> Self {
538            self.0.request.occurrence_note = v.into();
539            self
540        }
541
542        /// Sets the value of [occurrence_resource_uri][crate::model::ValidateAttestationOccurrenceRequest::occurrence_resource_uri].
543        pub fn set_occurrence_resource_uri<T: Into<std::string::String>>(mut self, v: T) -> Self {
544            self.0.request.occurrence_resource_uri = v.into();
545            self
546        }
547    }
548
549    impl gax::options::RequestBuilder for ValidateAttestationOccurrence {
550        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
551            &mut self.0.options
552        }
553    }
554}