google_cloud_containeranalysis_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 container_analysis {
18    use crate::Result;
19
20    /// A builder for [ContainerAnalysis][crate::client::ContainerAnalysis].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_containeranalysis_v1::*;
25    /// # use builder::container_analysis::ClientBuilder;
26    /// # use client::ContainerAnalysis;
27    /// let builder : ClientBuilder = ContainerAnalysis::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://containeranalysis.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::ContainerAnalysis;
38        pub struct Factory;
39        impl gax::client_builder::internal::ClientFactory for Factory {
40            type Client = ContainerAnalysis;
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::ContainerAnalysis] 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::ContainerAnalysis>,
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::ContainerAnalysis>,
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 [ContainerAnalysis::set_iam_policy][crate::client::ContainerAnalysis::set_iam_policy] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_containeranalysis_v1::builder;
79    /// use builder::container_analysis::SetIamPolicy;
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() -> SetIamPolicy {
87    ///   # panic!();
88    ///   // ... details omitted ...
89    /// }
90    /// ```
91    #[derive(Clone, Debug)]
92    pub struct SetIamPolicy(RequestBuilder<iam_v1::model::SetIamPolicyRequest>);
93
94    impl SetIamPolicy {
95        pub(crate) fn new(
96            stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
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<iam_v1::model::SetIamPolicyRequest>>(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<iam_v1::model::Policy> {
115            (*self.0.stub)
116                .set_iam_policy(self.0.request, self.0.options)
117                .await
118                .map(gax::response::Response::into_body)
119        }
120
121        /// Sets the value of [resource][iam_v1::model::SetIamPolicyRequest::resource].
122        ///
123        /// This is a **required** field for requests.
124        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
125            self.0.request.resource = v.into();
126            self
127        }
128
129        /// Sets the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
130        ///
131        /// This is a **required** field for requests.
132        pub fn set_policy<T>(mut self, v: T) -> Self
133        where
134            T: std::convert::Into<iam_v1::model::Policy>,
135        {
136            self.0.request.policy = std::option::Option::Some(v.into());
137            self
138        }
139
140        /// Sets or clears the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
141        ///
142        /// This is a **required** field for requests.
143        pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
144        where
145            T: std::convert::Into<iam_v1::model::Policy>,
146        {
147            self.0.request.policy = v.map(|x| x.into());
148            self
149        }
150
151        /// Sets the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
152        pub fn set_update_mask<T>(mut self, v: T) -> Self
153        where
154            T: std::convert::Into<wkt::FieldMask>,
155        {
156            self.0.request.update_mask = std::option::Option::Some(v.into());
157            self
158        }
159
160        /// Sets or clears the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
161        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
162        where
163            T: std::convert::Into<wkt::FieldMask>,
164        {
165            self.0.request.update_mask = v.map(|x| x.into());
166            self
167        }
168    }
169
170    #[doc(hidden)]
171    impl gax::options::internal::RequestBuilder for SetIamPolicy {
172        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
173            &mut self.0.options
174        }
175    }
176
177    /// The request builder for [ContainerAnalysis::get_iam_policy][crate::client::ContainerAnalysis::get_iam_policy] calls.
178    ///
179    /// # Example
180    /// ```no_run
181    /// # use google_cloud_containeranalysis_v1::builder;
182    /// use builder::container_analysis::GetIamPolicy;
183    /// # tokio_test::block_on(async {
184    ///
185    /// let builder = prepare_request_builder();
186    /// let response = builder.send().await?;
187    /// # gax::Result::<()>::Ok(()) });
188    ///
189    /// fn prepare_request_builder() -> GetIamPolicy {
190    ///   # panic!();
191    ///   // ... details omitted ...
192    /// }
193    /// ```
194    #[derive(Clone, Debug)]
195    pub struct GetIamPolicy(RequestBuilder<iam_v1::model::GetIamPolicyRequest>);
196
197    impl GetIamPolicy {
198        pub(crate) fn new(
199            stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
200        ) -> Self {
201            Self(RequestBuilder::new(stub))
202        }
203
204        /// Sets the full request, replacing any prior values.
205        pub fn with_request<V: Into<iam_v1::model::GetIamPolicyRequest>>(mut self, v: V) -> Self {
206            self.0.request = v.into();
207            self
208        }
209
210        /// Sets all the options, replacing any prior values.
211        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
212            self.0.options = v.into();
213            self
214        }
215
216        /// Sends the request.
217        pub async fn send(self) -> Result<iam_v1::model::Policy> {
218            (*self.0.stub)
219                .get_iam_policy(self.0.request, self.0.options)
220                .await
221                .map(gax::response::Response::into_body)
222        }
223
224        /// Sets the value of [resource][iam_v1::model::GetIamPolicyRequest::resource].
225        ///
226        /// This is a **required** field for requests.
227        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
228            self.0.request.resource = v.into();
229            self
230        }
231
232        /// Sets the value of [options][iam_v1::model::GetIamPolicyRequest::options].
233        pub fn set_options<T>(mut self, v: T) -> Self
234        where
235            T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
236        {
237            self.0.request.options = std::option::Option::Some(v.into());
238            self
239        }
240
241        /// Sets or clears the value of [options][iam_v1::model::GetIamPolicyRequest::options].
242        pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
243        where
244            T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
245        {
246            self.0.request.options = v.map(|x| x.into());
247            self
248        }
249    }
250
251    #[doc(hidden)]
252    impl gax::options::internal::RequestBuilder for GetIamPolicy {
253        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
254            &mut self.0.options
255        }
256    }
257
258    /// The request builder for [ContainerAnalysis::test_iam_permissions][crate::client::ContainerAnalysis::test_iam_permissions] calls.
259    ///
260    /// # Example
261    /// ```no_run
262    /// # use google_cloud_containeranalysis_v1::builder;
263    /// use builder::container_analysis::TestIamPermissions;
264    /// # tokio_test::block_on(async {
265    ///
266    /// let builder = prepare_request_builder();
267    /// let response = builder.send().await?;
268    /// # gax::Result::<()>::Ok(()) });
269    ///
270    /// fn prepare_request_builder() -> TestIamPermissions {
271    ///   # panic!();
272    ///   // ... details omitted ...
273    /// }
274    /// ```
275    #[derive(Clone, Debug)]
276    pub struct TestIamPermissions(RequestBuilder<iam_v1::model::TestIamPermissionsRequest>);
277
278    impl TestIamPermissions {
279        pub(crate) fn new(
280            stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
281        ) -> Self {
282            Self(RequestBuilder::new(stub))
283        }
284
285        /// Sets the full request, replacing any prior values.
286        pub fn with_request<V: Into<iam_v1::model::TestIamPermissionsRequest>>(
287            mut self,
288            v: V,
289        ) -> Self {
290            self.0.request = v.into();
291            self
292        }
293
294        /// Sets all the options, replacing any prior values.
295        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
296            self.0.options = v.into();
297            self
298        }
299
300        /// Sends the request.
301        pub async fn send(self) -> Result<iam_v1::model::TestIamPermissionsResponse> {
302            (*self.0.stub)
303                .test_iam_permissions(self.0.request, self.0.options)
304                .await
305                .map(gax::response::Response::into_body)
306        }
307
308        /// Sets the value of [resource][iam_v1::model::TestIamPermissionsRequest::resource].
309        ///
310        /// This is a **required** field for requests.
311        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
312            self.0.request.resource = v.into();
313            self
314        }
315
316        /// Sets the value of [permissions][iam_v1::model::TestIamPermissionsRequest::permissions].
317        ///
318        /// This is a **required** field for requests.
319        pub fn set_permissions<T, V>(mut self, v: T) -> Self
320        where
321            T: std::iter::IntoIterator<Item = V>,
322            V: std::convert::Into<std::string::String>,
323        {
324            use std::iter::Iterator;
325            self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
326            self
327        }
328    }
329
330    #[doc(hidden)]
331    impl gax::options::internal::RequestBuilder for TestIamPermissions {
332        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
333            &mut self.0.options
334        }
335    }
336
337    /// The request builder for [ContainerAnalysis::get_vulnerability_occurrences_summary][crate::client::ContainerAnalysis::get_vulnerability_occurrences_summary] calls.
338    ///
339    /// # Example
340    /// ```no_run
341    /// # use google_cloud_containeranalysis_v1::builder;
342    /// use builder::container_analysis::GetVulnerabilityOccurrencesSummary;
343    /// # tokio_test::block_on(async {
344    ///
345    /// let builder = prepare_request_builder();
346    /// let response = builder.send().await?;
347    /// # gax::Result::<()>::Ok(()) });
348    ///
349    /// fn prepare_request_builder() -> GetVulnerabilityOccurrencesSummary {
350    ///   # panic!();
351    ///   // ... details omitted ...
352    /// }
353    /// ```
354    #[derive(Clone, Debug)]
355    pub struct GetVulnerabilityOccurrencesSummary(
356        RequestBuilder<crate::model::GetVulnerabilityOccurrencesSummaryRequest>,
357    );
358
359    impl GetVulnerabilityOccurrencesSummary {
360        pub(crate) fn new(
361            stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
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::GetVulnerabilityOccurrencesSummaryRequest>>(
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::VulnerabilityOccurrencesSummary> {
383            (*self.0.stub)
384                .get_vulnerability_occurrences_summary(self.0.request, self.0.options)
385                .await
386                .map(gax::response::Response::into_body)
387        }
388
389        /// Sets the value of [parent][crate::model::GetVulnerabilityOccurrencesSummaryRequest::parent].
390        ///
391        /// This is a **required** field for requests.
392        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
393            self.0.request.parent = v.into();
394            self
395        }
396
397        /// Sets the value of [filter][crate::model::GetVulnerabilityOccurrencesSummaryRequest::filter].
398        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
399            self.0.request.filter = v.into();
400            self
401        }
402    }
403
404    #[doc(hidden)]
405    impl gax::options::internal::RequestBuilder for GetVulnerabilityOccurrencesSummary {
406        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
407            &mut self.0.options
408        }
409    }
410
411    /// The request builder for [ContainerAnalysis::export_sbom][crate::client::ContainerAnalysis::export_sbom] calls.
412    ///
413    /// # Example
414    /// ```no_run
415    /// # use google_cloud_containeranalysis_v1::builder;
416    /// use builder::container_analysis::ExportSBOM;
417    /// # tokio_test::block_on(async {
418    ///
419    /// let builder = prepare_request_builder();
420    /// let response = builder.send().await?;
421    /// # gax::Result::<()>::Ok(()) });
422    ///
423    /// fn prepare_request_builder() -> ExportSBOM {
424    ///   # panic!();
425    ///   // ... details omitted ...
426    /// }
427    /// ```
428    #[derive(Clone, Debug)]
429    pub struct ExportSBOM(RequestBuilder<crate::model::ExportSBOMRequest>);
430
431    impl ExportSBOM {
432        pub(crate) fn new(
433            stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
434        ) -> Self {
435            Self(RequestBuilder::new(stub))
436        }
437
438        /// Sets the full request, replacing any prior values.
439        pub fn with_request<V: Into<crate::model::ExportSBOMRequest>>(mut self, v: V) -> Self {
440            self.0.request = v.into();
441            self
442        }
443
444        /// Sets all the options, replacing any prior values.
445        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
446            self.0.options = v.into();
447            self
448        }
449
450        /// Sends the request.
451        pub async fn send(self) -> Result<crate::model::ExportSBOMResponse> {
452            (*self.0.stub)
453                .export_sbom(self.0.request, self.0.options)
454                .await
455                .map(gax::response::Response::into_body)
456        }
457
458        /// Sets the value of [name][crate::model::ExportSBOMRequest::name].
459        ///
460        /// This is a **required** field for requests.
461        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
462            self.0.request.name = v.into();
463            self
464        }
465
466        /// Sets the value of [target][crate::model::ExportSBOMRequest::target].
467        ///
468        /// Note that all the setters affecting `target` are
469        /// mutually exclusive.
470        pub fn set_target<T: Into<Option<crate::model::export_sbom_request::Target>>>(
471            mut self,
472            v: T,
473        ) -> Self {
474            self.0.request.target = v.into();
475            self
476        }
477
478        /// Sets the value of [target][crate::model::ExportSBOMRequest::target]
479        /// to hold a `CloudStorageLocation`.
480        ///
481        /// Note that all the setters affecting `target` are
482        /// mutually exclusive.
483        pub fn set_cloud_storage_location<
484            T: std::convert::Into<
485                    std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
486                >,
487        >(
488            mut self,
489            v: T,
490        ) -> Self {
491            self.0.request = self.0.request.set_cloud_storage_location(v);
492            self
493        }
494    }
495
496    #[doc(hidden)]
497    impl gax::options::internal::RequestBuilder for ExportSBOM {
498        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
499            &mut self.0.options
500        }
501    }
502}