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