Skip to main content

google_cloud_tpu_v2/
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 tpu {
18    use crate::Result;
19
20    /// A builder for [Tpu][crate::client::Tpu].
21    ///
22    /// ```
23    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24    /// # use google_cloud_tpu_v2::*;
25    /// # use builder::tpu::ClientBuilder;
26    /// # use client::Tpu;
27    /// let builder : ClientBuilder = Tpu::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://tpu.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::Tpu;
37        pub struct Factory;
38        impl crate::ClientFactory for Factory {
39            type Client = Tpu;
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::Tpu] 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::Tpu>,
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(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
63            Self {
64                stub,
65                request: R::default(),
66                options: crate::RequestOptions::default(),
67            }
68        }
69    }
70
71    /// The request builder for [Tpu::list_nodes][crate::client::Tpu::list_nodes] calls.
72    ///
73    /// # Example
74    /// ```
75    /// # use google_cloud_tpu_v2::builder::tpu::ListNodes;
76    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
77    /// use google_cloud_gax::paginator::ItemPaginator;
78    ///
79    /// let builder = prepare_request_builder();
80    /// let mut items = builder.by_item();
81    /// while let Some(result) = items.next().await {
82    ///   let item = result?;
83    /// }
84    /// # Ok(()) }
85    ///
86    /// fn prepare_request_builder() -> ListNodes {
87    ///   # panic!();
88    ///   // ... details omitted ...
89    /// }
90    /// ```
91    #[derive(Clone, Debug)]
92    pub struct ListNodes(RequestBuilder<crate::model::ListNodesRequest>);
93
94    impl ListNodes {
95        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
96            Self(RequestBuilder::new(stub))
97        }
98
99        /// Sets the full request, replacing any prior values.
100        pub fn with_request<V: Into<crate::model::ListNodesRequest>>(mut self, v: V) -> Self {
101            self.0.request = v.into();
102            self
103        }
104
105        /// Sets all the options, replacing any prior values.
106        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
107            self.0.options = v.into();
108            self
109        }
110
111        /// Sends the request.
112        pub async fn send(self) -> Result<crate::model::ListNodesResponse> {
113            (*self.0.stub)
114                .list_nodes(self.0.request, self.0.options)
115                .await
116                .map(crate::Response::into_body)
117        }
118
119        /// Streams each page in the collection.
120        pub fn by_page(
121            self,
122        ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListNodesResponse, crate::Error>
123        {
124            use std::clone::Clone;
125            let token = self.0.request.page_token.clone();
126            let execute = move |token: String| {
127                let mut builder = self.clone();
128                builder.0.request = builder.0.request.set_page_token(token);
129                builder.send()
130            };
131            google_cloud_gax::paginator::internal::new_paginator(token, execute)
132        }
133
134        /// Streams each item in the collection.
135        pub fn by_item(
136            self,
137        ) -> impl google_cloud_gax::paginator::ItemPaginator<crate::model::ListNodesResponse, crate::Error>
138        {
139            use google_cloud_gax::paginator::Paginator;
140            self.by_page().items()
141        }
142
143        /// Sets the value of [parent][crate::model::ListNodesRequest::parent].
144        ///
145        /// This is a **required** field for requests.
146        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
147            self.0.request.parent = v.into();
148            self
149        }
150
151        /// Sets the value of [page_size][crate::model::ListNodesRequest::page_size].
152        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
153            self.0.request.page_size = v.into();
154            self
155        }
156
157        /// Sets the value of [page_token][crate::model::ListNodesRequest::page_token].
158        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
159            self.0.request.page_token = v.into();
160            self
161        }
162    }
163
164    #[doc(hidden)]
165    impl crate::RequestBuilder for ListNodes {
166        fn request_options(&mut self) -> &mut crate::RequestOptions {
167            &mut self.0.options
168        }
169    }
170
171    /// The request builder for [Tpu::get_node][crate::client::Tpu::get_node] calls.
172    ///
173    /// # Example
174    /// ```
175    /// # use google_cloud_tpu_v2::builder::tpu::GetNode;
176    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
177    ///
178    /// let builder = prepare_request_builder();
179    /// let response = builder.send().await?;
180    /// # Ok(()) }
181    ///
182    /// fn prepare_request_builder() -> GetNode {
183    ///   # panic!();
184    ///   // ... details omitted ...
185    /// }
186    /// ```
187    #[derive(Clone, Debug)]
188    pub struct GetNode(RequestBuilder<crate::model::GetNodeRequest>);
189
190    impl GetNode {
191        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> 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::GetNodeRequest>>(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<crate::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::Node> {
209            (*self.0.stub)
210                .get_node(self.0.request, self.0.options)
211                .await
212                .map(crate::Response::into_body)
213        }
214
215        /// Sets the value of [name][crate::model::GetNodeRequest::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 crate::RequestBuilder for GetNode {
226        fn request_options(&mut self) -> &mut crate::RequestOptions {
227            &mut self.0.options
228        }
229    }
230
231    /// The request builder for [Tpu::create_node][crate::client::Tpu::create_node] calls.
232    ///
233    /// # Example
234    /// ```
235    /// # use google_cloud_tpu_v2::builder::tpu::CreateNode;
236    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
237    /// use google_cloud_lro::Poller;
238    ///
239    /// let builder = prepare_request_builder();
240    /// let response = builder.poller().until_done().await?;
241    /// # Ok(()) }
242    ///
243    /// fn prepare_request_builder() -> CreateNode {
244    ///   # panic!();
245    ///   // ... details omitted ...
246    /// }
247    /// ```
248    #[derive(Clone, Debug)]
249    pub struct CreateNode(RequestBuilder<crate::model::CreateNodeRequest>);
250
251    impl CreateNode {
252        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
253            Self(RequestBuilder::new(stub))
254        }
255
256        /// Sets the full request, replacing any prior values.
257        pub fn with_request<V: Into<crate::model::CreateNodeRequest>>(mut self, v: V) -> Self {
258            self.0.request = v.into();
259            self
260        }
261
262        /// Sets all the options, replacing any prior values.
263        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
264            self.0.options = v.into();
265            self
266        }
267
268        /// Sends the request.
269        ///
270        /// # Long running operations
271        ///
272        /// This starts, but does not poll, a longrunning operation. More information
273        /// on [create_node][crate::client::Tpu::create_node].
274        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
275            (*self.0.stub)
276                .create_node(self.0.request, self.0.options)
277                .await
278                .map(crate::Response::into_body)
279        }
280
281        /// Creates a [Poller][google_cloud_lro::Poller] to work with `create_node`.
282        pub fn poller(
283            self,
284        ) -> impl google_cloud_lro::Poller<crate::model::Node, crate::model::OperationMetadata>
285        {
286            type Operation = google_cloud_lro::internal::Operation<
287                crate::model::Node,
288                crate::model::OperationMetadata,
289            >;
290            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
291            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
292
293            let stub = self.0.stub.clone();
294            let mut options = self.0.options.clone();
295            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
296            let query = move |name| {
297                let stub = stub.clone();
298                let options = options.clone();
299                async {
300                    let op = GetOperation::new(stub)
301                        .set_name(name)
302                        .with_options(options)
303                        .send()
304                        .await?;
305                    Ok(Operation::new(op))
306                }
307            };
308
309            let start = move || async {
310                let op = self.send().await?;
311                Ok(Operation::new(op))
312            };
313
314            google_cloud_lro::internal::new_poller(
315                polling_error_policy,
316                polling_backoff_policy,
317                start,
318                query,
319            )
320        }
321
322        /// Sets the value of [parent][crate::model::CreateNodeRequest::parent].
323        ///
324        /// This is a **required** field for requests.
325        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
326            self.0.request.parent = v.into();
327            self
328        }
329
330        /// Sets the value of [node_id][crate::model::CreateNodeRequest::node_id].
331        pub fn set_node_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
332            self.0.request.node_id = v.into();
333            self
334        }
335
336        /// Sets the value of [node][crate::model::CreateNodeRequest::node].
337        ///
338        /// This is a **required** field for requests.
339        pub fn set_node<T>(mut self, v: T) -> Self
340        where
341            T: std::convert::Into<crate::model::Node>,
342        {
343            self.0.request.node = std::option::Option::Some(v.into());
344            self
345        }
346
347        /// Sets or clears the value of [node][crate::model::CreateNodeRequest::node].
348        ///
349        /// This is a **required** field for requests.
350        pub fn set_or_clear_node<T>(mut self, v: std::option::Option<T>) -> Self
351        where
352            T: std::convert::Into<crate::model::Node>,
353        {
354            self.0.request.node = v.map(|x| x.into());
355            self
356        }
357    }
358
359    #[doc(hidden)]
360    impl crate::RequestBuilder for CreateNode {
361        fn request_options(&mut self) -> &mut crate::RequestOptions {
362            &mut self.0.options
363        }
364    }
365
366    /// The request builder for [Tpu::delete_node][crate::client::Tpu::delete_node] calls.
367    ///
368    /// # Example
369    /// ```
370    /// # use google_cloud_tpu_v2::builder::tpu::DeleteNode;
371    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
372    /// use google_cloud_lro::Poller;
373    ///
374    /// let builder = prepare_request_builder();
375    /// let response = builder.poller().until_done().await?;
376    /// # Ok(()) }
377    ///
378    /// fn prepare_request_builder() -> DeleteNode {
379    ///   # panic!();
380    ///   // ... details omitted ...
381    /// }
382    /// ```
383    #[derive(Clone, Debug)]
384    pub struct DeleteNode(RequestBuilder<crate::model::DeleteNodeRequest>);
385
386    impl DeleteNode {
387        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
388            Self(RequestBuilder::new(stub))
389        }
390
391        /// Sets the full request, replacing any prior values.
392        pub fn with_request<V: Into<crate::model::DeleteNodeRequest>>(mut self, v: V) -> Self {
393            self.0.request = v.into();
394            self
395        }
396
397        /// Sets all the options, replacing any prior values.
398        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
399            self.0.options = v.into();
400            self
401        }
402
403        /// Sends the request.
404        ///
405        /// # Long running operations
406        ///
407        /// This starts, but does not poll, a longrunning operation. More information
408        /// on [delete_node][crate::client::Tpu::delete_node].
409        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
410            (*self.0.stub)
411                .delete_node(self.0.request, self.0.options)
412                .await
413                .map(crate::Response::into_body)
414        }
415
416        /// Creates a [Poller][google_cloud_lro::Poller] to work with `delete_node`.
417        pub fn poller(self) -> impl google_cloud_lro::Poller<(), crate::model::OperationMetadata> {
418            type Operation =
419                google_cloud_lro::internal::Operation<wkt::Empty, crate::model::OperationMetadata>;
420            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
421            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
422
423            let stub = self.0.stub.clone();
424            let mut options = self.0.options.clone();
425            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
426            let query = move |name| {
427                let stub = stub.clone();
428                let options = options.clone();
429                async {
430                    let op = GetOperation::new(stub)
431                        .set_name(name)
432                        .with_options(options)
433                        .send()
434                        .await?;
435                    Ok(Operation::new(op))
436                }
437            };
438
439            let start = move || async {
440                let op = self.send().await?;
441                Ok(Operation::new(op))
442            };
443
444            google_cloud_lro::internal::new_unit_response_poller(
445                polling_error_policy,
446                polling_backoff_policy,
447                start,
448                query,
449            )
450        }
451
452        /// Sets the value of [name][crate::model::DeleteNodeRequest::name].
453        ///
454        /// This is a **required** field for requests.
455        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
456            self.0.request.name = v.into();
457            self
458        }
459    }
460
461    #[doc(hidden)]
462    impl crate::RequestBuilder for DeleteNode {
463        fn request_options(&mut self) -> &mut crate::RequestOptions {
464            &mut self.0.options
465        }
466    }
467
468    /// The request builder for [Tpu::stop_node][crate::client::Tpu::stop_node] calls.
469    ///
470    /// # Example
471    /// ```
472    /// # use google_cloud_tpu_v2::builder::tpu::StopNode;
473    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
474    /// use google_cloud_lro::Poller;
475    ///
476    /// let builder = prepare_request_builder();
477    /// let response = builder.poller().until_done().await?;
478    /// # Ok(()) }
479    ///
480    /// fn prepare_request_builder() -> StopNode {
481    ///   # panic!();
482    ///   // ... details omitted ...
483    /// }
484    /// ```
485    #[derive(Clone, Debug)]
486    pub struct StopNode(RequestBuilder<crate::model::StopNodeRequest>);
487
488    impl StopNode {
489        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
490            Self(RequestBuilder::new(stub))
491        }
492
493        /// Sets the full request, replacing any prior values.
494        pub fn with_request<V: Into<crate::model::StopNodeRequest>>(mut self, v: V) -> Self {
495            self.0.request = v.into();
496            self
497        }
498
499        /// Sets all the options, replacing any prior values.
500        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
501            self.0.options = v.into();
502            self
503        }
504
505        /// Sends the request.
506        ///
507        /// # Long running operations
508        ///
509        /// This starts, but does not poll, a longrunning operation. More information
510        /// on [stop_node][crate::client::Tpu::stop_node].
511        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
512            (*self.0.stub)
513                .stop_node(self.0.request, self.0.options)
514                .await
515                .map(crate::Response::into_body)
516        }
517
518        /// Creates a [Poller][google_cloud_lro::Poller] to work with `stop_node`.
519        pub fn poller(
520            self,
521        ) -> impl google_cloud_lro::Poller<crate::model::Node, crate::model::OperationMetadata>
522        {
523            type Operation = google_cloud_lro::internal::Operation<
524                crate::model::Node,
525                crate::model::OperationMetadata,
526            >;
527            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
528            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
529
530            let stub = self.0.stub.clone();
531            let mut options = self.0.options.clone();
532            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
533            let query = move |name| {
534                let stub = stub.clone();
535                let options = options.clone();
536                async {
537                    let op = GetOperation::new(stub)
538                        .set_name(name)
539                        .with_options(options)
540                        .send()
541                        .await?;
542                    Ok(Operation::new(op))
543                }
544            };
545
546            let start = move || async {
547                let op = self.send().await?;
548                Ok(Operation::new(op))
549            };
550
551            google_cloud_lro::internal::new_poller(
552                polling_error_policy,
553                polling_backoff_policy,
554                start,
555                query,
556            )
557        }
558
559        /// Sets the value of [name][crate::model::StopNodeRequest::name].
560        ///
561        /// This is a **required** field for requests.
562        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
563            self.0.request.name = v.into();
564            self
565        }
566    }
567
568    #[doc(hidden)]
569    impl crate::RequestBuilder for StopNode {
570        fn request_options(&mut self) -> &mut crate::RequestOptions {
571            &mut self.0.options
572        }
573    }
574
575    /// The request builder for [Tpu::start_node][crate::client::Tpu::start_node] calls.
576    ///
577    /// # Example
578    /// ```
579    /// # use google_cloud_tpu_v2::builder::tpu::StartNode;
580    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
581    /// use google_cloud_lro::Poller;
582    ///
583    /// let builder = prepare_request_builder();
584    /// let response = builder.poller().until_done().await?;
585    /// # Ok(()) }
586    ///
587    /// fn prepare_request_builder() -> StartNode {
588    ///   # panic!();
589    ///   // ... details omitted ...
590    /// }
591    /// ```
592    #[derive(Clone, Debug)]
593    pub struct StartNode(RequestBuilder<crate::model::StartNodeRequest>);
594
595    impl StartNode {
596        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
597            Self(RequestBuilder::new(stub))
598        }
599
600        /// Sets the full request, replacing any prior values.
601        pub fn with_request<V: Into<crate::model::StartNodeRequest>>(mut self, v: V) -> Self {
602            self.0.request = v.into();
603            self
604        }
605
606        /// Sets all the options, replacing any prior values.
607        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
608            self.0.options = v.into();
609            self
610        }
611
612        /// Sends the request.
613        ///
614        /// # Long running operations
615        ///
616        /// This starts, but does not poll, a longrunning operation. More information
617        /// on [start_node][crate::client::Tpu::start_node].
618        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
619            (*self.0.stub)
620                .start_node(self.0.request, self.0.options)
621                .await
622                .map(crate::Response::into_body)
623        }
624
625        /// Creates a [Poller][google_cloud_lro::Poller] to work with `start_node`.
626        pub fn poller(
627            self,
628        ) -> impl google_cloud_lro::Poller<crate::model::Node, crate::model::OperationMetadata>
629        {
630            type Operation = google_cloud_lro::internal::Operation<
631                crate::model::Node,
632                crate::model::OperationMetadata,
633            >;
634            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
635            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
636
637            let stub = self.0.stub.clone();
638            let mut options = self.0.options.clone();
639            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
640            let query = move |name| {
641                let stub = stub.clone();
642                let options = options.clone();
643                async {
644                    let op = GetOperation::new(stub)
645                        .set_name(name)
646                        .with_options(options)
647                        .send()
648                        .await?;
649                    Ok(Operation::new(op))
650                }
651            };
652
653            let start = move || async {
654                let op = self.send().await?;
655                Ok(Operation::new(op))
656            };
657
658            google_cloud_lro::internal::new_poller(
659                polling_error_policy,
660                polling_backoff_policy,
661                start,
662                query,
663            )
664        }
665
666        /// Sets the value of [name][crate::model::StartNodeRequest::name].
667        ///
668        /// This is a **required** field for requests.
669        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
670            self.0.request.name = v.into();
671            self
672        }
673    }
674
675    #[doc(hidden)]
676    impl crate::RequestBuilder for StartNode {
677        fn request_options(&mut self) -> &mut crate::RequestOptions {
678            &mut self.0.options
679        }
680    }
681
682    /// The request builder for [Tpu::update_node][crate::client::Tpu::update_node] calls.
683    ///
684    /// # Example
685    /// ```
686    /// # use google_cloud_tpu_v2::builder::tpu::UpdateNode;
687    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
688    /// use google_cloud_lro::Poller;
689    ///
690    /// let builder = prepare_request_builder();
691    /// let response = builder.poller().until_done().await?;
692    /// # Ok(()) }
693    ///
694    /// fn prepare_request_builder() -> UpdateNode {
695    ///   # panic!();
696    ///   // ... details omitted ...
697    /// }
698    /// ```
699    #[derive(Clone, Debug)]
700    pub struct UpdateNode(RequestBuilder<crate::model::UpdateNodeRequest>);
701
702    impl UpdateNode {
703        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
704            Self(RequestBuilder::new(stub))
705        }
706
707        /// Sets the full request, replacing any prior values.
708        pub fn with_request<V: Into<crate::model::UpdateNodeRequest>>(mut self, v: V) -> Self {
709            self.0.request = v.into();
710            self
711        }
712
713        /// Sets all the options, replacing any prior values.
714        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
715            self.0.options = v.into();
716            self
717        }
718
719        /// Sends the request.
720        ///
721        /// # Long running operations
722        ///
723        /// This starts, but does not poll, a longrunning operation. More information
724        /// on [update_node][crate::client::Tpu::update_node].
725        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
726            (*self.0.stub)
727                .update_node(self.0.request, self.0.options)
728                .await
729                .map(crate::Response::into_body)
730        }
731
732        /// Creates a [Poller][google_cloud_lro::Poller] to work with `update_node`.
733        pub fn poller(
734            self,
735        ) -> impl google_cloud_lro::Poller<crate::model::Node, crate::model::OperationMetadata>
736        {
737            type Operation = google_cloud_lro::internal::Operation<
738                crate::model::Node,
739                crate::model::OperationMetadata,
740            >;
741            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
742            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
743
744            let stub = self.0.stub.clone();
745            let mut options = self.0.options.clone();
746            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
747            let query = move |name| {
748                let stub = stub.clone();
749                let options = options.clone();
750                async {
751                    let op = GetOperation::new(stub)
752                        .set_name(name)
753                        .with_options(options)
754                        .send()
755                        .await?;
756                    Ok(Operation::new(op))
757                }
758            };
759
760            let start = move || async {
761                let op = self.send().await?;
762                Ok(Operation::new(op))
763            };
764
765            google_cloud_lro::internal::new_poller(
766                polling_error_policy,
767                polling_backoff_policy,
768                start,
769                query,
770            )
771        }
772
773        /// Sets the value of [update_mask][crate::model::UpdateNodeRequest::update_mask].
774        ///
775        /// This is a **required** field for requests.
776        pub fn set_update_mask<T>(mut self, v: T) -> Self
777        where
778            T: std::convert::Into<wkt::FieldMask>,
779        {
780            self.0.request.update_mask = std::option::Option::Some(v.into());
781            self
782        }
783
784        /// Sets or clears the value of [update_mask][crate::model::UpdateNodeRequest::update_mask].
785        ///
786        /// This is a **required** field for requests.
787        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
788        where
789            T: std::convert::Into<wkt::FieldMask>,
790        {
791            self.0.request.update_mask = v.map(|x| x.into());
792            self
793        }
794
795        /// Sets the value of [node][crate::model::UpdateNodeRequest::node].
796        ///
797        /// This is a **required** field for requests.
798        pub fn set_node<T>(mut self, v: T) -> Self
799        where
800            T: std::convert::Into<crate::model::Node>,
801        {
802            self.0.request.node = std::option::Option::Some(v.into());
803            self
804        }
805
806        /// Sets or clears the value of [node][crate::model::UpdateNodeRequest::node].
807        ///
808        /// This is a **required** field for requests.
809        pub fn set_or_clear_node<T>(mut self, v: std::option::Option<T>) -> Self
810        where
811            T: std::convert::Into<crate::model::Node>,
812        {
813            self.0.request.node = v.map(|x| x.into());
814            self
815        }
816    }
817
818    #[doc(hidden)]
819    impl crate::RequestBuilder for UpdateNode {
820        fn request_options(&mut self) -> &mut crate::RequestOptions {
821            &mut self.0.options
822        }
823    }
824
825    /// The request builder for [Tpu::list_queued_resources][crate::client::Tpu::list_queued_resources] calls.
826    ///
827    /// # Example
828    /// ```
829    /// # use google_cloud_tpu_v2::builder::tpu::ListQueuedResources;
830    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
831    /// use google_cloud_gax::paginator::ItemPaginator;
832    ///
833    /// let builder = prepare_request_builder();
834    /// let mut items = builder.by_item();
835    /// while let Some(result) = items.next().await {
836    ///   let item = result?;
837    /// }
838    /// # Ok(()) }
839    ///
840    /// fn prepare_request_builder() -> ListQueuedResources {
841    ///   # panic!();
842    ///   // ... details omitted ...
843    /// }
844    /// ```
845    #[derive(Clone, Debug)]
846    pub struct ListQueuedResources(RequestBuilder<crate::model::ListQueuedResourcesRequest>);
847
848    impl ListQueuedResources {
849        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
850            Self(RequestBuilder::new(stub))
851        }
852
853        /// Sets the full request, replacing any prior values.
854        pub fn with_request<V: Into<crate::model::ListQueuedResourcesRequest>>(
855            mut self,
856            v: V,
857        ) -> Self {
858            self.0.request = v.into();
859            self
860        }
861
862        /// Sets all the options, replacing any prior values.
863        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
864            self.0.options = v.into();
865            self
866        }
867
868        /// Sends the request.
869        pub async fn send(self) -> Result<crate::model::ListQueuedResourcesResponse> {
870            (*self.0.stub)
871                .list_queued_resources(self.0.request, self.0.options)
872                .await
873                .map(crate::Response::into_body)
874        }
875
876        /// Streams each page in the collection.
877        pub fn by_page(
878            self,
879        ) -> impl google_cloud_gax::paginator::Paginator<
880            crate::model::ListQueuedResourcesResponse,
881            crate::Error,
882        > {
883            use std::clone::Clone;
884            let token = self.0.request.page_token.clone();
885            let execute = move |token: String| {
886                let mut builder = self.clone();
887                builder.0.request = builder.0.request.set_page_token(token);
888                builder.send()
889            };
890            google_cloud_gax::paginator::internal::new_paginator(token, execute)
891        }
892
893        /// Streams each item in the collection.
894        pub fn by_item(
895            self,
896        ) -> impl google_cloud_gax::paginator::ItemPaginator<
897            crate::model::ListQueuedResourcesResponse,
898            crate::Error,
899        > {
900            use google_cloud_gax::paginator::Paginator;
901            self.by_page().items()
902        }
903
904        /// Sets the value of [parent][crate::model::ListQueuedResourcesRequest::parent].
905        ///
906        /// This is a **required** field for requests.
907        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
908            self.0.request.parent = v.into();
909            self
910        }
911
912        /// Sets the value of [page_size][crate::model::ListQueuedResourcesRequest::page_size].
913        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
914            self.0.request.page_size = v.into();
915            self
916        }
917
918        /// Sets the value of [page_token][crate::model::ListQueuedResourcesRequest::page_token].
919        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
920            self.0.request.page_token = v.into();
921            self
922        }
923    }
924
925    #[doc(hidden)]
926    impl crate::RequestBuilder for ListQueuedResources {
927        fn request_options(&mut self) -> &mut crate::RequestOptions {
928            &mut self.0.options
929        }
930    }
931
932    /// The request builder for [Tpu::get_queued_resource][crate::client::Tpu::get_queued_resource] calls.
933    ///
934    /// # Example
935    /// ```
936    /// # use google_cloud_tpu_v2::builder::tpu::GetQueuedResource;
937    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
938    ///
939    /// let builder = prepare_request_builder();
940    /// let response = builder.send().await?;
941    /// # Ok(()) }
942    ///
943    /// fn prepare_request_builder() -> GetQueuedResource {
944    ///   # panic!();
945    ///   // ... details omitted ...
946    /// }
947    /// ```
948    #[derive(Clone, Debug)]
949    pub struct GetQueuedResource(RequestBuilder<crate::model::GetQueuedResourceRequest>);
950
951    impl GetQueuedResource {
952        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
953            Self(RequestBuilder::new(stub))
954        }
955
956        /// Sets the full request, replacing any prior values.
957        pub fn with_request<V: Into<crate::model::GetQueuedResourceRequest>>(
958            mut self,
959            v: V,
960        ) -> Self {
961            self.0.request = v.into();
962            self
963        }
964
965        /// Sets all the options, replacing any prior values.
966        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
967            self.0.options = v.into();
968            self
969        }
970
971        /// Sends the request.
972        pub async fn send(self) -> Result<crate::model::QueuedResource> {
973            (*self.0.stub)
974                .get_queued_resource(self.0.request, self.0.options)
975                .await
976                .map(crate::Response::into_body)
977        }
978
979        /// Sets the value of [name][crate::model::GetQueuedResourceRequest::name].
980        ///
981        /// This is a **required** field for requests.
982        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
983            self.0.request.name = v.into();
984            self
985        }
986    }
987
988    #[doc(hidden)]
989    impl crate::RequestBuilder for GetQueuedResource {
990        fn request_options(&mut self) -> &mut crate::RequestOptions {
991            &mut self.0.options
992        }
993    }
994
995    /// The request builder for [Tpu::create_queued_resource][crate::client::Tpu::create_queued_resource] calls.
996    ///
997    /// # Example
998    /// ```
999    /// # use google_cloud_tpu_v2::builder::tpu::CreateQueuedResource;
1000    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1001    /// use google_cloud_lro::Poller;
1002    ///
1003    /// let builder = prepare_request_builder();
1004    /// let response = builder.poller().until_done().await?;
1005    /// # Ok(()) }
1006    ///
1007    /// fn prepare_request_builder() -> CreateQueuedResource {
1008    ///   # panic!();
1009    ///   // ... details omitted ...
1010    /// }
1011    /// ```
1012    #[derive(Clone, Debug)]
1013    pub struct CreateQueuedResource(RequestBuilder<crate::model::CreateQueuedResourceRequest>);
1014
1015    impl CreateQueuedResource {
1016        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1017            Self(RequestBuilder::new(stub))
1018        }
1019
1020        /// Sets the full request, replacing any prior values.
1021        pub fn with_request<V: Into<crate::model::CreateQueuedResourceRequest>>(
1022            mut self,
1023            v: V,
1024        ) -> Self {
1025            self.0.request = v.into();
1026            self
1027        }
1028
1029        /// Sets all the options, replacing any prior values.
1030        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1031            self.0.options = v.into();
1032            self
1033        }
1034
1035        /// Sends the request.
1036        ///
1037        /// # Long running operations
1038        ///
1039        /// This starts, but does not poll, a longrunning operation. More information
1040        /// on [create_queued_resource][crate::client::Tpu::create_queued_resource].
1041        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1042            (*self.0.stub)
1043                .create_queued_resource(self.0.request, self.0.options)
1044                .await
1045                .map(crate::Response::into_body)
1046        }
1047
1048        /// Creates a [Poller][google_cloud_lro::Poller] to work with `create_queued_resource`.
1049        pub fn poller(
1050            self,
1051        ) -> impl google_cloud_lro::Poller<crate::model::QueuedResource, crate::model::OperationMetadata>
1052        {
1053            type Operation = google_cloud_lro::internal::Operation<
1054                crate::model::QueuedResource,
1055                crate::model::OperationMetadata,
1056            >;
1057            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1058            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1059
1060            let stub = self.0.stub.clone();
1061            let mut options = self.0.options.clone();
1062            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1063            let query = move |name| {
1064                let stub = stub.clone();
1065                let options = options.clone();
1066                async {
1067                    let op = GetOperation::new(stub)
1068                        .set_name(name)
1069                        .with_options(options)
1070                        .send()
1071                        .await?;
1072                    Ok(Operation::new(op))
1073                }
1074            };
1075
1076            let start = move || async {
1077                let op = self.send().await?;
1078                Ok(Operation::new(op))
1079            };
1080
1081            google_cloud_lro::internal::new_poller(
1082                polling_error_policy,
1083                polling_backoff_policy,
1084                start,
1085                query,
1086            )
1087        }
1088
1089        /// Sets the value of [parent][crate::model::CreateQueuedResourceRequest::parent].
1090        ///
1091        /// This is a **required** field for requests.
1092        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1093            self.0.request.parent = v.into();
1094            self
1095        }
1096
1097        /// Sets the value of [queued_resource_id][crate::model::CreateQueuedResourceRequest::queued_resource_id].
1098        pub fn set_queued_resource_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1099            self.0.request.queued_resource_id = v.into();
1100            self
1101        }
1102
1103        /// Sets the value of [queued_resource][crate::model::CreateQueuedResourceRequest::queued_resource].
1104        ///
1105        /// This is a **required** field for requests.
1106        pub fn set_queued_resource<T>(mut self, v: T) -> Self
1107        where
1108            T: std::convert::Into<crate::model::QueuedResource>,
1109        {
1110            self.0.request.queued_resource = std::option::Option::Some(v.into());
1111            self
1112        }
1113
1114        /// Sets or clears the value of [queued_resource][crate::model::CreateQueuedResourceRequest::queued_resource].
1115        ///
1116        /// This is a **required** field for requests.
1117        pub fn set_or_clear_queued_resource<T>(mut self, v: std::option::Option<T>) -> Self
1118        where
1119            T: std::convert::Into<crate::model::QueuedResource>,
1120        {
1121            self.0.request.queued_resource = v.map(|x| x.into());
1122            self
1123        }
1124
1125        /// Sets the value of [request_id][crate::model::CreateQueuedResourceRequest::request_id].
1126        pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1127            self.0.request.request_id = v.into();
1128            self
1129        }
1130    }
1131
1132    #[doc(hidden)]
1133    impl crate::RequestBuilder for CreateQueuedResource {
1134        fn request_options(&mut self) -> &mut crate::RequestOptions {
1135            &mut self.0.options
1136        }
1137    }
1138
1139    /// The request builder for [Tpu::delete_queued_resource][crate::client::Tpu::delete_queued_resource] calls.
1140    ///
1141    /// # Example
1142    /// ```
1143    /// # use google_cloud_tpu_v2::builder::tpu::DeleteQueuedResource;
1144    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1145    /// use google_cloud_lro::Poller;
1146    ///
1147    /// let builder = prepare_request_builder();
1148    /// let response = builder.poller().until_done().await?;
1149    /// # Ok(()) }
1150    ///
1151    /// fn prepare_request_builder() -> DeleteQueuedResource {
1152    ///   # panic!();
1153    ///   // ... details omitted ...
1154    /// }
1155    /// ```
1156    #[derive(Clone, Debug)]
1157    pub struct DeleteQueuedResource(RequestBuilder<crate::model::DeleteQueuedResourceRequest>);
1158
1159    impl DeleteQueuedResource {
1160        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1161            Self(RequestBuilder::new(stub))
1162        }
1163
1164        /// Sets the full request, replacing any prior values.
1165        pub fn with_request<V: Into<crate::model::DeleteQueuedResourceRequest>>(
1166            mut self,
1167            v: V,
1168        ) -> Self {
1169            self.0.request = v.into();
1170            self
1171        }
1172
1173        /// Sets all the options, replacing any prior values.
1174        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1175            self.0.options = v.into();
1176            self
1177        }
1178
1179        /// Sends the request.
1180        ///
1181        /// # Long running operations
1182        ///
1183        /// This starts, but does not poll, a longrunning operation. More information
1184        /// on [delete_queued_resource][crate::client::Tpu::delete_queued_resource].
1185        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1186            (*self.0.stub)
1187                .delete_queued_resource(self.0.request, self.0.options)
1188                .await
1189                .map(crate::Response::into_body)
1190        }
1191
1192        /// Creates a [Poller][google_cloud_lro::Poller] to work with `delete_queued_resource`.
1193        pub fn poller(self) -> impl google_cloud_lro::Poller<(), crate::model::OperationMetadata> {
1194            type Operation =
1195                google_cloud_lro::internal::Operation<wkt::Empty, crate::model::OperationMetadata>;
1196            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1197            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1198
1199            let stub = self.0.stub.clone();
1200            let mut options = self.0.options.clone();
1201            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1202            let query = move |name| {
1203                let stub = stub.clone();
1204                let options = options.clone();
1205                async {
1206                    let op = GetOperation::new(stub)
1207                        .set_name(name)
1208                        .with_options(options)
1209                        .send()
1210                        .await?;
1211                    Ok(Operation::new(op))
1212                }
1213            };
1214
1215            let start = move || async {
1216                let op = self.send().await?;
1217                Ok(Operation::new(op))
1218            };
1219
1220            google_cloud_lro::internal::new_unit_response_poller(
1221                polling_error_policy,
1222                polling_backoff_policy,
1223                start,
1224                query,
1225            )
1226        }
1227
1228        /// Sets the value of [name][crate::model::DeleteQueuedResourceRequest::name].
1229        ///
1230        /// This is a **required** field for requests.
1231        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1232            self.0.request.name = v.into();
1233            self
1234        }
1235
1236        /// Sets the value of [request_id][crate::model::DeleteQueuedResourceRequest::request_id].
1237        pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1238            self.0.request.request_id = v.into();
1239            self
1240        }
1241
1242        /// Sets the value of [force][crate::model::DeleteQueuedResourceRequest::force].
1243        pub fn set_force<T: Into<bool>>(mut self, v: T) -> Self {
1244            self.0.request.force = v.into();
1245            self
1246        }
1247    }
1248
1249    #[doc(hidden)]
1250    impl crate::RequestBuilder for DeleteQueuedResource {
1251        fn request_options(&mut self) -> &mut crate::RequestOptions {
1252            &mut self.0.options
1253        }
1254    }
1255
1256    /// The request builder for [Tpu::reset_queued_resource][crate::client::Tpu::reset_queued_resource] calls.
1257    ///
1258    /// # Example
1259    /// ```
1260    /// # use google_cloud_tpu_v2::builder::tpu::ResetQueuedResource;
1261    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1262    /// use google_cloud_lro::Poller;
1263    ///
1264    /// let builder = prepare_request_builder();
1265    /// let response = builder.poller().until_done().await?;
1266    /// # Ok(()) }
1267    ///
1268    /// fn prepare_request_builder() -> ResetQueuedResource {
1269    ///   # panic!();
1270    ///   // ... details omitted ...
1271    /// }
1272    /// ```
1273    #[derive(Clone, Debug)]
1274    pub struct ResetQueuedResource(RequestBuilder<crate::model::ResetQueuedResourceRequest>);
1275
1276    impl ResetQueuedResource {
1277        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1278            Self(RequestBuilder::new(stub))
1279        }
1280
1281        /// Sets the full request, replacing any prior values.
1282        pub fn with_request<V: Into<crate::model::ResetQueuedResourceRequest>>(
1283            mut self,
1284            v: V,
1285        ) -> Self {
1286            self.0.request = v.into();
1287            self
1288        }
1289
1290        /// Sets all the options, replacing any prior values.
1291        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1292            self.0.options = v.into();
1293            self
1294        }
1295
1296        /// Sends the request.
1297        ///
1298        /// # Long running operations
1299        ///
1300        /// This starts, but does not poll, a longrunning operation. More information
1301        /// on [reset_queued_resource][crate::client::Tpu::reset_queued_resource].
1302        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1303            (*self.0.stub)
1304                .reset_queued_resource(self.0.request, self.0.options)
1305                .await
1306                .map(crate::Response::into_body)
1307        }
1308
1309        /// Creates a [Poller][google_cloud_lro::Poller] to work with `reset_queued_resource`.
1310        pub fn poller(
1311            self,
1312        ) -> impl google_cloud_lro::Poller<crate::model::QueuedResource, crate::model::OperationMetadata>
1313        {
1314            type Operation = google_cloud_lro::internal::Operation<
1315                crate::model::QueuedResource,
1316                crate::model::OperationMetadata,
1317            >;
1318            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1319            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1320
1321            let stub = self.0.stub.clone();
1322            let mut options = self.0.options.clone();
1323            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1324            let query = move |name| {
1325                let stub = stub.clone();
1326                let options = options.clone();
1327                async {
1328                    let op = GetOperation::new(stub)
1329                        .set_name(name)
1330                        .with_options(options)
1331                        .send()
1332                        .await?;
1333                    Ok(Operation::new(op))
1334                }
1335            };
1336
1337            let start = move || async {
1338                let op = self.send().await?;
1339                Ok(Operation::new(op))
1340            };
1341
1342            google_cloud_lro::internal::new_poller(
1343                polling_error_policy,
1344                polling_backoff_policy,
1345                start,
1346                query,
1347            )
1348        }
1349
1350        /// Sets the value of [name][crate::model::ResetQueuedResourceRequest::name].
1351        ///
1352        /// This is a **required** field for requests.
1353        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1354            self.0.request.name = v.into();
1355            self
1356        }
1357    }
1358
1359    #[doc(hidden)]
1360    impl crate::RequestBuilder for ResetQueuedResource {
1361        fn request_options(&mut self) -> &mut crate::RequestOptions {
1362            &mut self.0.options
1363        }
1364    }
1365
1366    /// The request builder for [Tpu::generate_service_identity][crate::client::Tpu::generate_service_identity] calls.
1367    ///
1368    /// # Example
1369    /// ```
1370    /// # use google_cloud_tpu_v2::builder::tpu::GenerateServiceIdentity;
1371    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1372    ///
1373    /// let builder = prepare_request_builder();
1374    /// let response = builder.send().await?;
1375    /// # Ok(()) }
1376    ///
1377    /// fn prepare_request_builder() -> GenerateServiceIdentity {
1378    ///   # panic!();
1379    ///   // ... details omitted ...
1380    /// }
1381    /// ```
1382    #[derive(Clone, Debug)]
1383    pub struct GenerateServiceIdentity(
1384        RequestBuilder<crate::model::GenerateServiceIdentityRequest>,
1385    );
1386
1387    impl GenerateServiceIdentity {
1388        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1389            Self(RequestBuilder::new(stub))
1390        }
1391
1392        /// Sets the full request, replacing any prior values.
1393        pub fn with_request<V: Into<crate::model::GenerateServiceIdentityRequest>>(
1394            mut self,
1395            v: V,
1396        ) -> Self {
1397            self.0.request = v.into();
1398            self
1399        }
1400
1401        /// Sets all the options, replacing any prior values.
1402        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1403            self.0.options = v.into();
1404            self
1405        }
1406
1407        /// Sends the request.
1408        pub async fn send(self) -> Result<crate::model::GenerateServiceIdentityResponse> {
1409            (*self.0.stub)
1410                .generate_service_identity(self.0.request, self.0.options)
1411                .await
1412                .map(crate::Response::into_body)
1413        }
1414
1415        /// Sets the value of [parent][crate::model::GenerateServiceIdentityRequest::parent].
1416        ///
1417        /// This is a **required** field for requests.
1418        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1419            self.0.request.parent = v.into();
1420            self
1421        }
1422    }
1423
1424    #[doc(hidden)]
1425    impl crate::RequestBuilder for GenerateServiceIdentity {
1426        fn request_options(&mut self) -> &mut crate::RequestOptions {
1427            &mut self.0.options
1428        }
1429    }
1430
1431    /// The request builder for [Tpu::list_accelerator_types][crate::client::Tpu::list_accelerator_types] calls.
1432    ///
1433    /// # Example
1434    /// ```
1435    /// # use google_cloud_tpu_v2::builder::tpu::ListAcceleratorTypes;
1436    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1437    /// use google_cloud_gax::paginator::ItemPaginator;
1438    ///
1439    /// let builder = prepare_request_builder();
1440    /// let mut items = builder.by_item();
1441    /// while let Some(result) = items.next().await {
1442    ///   let item = result?;
1443    /// }
1444    /// # Ok(()) }
1445    ///
1446    /// fn prepare_request_builder() -> ListAcceleratorTypes {
1447    ///   # panic!();
1448    ///   // ... details omitted ...
1449    /// }
1450    /// ```
1451    #[derive(Clone, Debug)]
1452    pub struct ListAcceleratorTypes(RequestBuilder<crate::model::ListAcceleratorTypesRequest>);
1453
1454    impl ListAcceleratorTypes {
1455        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1456            Self(RequestBuilder::new(stub))
1457        }
1458
1459        /// Sets the full request, replacing any prior values.
1460        pub fn with_request<V: Into<crate::model::ListAcceleratorTypesRequest>>(
1461            mut self,
1462            v: V,
1463        ) -> Self {
1464            self.0.request = v.into();
1465            self
1466        }
1467
1468        /// Sets all the options, replacing any prior values.
1469        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1470            self.0.options = v.into();
1471            self
1472        }
1473
1474        /// Sends the request.
1475        pub async fn send(self) -> Result<crate::model::ListAcceleratorTypesResponse> {
1476            (*self.0.stub)
1477                .list_accelerator_types(self.0.request, self.0.options)
1478                .await
1479                .map(crate::Response::into_body)
1480        }
1481
1482        /// Streams each page in the collection.
1483        pub fn by_page(
1484            self,
1485        ) -> impl google_cloud_gax::paginator::Paginator<
1486            crate::model::ListAcceleratorTypesResponse,
1487            crate::Error,
1488        > {
1489            use std::clone::Clone;
1490            let token = self.0.request.page_token.clone();
1491            let execute = move |token: String| {
1492                let mut builder = self.clone();
1493                builder.0.request = builder.0.request.set_page_token(token);
1494                builder.send()
1495            };
1496            google_cloud_gax::paginator::internal::new_paginator(token, execute)
1497        }
1498
1499        /// Streams each item in the collection.
1500        pub fn by_item(
1501            self,
1502        ) -> impl google_cloud_gax::paginator::ItemPaginator<
1503            crate::model::ListAcceleratorTypesResponse,
1504            crate::Error,
1505        > {
1506            use google_cloud_gax::paginator::Paginator;
1507            self.by_page().items()
1508        }
1509
1510        /// Sets the value of [parent][crate::model::ListAcceleratorTypesRequest::parent].
1511        ///
1512        /// This is a **required** field for requests.
1513        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1514            self.0.request.parent = v.into();
1515            self
1516        }
1517
1518        /// Sets the value of [page_size][crate::model::ListAcceleratorTypesRequest::page_size].
1519        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1520            self.0.request.page_size = v.into();
1521            self
1522        }
1523
1524        /// Sets the value of [page_token][crate::model::ListAcceleratorTypesRequest::page_token].
1525        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1526            self.0.request.page_token = v.into();
1527            self
1528        }
1529
1530        /// Sets the value of [filter][crate::model::ListAcceleratorTypesRequest::filter].
1531        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1532            self.0.request.filter = v.into();
1533            self
1534        }
1535
1536        /// Sets the value of [order_by][crate::model::ListAcceleratorTypesRequest::order_by].
1537        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
1538            self.0.request.order_by = v.into();
1539            self
1540        }
1541    }
1542
1543    #[doc(hidden)]
1544    impl crate::RequestBuilder for ListAcceleratorTypes {
1545        fn request_options(&mut self) -> &mut crate::RequestOptions {
1546            &mut self.0.options
1547        }
1548    }
1549
1550    /// The request builder for [Tpu::get_accelerator_type][crate::client::Tpu::get_accelerator_type] calls.
1551    ///
1552    /// # Example
1553    /// ```
1554    /// # use google_cloud_tpu_v2::builder::tpu::GetAcceleratorType;
1555    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1556    ///
1557    /// let builder = prepare_request_builder();
1558    /// let response = builder.send().await?;
1559    /// # Ok(()) }
1560    ///
1561    /// fn prepare_request_builder() -> GetAcceleratorType {
1562    ///   # panic!();
1563    ///   // ... details omitted ...
1564    /// }
1565    /// ```
1566    #[derive(Clone, Debug)]
1567    pub struct GetAcceleratorType(RequestBuilder<crate::model::GetAcceleratorTypeRequest>);
1568
1569    impl GetAcceleratorType {
1570        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1571            Self(RequestBuilder::new(stub))
1572        }
1573
1574        /// Sets the full request, replacing any prior values.
1575        pub fn with_request<V: Into<crate::model::GetAcceleratorTypeRequest>>(
1576            mut self,
1577            v: V,
1578        ) -> Self {
1579            self.0.request = v.into();
1580            self
1581        }
1582
1583        /// Sets all the options, replacing any prior values.
1584        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1585            self.0.options = v.into();
1586            self
1587        }
1588
1589        /// Sends the request.
1590        pub async fn send(self) -> Result<crate::model::AcceleratorType> {
1591            (*self.0.stub)
1592                .get_accelerator_type(self.0.request, self.0.options)
1593                .await
1594                .map(crate::Response::into_body)
1595        }
1596
1597        /// Sets the value of [name][crate::model::GetAcceleratorTypeRequest::name].
1598        ///
1599        /// This is a **required** field for requests.
1600        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1601            self.0.request.name = v.into();
1602            self
1603        }
1604    }
1605
1606    #[doc(hidden)]
1607    impl crate::RequestBuilder for GetAcceleratorType {
1608        fn request_options(&mut self) -> &mut crate::RequestOptions {
1609            &mut self.0.options
1610        }
1611    }
1612
1613    /// The request builder for [Tpu::list_runtime_versions][crate::client::Tpu::list_runtime_versions] calls.
1614    ///
1615    /// # Example
1616    /// ```
1617    /// # use google_cloud_tpu_v2::builder::tpu::ListRuntimeVersions;
1618    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1619    /// use google_cloud_gax::paginator::ItemPaginator;
1620    ///
1621    /// let builder = prepare_request_builder();
1622    /// let mut items = builder.by_item();
1623    /// while let Some(result) = items.next().await {
1624    ///   let item = result?;
1625    /// }
1626    /// # Ok(()) }
1627    ///
1628    /// fn prepare_request_builder() -> ListRuntimeVersions {
1629    ///   # panic!();
1630    ///   // ... details omitted ...
1631    /// }
1632    /// ```
1633    #[derive(Clone, Debug)]
1634    pub struct ListRuntimeVersions(RequestBuilder<crate::model::ListRuntimeVersionsRequest>);
1635
1636    impl ListRuntimeVersions {
1637        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1638            Self(RequestBuilder::new(stub))
1639        }
1640
1641        /// Sets the full request, replacing any prior values.
1642        pub fn with_request<V: Into<crate::model::ListRuntimeVersionsRequest>>(
1643            mut self,
1644            v: V,
1645        ) -> Self {
1646            self.0.request = v.into();
1647            self
1648        }
1649
1650        /// Sets all the options, replacing any prior values.
1651        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1652            self.0.options = v.into();
1653            self
1654        }
1655
1656        /// Sends the request.
1657        pub async fn send(self) -> Result<crate::model::ListRuntimeVersionsResponse> {
1658            (*self.0.stub)
1659                .list_runtime_versions(self.0.request, self.0.options)
1660                .await
1661                .map(crate::Response::into_body)
1662        }
1663
1664        /// Streams each page in the collection.
1665        pub fn by_page(
1666            self,
1667        ) -> impl google_cloud_gax::paginator::Paginator<
1668            crate::model::ListRuntimeVersionsResponse,
1669            crate::Error,
1670        > {
1671            use std::clone::Clone;
1672            let token = self.0.request.page_token.clone();
1673            let execute = move |token: String| {
1674                let mut builder = self.clone();
1675                builder.0.request = builder.0.request.set_page_token(token);
1676                builder.send()
1677            };
1678            google_cloud_gax::paginator::internal::new_paginator(token, execute)
1679        }
1680
1681        /// Streams each item in the collection.
1682        pub fn by_item(
1683            self,
1684        ) -> impl google_cloud_gax::paginator::ItemPaginator<
1685            crate::model::ListRuntimeVersionsResponse,
1686            crate::Error,
1687        > {
1688            use google_cloud_gax::paginator::Paginator;
1689            self.by_page().items()
1690        }
1691
1692        /// Sets the value of [parent][crate::model::ListRuntimeVersionsRequest::parent].
1693        ///
1694        /// This is a **required** field for requests.
1695        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1696            self.0.request.parent = v.into();
1697            self
1698        }
1699
1700        /// Sets the value of [page_size][crate::model::ListRuntimeVersionsRequest::page_size].
1701        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1702            self.0.request.page_size = v.into();
1703            self
1704        }
1705
1706        /// Sets the value of [page_token][crate::model::ListRuntimeVersionsRequest::page_token].
1707        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1708            self.0.request.page_token = v.into();
1709            self
1710        }
1711
1712        /// Sets the value of [filter][crate::model::ListRuntimeVersionsRequest::filter].
1713        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1714            self.0.request.filter = v.into();
1715            self
1716        }
1717
1718        /// Sets the value of [order_by][crate::model::ListRuntimeVersionsRequest::order_by].
1719        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
1720            self.0.request.order_by = v.into();
1721            self
1722        }
1723    }
1724
1725    #[doc(hidden)]
1726    impl crate::RequestBuilder for ListRuntimeVersions {
1727        fn request_options(&mut self) -> &mut crate::RequestOptions {
1728            &mut self.0.options
1729        }
1730    }
1731
1732    /// The request builder for [Tpu::get_runtime_version][crate::client::Tpu::get_runtime_version] calls.
1733    ///
1734    /// # Example
1735    /// ```
1736    /// # use google_cloud_tpu_v2::builder::tpu::GetRuntimeVersion;
1737    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1738    ///
1739    /// let builder = prepare_request_builder();
1740    /// let response = builder.send().await?;
1741    /// # Ok(()) }
1742    ///
1743    /// fn prepare_request_builder() -> GetRuntimeVersion {
1744    ///   # panic!();
1745    ///   // ... details omitted ...
1746    /// }
1747    /// ```
1748    #[derive(Clone, Debug)]
1749    pub struct GetRuntimeVersion(RequestBuilder<crate::model::GetRuntimeVersionRequest>);
1750
1751    impl GetRuntimeVersion {
1752        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1753            Self(RequestBuilder::new(stub))
1754        }
1755
1756        /// Sets the full request, replacing any prior values.
1757        pub fn with_request<V: Into<crate::model::GetRuntimeVersionRequest>>(
1758            mut self,
1759            v: V,
1760        ) -> Self {
1761            self.0.request = v.into();
1762            self
1763        }
1764
1765        /// Sets all the options, replacing any prior values.
1766        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1767            self.0.options = v.into();
1768            self
1769        }
1770
1771        /// Sends the request.
1772        pub async fn send(self) -> Result<crate::model::RuntimeVersion> {
1773            (*self.0.stub)
1774                .get_runtime_version(self.0.request, self.0.options)
1775                .await
1776                .map(crate::Response::into_body)
1777        }
1778
1779        /// Sets the value of [name][crate::model::GetRuntimeVersionRequest::name].
1780        ///
1781        /// This is a **required** field for requests.
1782        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1783            self.0.request.name = v.into();
1784            self
1785        }
1786    }
1787
1788    #[doc(hidden)]
1789    impl crate::RequestBuilder for GetRuntimeVersion {
1790        fn request_options(&mut self) -> &mut crate::RequestOptions {
1791            &mut self.0.options
1792        }
1793    }
1794
1795    /// The request builder for [Tpu::get_guest_attributes][crate::client::Tpu::get_guest_attributes] calls.
1796    ///
1797    /// # Example
1798    /// ```
1799    /// # use google_cloud_tpu_v2::builder::tpu::GetGuestAttributes;
1800    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1801    ///
1802    /// let builder = prepare_request_builder();
1803    /// let response = builder.send().await?;
1804    /// # Ok(()) }
1805    ///
1806    /// fn prepare_request_builder() -> GetGuestAttributes {
1807    ///   # panic!();
1808    ///   // ... details omitted ...
1809    /// }
1810    /// ```
1811    #[derive(Clone, Debug)]
1812    pub struct GetGuestAttributes(RequestBuilder<crate::model::GetGuestAttributesRequest>);
1813
1814    impl GetGuestAttributes {
1815        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1816            Self(RequestBuilder::new(stub))
1817        }
1818
1819        /// Sets the full request, replacing any prior values.
1820        pub fn with_request<V: Into<crate::model::GetGuestAttributesRequest>>(
1821            mut self,
1822            v: V,
1823        ) -> Self {
1824            self.0.request = v.into();
1825            self
1826        }
1827
1828        /// Sets all the options, replacing any prior values.
1829        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1830            self.0.options = v.into();
1831            self
1832        }
1833
1834        /// Sends the request.
1835        pub async fn send(self) -> Result<crate::model::GetGuestAttributesResponse> {
1836            (*self.0.stub)
1837                .get_guest_attributes(self.0.request, self.0.options)
1838                .await
1839                .map(crate::Response::into_body)
1840        }
1841
1842        /// Sets the value of [name][crate::model::GetGuestAttributesRequest::name].
1843        ///
1844        /// This is a **required** field for requests.
1845        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1846            self.0.request.name = v.into();
1847            self
1848        }
1849
1850        /// Sets the value of [query_path][crate::model::GetGuestAttributesRequest::query_path].
1851        pub fn set_query_path<T: Into<std::string::String>>(mut self, v: T) -> Self {
1852            self.0.request.query_path = v.into();
1853            self
1854        }
1855
1856        /// Sets the value of [worker_ids][crate::model::GetGuestAttributesRequest::worker_ids].
1857        pub fn set_worker_ids<T, V>(mut self, v: T) -> Self
1858        where
1859            T: std::iter::IntoIterator<Item = V>,
1860            V: std::convert::Into<std::string::String>,
1861        {
1862            use std::iter::Iterator;
1863            self.0.request.worker_ids = v.into_iter().map(|i| i.into()).collect();
1864            self
1865        }
1866    }
1867
1868    #[doc(hidden)]
1869    impl crate::RequestBuilder for GetGuestAttributes {
1870        fn request_options(&mut self) -> &mut crate::RequestOptions {
1871            &mut self.0.options
1872        }
1873    }
1874
1875    /// The request builder for [Tpu::list_locations][crate::client::Tpu::list_locations] calls.
1876    ///
1877    /// # Example
1878    /// ```
1879    /// # use google_cloud_tpu_v2::builder::tpu::ListLocations;
1880    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1881    /// use google_cloud_gax::paginator::ItemPaginator;
1882    ///
1883    /// let builder = prepare_request_builder();
1884    /// let mut items = builder.by_item();
1885    /// while let Some(result) = items.next().await {
1886    ///   let item = result?;
1887    /// }
1888    /// # Ok(()) }
1889    ///
1890    /// fn prepare_request_builder() -> ListLocations {
1891    ///   # panic!();
1892    ///   // ... details omitted ...
1893    /// }
1894    /// ```
1895    #[derive(Clone, Debug)]
1896    pub struct ListLocations(RequestBuilder<google_cloud_location::model::ListLocationsRequest>);
1897
1898    impl ListLocations {
1899        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
1900            Self(RequestBuilder::new(stub))
1901        }
1902
1903        /// Sets the full request, replacing any prior values.
1904        pub fn with_request<V: Into<google_cloud_location::model::ListLocationsRequest>>(
1905            mut self,
1906            v: V,
1907        ) -> Self {
1908            self.0.request = v.into();
1909            self
1910        }
1911
1912        /// Sets all the options, replacing any prior values.
1913        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1914            self.0.options = v.into();
1915            self
1916        }
1917
1918        /// Sends the request.
1919        pub async fn send(self) -> Result<google_cloud_location::model::ListLocationsResponse> {
1920            (*self.0.stub)
1921                .list_locations(self.0.request, self.0.options)
1922                .await
1923                .map(crate::Response::into_body)
1924        }
1925
1926        /// Streams each page in the collection.
1927        pub fn by_page(
1928            self,
1929        ) -> impl google_cloud_gax::paginator::Paginator<
1930            google_cloud_location::model::ListLocationsResponse,
1931            crate::Error,
1932        > {
1933            use std::clone::Clone;
1934            let token = self.0.request.page_token.clone();
1935            let execute = move |token: String| {
1936                let mut builder = self.clone();
1937                builder.0.request = builder.0.request.set_page_token(token);
1938                builder.send()
1939            };
1940            google_cloud_gax::paginator::internal::new_paginator(token, execute)
1941        }
1942
1943        /// Streams each item in the collection.
1944        pub fn by_item(
1945            self,
1946        ) -> impl google_cloud_gax::paginator::ItemPaginator<
1947            google_cloud_location::model::ListLocationsResponse,
1948            crate::Error,
1949        > {
1950            use google_cloud_gax::paginator::Paginator;
1951            self.by_page().items()
1952        }
1953
1954        /// Sets the value of [name][google_cloud_location::model::ListLocationsRequest::name].
1955        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1956            self.0.request.name = v.into();
1957            self
1958        }
1959
1960        /// Sets the value of [filter][google_cloud_location::model::ListLocationsRequest::filter].
1961        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1962            self.0.request.filter = v.into();
1963            self
1964        }
1965
1966        /// Sets the value of [page_size][google_cloud_location::model::ListLocationsRequest::page_size].
1967        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1968            self.0.request.page_size = v.into();
1969            self
1970        }
1971
1972        /// Sets the value of [page_token][google_cloud_location::model::ListLocationsRequest::page_token].
1973        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1974            self.0.request.page_token = v.into();
1975            self
1976        }
1977    }
1978
1979    #[doc(hidden)]
1980    impl crate::RequestBuilder for ListLocations {
1981        fn request_options(&mut self) -> &mut crate::RequestOptions {
1982            &mut self.0.options
1983        }
1984    }
1985
1986    /// The request builder for [Tpu::get_location][crate::client::Tpu::get_location] calls.
1987    ///
1988    /// # Example
1989    /// ```
1990    /// # use google_cloud_tpu_v2::builder::tpu::GetLocation;
1991    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
1992    ///
1993    /// let builder = prepare_request_builder();
1994    /// let response = builder.send().await?;
1995    /// # Ok(()) }
1996    ///
1997    /// fn prepare_request_builder() -> GetLocation {
1998    ///   # panic!();
1999    ///   // ... details omitted ...
2000    /// }
2001    /// ```
2002    #[derive(Clone, Debug)]
2003    pub struct GetLocation(RequestBuilder<google_cloud_location::model::GetLocationRequest>);
2004
2005    impl GetLocation {
2006        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
2007            Self(RequestBuilder::new(stub))
2008        }
2009
2010        /// Sets the full request, replacing any prior values.
2011        pub fn with_request<V: Into<google_cloud_location::model::GetLocationRequest>>(
2012            mut self,
2013            v: V,
2014        ) -> Self {
2015            self.0.request = v.into();
2016            self
2017        }
2018
2019        /// Sets all the options, replacing any prior values.
2020        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2021            self.0.options = v.into();
2022            self
2023        }
2024
2025        /// Sends the request.
2026        pub async fn send(self) -> Result<google_cloud_location::model::Location> {
2027            (*self.0.stub)
2028                .get_location(self.0.request, self.0.options)
2029                .await
2030                .map(crate::Response::into_body)
2031        }
2032
2033        /// Sets the value of [name][google_cloud_location::model::GetLocationRequest::name].
2034        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2035            self.0.request.name = v.into();
2036            self
2037        }
2038    }
2039
2040    #[doc(hidden)]
2041    impl crate::RequestBuilder for GetLocation {
2042        fn request_options(&mut self) -> &mut crate::RequestOptions {
2043            &mut self.0.options
2044        }
2045    }
2046
2047    /// The request builder for [Tpu::list_operations][crate::client::Tpu::list_operations] calls.
2048    ///
2049    /// # Example
2050    /// ```
2051    /// # use google_cloud_tpu_v2::builder::tpu::ListOperations;
2052    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
2053    /// use google_cloud_gax::paginator::ItemPaginator;
2054    ///
2055    /// let builder = prepare_request_builder();
2056    /// let mut items = builder.by_item();
2057    /// while let Some(result) = items.next().await {
2058    ///   let item = result?;
2059    /// }
2060    /// # Ok(()) }
2061    ///
2062    /// fn prepare_request_builder() -> ListOperations {
2063    ///   # panic!();
2064    ///   // ... details omitted ...
2065    /// }
2066    /// ```
2067    #[derive(Clone, Debug)]
2068    pub struct ListOperations(
2069        RequestBuilder<google_cloud_longrunning::model::ListOperationsRequest>,
2070    );
2071
2072    impl ListOperations {
2073        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
2074            Self(RequestBuilder::new(stub))
2075        }
2076
2077        /// Sets the full request, replacing any prior values.
2078        pub fn with_request<V: Into<google_cloud_longrunning::model::ListOperationsRequest>>(
2079            mut self,
2080            v: V,
2081        ) -> Self {
2082            self.0.request = v.into();
2083            self
2084        }
2085
2086        /// Sets all the options, replacing any prior values.
2087        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2088            self.0.options = v.into();
2089            self
2090        }
2091
2092        /// Sends the request.
2093        pub async fn send(self) -> Result<google_cloud_longrunning::model::ListOperationsResponse> {
2094            (*self.0.stub)
2095                .list_operations(self.0.request, self.0.options)
2096                .await
2097                .map(crate::Response::into_body)
2098        }
2099
2100        /// Streams each page in the collection.
2101        pub fn by_page(
2102            self,
2103        ) -> impl google_cloud_gax::paginator::Paginator<
2104            google_cloud_longrunning::model::ListOperationsResponse,
2105            crate::Error,
2106        > {
2107            use std::clone::Clone;
2108            let token = self.0.request.page_token.clone();
2109            let execute = move |token: String| {
2110                let mut builder = self.clone();
2111                builder.0.request = builder.0.request.set_page_token(token);
2112                builder.send()
2113            };
2114            google_cloud_gax::paginator::internal::new_paginator(token, execute)
2115        }
2116
2117        /// Streams each item in the collection.
2118        pub fn by_item(
2119            self,
2120        ) -> impl google_cloud_gax::paginator::ItemPaginator<
2121            google_cloud_longrunning::model::ListOperationsResponse,
2122            crate::Error,
2123        > {
2124            use google_cloud_gax::paginator::Paginator;
2125            self.by_page().items()
2126        }
2127
2128        /// Sets the value of [name][google_cloud_longrunning::model::ListOperationsRequest::name].
2129        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2130            self.0.request.name = v.into();
2131            self
2132        }
2133
2134        /// Sets the value of [filter][google_cloud_longrunning::model::ListOperationsRequest::filter].
2135        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
2136            self.0.request.filter = v.into();
2137            self
2138        }
2139
2140        /// Sets the value of [page_size][google_cloud_longrunning::model::ListOperationsRequest::page_size].
2141        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
2142            self.0.request.page_size = v.into();
2143            self
2144        }
2145
2146        /// Sets the value of [page_token][google_cloud_longrunning::model::ListOperationsRequest::page_token].
2147        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
2148            self.0.request.page_token = v.into();
2149            self
2150        }
2151
2152        /// Sets the value of [return_partial_success][google_cloud_longrunning::model::ListOperationsRequest::return_partial_success].
2153        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
2154            self.0.request.return_partial_success = v.into();
2155            self
2156        }
2157    }
2158
2159    #[doc(hidden)]
2160    impl crate::RequestBuilder for ListOperations {
2161        fn request_options(&mut self) -> &mut crate::RequestOptions {
2162            &mut self.0.options
2163        }
2164    }
2165
2166    /// The request builder for [Tpu::get_operation][crate::client::Tpu::get_operation] calls.
2167    ///
2168    /// # Example
2169    /// ```
2170    /// # use google_cloud_tpu_v2::builder::tpu::GetOperation;
2171    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
2172    ///
2173    /// let builder = prepare_request_builder();
2174    /// let response = builder.send().await?;
2175    /// # Ok(()) }
2176    ///
2177    /// fn prepare_request_builder() -> GetOperation {
2178    ///   # panic!();
2179    ///   // ... details omitted ...
2180    /// }
2181    /// ```
2182    #[derive(Clone, Debug)]
2183    pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
2184
2185    impl GetOperation {
2186        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
2187            Self(RequestBuilder::new(stub))
2188        }
2189
2190        /// Sets the full request, replacing any prior values.
2191        pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
2192            mut self,
2193            v: V,
2194        ) -> Self {
2195            self.0.request = v.into();
2196            self
2197        }
2198
2199        /// Sets all the options, replacing any prior values.
2200        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2201            self.0.options = v.into();
2202            self
2203        }
2204
2205        /// Sends the request.
2206        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
2207            (*self.0.stub)
2208                .get_operation(self.0.request, self.0.options)
2209                .await
2210                .map(crate::Response::into_body)
2211        }
2212
2213        /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
2214        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2215            self.0.request.name = v.into();
2216            self
2217        }
2218    }
2219
2220    #[doc(hidden)]
2221    impl crate::RequestBuilder for GetOperation {
2222        fn request_options(&mut self) -> &mut crate::RequestOptions {
2223            &mut self.0.options
2224        }
2225    }
2226
2227    /// The request builder for [Tpu::delete_operation][crate::client::Tpu::delete_operation] calls.
2228    ///
2229    /// # Example
2230    /// ```
2231    /// # use google_cloud_tpu_v2::builder::tpu::DeleteOperation;
2232    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
2233    ///
2234    /// let builder = prepare_request_builder();
2235    /// let response = builder.send().await?;
2236    /// # Ok(()) }
2237    ///
2238    /// fn prepare_request_builder() -> DeleteOperation {
2239    ///   # panic!();
2240    ///   // ... details omitted ...
2241    /// }
2242    /// ```
2243    #[derive(Clone, Debug)]
2244    pub struct DeleteOperation(
2245        RequestBuilder<google_cloud_longrunning::model::DeleteOperationRequest>,
2246    );
2247
2248    impl DeleteOperation {
2249        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
2250            Self(RequestBuilder::new(stub))
2251        }
2252
2253        /// Sets the full request, replacing any prior values.
2254        pub fn with_request<V: Into<google_cloud_longrunning::model::DeleteOperationRequest>>(
2255            mut self,
2256            v: V,
2257        ) -> Self {
2258            self.0.request = v.into();
2259            self
2260        }
2261
2262        /// Sets all the options, replacing any prior values.
2263        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2264            self.0.options = v.into();
2265            self
2266        }
2267
2268        /// Sends the request.
2269        pub async fn send(self) -> Result<()> {
2270            (*self.0.stub)
2271                .delete_operation(self.0.request, self.0.options)
2272                .await
2273                .map(crate::Response::into_body)
2274        }
2275
2276        /// Sets the value of [name][google_cloud_longrunning::model::DeleteOperationRequest::name].
2277        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2278            self.0.request.name = v.into();
2279            self
2280        }
2281    }
2282
2283    #[doc(hidden)]
2284    impl crate::RequestBuilder for DeleteOperation {
2285        fn request_options(&mut self) -> &mut crate::RequestOptions {
2286            &mut self.0.options
2287        }
2288    }
2289
2290    /// The request builder for [Tpu::cancel_operation][crate::client::Tpu::cancel_operation] calls.
2291    ///
2292    /// # Example
2293    /// ```
2294    /// # use google_cloud_tpu_v2::builder::tpu::CancelOperation;
2295    /// # async fn sample() -> google_cloud_tpu_v2::Result<()> {
2296    ///
2297    /// let builder = prepare_request_builder();
2298    /// let response = builder.send().await?;
2299    /// # Ok(()) }
2300    ///
2301    /// fn prepare_request_builder() -> CancelOperation {
2302    ///   # panic!();
2303    ///   // ... details omitted ...
2304    /// }
2305    /// ```
2306    #[derive(Clone, Debug)]
2307    pub struct CancelOperation(
2308        RequestBuilder<google_cloud_longrunning::model::CancelOperationRequest>,
2309    );
2310
2311    impl CancelOperation {
2312        pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Tpu>) -> Self {
2313            Self(RequestBuilder::new(stub))
2314        }
2315
2316        /// Sets the full request, replacing any prior values.
2317        pub fn with_request<V: Into<google_cloud_longrunning::model::CancelOperationRequest>>(
2318            mut self,
2319            v: V,
2320        ) -> Self {
2321            self.0.request = v.into();
2322            self
2323        }
2324
2325        /// Sets all the options, replacing any prior values.
2326        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
2327            self.0.options = v.into();
2328            self
2329        }
2330
2331        /// Sends the request.
2332        pub async fn send(self) -> Result<()> {
2333            (*self.0.stub)
2334                .cancel_operation(self.0.request, self.0.options)
2335                .await
2336                .map(crate::Response::into_body)
2337        }
2338
2339        /// Sets the value of [name][google_cloud_longrunning::model::CancelOperationRequest::name].
2340        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2341            self.0.request.name = v.into();
2342            self
2343        }
2344    }
2345
2346    #[doc(hidden)]
2347    impl crate::RequestBuilder for CancelOperation {
2348        fn request_options(&mut self) -> &mut crate::RequestOptions {
2349            &mut self.0.options
2350        }
2351    }
2352}