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][super::super::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::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(self, config: gaxi::options::ClientConfig) -> gax::Result<Self::Client> {
43 Self::Client::new(config).await
44 }
45 }
46 }
47
48 /// Common implementation for [super::super::client::ContainerAnalysis] request builders.
49 #[derive(Clone, Debug)]
50 pub(crate) struct RequestBuilder<R: std::default::Default> {
51 stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
52 request: R,
53 options: gax::options::RequestOptions,
54 }
55
56 impl<R> RequestBuilder<R>
57 where
58 R: std::default::Default,
59 {
60 pub(crate) fn new(
61 stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
62 ) -> Self {
63 Self {
64 stub,
65 request: R::default(),
66 options: gax::options::RequestOptions::default(),
67 }
68 }
69 }
70
71 /// The request builder for [ContainerAnalysis::set_iam_policy][super::super::client::ContainerAnalysis::set_iam_policy] calls.
72 ///
73 /// # Example
74 /// ```no_run
75 /// # use google_cloud_containeranalysis_v1::builder;
76 /// use builder::container_analysis::SetIamPolicy;
77 /// # tokio_test::block_on(async {
78 /// let builder = prepare_request_builder();
79 /// let response = builder.send().await?;
80 /// # gax::Result::<()>::Ok(()) });
81 ///
82 /// fn prepare_request_builder() -> SetIamPolicy {
83 /// # panic!();
84 /// // ... details omitted ...
85 /// }
86 /// ```
87 #[derive(Clone, Debug)]
88 pub struct SetIamPolicy(RequestBuilder<iam_v1::model::SetIamPolicyRequest>);
89
90 impl SetIamPolicy {
91 pub(crate) fn new(
92 stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
93 ) -> Self {
94 Self(RequestBuilder::new(stub))
95 }
96
97 /// Sets the full request, replacing any prior values.
98 pub fn with_request<V: Into<iam_v1::model::SetIamPolicyRequest>>(mut self, v: V) -> Self {
99 self.0.request = v.into();
100 self
101 }
102
103 /// Sets all the options, replacing any prior values.
104 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
105 self.0.options = v.into();
106 self
107 }
108
109 /// Sends the request.
110 pub async fn send(self) -> Result<iam_v1::model::Policy> {
111 (*self.0.stub)
112 .set_iam_policy(self.0.request, self.0.options)
113 .await
114 .map(gax::response::Response::into_body)
115 }
116
117 /// Sets the value of [resource][iam_v1::model::SetIamPolicyRequest::resource].
118 ///
119 /// This is a **required** field for requests.
120 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
121 self.0.request.resource = v.into();
122 self
123 }
124
125 /// Sets the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
126 ///
127 /// This is a **required** field for requests.
128 pub fn set_policy<T: Into<std::option::Option<iam_v1::model::Policy>>>(
129 mut self,
130 v: T,
131 ) -> Self {
132 self.0.request.policy = v.into();
133 self
134 }
135
136 /// Sets the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
137 pub fn set_update_mask<T: Into<std::option::Option<wkt::FieldMask>>>(
138 mut self,
139 v: T,
140 ) -> Self {
141 self.0.request.update_mask = v.into();
142 self
143 }
144 }
145
146 #[doc(hidden)]
147 impl gax::options::internal::RequestBuilder for SetIamPolicy {
148 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
149 &mut self.0.options
150 }
151 }
152
153 /// The request builder for [ContainerAnalysis::get_iam_policy][super::super::client::ContainerAnalysis::get_iam_policy] calls.
154 ///
155 /// # Example
156 /// ```no_run
157 /// # use google_cloud_containeranalysis_v1::builder;
158 /// use builder::container_analysis::GetIamPolicy;
159 /// # tokio_test::block_on(async {
160 /// let builder = prepare_request_builder();
161 /// let response = builder.send().await?;
162 /// # gax::Result::<()>::Ok(()) });
163 ///
164 /// fn prepare_request_builder() -> GetIamPolicy {
165 /// # panic!();
166 /// // ... details omitted ...
167 /// }
168 /// ```
169 #[derive(Clone, Debug)]
170 pub struct GetIamPolicy(RequestBuilder<iam_v1::model::GetIamPolicyRequest>);
171
172 impl GetIamPolicy {
173 pub(crate) fn new(
174 stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
175 ) -> Self {
176 Self(RequestBuilder::new(stub))
177 }
178
179 /// Sets the full request, replacing any prior values.
180 pub fn with_request<V: Into<iam_v1::model::GetIamPolicyRequest>>(mut self, v: V) -> Self {
181 self.0.request = v.into();
182 self
183 }
184
185 /// Sets all the options, replacing any prior values.
186 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
187 self.0.options = v.into();
188 self
189 }
190
191 /// Sends the request.
192 pub async fn send(self) -> Result<iam_v1::model::Policy> {
193 (*self.0.stub)
194 .get_iam_policy(self.0.request, self.0.options)
195 .await
196 .map(gax::response::Response::into_body)
197 }
198
199 /// Sets the value of [resource][iam_v1::model::GetIamPolicyRequest::resource].
200 ///
201 /// This is a **required** field for requests.
202 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
203 self.0.request.resource = v.into();
204 self
205 }
206
207 /// Sets the value of [options][iam_v1::model::GetIamPolicyRequest::options].
208 pub fn set_options<T: Into<std::option::Option<iam_v1::model::GetPolicyOptions>>>(
209 mut self,
210 v: T,
211 ) -> Self {
212 self.0.request.options = v.into();
213 self
214 }
215 }
216
217 #[doc(hidden)]
218 impl gax::options::internal::RequestBuilder for GetIamPolicy {
219 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
220 &mut self.0.options
221 }
222 }
223
224 /// The request builder for [ContainerAnalysis::test_iam_permissions][super::super::client::ContainerAnalysis::test_iam_permissions] calls.
225 ///
226 /// # Example
227 /// ```no_run
228 /// # use google_cloud_containeranalysis_v1::builder;
229 /// use builder::container_analysis::TestIamPermissions;
230 /// # tokio_test::block_on(async {
231 /// let builder = prepare_request_builder();
232 /// let response = builder.send().await?;
233 /// # gax::Result::<()>::Ok(()) });
234 ///
235 /// fn prepare_request_builder() -> TestIamPermissions {
236 /// # panic!();
237 /// // ... details omitted ...
238 /// }
239 /// ```
240 #[derive(Clone, Debug)]
241 pub struct TestIamPermissions(RequestBuilder<iam_v1::model::TestIamPermissionsRequest>);
242
243 impl TestIamPermissions {
244 pub(crate) fn new(
245 stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
246 ) -> Self {
247 Self(RequestBuilder::new(stub))
248 }
249
250 /// Sets the full request, replacing any prior values.
251 pub fn with_request<V: Into<iam_v1::model::TestIamPermissionsRequest>>(
252 mut self,
253 v: V,
254 ) -> Self {
255 self.0.request = v.into();
256 self
257 }
258
259 /// Sets all the options, replacing any prior values.
260 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
261 self.0.options = v.into();
262 self
263 }
264
265 /// Sends the request.
266 pub async fn send(self) -> Result<iam_v1::model::TestIamPermissionsResponse> {
267 (*self.0.stub)
268 .test_iam_permissions(self.0.request, self.0.options)
269 .await
270 .map(gax::response::Response::into_body)
271 }
272
273 /// Sets the value of [resource][iam_v1::model::TestIamPermissionsRequest::resource].
274 ///
275 /// This is a **required** field for requests.
276 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
277 self.0.request.resource = v.into();
278 self
279 }
280
281 /// Sets the value of [permissions][iam_v1::model::TestIamPermissionsRequest::permissions].
282 ///
283 /// This is a **required** field for requests.
284 pub fn set_permissions<T, V>(mut self, v: T) -> Self
285 where
286 T: std::iter::IntoIterator<Item = V>,
287 V: std::convert::Into<std::string::String>,
288 {
289 use std::iter::Iterator;
290 self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
291 self
292 }
293 }
294
295 #[doc(hidden)]
296 impl gax::options::internal::RequestBuilder for TestIamPermissions {
297 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
298 &mut self.0.options
299 }
300 }
301
302 /// The request builder for [ContainerAnalysis::get_vulnerability_occurrences_summary][super::super::client::ContainerAnalysis::get_vulnerability_occurrences_summary] calls.
303 ///
304 /// # Example
305 /// ```no_run
306 /// # use google_cloud_containeranalysis_v1::builder;
307 /// use builder::container_analysis::GetVulnerabilityOccurrencesSummary;
308 /// # tokio_test::block_on(async {
309 /// let builder = prepare_request_builder();
310 /// let response = builder.send().await?;
311 /// # gax::Result::<()>::Ok(()) });
312 ///
313 /// fn prepare_request_builder() -> GetVulnerabilityOccurrencesSummary {
314 /// # panic!();
315 /// // ... details omitted ...
316 /// }
317 /// ```
318 #[derive(Clone, Debug)]
319 pub struct GetVulnerabilityOccurrencesSummary(
320 RequestBuilder<crate::model::GetVulnerabilityOccurrencesSummaryRequest>,
321 );
322
323 impl GetVulnerabilityOccurrencesSummary {
324 pub(crate) fn new(
325 stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
326 ) -> Self {
327 Self(RequestBuilder::new(stub))
328 }
329
330 /// Sets the full request, replacing any prior values.
331 pub fn with_request<V: Into<crate::model::GetVulnerabilityOccurrencesSummaryRequest>>(
332 mut self,
333 v: V,
334 ) -> Self {
335 self.0.request = v.into();
336 self
337 }
338
339 /// Sets all the options, replacing any prior values.
340 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
341 self.0.options = v.into();
342 self
343 }
344
345 /// Sends the request.
346 pub async fn send(self) -> Result<crate::model::VulnerabilityOccurrencesSummary> {
347 (*self.0.stub)
348 .get_vulnerability_occurrences_summary(self.0.request, self.0.options)
349 .await
350 .map(gax::response::Response::into_body)
351 }
352
353 /// Sets the value of [parent][crate::model::GetVulnerabilityOccurrencesSummaryRequest::parent].
354 ///
355 /// This is a **required** field for requests.
356 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
357 self.0.request.parent = v.into();
358 self
359 }
360
361 /// Sets the value of [filter][crate::model::GetVulnerabilityOccurrencesSummaryRequest::filter].
362 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
363 self.0.request.filter = v.into();
364 self
365 }
366 }
367
368 #[doc(hidden)]
369 impl gax::options::internal::RequestBuilder for GetVulnerabilityOccurrencesSummary {
370 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
371 &mut self.0.options
372 }
373 }
374
375 /// The request builder for [ContainerAnalysis::export_sbom][super::super::client::ContainerAnalysis::export_sbom] calls.
376 ///
377 /// # Example
378 /// ```no_run
379 /// # use google_cloud_containeranalysis_v1::builder;
380 /// use builder::container_analysis::ExportSBOM;
381 /// # tokio_test::block_on(async {
382 /// let builder = prepare_request_builder();
383 /// let response = builder.send().await?;
384 /// # gax::Result::<()>::Ok(()) });
385 ///
386 /// fn prepare_request_builder() -> ExportSBOM {
387 /// # panic!();
388 /// // ... details omitted ...
389 /// }
390 /// ```
391 #[derive(Clone, Debug)]
392 pub struct ExportSBOM(RequestBuilder<crate::model::ExportSBOMRequest>);
393
394 impl ExportSBOM {
395 pub(crate) fn new(
396 stub: std::sync::Arc<dyn super::super::stub::dynamic::ContainerAnalysis>,
397 ) -> Self {
398 Self(RequestBuilder::new(stub))
399 }
400
401 /// Sets the full request, replacing any prior values.
402 pub fn with_request<V: Into<crate::model::ExportSBOMRequest>>(mut self, v: V) -> Self {
403 self.0.request = v.into();
404 self
405 }
406
407 /// Sets all the options, replacing any prior values.
408 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
409 self.0.options = v.into();
410 self
411 }
412
413 /// Sends the request.
414 pub async fn send(self) -> Result<crate::model::ExportSBOMResponse> {
415 (*self.0.stub)
416 .export_sbom(self.0.request, self.0.options)
417 .await
418 .map(gax::response::Response::into_body)
419 }
420
421 /// Sets the value of [name][crate::model::ExportSBOMRequest::name].
422 ///
423 /// This is a **required** field for requests.
424 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
425 self.0.request.name = v.into();
426 self
427 }
428
429 /// Sets the value of [target][crate::model::ExportSBOMRequest::target].
430 ///
431 /// Note that all the setters affecting `target` are
432 /// mutually exclusive.
433 pub fn set_target<T: Into<Option<crate::model::export_sbom_request::Target>>>(
434 mut self,
435 v: T,
436 ) -> Self {
437 self.0.request.target = v.into();
438 self
439 }
440
441 /// Sets the value of [target][crate::model::ExportSBOMRequest::target]
442 /// to hold a `CloudStorageLocation`.
443 ///
444 /// Note that all the setters affecting `target` are
445 /// mutually exclusive.
446 pub fn set_cloud_storage_location<
447 T: std::convert::Into<
448 std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
449 >,
450 >(
451 mut self,
452 v: T,
453 ) -> Self {
454 self.0.request = self.0.request.set_cloud_storage_location(v);
455 self
456 }
457 }
458
459 #[doc(hidden)]
460 impl gax::options::internal::RequestBuilder for ExportSBOM {
461 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
462 &mut self.0.options
463 }
464 }
465}