google_cloud_workflows_executions_v1/
builder.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17pub mod executions {
18    use crate::Result;
19
20    /// A builder for [Executions][crate::client::Executions].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_workflows_executions_v1::*;
25    /// # use builder::executions::ClientBuilder;
26    /// # use client::Executions;
27    /// let builder : ClientBuilder = Executions::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://workflowexecutions.googleapis.com")
30    ///     .build().await?;
31    /// # gax::client_builder::Result::<()>::Ok(()) });
32    /// ```
33    pub type ClientBuilder =
34        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36    pub(crate) mod client {
37        use super::super::super::client::Executions;
38        pub struct Factory;
39        impl gax::client_builder::internal::ClientFactory for Factory {
40            type Client = Executions;
41            type Credentials = gaxi::options::Credentials;
42            async fn build(
43                self,
44                config: gaxi::options::ClientConfig,
45            ) -> gax::client_builder::Result<Self::Client> {
46                Self::Client::new(config).await
47            }
48        }
49    }
50
51    /// Common implementation for [crate::client::Executions] 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::Executions>,
55        request: R,
56        options: gax::options::RequestOptions,
57    }
58
59    impl<R> RequestBuilder<R>
60    where
61        R: std::default::Default,
62    {
63        pub(crate) fn new(
64            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: gax::options::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [Executions::list_executions][crate::client::Executions::list_executions] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_workflows_executions_v1::builder;
79    /// use builder::executions::ListExecutions;
80    /// # tokio_test::block_on(async {
81    /// use gax::paginator::ItemPaginator;
82    ///
83    /// let builder = prepare_request_builder();
84    /// let mut items = builder.by_item();
85    /// while let Some(result) = items.next().await {
86    ///   let item = result?;
87    /// }
88    /// # gax::Result::<()>::Ok(()) });
89    ///
90    /// fn prepare_request_builder() -> ListExecutions {
91    ///   # panic!();
92    ///   // ... details omitted ...
93    /// }
94    /// ```
95    #[derive(Clone, Debug)]
96    pub struct ListExecutions(RequestBuilder<crate::model::ListExecutionsRequest>);
97
98    impl ListExecutions {
99        pub(crate) fn new(
100            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
101        ) -> Self {
102            Self(RequestBuilder::new(stub))
103        }
104
105        /// Sets the full request, replacing any prior values.
106        pub fn with_request<V: Into<crate::model::ListExecutionsRequest>>(mut self, v: V) -> Self {
107            self.0.request = v.into();
108            self
109        }
110
111        /// Sets all the options, replacing any prior values.
112        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
113            self.0.options = v.into();
114            self
115        }
116
117        /// Sends the request.
118        pub async fn send(self) -> Result<crate::model::ListExecutionsResponse> {
119            (*self.0.stub)
120                .list_executions(self.0.request, self.0.options)
121                .await
122                .map(gax::response::Response::into_body)
123        }
124
125        /// Streams each page in the collection.
126        pub fn by_page(
127            self,
128        ) -> impl gax::paginator::Paginator<crate::model::ListExecutionsResponse, gax::error::Error>
129        {
130            use std::clone::Clone;
131            let token = self.0.request.page_token.clone();
132            let execute = move |token: String| {
133                let mut builder = self.clone();
134                builder.0.request = builder.0.request.set_page_token(token);
135                builder.send()
136            };
137            gax::paginator::internal::new_paginator(token, execute)
138        }
139
140        /// Streams each item in the collection.
141        pub fn by_item(
142            self,
143        ) -> impl gax::paginator::ItemPaginator<crate::model::ListExecutionsResponse, gax::error::Error>
144        {
145            use gax::paginator::Paginator;
146            self.by_page().items()
147        }
148
149        /// Sets the value of [parent][crate::model::ListExecutionsRequest::parent].
150        ///
151        /// This is a **required** field for requests.
152        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
153            self.0.request.parent = v.into();
154            self
155        }
156
157        /// Sets the value of [page_size][crate::model::ListExecutionsRequest::page_size].
158        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
159            self.0.request.page_size = v.into();
160            self
161        }
162
163        /// Sets the value of [page_token][crate::model::ListExecutionsRequest::page_token].
164        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
165            self.0.request.page_token = v.into();
166            self
167        }
168
169        /// Sets the value of [view][crate::model::ListExecutionsRequest::view].
170        pub fn set_view<T: Into<crate::model::ExecutionView>>(mut self, v: T) -> Self {
171            self.0.request.view = v.into();
172            self
173        }
174
175        /// Sets the value of [filter][crate::model::ListExecutionsRequest::filter].
176        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
177            self.0.request.filter = v.into();
178            self
179        }
180
181        /// Sets the value of [order_by][crate::model::ListExecutionsRequest::order_by].
182        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
183            self.0.request.order_by = v.into();
184            self
185        }
186    }
187
188    #[doc(hidden)]
189    impl gax::options::internal::RequestBuilder for ListExecutions {
190        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
191            &mut self.0.options
192        }
193    }
194
195    /// The request builder for [Executions::create_execution][crate::client::Executions::create_execution] calls.
196    ///
197    /// # Example
198    /// ```no_run
199    /// # use google_cloud_workflows_executions_v1::builder;
200    /// use builder::executions::CreateExecution;
201    /// # tokio_test::block_on(async {
202    ///
203    /// let builder = prepare_request_builder();
204    /// let response = builder.send().await?;
205    /// # gax::Result::<()>::Ok(()) });
206    ///
207    /// fn prepare_request_builder() -> CreateExecution {
208    ///   # panic!();
209    ///   // ... details omitted ...
210    /// }
211    /// ```
212    #[derive(Clone, Debug)]
213    pub struct CreateExecution(RequestBuilder<crate::model::CreateExecutionRequest>);
214
215    impl CreateExecution {
216        pub(crate) fn new(
217            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
218        ) -> Self {
219            Self(RequestBuilder::new(stub))
220        }
221
222        /// Sets the full request, replacing any prior values.
223        pub fn with_request<V: Into<crate::model::CreateExecutionRequest>>(mut self, v: V) -> Self {
224            self.0.request = v.into();
225            self
226        }
227
228        /// Sets all the options, replacing any prior values.
229        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
230            self.0.options = v.into();
231            self
232        }
233
234        /// Sends the request.
235        pub async fn send(self) -> Result<crate::model::Execution> {
236            (*self.0.stub)
237                .create_execution(self.0.request, self.0.options)
238                .await
239                .map(gax::response::Response::into_body)
240        }
241
242        /// Sets the value of [parent][crate::model::CreateExecutionRequest::parent].
243        ///
244        /// This is a **required** field for requests.
245        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
246            self.0.request.parent = v.into();
247            self
248        }
249
250        /// Sets the value of [execution][crate::model::CreateExecutionRequest::execution].
251        ///
252        /// This is a **required** field for requests.
253        pub fn set_execution<T>(mut self, v: T) -> Self
254        where
255            T: std::convert::Into<crate::model::Execution>,
256        {
257            self.0.request.execution = std::option::Option::Some(v.into());
258            self
259        }
260
261        /// Sets or clears the value of [execution][crate::model::CreateExecutionRequest::execution].
262        ///
263        /// This is a **required** field for requests.
264        pub fn set_or_clear_execution<T>(mut self, v: std::option::Option<T>) -> Self
265        where
266            T: std::convert::Into<crate::model::Execution>,
267        {
268            self.0.request.execution = v.map(|x| x.into());
269            self
270        }
271    }
272
273    #[doc(hidden)]
274    impl gax::options::internal::RequestBuilder for CreateExecution {
275        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
276            &mut self.0.options
277        }
278    }
279
280    /// The request builder for [Executions::get_execution][crate::client::Executions::get_execution] calls.
281    ///
282    /// # Example
283    /// ```no_run
284    /// # use google_cloud_workflows_executions_v1::builder;
285    /// use builder::executions::GetExecution;
286    /// # tokio_test::block_on(async {
287    ///
288    /// let builder = prepare_request_builder();
289    /// let response = builder.send().await?;
290    /// # gax::Result::<()>::Ok(()) });
291    ///
292    /// fn prepare_request_builder() -> GetExecution {
293    ///   # panic!();
294    ///   // ... details omitted ...
295    /// }
296    /// ```
297    #[derive(Clone, Debug)]
298    pub struct GetExecution(RequestBuilder<crate::model::GetExecutionRequest>);
299
300    impl GetExecution {
301        pub(crate) fn new(
302            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
303        ) -> Self {
304            Self(RequestBuilder::new(stub))
305        }
306
307        /// Sets the full request, replacing any prior values.
308        pub fn with_request<V: Into<crate::model::GetExecutionRequest>>(mut self, v: V) -> Self {
309            self.0.request = v.into();
310            self
311        }
312
313        /// Sets all the options, replacing any prior values.
314        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
315            self.0.options = v.into();
316            self
317        }
318
319        /// Sends the request.
320        pub async fn send(self) -> Result<crate::model::Execution> {
321            (*self.0.stub)
322                .get_execution(self.0.request, self.0.options)
323                .await
324                .map(gax::response::Response::into_body)
325        }
326
327        /// Sets the value of [name][crate::model::GetExecutionRequest::name].
328        ///
329        /// This is a **required** field for requests.
330        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
331            self.0.request.name = v.into();
332            self
333        }
334
335        /// Sets the value of [view][crate::model::GetExecutionRequest::view].
336        pub fn set_view<T: Into<crate::model::ExecutionView>>(mut self, v: T) -> Self {
337            self.0.request.view = v.into();
338            self
339        }
340    }
341
342    #[doc(hidden)]
343    impl gax::options::internal::RequestBuilder for GetExecution {
344        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
345            &mut self.0.options
346        }
347    }
348
349    /// The request builder for [Executions::cancel_execution][crate::client::Executions::cancel_execution] calls.
350    ///
351    /// # Example
352    /// ```no_run
353    /// # use google_cloud_workflows_executions_v1::builder;
354    /// use builder::executions::CancelExecution;
355    /// # tokio_test::block_on(async {
356    ///
357    /// let builder = prepare_request_builder();
358    /// let response = builder.send().await?;
359    /// # gax::Result::<()>::Ok(()) });
360    ///
361    /// fn prepare_request_builder() -> CancelExecution {
362    ///   # panic!();
363    ///   // ... details omitted ...
364    /// }
365    /// ```
366    #[derive(Clone, Debug)]
367    pub struct CancelExecution(RequestBuilder<crate::model::CancelExecutionRequest>);
368
369    impl CancelExecution {
370        pub(crate) fn new(
371            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
372        ) -> Self {
373            Self(RequestBuilder::new(stub))
374        }
375
376        /// Sets the full request, replacing any prior values.
377        pub fn with_request<V: Into<crate::model::CancelExecutionRequest>>(mut self, v: V) -> Self {
378            self.0.request = v.into();
379            self
380        }
381
382        /// Sets all the options, replacing any prior values.
383        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
384            self.0.options = v.into();
385            self
386        }
387
388        /// Sends the request.
389        pub async fn send(self) -> Result<crate::model::Execution> {
390            (*self.0.stub)
391                .cancel_execution(self.0.request, self.0.options)
392                .await
393                .map(gax::response::Response::into_body)
394        }
395
396        /// Sets the value of [name][crate::model::CancelExecutionRequest::name].
397        ///
398        /// This is a **required** field for requests.
399        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
400            self.0.request.name = v.into();
401            self
402        }
403    }
404
405    #[doc(hidden)]
406    impl gax::options::internal::RequestBuilder for CancelExecution {
407        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
408            &mut self.0.options
409        }
410    }
411}