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