Skip to main content

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