google_cloud_privilegedaccessmanager_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
17/// Request and client builders for [PrivilegedAccessManager][crate::client::PrivilegedAccessManager].
18pub mod privileged_access_manager {
19 use crate::Result;
20
21 /// A builder for [PrivilegedAccessManager][crate::client::PrivilegedAccessManager].
22 ///
23 /// ```
24 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25 /// # use google_cloud_privilegedaccessmanager_v1::*;
26 /// # use builder::privileged_access_manager::ClientBuilder;
27 /// # use client::PrivilegedAccessManager;
28 /// let builder : ClientBuilder = PrivilegedAccessManager::builder();
29 /// let client = builder
30 /// .with_endpoint("https://privilegedaccessmanager.googleapis.com")
31 /// .build().await?;
32 /// # Ok(()) }
33 /// ```
34 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::PrivilegedAccessManager;
38 pub struct Factory;
39 impl crate::ClientFactory for Factory {
40 type Client = PrivilegedAccessManager;
41 type Credentials = gaxi::options::Credentials;
42 async fn build(
43 self,
44 config: gaxi::options::ClientConfig,
45 ) -> crate::ClientBuilderResult<Self::Client> {
46 Self::Client::new(config).await
47 }
48 }
49 }
50
51 /// Common implementation for [crate::client::PrivilegedAccessManager] 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::PrivilegedAccessManager>,
55 request: R,
56 options: crate::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::PrivilegedAccessManager>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: crate::RequestOptions::default(),
70 }
71 }
72 }
73
74 /// The request builder for [PrivilegedAccessManager::check_onboarding_status][crate::client::PrivilegedAccessManager::check_onboarding_status] calls.
75 ///
76 /// # Example
77 /// ```
78 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::CheckOnboardingStatus;
79 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
80 ///
81 /// let builder = prepare_request_builder();
82 /// let response = builder.send().await?;
83 /// # Ok(()) }
84 ///
85 /// fn prepare_request_builder() -> CheckOnboardingStatus {
86 /// # panic!();
87 /// // ... details omitted ...
88 /// }
89 /// ```
90 #[derive(Clone, Debug)]
91 pub struct CheckOnboardingStatus(RequestBuilder<crate::model::CheckOnboardingStatusRequest>);
92
93 impl CheckOnboardingStatus {
94 pub(crate) fn new(
95 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
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<crate::model::CheckOnboardingStatusRequest>>(
102 mut self,
103 v: V,
104 ) -> Self {
105 self.0.request = v.into();
106 self
107 }
108
109 /// Sets all the options, replacing any prior values.
110 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
111 self.0.options = v.into();
112 self
113 }
114
115 /// Sends the request.
116 pub async fn send(self) -> Result<crate::model::CheckOnboardingStatusResponse> {
117 (*self.0.stub)
118 .check_onboarding_status(self.0.request, self.0.options)
119 .await
120 .map(crate::Response::into_body)
121 }
122
123 /// Sets the value of [parent][crate::model::CheckOnboardingStatusRequest::parent].
124 ///
125 /// This is a **required** field for requests.
126 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
127 self.0.request.parent = v.into();
128 self
129 }
130 }
131
132 #[doc(hidden)]
133 impl crate::RequestBuilder for CheckOnboardingStatus {
134 fn request_options(&mut self) -> &mut crate::RequestOptions {
135 &mut self.0.options
136 }
137 }
138
139 /// The request builder for [PrivilegedAccessManager::list_entitlements][crate::client::PrivilegedAccessManager::list_entitlements] calls.
140 ///
141 /// # Example
142 /// ```
143 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::ListEntitlements;
144 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
145 /// use google_cloud_gax::paginator::ItemPaginator;
146 ///
147 /// let builder = prepare_request_builder();
148 /// let mut items = builder.by_item();
149 /// while let Some(result) = items.next().await {
150 /// let item = result?;
151 /// }
152 /// # Ok(()) }
153 ///
154 /// fn prepare_request_builder() -> ListEntitlements {
155 /// # panic!();
156 /// // ... details omitted ...
157 /// }
158 /// ```
159 #[derive(Clone, Debug)]
160 pub struct ListEntitlements(RequestBuilder<crate::model::ListEntitlementsRequest>);
161
162 impl ListEntitlements {
163 pub(crate) fn new(
164 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
165 ) -> Self {
166 Self(RequestBuilder::new(stub))
167 }
168
169 /// Sets the full request, replacing any prior values.
170 pub fn with_request<V: Into<crate::model::ListEntitlementsRequest>>(
171 mut self,
172 v: V,
173 ) -> Self {
174 self.0.request = v.into();
175 self
176 }
177
178 /// Sets all the options, replacing any prior values.
179 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
180 self.0.options = v.into();
181 self
182 }
183
184 /// Sends the request.
185 pub async fn send(self) -> Result<crate::model::ListEntitlementsResponse> {
186 (*self.0.stub)
187 .list_entitlements(self.0.request, self.0.options)
188 .await
189 .map(crate::Response::into_body)
190 }
191
192 /// Streams each page in the collection.
193 pub fn by_page(
194 self,
195 ) -> impl google_cloud_gax::paginator::Paginator<
196 crate::model::ListEntitlementsResponse,
197 crate::Error,
198 > {
199 use std::clone::Clone;
200 let token = self.0.request.page_token.clone();
201 let execute = move |token: String| {
202 let mut builder = self.clone();
203 builder.0.request = builder.0.request.set_page_token(token);
204 builder.send()
205 };
206 google_cloud_gax::paginator::internal::new_paginator(token, execute)
207 }
208
209 /// Streams each item in the collection.
210 pub fn by_item(
211 self,
212 ) -> impl google_cloud_gax::paginator::ItemPaginator<
213 crate::model::ListEntitlementsResponse,
214 crate::Error,
215 > {
216 use google_cloud_gax::paginator::Paginator;
217 self.by_page().items()
218 }
219
220 /// Sets the value of [parent][crate::model::ListEntitlementsRequest::parent].
221 ///
222 /// This is a **required** field for requests.
223 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
224 self.0.request.parent = v.into();
225 self
226 }
227
228 /// Sets the value of [page_size][crate::model::ListEntitlementsRequest::page_size].
229 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
230 self.0.request.page_size = v.into();
231 self
232 }
233
234 /// Sets the value of [page_token][crate::model::ListEntitlementsRequest::page_token].
235 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
236 self.0.request.page_token = v.into();
237 self
238 }
239
240 /// Sets the value of [filter][crate::model::ListEntitlementsRequest::filter].
241 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
242 self.0.request.filter = v.into();
243 self
244 }
245
246 /// Sets the value of [order_by][crate::model::ListEntitlementsRequest::order_by].
247 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
248 self.0.request.order_by = v.into();
249 self
250 }
251 }
252
253 #[doc(hidden)]
254 impl crate::RequestBuilder for ListEntitlements {
255 fn request_options(&mut self) -> &mut crate::RequestOptions {
256 &mut self.0.options
257 }
258 }
259
260 /// The request builder for [PrivilegedAccessManager::search_entitlements][crate::client::PrivilegedAccessManager::search_entitlements] calls.
261 ///
262 /// # Example
263 /// ```
264 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::SearchEntitlements;
265 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
266 /// use google_cloud_gax::paginator::ItemPaginator;
267 ///
268 /// let builder = prepare_request_builder();
269 /// let mut items = builder.by_item();
270 /// while let Some(result) = items.next().await {
271 /// let item = result?;
272 /// }
273 /// # Ok(()) }
274 ///
275 /// fn prepare_request_builder() -> SearchEntitlements {
276 /// # panic!();
277 /// // ... details omitted ...
278 /// }
279 /// ```
280 #[derive(Clone, Debug)]
281 pub struct SearchEntitlements(RequestBuilder<crate::model::SearchEntitlementsRequest>);
282
283 impl SearchEntitlements {
284 pub(crate) fn new(
285 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
286 ) -> Self {
287 Self(RequestBuilder::new(stub))
288 }
289
290 /// Sets the full request, replacing any prior values.
291 pub fn with_request<V: Into<crate::model::SearchEntitlementsRequest>>(
292 mut self,
293 v: V,
294 ) -> Self {
295 self.0.request = v.into();
296 self
297 }
298
299 /// Sets all the options, replacing any prior values.
300 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
301 self.0.options = v.into();
302 self
303 }
304
305 /// Sends the request.
306 pub async fn send(self) -> Result<crate::model::SearchEntitlementsResponse> {
307 (*self.0.stub)
308 .search_entitlements(self.0.request, self.0.options)
309 .await
310 .map(crate::Response::into_body)
311 }
312
313 /// Streams each page in the collection.
314 pub fn by_page(
315 self,
316 ) -> impl google_cloud_gax::paginator::Paginator<
317 crate::model::SearchEntitlementsResponse,
318 crate::Error,
319 > {
320 use std::clone::Clone;
321 let token = self.0.request.page_token.clone();
322 let execute = move |token: String| {
323 let mut builder = self.clone();
324 builder.0.request = builder.0.request.set_page_token(token);
325 builder.send()
326 };
327 google_cloud_gax::paginator::internal::new_paginator(token, execute)
328 }
329
330 /// Streams each item in the collection.
331 pub fn by_item(
332 self,
333 ) -> impl google_cloud_gax::paginator::ItemPaginator<
334 crate::model::SearchEntitlementsResponse,
335 crate::Error,
336 > {
337 use google_cloud_gax::paginator::Paginator;
338 self.by_page().items()
339 }
340
341 /// Sets the value of [parent][crate::model::SearchEntitlementsRequest::parent].
342 ///
343 /// This is a **required** field for requests.
344 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
345 self.0.request.parent = v.into();
346 self
347 }
348
349 /// Sets the value of [caller_access_type][crate::model::SearchEntitlementsRequest::caller_access_type].
350 ///
351 /// This is a **required** field for requests.
352 pub fn set_caller_access_type<
353 T: Into<crate::model::search_entitlements_request::CallerAccessType>,
354 >(
355 mut self,
356 v: T,
357 ) -> Self {
358 self.0.request.caller_access_type = v.into();
359 self
360 }
361
362 /// Sets the value of [filter][crate::model::SearchEntitlementsRequest::filter].
363 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
364 self.0.request.filter = v.into();
365 self
366 }
367
368 /// Sets the value of [page_size][crate::model::SearchEntitlementsRequest::page_size].
369 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
370 self.0.request.page_size = v.into();
371 self
372 }
373
374 /// Sets the value of [page_token][crate::model::SearchEntitlementsRequest::page_token].
375 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
376 self.0.request.page_token = v.into();
377 self
378 }
379 }
380
381 #[doc(hidden)]
382 impl crate::RequestBuilder for SearchEntitlements {
383 fn request_options(&mut self) -> &mut crate::RequestOptions {
384 &mut self.0.options
385 }
386 }
387
388 /// The request builder for [PrivilegedAccessManager::get_entitlement][crate::client::PrivilegedAccessManager::get_entitlement] calls.
389 ///
390 /// # Example
391 /// ```
392 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::GetEntitlement;
393 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
394 ///
395 /// let builder = prepare_request_builder();
396 /// let response = builder.send().await?;
397 /// # Ok(()) }
398 ///
399 /// fn prepare_request_builder() -> GetEntitlement {
400 /// # panic!();
401 /// // ... details omitted ...
402 /// }
403 /// ```
404 #[derive(Clone, Debug)]
405 pub struct GetEntitlement(RequestBuilder<crate::model::GetEntitlementRequest>);
406
407 impl GetEntitlement {
408 pub(crate) fn new(
409 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
410 ) -> Self {
411 Self(RequestBuilder::new(stub))
412 }
413
414 /// Sets the full request, replacing any prior values.
415 pub fn with_request<V: Into<crate::model::GetEntitlementRequest>>(mut self, v: V) -> Self {
416 self.0.request = v.into();
417 self
418 }
419
420 /// Sets all the options, replacing any prior values.
421 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
422 self.0.options = v.into();
423 self
424 }
425
426 /// Sends the request.
427 pub async fn send(self) -> Result<crate::model::Entitlement> {
428 (*self.0.stub)
429 .get_entitlement(self.0.request, self.0.options)
430 .await
431 .map(crate::Response::into_body)
432 }
433
434 /// Sets the value of [name][crate::model::GetEntitlementRequest::name].
435 ///
436 /// This is a **required** field for requests.
437 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
438 self.0.request.name = v.into();
439 self
440 }
441 }
442
443 #[doc(hidden)]
444 impl crate::RequestBuilder for GetEntitlement {
445 fn request_options(&mut self) -> &mut crate::RequestOptions {
446 &mut self.0.options
447 }
448 }
449
450 /// The request builder for [PrivilegedAccessManager::create_entitlement][crate::client::PrivilegedAccessManager::create_entitlement] calls.
451 ///
452 /// # Example
453 /// ```
454 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::CreateEntitlement;
455 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
456 /// use google_cloud_lro::Poller;
457 ///
458 /// let builder = prepare_request_builder();
459 /// let response = builder.poller().until_done().await?;
460 /// # Ok(()) }
461 ///
462 /// fn prepare_request_builder() -> CreateEntitlement {
463 /// # panic!();
464 /// // ... details omitted ...
465 /// }
466 /// ```
467 #[derive(Clone, Debug)]
468 pub struct CreateEntitlement(RequestBuilder<crate::model::CreateEntitlementRequest>);
469
470 impl CreateEntitlement {
471 pub(crate) fn new(
472 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
473 ) -> Self {
474 Self(RequestBuilder::new(stub))
475 }
476
477 /// Sets the full request, replacing any prior values.
478 pub fn with_request<V: Into<crate::model::CreateEntitlementRequest>>(
479 mut self,
480 v: V,
481 ) -> Self {
482 self.0.request = v.into();
483 self
484 }
485
486 /// Sets all the options, replacing any prior values.
487 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
488 self.0.options = v.into();
489 self
490 }
491
492 /// Sends the request.
493 ///
494 /// # Long running operations
495 ///
496 /// This starts, but does not poll, a longrunning operation. More information
497 /// on [create_entitlement][crate::client::PrivilegedAccessManager::create_entitlement].
498 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
499 (*self.0.stub)
500 .create_entitlement(self.0.request, self.0.options)
501 .await
502 .map(crate::Response::into_body)
503 }
504
505 /// Creates a [Poller][google_cloud_lro::Poller] to work with `create_entitlement`.
506 pub fn poller(
507 self,
508 ) -> impl google_cloud_lro::Poller<crate::model::Entitlement, crate::model::OperationMetadata>
509 {
510 type Operation = google_cloud_lro::internal::Operation<
511 crate::model::Entitlement,
512 crate::model::OperationMetadata,
513 >;
514 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
515 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
516
517 let stub = self.0.stub.clone();
518 let mut options = self.0.options.clone();
519 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
520 let query = move |name| {
521 let stub = stub.clone();
522 let options = options.clone();
523 async {
524 let op = GetOperation::new(stub)
525 .set_name(name)
526 .with_options(options)
527 .send()
528 .await?;
529 Ok(Operation::new(op))
530 }
531 };
532
533 let start = move || async {
534 let op = self.send().await?;
535 Ok(Operation::new(op))
536 };
537
538 google_cloud_lro::internal::new_poller(
539 polling_error_policy,
540 polling_backoff_policy,
541 start,
542 query,
543 )
544 }
545
546 /// Sets the value of [parent][crate::model::CreateEntitlementRequest::parent].
547 ///
548 /// This is a **required** field for requests.
549 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
550 self.0.request.parent = v.into();
551 self
552 }
553
554 /// Sets the value of [entitlement_id][crate::model::CreateEntitlementRequest::entitlement_id].
555 ///
556 /// This is a **required** field for requests.
557 pub fn set_entitlement_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
558 self.0.request.entitlement_id = v.into();
559 self
560 }
561
562 /// Sets the value of [entitlement][crate::model::CreateEntitlementRequest::entitlement].
563 ///
564 /// This is a **required** field for requests.
565 pub fn set_entitlement<T>(mut self, v: T) -> Self
566 where
567 T: std::convert::Into<crate::model::Entitlement>,
568 {
569 self.0.request.entitlement = std::option::Option::Some(v.into());
570 self
571 }
572
573 /// Sets or clears the value of [entitlement][crate::model::CreateEntitlementRequest::entitlement].
574 ///
575 /// This is a **required** field for requests.
576 pub fn set_or_clear_entitlement<T>(mut self, v: std::option::Option<T>) -> Self
577 where
578 T: std::convert::Into<crate::model::Entitlement>,
579 {
580 self.0.request.entitlement = v.map(|x| x.into());
581 self
582 }
583
584 /// Sets the value of [request_id][crate::model::CreateEntitlementRequest::request_id].
585 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
586 self.0.request.request_id = v.into();
587 self
588 }
589 }
590
591 #[doc(hidden)]
592 impl crate::RequestBuilder for CreateEntitlement {
593 fn request_options(&mut self) -> &mut crate::RequestOptions {
594 &mut self.0.options
595 }
596 }
597
598 /// The request builder for [PrivilegedAccessManager::delete_entitlement][crate::client::PrivilegedAccessManager::delete_entitlement] calls.
599 ///
600 /// # Example
601 /// ```
602 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::DeleteEntitlement;
603 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
604 /// use google_cloud_lro::Poller;
605 ///
606 /// let builder = prepare_request_builder();
607 /// let response = builder.poller().until_done().await?;
608 /// # Ok(()) }
609 ///
610 /// fn prepare_request_builder() -> DeleteEntitlement {
611 /// # panic!();
612 /// // ... details omitted ...
613 /// }
614 /// ```
615 #[derive(Clone, Debug)]
616 pub struct DeleteEntitlement(RequestBuilder<crate::model::DeleteEntitlementRequest>);
617
618 impl DeleteEntitlement {
619 pub(crate) fn new(
620 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
621 ) -> Self {
622 Self(RequestBuilder::new(stub))
623 }
624
625 /// Sets the full request, replacing any prior values.
626 pub fn with_request<V: Into<crate::model::DeleteEntitlementRequest>>(
627 mut self,
628 v: V,
629 ) -> Self {
630 self.0.request = v.into();
631 self
632 }
633
634 /// Sets all the options, replacing any prior values.
635 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
636 self.0.options = v.into();
637 self
638 }
639
640 /// Sends the request.
641 ///
642 /// # Long running operations
643 ///
644 /// This starts, but does not poll, a longrunning operation. More information
645 /// on [delete_entitlement][crate::client::PrivilegedAccessManager::delete_entitlement].
646 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
647 (*self.0.stub)
648 .delete_entitlement(self.0.request, self.0.options)
649 .await
650 .map(crate::Response::into_body)
651 }
652
653 /// Creates a [Poller][google_cloud_lro::Poller] to work with `delete_entitlement`.
654 pub fn poller(
655 self,
656 ) -> impl google_cloud_lro::Poller<crate::model::Entitlement, crate::model::OperationMetadata>
657 {
658 type Operation = google_cloud_lro::internal::Operation<
659 crate::model::Entitlement,
660 crate::model::OperationMetadata,
661 >;
662 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
663 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
664
665 let stub = self.0.stub.clone();
666 let mut options = self.0.options.clone();
667 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
668 let query = move |name| {
669 let stub = stub.clone();
670 let options = options.clone();
671 async {
672 let op = GetOperation::new(stub)
673 .set_name(name)
674 .with_options(options)
675 .send()
676 .await?;
677 Ok(Operation::new(op))
678 }
679 };
680
681 let start = move || async {
682 let op = self.send().await?;
683 Ok(Operation::new(op))
684 };
685
686 google_cloud_lro::internal::new_poller(
687 polling_error_policy,
688 polling_backoff_policy,
689 start,
690 query,
691 )
692 }
693
694 /// Sets the value of [name][crate::model::DeleteEntitlementRequest::name].
695 ///
696 /// This is a **required** field for requests.
697 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
698 self.0.request.name = v.into();
699 self
700 }
701
702 /// Sets the value of [request_id][crate::model::DeleteEntitlementRequest::request_id].
703 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
704 self.0.request.request_id = v.into();
705 self
706 }
707
708 /// Sets the value of [force][crate::model::DeleteEntitlementRequest::force].
709 pub fn set_force<T: Into<bool>>(mut self, v: T) -> Self {
710 self.0.request.force = v.into();
711 self
712 }
713 }
714
715 #[doc(hidden)]
716 impl crate::RequestBuilder for DeleteEntitlement {
717 fn request_options(&mut self) -> &mut crate::RequestOptions {
718 &mut self.0.options
719 }
720 }
721
722 /// The request builder for [PrivilegedAccessManager::update_entitlement][crate::client::PrivilegedAccessManager::update_entitlement] calls.
723 ///
724 /// # Example
725 /// ```
726 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::UpdateEntitlement;
727 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
728 /// use google_cloud_lro::Poller;
729 ///
730 /// let builder = prepare_request_builder();
731 /// let response = builder.poller().until_done().await?;
732 /// # Ok(()) }
733 ///
734 /// fn prepare_request_builder() -> UpdateEntitlement {
735 /// # panic!();
736 /// // ... details omitted ...
737 /// }
738 /// ```
739 #[derive(Clone, Debug)]
740 pub struct UpdateEntitlement(RequestBuilder<crate::model::UpdateEntitlementRequest>);
741
742 impl UpdateEntitlement {
743 pub(crate) fn new(
744 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
745 ) -> Self {
746 Self(RequestBuilder::new(stub))
747 }
748
749 /// Sets the full request, replacing any prior values.
750 pub fn with_request<V: Into<crate::model::UpdateEntitlementRequest>>(
751 mut self,
752 v: V,
753 ) -> Self {
754 self.0.request = v.into();
755 self
756 }
757
758 /// Sets all the options, replacing any prior values.
759 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
760 self.0.options = v.into();
761 self
762 }
763
764 /// Sends the request.
765 ///
766 /// # Long running operations
767 ///
768 /// This starts, but does not poll, a longrunning operation. More information
769 /// on [update_entitlement][crate::client::PrivilegedAccessManager::update_entitlement].
770 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
771 (*self.0.stub)
772 .update_entitlement(self.0.request, self.0.options)
773 .await
774 .map(crate::Response::into_body)
775 }
776
777 /// Creates a [Poller][google_cloud_lro::Poller] to work with `update_entitlement`.
778 pub fn poller(
779 self,
780 ) -> impl google_cloud_lro::Poller<crate::model::Entitlement, crate::model::OperationMetadata>
781 {
782 type Operation = google_cloud_lro::internal::Operation<
783 crate::model::Entitlement,
784 crate::model::OperationMetadata,
785 >;
786 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
787 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
788
789 let stub = self.0.stub.clone();
790 let mut options = self.0.options.clone();
791 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
792 let query = move |name| {
793 let stub = stub.clone();
794 let options = options.clone();
795 async {
796 let op = GetOperation::new(stub)
797 .set_name(name)
798 .with_options(options)
799 .send()
800 .await?;
801 Ok(Operation::new(op))
802 }
803 };
804
805 let start = move || async {
806 let op = self.send().await?;
807 Ok(Operation::new(op))
808 };
809
810 google_cloud_lro::internal::new_poller(
811 polling_error_policy,
812 polling_backoff_policy,
813 start,
814 query,
815 )
816 }
817
818 /// Sets the value of [entitlement][crate::model::UpdateEntitlementRequest::entitlement].
819 ///
820 /// This is a **required** field for requests.
821 pub fn set_entitlement<T>(mut self, v: T) -> Self
822 where
823 T: std::convert::Into<crate::model::Entitlement>,
824 {
825 self.0.request.entitlement = std::option::Option::Some(v.into());
826 self
827 }
828
829 /// Sets or clears the value of [entitlement][crate::model::UpdateEntitlementRequest::entitlement].
830 ///
831 /// This is a **required** field for requests.
832 pub fn set_or_clear_entitlement<T>(mut self, v: std::option::Option<T>) -> Self
833 where
834 T: std::convert::Into<crate::model::Entitlement>,
835 {
836 self.0.request.entitlement = v.map(|x| x.into());
837 self
838 }
839
840 /// Sets the value of [update_mask][crate::model::UpdateEntitlementRequest::update_mask].
841 ///
842 /// This is a **required** field for requests.
843 pub fn set_update_mask<T>(mut self, v: T) -> Self
844 where
845 T: std::convert::Into<wkt::FieldMask>,
846 {
847 self.0.request.update_mask = std::option::Option::Some(v.into());
848 self
849 }
850
851 /// Sets or clears the value of [update_mask][crate::model::UpdateEntitlementRequest::update_mask].
852 ///
853 /// This is a **required** field for requests.
854 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
855 where
856 T: std::convert::Into<wkt::FieldMask>,
857 {
858 self.0.request.update_mask = v.map(|x| x.into());
859 self
860 }
861 }
862
863 #[doc(hidden)]
864 impl crate::RequestBuilder for UpdateEntitlement {
865 fn request_options(&mut self) -> &mut crate::RequestOptions {
866 &mut self.0.options
867 }
868 }
869
870 /// The request builder for [PrivilegedAccessManager::list_grants][crate::client::PrivilegedAccessManager::list_grants] calls.
871 ///
872 /// # Example
873 /// ```
874 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::ListGrants;
875 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
876 /// use google_cloud_gax::paginator::ItemPaginator;
877 ///
878 /// let builder = prepare_request_builder();
879 /// let mut items = builder.by_item();
880 /// while let Some(result) = items.next().await {
881 /// let item = result?;
882 /// }
883 /// # Ok(()) }
884 ///
885 /// fn prepare_request_builder() -> ListGrants {
886 /// # panic!();
887 /// // ... details omitted ...
888 /// }
889 /// ```
890 #[derive(Clone, Debug)]
891 pub struct ListGrants(RequestBuilder<crate::model::ListGrantsRequest>);
892
893 impl ListGrants {
894 pub(crate) fn new(
895 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
896 ) -> Self {
897 Self(RequestBuilder::new(stub))
898 }
899
900 /// Sets the full request, replacing any prior values.
901 pub fn with_request<V: Into<crate::model::ListGrantsRequest>>(mut self, v: V) -> Self {
902 self.0.request = v.into();
903 self
904 }
905
906 /// Sets all the options, replacing any prior values.
907 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
908 self.0.options = v.into();
909 self
910 }
911
912 /// Sends the request.
913 pub async fn send(self) -> Result<crate::model::ListGrantsResponse> {
914 (*self.0.stub)
915 .list_grants(self.0.request, self.0.options)
916 .await
917 .map(crate::Response::into_body)
918 }
919
920 /// Streams each page in the collection.
921 pub fn by_page(
922 self,
923 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListGrantsResponse, crate::Error>
924 {
925 use std::clone::Clone;
926 let token = self.0.request.page_token.clone();
927 let execute = move |token: String| {
928 let mut builder = self.clone();
929 builder.0.request = builder.0.request.set_page_token(token);
930 builder.send()
931 };
932 google_cloud_gax::paginator::internal::new_paginator(token, execute)
933 }
934
935 /// Streams each item in the collection.
936 pub fn by_item(
937 self,
938 ) -> impl google_cloud_gax::paginator::ItemPaginator<
939 crate::model::ListGrantsResponse,
940 crate::Error,
941 > {
942 use google_cloud_gax::paginator::Paginator;
943 self.by_page().items()
944 }
945
946 /// Sets the value of [parent][crate::model::ListGrantsRequest::parent].
947 ///
948 /// This is a **required** field for requests.
949 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
950 self.0.request.parent = v.into();
951 self
952 }
953
954 /// Sets the value of [page_size][crate::model::ListGrantsRequest::page_size].
955 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
956 self.0.request.page_size = v.into();
957 self
958 }
959
960 /// Sets the value of [page_token][crate::model::ListGrantsRequest::page_token].
961 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
962 self.0.request.page_token = v.into();
963 self
964 }
965
966 /// Sets the value of [filter][crate::model::ListGrantsRequest::filter].
967 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
968 self.0.request.filter = v.into();
969 self
970 }
971
972 /// Sets the value of [order_by][crate::model::ListGrantsRequest::order_by].
973 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
974 self.0.request.order_by = v.into();
975 self
976 }
977 }
978
979 #[doc(hidden)]
980 impl crate::RequestBuilder for ListGrants {
981 fn request_options(&mut self) -> &mut crate::RequestOptions {
982 &mut self.0.options
983 }
984 }
985
986 /// The request builder for [PrivilegedAccessManager::search_grants][crate::client::PrivilegedAccessManager::search_grants] calls.
987 ///
988 /// # Example
989 /// ```
990 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::SearchGrants;
991 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
992 /// use google_cloud_gax::paginator::ItemPaginator;
993 ///
994 /// let builder = prepare_request_builder();
995 /// let mut items = builder.by_item();
996 /// while let Some(result) = items.next().await {
997 /// let item = result?;
998 /// }
999 /// # Ok(()) }
1000 ///
1001 /// fn prepare_request_builder() -> SearchGrants {
1002 /// # panic!();
1003 /// // ... details omitted ...
1004 /// }
1005 /// ```
1006 #[derive(Clone, Debug)]
1007 pub struct SearchGrants(RequestBuilder<crate::model::SearchGrantsRequest>);
1008
1009 impl SearchGrants {
1010 pub(crate) fn new(
1011 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1012 ) -> Self {
1013 Self(RequestBuilder::new(stub))
1014 }
1015
1016 /// Sets the full request, replacing any prior values.
1017 pub fn with_request<V: Into<crate::model::SearchGrantsRequest>>(mut self, v: V) -> Self {
1018 self.0.request = v.into();
1019 self
1020 }
1021
1022 /// Sets all the options, replacing any prior values.
1023 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1024 self.0.options = v.into();
1025 self
1026 }
1027
1028 /// Sends the request.
1029 pub async fn send(self) -> Result<crate::model::SearchGrantsResponse> {
1030 (*self.0.stub)
1031 .search_grants(self.0.request, self.0.options)
1032 .await
1033 .map(crate::Response::into_body)
1034 }
1035
1036 /// Streams each page in the collection.
1037 pub fn by_page(
1038 self,
1039 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::SearchGrantsResponse, crate::Error>
1040 {
1041 use std::clone::Clone;
1042 let token = self.0.request.page_token.clone();
1043 let execute = move |token: String| {
1044 let mut builder = self.clone();
1045 builder.0.request = builder.0.request.set_page_token(token);
1046 builder.send()
1047 };
1048 google_cloud_gax::paginator::internal::new_paginator(token, execute)
1049 }
1050
1051 /// Streams each item in the collection.
1052 pub fn by_item(
1053 self,
1054 ) -> impl google_cloud_gax::paginator::ItemPaginator<
1055 crate::model::SearchGrantsResponse,
1056 crate::Error,
1057 > {
1058 use google_cloud_gax::paginator::Paginator;
1059 self.by_page().items()
1060 }
1061
1062 /// Sets the value of [parent][crate::model::SearchGrantsRequest::parent].
1063 ///
1064 /// This is a **required** field for requests.
1065 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1066 self.0.request.parent = v.into();
1067 self
1068 }
1069
1070 /// Sets the value of [caller_relationship][crate::model::SearchGrantsRequest::caller_relationship].
1071 ///
1072 /// This is a **required** field for requests.
1073 pub fn set_caller_relationship<
1074 T: Into<crate::model::search_grants_request::CallerRelationshipType>,
1075 >(
1076 mut self,
1077 v: T,
1078 ) -> Self {
1079 self.0.request.caller_relationship = v.into();
1080 self
1081 }
1082
1083 /// Sets the value of [filter][crate::model::SearchGrantsRequest::filter].
1084 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1085 self.0.request.filter = v.into();
1086 self
1087 }
1088
1089 /// Sets the value of [page_size][crate::model::SearchGrantsRequest::page_size].
1090 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1091 self.0.request.page_size = v.into();
1092 self
1093 }
1094
1095 /// Sets the value of [page_token][crate::model::SearchGrantsRequest::page_token].
1096 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1097 self.0.request.page_token = v.into();
1098 self
1099 }
1100 }
1101
1102 #[doc(hidden)]
1103 impl crate::RequestBuilder for SearchGrants {
1104 fn request_options(&mut self) -> &mut crate::RequestOptions {
1105 &mut self.0.options
1106 }
1107 }
1108
1109 /// The request builder for [PrivilegedAccessManager::get_grant][crate::client::PrivilegedAccessManager::get_grant] calls.
1110 ///
1111 /// # Example
1112 /// ```
1113 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::GetGrant;
1114 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1115 ///
1116 /// let builder = prepare_request_builder();
1117 /// let response = builder.send().await?;
1118 /// # Ok(()) }
1119 ///
1120 /// fn prepare_request_builder() -> GetGrant {
1121 /// # panic!();
1122 /// // ... details omitted ...
1123 /// }
1124 /// ```
1125 #[derive(Clone, Debug)]
1126 pub struct GetGrant(RequestBuilder<crate::model::GetGrantRequest>);
1127
1128 impl GetGrant {
1129 pub(crate) fn new(
1130 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1131 ) -> Self {
1132 Self(RequestBuilder::new(stub))
1133 }
1134
1135 /// Sets the full request, replacing any prior values.
1136 pub fn with_request<V: Into<crate::model::GetGrantRequest>>(mut self, v: V) -> Self {
1137 self.0.request = v.into();
1138 self
1139 }
1140
1141 /// Sets all the options, replacing any prior values.
1142 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1143 self.0.options = v.into();
1144 self
1145 }
1146
1147 /// Sends the request.
1148 pub async fn send(self) -> Result<crate::model::Grant> {
1149 (*self.0.stub)
1150 .get_grant(self.0.request, self.0.options)
1151 .await
1152 .map(crate::Response::into_body)
1153 }
1154
1155 /// Sets the value of [name][crate::model::GetGrantRequest::name].
1156 ///
1157 /// This is a **required** field for requests.
1158 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1159 self.0.request.name = v.into();
1160 self
1161 }
1162 }
1163
1164 #[doc(hidden)]
1165 impl crate::RequestBuilder for GetGrant {
1166 fn request_options(&mut self) -> &mut crate::RequestOptions {
1167 &mut self.0.options
1168 }
1169 }
1170
1171 /// The request builder for [PrivilegedAccessManager::create_grant][crate::client::PrivilegedAccessManager::create_grant] calls.
1172 ///
1173 /// # Example
1174 /// ```
1175 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::CreateGrant;
1176 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1177 ///
1178 /// let builder = prepare_request_builder();
1179 /// let response = builder.send().await?;
1180 /// # Ok(()) }
1181 ///
1182 /// fn prepare_request_builder() -> CreateGrant {
1183 /// # panic!();
1184 /// // ... details omitted ...
1185 /// }
1186 /// ```
1187 #[derive(Clone, Debug)]
1188 pub struct CreateGrant(RequestBuilder<crate::model::CreateGrantRequest>);
1189
1190 impl CreateGrant {
1191 pub(crate) fn new(
1192 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1193 ) -> Self {
1194 Self(RequestBuilder::new(stub))
1195 }
1196
1197 /// Sets the full request, replacing any prior values.
1198 pub fn with_request<V: Into<crate::model::CreateGrantRequest>>(mut self, v: V) -> Self {
1199 self.0.request = v.into();
1200 self
1201 }
1202
1203 /// Sets all the options, replacing any prior values.
1204 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1205 self.0.options = v.into();
1206 self
1207 }
1208
1209 /// Sends the request.
1210 pub async fn send(self) -> Result<crate::model::Grant> {
1211 (*self.0.stub)
1212 .create_grant(self.0.request, self.0.options)
1213 .await
1214 .map(crate::Response::into_body)
1215 }
1216
1217 /// Sets the value of [parent][crate::model::CreateGrantRequest::parent].
1218 ///
1219 /// This is a **required** field for requests.
1220 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1221 self.0.request.parent = v.into();
1222 self
1223 }
1224
1225 /// Sets the value of [grant][crate::model::CreateGrantRequest::grant].
1226 ///
1227 /// This is a **required** field for requests.
1228 pub fn set_grant<T>(mut self, v: T) -> Self
1229 where
1230 T: std::convert::Into<crate::model::Grant>,
1231 {
1232 self.0.request.grant = std::option::Option::Some(v.into());
1233 self
1234 }
1235
1236 /// Sets or clears the value of [grant][crate::model::CreateGrantRequest::grant].
1237 ///
1238 /// This is a **required** field for requests.
1239 pub fn set_or_clear_grant<T>(mut self, v: std::option::Option<T>) -> Self
1240 where
1241 T: std::convert::Into<crate::model::Grant>,
1242 {
1243 self.0.request.grant = v.map(|x| x.into());
1244 self
1245 }
1246
1247 /// Sets the value of [request_id][crate::model::CreateGrantRequest::request_id].
1248 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1249 self.0.request.request_id = v.into();
1250 self
1251 }
1252 }
1253
1254 #[doc(hidden)]
1255 impl crate::RequestBuilder for CreateGrant {
1256 fn request_options(&mut self) -> &mut crate::RequestOptions {
1257 &mut self.0.options
1258 }
1259 }
1260
1261 /// The request builder for [PrivilegedAccessManager::approve_grant][crate::client::PrivilegedAccessManager::approve_grant] calls.
1262 ///
1263 /// # Example
1264 /// ```
1265 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::ApproveGrant;
1266 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1267 ///
1268 /// let builder = prepare_request_builder();
1269 /// let response = builder.send().await?;
1270 /// # Ok(()) }
1271 ///
1272 /// fn prepare_request_builder() -> ApproveGrant {
1273 /// # panic!();
1274 /// // ... details omitted ...
1275 /// }
1276 /// ```
1277 #[derive(Clone, Debug)]
1278 pub struct ApproveGrant(RequestBuilder<crate::model::ApproveGrantRequest>);
1279
1280 impl ApproveGrant {
1281 pub(crate) fn new(
1282 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1283 ) -> Self {
1284 Self(RequestBuilder::new(stub))
1285 }
1286
1287 /// Sets the full request, replacing any prior values.
1288 pub fn with_request<V: Into<crate::model::ApproveGrantRequest>>(mut self, v: V) -> Self {
1289 self.0.request = v.into();
1290 self
1291 }
1292
1293 /// Sets all the options, replacing any prior values.
1294 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1295 self.0.options = v.into();
1296 self
1297 }
1298
1299 /// Sends the request.
1300 pub async fn send(self) -> Result<crate::model::Grant> {
1301 (*self.0.stub)
1302 .approve_grant(self.0.request, self.0.options)
1303 .await
1304 .map(crate::Response::into_body)
1305 }
1306
1307 /// Sets the value of [name][crate::model::ApproveGrantRequest::name].
1308 ///
1309 /// This is a **required** field for requests.
1310 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1311 self.0.request.name = v.into();
1312 self
1313 }
1314
1315 /// Sets the value of [reason][crate::model::ApproveGrantRequest::reason].
1316 pub fn set_reason<T: Into<std::string::String>>(mut self, v: T) -> Self {
1317 self.0.request.reason = v.into();
1318 self
1319 }
1320 }
1321
1322 #[doc(hidden)]
1323 impl crate::RequestBuilder for ApproveGrant {
1324 fn request_options(&mut self) -> &mut crate::RequestOptions {
1325 &mut self.0.options
1326 }
1327 }
1328
1329 /// The request builder for [PrivilegedAccessManager::deny_grant][crate::client::PrivilegedAccessManager::deny_grant] calls.
1330 ///
1331 /// # Example
1332 /// ```
1333 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::DenyGrant;
1334 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1335 ///
1336 /// let builder = prepare_request_builder();
1337 /// let response = builder.send().await?;
1338 /// # Ok(()) }
1339 ///
1340 /// fn prepare_request_builder() -> DenyGrant {
1341 /// # panic!();
1342 /// // ... details omitted ...
1343 /// }
1344 /// ```
1345 #[derive(Clone, Debug)]
1346 pub struct DenyGrant(RequestBuilder<crate::model::DenyGrantRequest>);
1347
1348 impl DenyGrant {
1349 pub(crate) fn new(
1350 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1351 ) -> Self {
1352 Self(RequestBuilder::new(stub))
1353 }
1354
1355 /// Sets the full request, replacing any prior values.
1356 pub fn with_request<V: Into<crate::model::DenyGrantRequest>>(mut self, v: V) -> Self {
1357 self.0.request = v.into();
1358 self
1359 }
1360
1361 /// Sets all the options, replacing any prior values.
1362 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1363 self.0.options = v.into();
1364 self
1365 }
1366
1367 /// Sends the request.
1368 pub async fn send(self) -> Result<crate::model::Grant> {
1369 (*self.0.stub)
1370 .deny_grant(self.0.request, self.0.options)
1371 .await
1372 .map(crate::Response::into_body)
1373 }
1374
1375 /// Sets the value of [name][crate::model::DenyGrantRequest::name].
1376 ///
1377 /// This is a **required** field for requests.
1378 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1379 self.0.request.name = v.into();
1380 self
1381 }
1382
1383 /// Sets the value of [reason][crate::model::DenyGrantRequest::reason].
1384 pub fn set_reason<T: Into<std::string::String>>(mut self, v: T) -> Self {
1385 self.0.request.reason = v.into();
1386 self
1387 }
1388 }
1389
1390 #[doc(hidden)]
1391 impl crate::RequestBuilder for DenyGrant {
1392 fn request_options(&mut self) -> &mut crate::RequestOptions {
1393 &mut self.0.options
1394 }
1395 }
1396
1397 /// The request builder for [PrivilegedAccessManager::revoke_grant][crate::client::PrivilegedAccessManager::revoke_grant] calls.
1398 ///
1399 /// # Example
1400 /// ```
1401 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::RevokeGrant;
1402 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1403 /// use google_cloud_lro::Poller;
1404 ///
1405 /// let builder = prepare_request_builder();
1406 /// let response = builder.poller().until_done().await?;
1407 /// # Ok(()) }
1408 ///
1409 /// fn prepare_request_builder() -> RevokeGrant {
1410 /// # panic!();
1411 /// // ... details omitted ...
1412 /// }
1413 /// ```
1414 #[derive(Clone, Debug)]
1415 pub struct RevokeGrant(RequestBuilder<crate::model::RevokeGrantRequest>);
1416
1417 impl RevokeGrant {
1418 pub(crate) fn new(
1419 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1420 ) -> Self {
1421 Self(RequestBuilder::new(stub))
1422 }
1423
1424 /// Sets the full request, replacing any prior values.
1425 pub fn with_request<V: Into<crate::model::RevokeGrantRequest>>(mut self, v: V) -> Self {
1426 self.0.request = v.into();
1427 self
1428 }
1429
1430 /// Sets all the options, replacing any prior values.
1431 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1432 self.0.options = v.into();
1433 self
1434 }
1435
1436 /// Sends the request.
1437 ///
1438 /// # Long running operations
1439 ///
1440 /// This starts, but does not poll, a longrunning operation. More information
1441 /// on [revoke_grant][crate::client::PrivilegedAccessManager::revoke_grant].
1442 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1443 (*self.0.stub)
1444 .revoke_grant(self.0.request, self.0.options)
1445 .await
1446 .map(crate::Response::into_body)
1447 }
1448
1449 /// Creates a [Poller][google_cloud_lro::Poller] to work with `revoke_grant`.
1450 pub fn poller(
1451 self,
1452 ) -> impl google_cloud_lro::Poller<crate::model::Grant, crate::model::OperationMetadata>
1453 {
1454 type Operation = google_cloud_lro::internal::Operation<
1455 crate::model::Grant,
1456 crate::model::OperationMetadata,
1457 >;
1458 let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1459 let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1460
1461 let stub = self.0.stub.clone();
1462 let mut options = self.0.options.clone();
1463 options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1464 let query = move |name| {
1465 let stub = stub.clone();
1466 let options = options.clone();
1467 async {
1468 let op = GetOperation::new(stub)
1469 .set_name(name)
1470 .with_options(options)
1471 .send()
1472 .await?;
1473 Ok(Operation::new(op))
1474 }
1475 };
1476
1477 let start = move || async {
1478 let op = self.send().await?;
1479 Ok(Operation::new(op))
1480 };
1481
1482 google_cloud_lro::internal::new_poller(
1483 polling_error_policy,
1484 polling_backoff_policy,
1485 start,
1486 query,
1487 )
1488 }
1489
1490 /// Sets the value of [name][crate::model::RevokeGrantRequest::name].
1491 ///
1492 /// This is a **required** field for requests.
1493 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1494 self.0.request.name = v.into();
1495 self
1496 }
1497
1498 /// Sets the value of [reason][crate::model::RevokeGrantRequest::reason].
1499 pub fn set_reason<T: Into<std::string::String>>(mut self, v: T) -> Self {
1500 self.0.request.reason = v.into();
1501 self
1502 }
1503 }
1504
1505 #[doc(hidden)]
1506 impl crate::RequestBuilder for RevokeGrant {
1507 fn request_options(&mut self) -> &mut crate::RequestOptions {
1508 &mut self.0.options
1509 }
1510 }
1511
1512 /// The request builder for [PrivilegedAccessManager::list_locations][crate::client::PrivilegedAccessManager::list_locations] calls.
1513 ///
1514 /// # Example
1515 /// ```
1516 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::ListLocations;
1517 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1518 /// use google_cloud_gax::paginator::ItemPaginator;
1519 ///
1520 /// let builder = prepare_request_builder();
1521 /// let mut items = builder.by_item();
1522 /// while let Some(result) = items.next().await {
1523 /// let item = result?;
1524 /// }
1525 /// # Ok(()) }
1526 ///
1527 /// fn prepare_request_builder() -> ListLocations {
1528 /// # panic!();
1529 /// // ... details omitted ...
1530 /// }
1531 /// ```
1532 #[derive(Clone, Debug)]
1533 pub struct ListLocations(RequestBuilder<google_cloud_location::model::ListLocationsRequest>);
1534
1535 impl ListLocations {
1536 pub(crate) fn new(
1537 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1538 ) -> Self {
1539 Self(RequestBuilder::new(stub))
1540 }
1541
1542 /// Sets the full request, replacing any prior values.
1543 pub fn with_request<V: Into<google_cloud_location::model::ListLocationsRequest>>(
1544 mut self,
1545 v: V,
1546 ) -> Self {
1547 self.0.request = v.into();
1548 self
1549 }
1550
1551 /// Sets all the options, replacing any prior values.
1552 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1553 self.0.options = v.into();
1554 self
1555 }
1556
1557 /// Sends the request.
1558 pub async fn send(self) -> Result<google_cloud_location::model::ListLocationsResponse> {
1559 (*self.0.stub)
1560 .list_locations(self.0.request, self.0.options)
1561 .await
1562 .map(crate::Response::into_body)
1563 }
1564
1565 /// Streams each page in the collection.
1566 pub fn by_page(
1567 self,
1568 ) -> impl google_cloud_gax::paginator::Paginator<
1569 google_cloud_location::model::ListLocationsResponse,
1570 crate::Error,
1571 > {
1572 use std::clone::Clone;
1573 let token = self.0.request.page_token.clone();
1574 let execute = move |token: String| {
1575 let mut builder = self.clone();
1576 builder.0.request = builder.0.request.set_page_token(token);
1577 builder.send()
1578 };
1579 google_cloud_gax::paginator::internal::new_paginator(token, execute)
1580 }
1581
1582 /// Streams each item in the collection.
1583 pub fn by_item(
1584 self,
1585 ) -> impl google_cloud_gax::paginator::ItemPaginator<
1586 google_cloud_location::model::ListLocationsResponse,
1587 crate::Error,
1588 > {
1589 use google_cloud_gax::paginator::Paginator;
1590 self.by_page().items()
1591 }
1592
1593 /// Sets the value of [name][google_cloud_location::model::ListLocationsRequest::name].
1594 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1595 self.0.request.name = v.into();
1596 self
1597 }
1598
1599 /// Sets the value of [filter][google_cloud_location::model::ListLocationsRequest::filter].
1600 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1601 self.0.request.filter = v.into();
1602 self
1603 }
1604
1605 /// Sets the value of [page_size][google_cloud_location::model::ListLocationsRequest::page_size].
1606 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1607 self.0.request.page_size = v.into();
1608 self
1609 }
1610
1611 /// Sets the value of [page_token][google_cloud_location::model::ListLocationsRequest::page_token].
1612 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1613 self.0.request.page_token = v.into();
1614 self
1615 }
1616 }
1617
1618 #[doc(hidden)]
1619 impl crate::RequestBuilder for ListLocations {
1620 fn request_options(&mut self) -> &mut crate::RequestOptions {
1621 &mut self.0.options
1622 }
1623 }
1624
1625 /// The request builder for [PrivilegedAccessManager::get_location][crate::client::PrivilegedAccessManager::get_location] calls.
1626 ///
1627 /// # Example
1628 /// ```
1629 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::GetLocation;
1630 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1631 ///
1632 /// let builder = prepare_request_builder();
1633 /// let response = builder.send().await?;
1634 /// # Ok(()) }
1635 ///
1636 /// fn prepare_request_builder() -> GetLocation {
1637 /// # panic!();
1638 /// // ... details omitted ...
1639 /// }
1640 /// ```
1641 #[derive(Clone, Debug)]
1642 pub struct GetLocation(RequestBuilder<google_cloud_location::model::GetLocationRequest>);
1643
1644 impl GetLocation {
1645 pub(crate) fn new(
1646 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1647 ) -> Self {
1648 Self(RequestBuilder::new(stub))
1649 }
1650
1651 /// Sets the full request, replacing any prior values.
1652 pub fn with_request<V: Into<google_cloud_location::model::GetLocationRequest>>(
1653 mut self,
1654 v: V,
1655 ) -> Self {
1656 self.0.request = v.into();
1657 self
1658 }
1659
1660 /// Sets all the options, replacing any prior values.
1661 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1662 self.0.options = v.into();
1663 self
1664 }
1665
1666 /// Sends the request.
1667 pub async fn send(self) -> Result<google_cloud_location::model::Location> {
1668 (*self.0.stub)
1669 .get_location(self.0.request, self.0.options)
1670 .await
1671 .map(crate::Response::into_body)
1672 }
1673
1674 /// Sets the value of [name][google_cloud_location::model::GetLocationRequest::name].
1675 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1676 self.0.request.name = v.into();
1677 self
1678 }
1679 }
1680
1681 #[doc(hidden)]
1682 impl crate::RequestBuilder for GetLocation {
1683 fn request_options(&mut self) -> &mut crate::RequestOptions {
1684 &mut self.0.options
1685 }
1686 }
1687
1688 /// The request builder for [PrivilegedAccessManager::list_operations][crate::client::PrivilegedAccessManager::list_operations] calls.
1689 ///
1690 /// # Example
1691 /// ```
1692 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::ListOperations;
1693 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1694 /// use google_cloud_gax::paginator::ItemPaginator;
1695 ///
1696 /// let builder = prepare_request_builder();
1697 /// let mut items = builder.by_item();
1698 /// while let Some(result) = items.next().await {
1699 /// let item = result?;
1700 /// }
1701 /// # Ok(()) }
1702 ///
1703 /// fn prepare_request_builder() -> ListOperations {
1704 /// # panic!();
1705 /// // ... details omitted ...
1706 /// }
1707 /// ```
1708 #[derive(Clone, Debug)]
1709 pub struct ListOperations(
1710 RequestBuilder<google_cloud_longrunning::model::ListOperationsRequest>,
1711 );
1712
1713 impl ListOperations {
1714 pub(crate) fn new(
1715 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1716 ) -> Self {
1717 Self(RequestBuilder::new(stub))
1718 }
1719
1720 /// Sets the full request, replacing any prior values.
1721 pub fn with_request<V: Into<google_cloud_longrunning::model::ListOperationsRequest>>(
1722 mut self,
1723 v: V,
1724 ) -> Self {
1725 self.0.request = v.into();
1726 self
1727 }
1728
1729 /// Sets all the options, replacing any prior values.
1730 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1731 self.0.options = v.into();
1732 self
1733 }
1734
1735 /// Sends the request.
1736 pub async fn send(self) -> Result<google_cloud_longrunning::model::ListOperationsResponse> {
1737 (*self.0.stub)
1738 .list_operations(self.0.request, self.0.options)
1739 .await
1740 .map(crate::Response::into_body)
1741 }
1742
1743 /// Streams each page in the collection.
1744 pub fn by_page(
1745 self,
1746 ) -> impl google_cloud_gax::paginator::Paginator<
1747 google_cloud_longrunning::model::ListOperationsResponse,
1748 crate::Error,
1749 > {
1750 use std::clone::Clone;
1751 let token = self.0.request.page_token.clone();
1752 let execute = move |token: String| {
1753 let mut builder = self.clone();
1754 builder.0.request = builder.0.request.set_page_token(token);
1755 builder.send()
1756 };
1757 google_cloud_gax::paginator::internal::new_paginator(token, execute)
1758 }
1759
1760 /// Streams each item in the collection.
1761 pub fn by_item(
1762 self,
1763 ) -> impl google_cloud_gax::paginator::ItemPaginator<
1764 google_cloud_longrunning::model::ListOperationsResponse,
1765 crate::Error,
1766 > {
1767 use google_cloud_gax::paginator::Paginator;
1768 self.by_page().items()
1769 }
1770
1771 /// Sets the value of [name][google_cloud_longrunning::model::ListOperationsRequest::name].
1772 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1773 self.0.request.name = v.into();
1774 self
1775 }
1776
1777 /// Sets the value of [filter][google_cloud_longrunning::model::ListOperationsRequest::filter].
1778 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1779 self.0.request.filter = v.into();
1780 self
1781 }
1782
1783 /// Sets the value of [page_size][google_cloud_longrunning::model::ListOperationsRequest::page_size].
1784 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1785 self.0.request.page_size = v.into();
1786 self
1787 }
1788
1789 /// Sets the value of [page_token][google_cloud_longrunning::model::ListOperationsRequest::page_token].
1790 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1791 self.0.request.page_token = v.into();
1792 self
1793 }
1794
1795 /// Sets the value of [return_partial_success][google_cloud_longrunning::model::ListOperationsRequest::return_partial_success].
1796 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
1797 self.0.request.return_partial_success = v.into();
1798 self
1799 }
1800 }
1801
1802 #[doc(hidden)]
1803 impl crate::RequestBuilder for ListOperations {
1804 fn request_options(&mut self) -> &mut crate::RequestOptions {
1805 &mut self.0.options
1806 }
1807 }
1808
1809 /// The request builder for [PrivilegedAccessManager::get_operation][crate::client::PrivilegedAccessManager::get_operation] calls.
1810 ///
1811 /// # Example
1812 /// ```
1813 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::GetOperation;
1814 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1815 ///
1816 /// let builder = prepare_request_builder();
1817 /// let response = builder.send().await?;
1818 /// # Ok(()) }
1819 ///
1820 /// fn prepare_request_builder() -> GetOperation {
1821 /// # panic!();
1822 /// // ... details omitted ...
1823 /// }
1824 /// ```
1825 #[derive(Clone, Debug)]
1826 pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
1827
1828 impl GetOperation {
1829 pub(crate) fn new(
1830 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1831 ) -> Self {
1832 Self(RequestBuilder::new(stub))
1833 }
1834
1835 /// Sets the full request, replacing any prior values.
1836 pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
1837 mut self,
1838 v: V,
1839 ) -> Self {
1840 self.0.request = v.into();
1841 self
1842 }
1843
1844 /// Sets all the options, replacing any prior values.
1845 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1846 self.0.options = v.into();
1847 self
1848 }
1849
1850 /// Sends the request.
1851 pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1852 (*self.0.stub)
1853 .get_operation(self.0.request, self.0.options)
1854 .await
1855 .map(crate::Response::into_body)
1856 }
1857
1858 /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
1859 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1860 self.0.request.name = v.into();
1861 self
1862 }
1863 }
1864
1865 #[doc(hidden)]
1866 impl crate::RequestBuilder for GetOperation {
1867 fn request_options(&mut self) -> &mut crate::RequestOptions {
1868 &mut self.0.options
1869 }
1870 }
1871
1872 /// The request builder for [PrivilegedAccessManager::delete_operation][crate::client::PrivilegedAccessManager::delete_operation] calls.
1873 ///
1874 /// # Example
1875 /// ```
1876 /// # use google_cloud_privilegedaccessmanager_v1::builder::privileged_access_manager::DeleteOperation;
1877 /// # async fn sample() -> google_cloud_privilegedaccessmanager_v1::Result<()> {
1878 ///
1879 /// let builder = prepare_request_builder();
1880 /// let response = builder.send().await?;
1881 /// # Ok(()) }
1882 ///
1883 /// fn prepare_request_builder() -> DeleteOperation {
1884 /// # panic!();
1885 /// // ... details omitted ...
1886 /// }
1887 /// ```
1888 #[derive(Clone, Debug)]
1889 pub struct DeleteOperation(
1890 RequestBuilder<google_cloud_longrunning::model::DeleteOperationRequest>,
1891 );
1892
1893 impl DeleteOperation {
1894 pub(crate) fn new(
1895 stub: std::sync::Arc<dyn super::super::stub::dynamic::PrivilegedAccessManager>,
1896 ) -> Self {
1897 Self(RequestBuilder::new(stub))
1898 }
1899
1900 /// Sets the full request, replacing any prior values.
1901 pub fn with_request<V: Into<google_cloud_longrunning::model::DeleteOperationRequest>>(
1902 mut self,
1903 v: V,
1904 ) -> Self {
1905 self.0.request = v.into();
1906 self
1907 }
1908
1909 /// Sets all the options, replacing any prior values.
1910 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1911 self.0.options = v.into();
1912 self
1913 }
1914
1915 /// Sends the request.
1916 pub async fn send(self) -> Result<()> {
1917 (*self.0.stub)
1918 .delete_operation(self.0.request, self.0.options)
1919 .await
1920 .map(crate::Response::into_body)
1921 }
1922
1923 /// Sets the value of [name][google_cloud_longrunning::model::DeleteOperationRequest::name].
1924 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1925 self.0.request.name = v.into();
1926 self
1927 }
1928 }
1929
1930 #[doc(hidden)]
1931 impl crate::RequestBuilder for DeleteOperation {
1932 fn request_options(&mut self) -> &mut crate::RequestOptions {
1933 &mut self.0.options
1934 }
1935 }
1936}