google_cloud_bigquery_connection_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 connection_service {
18 use crate::Result;
19
20 /// A builder for [ConnectionService][crate::client::ConnectionService].
21 ///
22 /// ```
23 /// # tokio_test::block_on(async {
24 /// # use google_cloud_bigquery_connection_v1::*;
25 /// # use builder::connection_service::ClientBuilder;
26 /// # use client::ConnectionService;
27 /// let builder : ClientBuilder = ConnectionService::builder();
28 /// let client = builder
29 /// .with_endpoint("https://bigqueryconnection.googleapis.com")
30 /// .build().await?;
31 /// # gax::client_builder::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::ConnectionService;
38 pub struct Factory;
39 impl gax::client_builder::internal::ClientFactory for Factory {
40 type Client = ConnectionService;
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::ConnectionService] 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::ConnectionService>,
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::ConnectionService>,
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 [ConnectionService::create_connection][crate::client::ConnectionService::create_connection] calls.
75 ///
76 /// # Example
77 /// ```no_run
78 /// # use google_cloud_bigquery_connection_v1::builder;
79 /// use builder::connection_service::CreateConnection;
80 /// # tokio_test::block_on(async {
81 ///
82 /// let builder = prepare_request_builder();
83 /// let response = builder.send().await?;
84 /// # gax::Result::<()>::Ok(()) });
85 ///
86 /// fn prepare_request_builder() -> CreateConnection {
87 /// # panic!();
88 /// // ... details omitted ...
89 /// }
90 /// ```
91 #[derive(Clone, Debug)]
92 pub struct CreateConnection(RequestBuilder<crate::model::CreateConnectionRequest>);
93
94 impl CreateConnection {
95 pub(crate) fn new(
96 stub: std::sync::Arc<dyn super::super::stub::dynamic::ConnectionService>,
97 ) -> Self {
98 Self(RequestBuilder::new(stub))
99 }
100
101 /// Sets the full request, replacing any prior values.
102 pub fn with_request<V: Into<crate::model::CreateConnectionRequest>>(
103 mut self,
104 v: V,
105 ) -> Self {
106 self.0.request = v.into();
107 self
108 }
109
110 /// Sets all the options, replacing any prior values.
111 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
112 self.0.options = v.into();
113 self
114 }
115
116 /// Sends the request.
117 pub async fn send(self) -> Result<crate::model::Connection> {
118 (*self.0.stub)
119 .create_connection(self.0.request, self.0.options)
120 .await
121 .map(gax::response::Response::into_body)
122 }
123
124 /// Sets the value of [parent][crate::model::CreateConnectionRequest::parent].
125 ///
126 /// This is a **required** field for requests.
127 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
128 self.0.request.parent = v.into();
129 self
130 }
131
132 /// Sets the value of [connection_id][crate::model::CreateConnectionRequest::connection_id].
133 pub fn set_connection_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
134 self.0.request.connection_id = v.into();
135 self
136 }
137
138 /// Sets the value of [connection][crate::model::CreateConnectionRequest::connection].
139 ///
140 /// This is a **required** field for requests.
141 pub fn set_connection<T>(mut self, v: T) -> Self
142 where
143 T: std::convert::Into<crate::model::Connection>,
144 {
145 self.0.request.connection = std::option::Option::Some(v.into());
146 self
147 }
148
149 /// Sets or clears the value of [connection][crate::model::CreateConnectionRequest::connection].
150 ///
151 /// This is a **required** field for requests.
152 pub fn set_or_clear_connection<T>(mut self, v: std::option::Option<T>) -> Self
153 where
154 T: std::convert::Into<crate::model::Connection>,
155 {
156 self.0.request.connection = v.map(|x| x.into());
157 self
158 }
159 }
160
161 #[doc(hidden)]
162 impl gax::options::internal::RequestBuilder for CreateConnection {
163 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
164 &mut self.0.options
165 }
166 }
167
168 /// The request builder for [ConnectionService::get_connection][crate::client::ConnectionService::get_connection] calls.
169 ///
170 /// # Example
171 /// ```no_run
172 /// # use google_cloud_bigquery_connection_v1::builder;
173 /// use builder::connection_service::GetConnection;
174 /// # tokio_test::block_on(async {
175 ///
176 /// let builder = prepare_request_builder();
177 /// let response = builder.send().await?;
178 /// # gax::Result::<()>::Ok(()) });
179 ///
180 /// fn prepare_request_builder() -> GetConnection {
181 /// # panic!();
182 /// // ... details omitted ...
183 /// }
184 /// ```
185 #[derive(Clone, Debug)]
186 pub struct GetConnection(RequestBuilder<crate::model::GetConnectionRequest>);
187
188 impl GetConnection {
189 pub(crate) fn new(
190 stub: std::sync::Arc<dyn super::super::stub::dynamic::ConnectionService>,
191 ) -> Self {
192 Self(RequestBuilder::new(stub))
193 }
194
195 /// Sets the full request, replacing any prior values.
196 pub fn with_request<V: Into<crate::model::GetConnectionRequest>>(mut self, v: V) -> Self {
197 self.0.request = v.into();
198 self
199 }
200
201 /// Sets all the options, replacing any prior values.
202 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
203 self.0.options = v.into();
204 self
205 }
206
207 /// Sends the request.
208 pub async fn send(self) -> Result<crate::model::Connection> {
209 (*self.0.stub)
210 .get_connection(self.0.request, self.0.options)
211 .await
212 .map(gax::response::Response::into_body)
213 }
214
215 /// Sets the value of [name][crate::model::GetConnectionRequest::name].
216 ///
217 /// This is a **required** field for requests.
218 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
219 self.0.request.name = v.into();
220 self
221 }
222 }
223
224 #[doc(hidden)]
225 impl gax::options::internal::RequestBuilder for GetConnection {
226 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
227 &mut self.0.options
228 }
229 }
230
231 /// The request builder for [ConnectionService::list_connections][crate::client::ConnectionService::list_connections] calls.
232 ///
233 /// # Example
234 /// ```no_run
235 /// # use google_cloud_bigquery_connection_v1::builder;
236 /// use builder::connection_service::ListConnections;
237 /// # tokio_test::block_on(async {
238 /// use gax::paginator::ItemPaginator;
239 ///
240 /// let builder = prepare_request_builder();
241 /// let mut items = builder.by_item();
242 /// while let Some(result) = items.next().await {
243 /// let item = result?;
244 /// }
245 /// # gax::Result::<()>::Ok(()) });
246 ///
247 /// fn prepare_request_builder() -> ListConnections {
248 /// # panic!();
249 /// // ... details omitted ...
250 /// }
251 /// ```
252 #[derive(Clone, Debug)]
253 pub struct ListConnections(RequestBuilder<crate::model::ListConnectionsRequest>);
254
255 impl ListConnections {
256 pub(crate) fn new(
257 stub: std::sync::Arc<dyn super::super::stub::dynamic::ConnectionService>,
258 ) -> Self {
259 Self(RequestBuilder::new(stub))
260 }
261
262 /// Sets the full request, replacing any prior values.
263 pub fn with_request<V: Into<crate::model::ListConnectionsRequest>>(mut self, v: V) -> Self {
264 self.0.request = v.into();
265 self
266 }
267
268 /// Sets all the options, replacing any prior values.
269 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
270 self.0.options = v.into();
271 self
272 }
273
274 /// Sends the request.
275 pub async fn send(self) -> Result<crate::model::ListConnectionsResponse> {
276 (*self.0.stub)
277 .list_connections(self.0.request, self.0.options)
278 .await
279 .map(gax::response::Response::into_body)
280 }
281
282 /// Streams each page in the collection.
283 pub fn by_page(
284 self,
285 ) -> impl gax::paginator::Paginator<crate::model::ListConnectionsResponse, gax::error::Error>
286 {
287 use std::clone::Clone;
288 let token = self.0.request.page_token.clone();
289 let execute = move |token: String| {
290 let mut builder = self.clone();
291 builder.0.request = builder.0.request.set_page_token(token);
292 builder.send()
293 };
294 gax::paginator::internal::new_paginator(token, execute)
295 }
296
297 /// Streams each item in the collection.
298 pub fn by_item(
299 self,
300 ) -> impl gax::paginator::ItemPaginator<crate::model::ListConnectionsResponse, gax::error::Error>
301 {
302 use gax::paginator::Paginator;
303 self.by_page().items()
304 }
305
306 /// Sets the value of [parent][crate::model::ListConnectionsRequest::parent].
307 ///
308 /// This is a **required** field for requests.
309 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
310 self.0.request.parent = v.into();
311 self
312 }
313
314 /// Sets the value of [page_size][crate::model::ListConnectionsRequest::page_size].
315 ///
316 /// This is a **required** field for requests.
317 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
318 self.0.request.page_size = v.into();
319 self
320 }
321
322 /// Sets the value of [page_token][crate::model::ListConnectionsRequest::page_token].
323 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
324 self.0.request.page_token = v.into();
325 self
326 }
327 }
328
329 #[doc(hidden)]
330 impl gax::options::internal::RequestBuilder for ListConnections {
331 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
332 &mut self.0.options
333 }
334 }
335
336 /// The request builder for [ConnectionService::update_connection][crate::client::ConnectionService::update_connection] calls.
337 ///
338 /// # Example
339 /// ```no_run
340 /// # use google_cloud_bigquery_connection_v1::builder;
341 /// use builder::connection_service::UpdateConnection;
342 /// # tokio_test::block_on(async {
343 ///
344 /// let builder = prepare_request_builder();
345 /// let response = builder.send().await?;
346 /// # gax::Result::<()>::Ok(()) });
347 ///
348 /// fn prepare_request_builder() -> UpdateConnection {
349 /// # panic!();
350 /// // ... details omitted ...
351 /// }
352 /// ```
353 #[derive(Clone, Debug)]
354 pub struct UpdateConnection(RequestBuilder<crate::model::UpdateConnectionRequest>);
355
356 impl UpdateConnection {
357 pub(crate) fn new(
358 stub: std::sync::Arc<dyn super::super::stub::dynamic::ConnectionService>,
359 ) -> Self {
360 Self(RequestBuilder::new(stub))
361 }
362
363 /// Sets the full request, replacing any prior values.
364 pub fn with_request<V: Into<crate::model::UpdateConnectionRequest>>(
365 mut self,
366 v: V,
367 ) -> Self {
368 self.0.request = v.into();
369 self
370 }
371
372 /// Sets all the options, replacing any prior values.
373 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
374 self.0.options = v.into();
375 self
376 }
377
378 /// Sends the request.
379 pub async fn send(self) -> Result<crate::model::Connection> {
380 (*self.0.stub)
381 .update_connection(self.0.request, self.0.options)
382 .await
383 .map(gax::response::Response::into_body)
384 }
385
386 /// Sets the value of [name][crate::model::UpdateConnectionRequest::name].
387 ///
388 /// This is a **required** field for requests.
389 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
390 self.0.request.name = v.into();
391 self
392 }
393
394 /// Sets the value of [connection][crate::model::UpdateConnectionRequest::connection].
395 ///
396 /// This is a **required** field for requests.
397 pub fn set_connection<T>(mut self, v: T) -> Self
398 where
399 T: std::convert::Into<crate::model::Connection>,
400 {
401 self.0.request.connection = std::option::Option::Some(v.into());
402 self
403 }
404
405 /// Sets or clears the value of [connection][crate::model::UpdateConnectionRequest::connection].
406 ///
407 /// This is a **required** field for requests.
408 pub fn set_or_clear_connection<T>(mut self, v: std::option::Option<T>) -> Self
409 where
410 T: std::convert::Into<crate::model::Connection>,
411 {
412 self.0.request.connection = v.map(|x| x.into());
413 self
414 }
415
416 /// Sets the value of [update_mask][crate::model::UpdateConnectionRequest::update_mask].
417 ///
418 /// This is a **required** field for requests.
419 pub fn set_update_mask<T>(mut self, v: T) -> Self
420 where
421 T: std::convert::Into<wkt::FieldMask>,
422 {
423 self.0.request.update_mask = std::option::Option::Some(v.into());
424 self
425 }
426
427 /// Sets or clears the value of [update_mask][crate::model::UpdateConnectionRequest::update_mask].
428 ///
429 /// This is a **required** field for requests.
430 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
431 where
432 T: std::convert::Into<wkt::FieldMask>,
433 {
434 self.0.request.update_mask = v.map(|x| x.into());
435 self
436 }
437 }
438
439 #[doc(hidden)]
440 impl gax::options::internal::RequestBuilder for UpdateConnection {
441 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
442 &mut self.0.options
443 }
444 }
445
446 /// The request builder for [ConnectionService::delete_connection][crate::client::ConnectionService::delete_connection] calls.
447 ///
448 /// # Example
449 /// ```no_run
450 /// # use google_cloud_bigquery_connection_v1::builder;
451 /// use builder::connection_service::DeleteConnection;
452 /// # tokio_test::block_on(async {
453 ///
454 /// let builder = prepare_request_builder();
455 /// let response = builder.send().await?;
456 /// # gax::Result::<()>::Ok(()) });
457 ///
458 /// fn prepare_request_builder() -> DeleteConnection {
459 /// # panic!();
460 /// // ... details omitted ...
461 /// }
462 /// ```
463 #[derive(Clone, Debug)]
464 pub struct DeleteConnection(RequestBuilder<crate::model::DeleteConnectionRequest>);
465
466 impl DeleteConnection {
467 pub(crate) fn new(
468 stub: std::sync::Arc<dyn super::super::stub::dynamic::ConnectionService>,
469 ) -> Self {
470 Self(RequestBuilder::new(stub))
471 }
472
473 /// Sets the full request, replacing any prior values.
474 pub fn with_request<V: Into<crate::model::DeleteConnectionRequest>>(
475 mut self,
476 v: V,
477 ) -> Self {
478 self.0.request = v.into();
479 self
480 }
481
482 /// Sets all the options, replacing any prior values.
483 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
484 self.0.options = v.into();
485 self
486 }
487
488 /// Sends the request.
489 pub async fn send(self) -> Result<()> {
490 (*self.0.stub)
491 .delete_connection(self.0.request, self.0.options)
492 .await
493 .map(gax::response::Response::into_body)
494 }
495
496 /// Sets the value of [name][crate::model::DeleteConnectionRequest::name].
497 ///
498 /// This is a **required** field for requests.
499 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
500 self.0.request.name = v.into();
501 self
502 }
503 }
504
505 #[doc(hidden)]
506 impl gax::options::internal::RequestBuilder for DeleteConnection {
507 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
508 &mut self.0.options
509 }
510 }
511
512 /// The request builder for [ConnectionService::get_iam_policy][crate::client::ConnectionService::get_iam_policy] calls.
513 ///
514 /// # Example
515 /// ```no_run
516 /// # use google_cloud_bigquery_connection_v1::builder;
517 /// use builder::connection_service::GetIamPolicy;
518 /// # tokio_test::block_on(async {
519 ///
520 /// let builder = prepare_request_builder();
521 /// let response = builder.send().await?;
522 /// # gax::Result::<()>::Ok(()) });
523 ///
524 /// fn prepare_request_builder() -> GetIamPolicy {
525 /// # panic!();
526 /// // ... details omitted ...
527 /// }
528 /// ```
529 #[derive(Clone, Debug)]
530 pub struct GetIamPolicy(RequestBuilder<iam_v1::model::GetIamPolicyRequest>);
531
532 impl GetIamPolicy {
533 pub(crate) fn new(
534 stub: std::sync::Arc<dyn super::super::stub::dynamic::ConnectionService>,
535 ) -> Self {
536 Self(RequestBuilder::new(stub))
537 }
538
539 /// Sets the full request, replacing any prior values.
540 pub fn with_request<V: Into<iam_v1::model::GetIamPolicyRequest>>(mut self, v: V) -> Self {
541 self.0.request = v.into();
542 self
543 }
544
545 /// Sets all the options, replacing any prior values.
546 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
547 self.0.options = v.into();
548 self
549 }
550
551 /// Sends the request.
552 pub async fn send(self) -> Result<iam_v1::model::Policy> {
553 (*self.0.stub)
554 .get_iam_policy(self.0.request, self.0.options)
555 .await
556 .map(gax::response::Response::into_body)
557 }
558
559 /// Sets the value of [resource][iam_v1::model::GetIamPolicyRequest::resource].
560 ///
561 /// This is a **required** field for requests.
562 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
563 self.0.request.resource = v.into();
564 self
565 }
566
567 /// Sets the value of [options][iam_v1::model::GetIamPolicyRequest::options].
568 pub fn set_options<T>(mut self, v: T) -> Self
569 where
570 T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
571 {
572 self.0.request.options = std::option::Option::Some(v.into());
573 self
574 }
575
576 /// Sets or clears the value of [options][iam_v1::model::GetIamPolicyRequest::options].
577 pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
578 where
579 T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
580 {
581 self.0.request.options = v.map(|x| x.into());
582 self
583 }
584 }
585
586 #[doc(hidden)]
587 impl gax::options::internal::RequestBuilder for GetIamPolicy {
588 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
589 &mut self.0.options
590 }
591 }
592
593 /// The request builder for [ConnectionService::set_iam_policy][crate::client::ConnectionService::set_iam_policy] calls.
594 ///
595 /// # Example
596 /// ```no_run
597 /// # use google_cloud_bigquery_connection_v1::builder;
598 /// use builder::connection_service::SetIamPolicy;
599 /// # tokio_test::block_on(async {
600 ///
601 /// let builder = prepare_request_builder();
602 /// let response = builder.send().await?;
603 /// # gax::Result::<()>::Ok(()) });
604 ///
605 /// fn prepare_request_builder() -> SetIamPolicy {
606 /// # panic!();
607 /// // ... details omitted ...
608 /// }
609 /// ```
610 #[derive(Clone, Debug)]
611 pub struct SetIamPolicy(RequestBuilder<iam_v1::model::SetIamPolicyRequest>);
612
613 impl SetIamPolicy {
614 pub(crate) fn new(
615 stub: std::sync::Arc<dyn super::super::stub::dynamic::ConnectionService>,
616 ) -> Self {
617 Self(RequestBuilder::new(stub))
618 }
619
620 /// Sets the full request, replacing any prior values.
621 pub fn with_request<V: Into<iam_v1::model::SetIamPolicyRequest>>(mut self, v: V) -> Self {
622 self.0.request = v.into();
623 self
624 }
625
626 /// Sets all the options, replacing any prior values.
627 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
628 self.0.options = v.into();
629 self
630 }
631
632 /// Sends the request.
633 pub async fn send(self) -> Result<iam_v1::model::Policy> {
634 (*self.0.stub)
635 .set_iam_policy(self.0.request, self.0.options)
636 .await
637 .map(gax::response::Response::into_body)
638 }
639
640 /// Sets the value of [resource][iam_v1::model::SetIamPolicyRequest::resource].
641 ///
642 /// This is a **required** field for requests.
643 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
644 self.0.request.resource = v.into();
645 self
646 }
647
648 /// Sets the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
649 ///
650 /// This is a **required** field for requests.
651 pub fn set_policy<T>(mut self, v: T) -> Self
652 where
653 T: std::convert::Into<iam_v1::model::Policy>,
654 {
655 self.0.request.policy = std::option::Option::Some(v.into());
656 self
657 }
658
659 /// Sets or clears the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
660 ///
661 /// This is a **required** field for requests.
662 pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
663 where
664 T: std::convert::Into<iam_v1::model::Policy>,
665 {
666 self.0.request.policy = v.map(|x| x.into());
667 self
668 }
669
670 /// Sets the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
671 pub fn set_update_mask<T>(mut self, v: T) -> Self
672 where
673 T: std::convert::Into<wkt::FieldMask>,
674 {
675 self.0.request.update_mask = std::option::Option::Some(v.into());
676 self
677 }
678
679 /// Sets or clears the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
680 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
681 where
682 T: std::convert::Into<wkt::FieldMask>,
683 {
684 self.0.request.update_mask = v.map(|x| x.into());
685 self
686 }
687 }
688
689 #[doc(hidden)]
690 impl gax::options::internal::RequestBuilder for SetIamPolicy {
691 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
692 &mut self.0.options
693 }
694 }
695
696 /// The request builder for [ConnectionService::test_iam_permissions][crate::client::ConnectionService::test_iam_permissions] calls.
697 ///
698 /// # Example
699 /// ```no_run
700 /// # use google_cloud_bigquery_connection_v1::builder;
701 /// use builder::connection_service::TestIamPermissions;
702 /// # tokio_test::block_on(async {
703 ///
704 /// let builder = prepare_request_builder();
705 /// let response = builder.send().await?;
706 /// # gax::Result::<()>::Ok(()) });
707 ///
708 /// fn prepare_request_builder() -> TestIamPermissions {
709 /// # panic!();
710 /// // ... details omitted ...
711 /// }
712 /// ```
713 #[derive(Clone, Debug)]
714 pub struct TestIamPermissions(RequestBuilder<iam_v1::model::TestIamPermissionsRequest>);
715
716 impl TestIamPermissions {
717 pub(crate) fn new(
718 stub: std::sync::Arc<dyn super::super::stub::dynamic::ConnectionService>,
719 ) -> Self {
720 Self(RequestBuilder::new(stub))
721 }
722
723 /// Sets the full request, replacing any prior values.
724 pub fn with_request<V: Into<iam_v1::model::TestIamPermissionsRequest>>(
725 mut self,
726 v: V,
727 ) -> Self {
728 self.0.request = v.into();
729 self
730 }
731
732 /// Sets all the options, replacing any prior values.
733 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
734 self.0.options = v.into();
735 self
736 }
737
738 /// Sends the request.
739 pub async fn send(self) -> Result<iam_v1::model::TestIamPermissionsResponse> {
740 (*self.0.stub)
741 .test_iam_permissions(self.0.request, self.0.options)
742 .await
743 .map(gax::response::Response::into_body)
744 }
745
746 /// Sets the value of [resource][iam_v1::model::TestIamPermissionsRequest::resource].
747 ///
748 /// This is a **required** field for requests.
749 pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
750 self.0.request.resource = v.into();
751 self
752 }
753
754 /// Sets the value of [permissions][iam_v1::model::TestIamPermissionsRequest::permissions].
755 ///
756 /// This is a **required** field for requests.
757 pub fn set_permissions<T, V>(mut self, v: T) -> Self
758 where
759 T: std::iter::IntoIterator<Item = V>,
760 V: std::convert::Into<std::string::String>,
761 {
762 use std::iter::Iterator;
763 self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
764 self
765 }
766 }
767
768 #[doc(hidden)]
769 impl gax::options::internal::RequestBuilder for TestIamPermissions {
770 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
771 &mut self.0.options
772 }
773 }
774}