google_cloud_containeranalysis_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 container_analysis {
18    use crate::Result;
19    use std::sync::Arc;
20
21    /// Common implementation for [crate::client::ContainerAnalysis] request builders.
22    #[derive(Clone, Debug)]
23    pub struct RequestBuilder<R: std::default::Default> {
24        stub: Arc<dyn crate::stubs::dynamic::ContainerAnalysis>,
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(stub: Arc<dyn crate::stubs::dynamic::ContainerAnalysis>) -> Self {
34            Self {
35                stub,
36                request: R::default(),
37                options: gax::options::RequestOptions::default(),
38            }
39        }
40    }
41
42    /// The request builder for a ContainerAnalysis::set_iam_policy call.
43    #[derive(Clone, Debug)]
44    pub struct SetIamPolicy(RequestBuilder<iam_v1::model::SetIamPolicyRequest>);
45
46    impl SetIamPolicy {
47        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ContainerAnalysis>) -> Self {
48            Self(RequestBuilder::new(stub))
49        }
50
51        /// Sets the full request, replacing any prior values.
52        pub fn with_request<V: Into<iam_v1::model::SetIamPolicyRequest>>(mut self, v: V) -> Self {
53            self.0.request = v.into();
54            self
55        }
56
57        /// Sets all the options, replacing any prior values.
58        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
59            self.0.options = v.into();
60            self
61        }
62
63        /// Sends the request.
64        pub async fn send(self) -> Result<iam_v1::model::Policy> {
65            (*self.0.stub)
66                .set_iam_policy(self.0.request, self.0.options)
67                .await
68        }
69
70        /// Sets the value of [resource][iam_v1::model::SetIamPolicyRequest::resource].
71        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
72            self.0.request.resource = v.into();
73            self
74        }
75
76        /// Sets the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
77        pub fn set_policy<T: Into<std::option::Option<iam_v1::model::Policy>>>(
78            mut self,
79            v: T,
80        ) -> Self {
81            self.0.request.policy = v.into();
82            self
83        }
84
85        /// Sets the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
86        pub fn set_update_mask<T: Into<std::option::Option<wkt::FieldMask>>>(
87            mut self,
88            v: T,
89        ) -> Self {
90            self.0.request.update_mask = v.into();
91            self
92        }
93    }
94
95    impl gax::options::RequestBuilder for SetIamPolicy {
96        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
97            &mut self.0.options
98        }
99    }
100
101    /// The request builder for a ContainerAnalysis::get_iam_policy call.
102    #[derive(Clone, Debug)]
103    pub struct GetIamPolicy(RequestBuilder<iam_v1::model::GetIamPolicyRequest>);
104
105    impl GetIamPolicy {
106        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ContainerAnalysis>) -> Self {
107            Self(RequestBuilder::new(stub))
108        }
109
110        /// Sets the full request, replacing any prior values.
111        pub fn with_request<V: Into<iam_v1::model::GetIamPolicyRequest>>(mut self, v: V) -> Self {
112            self.0.request = v.into();
113            self
114        }
115
116        /// Sets all the options, replacing any prior values.
117        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
118            self.0.options = v.into();
119            self
120        }
121
122        /// Sends the request.
123        pub async fn send(self) -> Result<iam_v1::model::Policy> {
124            (*self.0.stub)
125                .get_iam_policy(self.0.request, self.0.options)
126                .await
127        }
128
129        /// Sets the value of [resource][iam_v1::model::GetIamPolicyRequest::resource].
130        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
131            self.0.request.resource = v.into();
132            self
133        }
134
135        /// Sets the value of [options][iam_v1::model::GetIamPolicyRequest::options].
136        pub fn set_options<T: Into<std::option::Option<iam_v1::model::GetPolicyOptions>>>(
137            mut self,
138            v: T,
139        ) -> Self {
140            self.0.request.options = v.into();
141            self
142        }
143    }
144
145    impl gax::options::RequestBuilder for GetIamPolicy {
146        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
147            &mut self.0.options
148        }
149    }
150
151    /// The request builder for a ContainerAnalysis::test_iam_permissions call.
152    #[derive(Clone, Debug)]
153    pub struct TestIamPermissions(RequestBuilder<iam_v1::model::TestIamPermissionsRequest>);
154
155    impl TestIamPermissions {
156        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ContainerAnalysis>) -> Self {
157            Self(RequestBuilder::new(stub))
158        }
159
160        /// Sets the full request, replacing any prior values.
161        pub fn with_request<V: Into<iam_v1::model::TestIamPermissionsRequest>>(
162            mut self,
163            v: V,
164        ) -> Self {
165            self.0.request = v.into();
166            self
167        }
168
169        /// Sets all the options, replacing any prior values.
170        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
171            self.0.options = v.into();
172            self
173        }
174
175        /// Sends the request.
176        pub async fn send(self) -> Result<iam_v1::model::TestIamPermissionsResponse> {
177            (*self.0.stub)
178                .test_iam_permissions(self.0.request, self.0.options)
179                .await
180        }
181
182        /// Sets the value of [resource][iam_v1::model::TestIamPermissionsRequest::resource].
183        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
184            self.0.request.resource = v.into();
185            self
186        }
187
188        /// Sets the value of [permissions][iam_v1::model::TestIamPermissionsRequest::permissions].
189        pub fn set_permissions<T, V>(mut self, v: T) -> Self
190        where
191            T: std::iter::IntoIterator<Item = V>,
192            V: std::convert::Into<std::string::String>,
193        {
194            use std::iter::Iterator;
195            self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
196            self
197        }
198    }
199
200    impl gax::options::RequestBuilder for TestIamPermissions {
201        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
202            &mut self.0.options
203        }
204    }
205
206    /// The request builder for a ContainerAnalysis::get_vulnerability_occurrences_summary call.
207    #[derive(Clone, Debug)]
208    pub struct GetVulnerabilityOccurrencesSummary(
209        RequestBuilder<crate::model::GetVulnerabilityOccurrencesSummaryRequest>,
210    );
211
212    impl GetVulnerabilityOccurrencesSummary {
213        pub(crate) fn new(stub: Arc<dyn crate::stubs::dynamic::ContainerAnalysis>) -> Self {
214            Self(RequestBuilder::new(stub))
215        }
216
217        /// Sets the full request, replacing any prior values.
218        pub fn with_request<V: Into<crate::model::GetVulnerabilityOccurrencesSummaryRequest>>(
219            mut self,
220            v: V,
221        ) -> Self {
222            self.0.request = v.into();
223            self
224        }
225
226        /// Sets all the options, replacing any prior values.
227        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
228            self.0.options = v.into();
229            self
230        }
231
232        /// Sends the request.
233        pub async fn send(self) -> Result<crate::model::VulnerabilityOccurrencesSummary> {
234            (*self.0.stub)
235                .get_vulnerability_occurrences_summary(self.0.request, self.0.options)
236                .await
237        }
238
239        /// Sets the value of [parent][crate::model::GetVulnerabilityOccurrencesSummaryRequest::parent].
240        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
241            self.0.request.parent = v.into();
242            self
243        }
244
245        /// Sets the value of [filter][crate::model::GetVulnerabilityOccurrencesSummaryRequest::filter].
246        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
247            self.0.request.filter = v.into();
248            self
249        }
250    }
251
252    impl gax::options::RequestBuilder for GetVulnerabilityOccurrencesSummary {
253        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
254            &mut self.0.options
255        }
256    }
257}