Skip to main content

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
17/// Request and client builders for [Executions][crate::client::Executions].
18pub mod executions {
19    use crate::Result;
20
21    /// A builder for [Executions][crate::client::Executions].
22    ///
23    /// ```
24    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25    /// # use google_cloud_workflows_executions_v1::*;
26    /// # use builder::executions::ClientBuilder;
27    /// # use client::Executions;
28    /// let builder : ClientBuilder = Executions::builder();
29    /// let client = builder
30    ///     .with_endpoint("https://workflowexecutions.googleapis.com")
31    ///     .build().await?;
32    /// # Ok(()) }
33    /// ```
34    pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36    pub(crate) mod client {
37        use super::super::super::client::Executions;
38        pub struct Factory;
39        impl crate::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            ) -> crate::ClientBuilderResult<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: crate::RequestOptions,
57    }
58
59    impl<R> RequestBuilder<R>
60    where
61        R: std::default::Default,
62    {
63        pub(crate) fn new(
64            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: crate::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [Executions::list_executions][crate::client::Executions::list_executions] calls.
75    ///
76    /// # Example
77    /// ```
78    /// # use google_cloud_workflows_executions_v1::builder::executions::ListExecutions;
79    /// # async fn sample() -> google_cloud_workflows_executions_v1::Result<()> {
80    /// use google_cloud_gax::paginator::ItemPaginator;
81    ///
82    /// let builder = prepare_request_builder();
83    /// let mut items = builder.by_item();
84    /// while let Some(result) = items.next().await {
85    ///   let item = result?;
86    /// }
87    /// # Ok(()) }
88    ///
89    /// fn prepare_request_builder() -> ListExecutions {
90    ///   # panic!();
91    ///   // ... details omitted ...
92    /// }
93    /// ```
94    #[derive(Clone, Debug)]
95    pub struct ListExecutions(RequestBuilder<crate::model::ListExecutionsRequest>);
96
97    impl ListExecutions {
98        pub(crate) fn new(
99            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
100        ) -> Self {
101            Self(RequestBuilder::new(stub))
102        }
103
104        /// Sets the full request, replacing any prior values.
105        pub fn with_request<V: Into<crate::model::ListExecutionsRequest>>(mut self, v: V) -> Self {
106            self.0.request = v.into();
107            self
108        }
109
110        /// Sets all the options, replacing any prior values.
111        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
112            self.0.options = v.into();
113            self
114        }
115
116        /// Sends the request.
117        pub async fn send(self) -> Result<crate::model::ListExecutionsResponse> {
118            (*self.0.stub)
119                .list_executions(self.0.request, self.0.options)
120                .await
121                .map(crate::Response::into_body)
122        }
123
124        /// Streams each page in the collection.
125        pub fn by_page(
126            self,
127        ) -> impl google_cloud_gax::paginator::Paginator<
128            crate::model::ListExecutionsResponse,
129            crate::Error,
130        > {
131            use std::clone::Clone;
132            let token = self.0.request.page_token.clone();
133            let execute = move |token: String| {
134                let mut builder = self.clone();
135                builder.0.request = builder.0.request.set_page_token(token);
136                builder.send()
137            };
138            google_cloud_gax::paginator::internal::new_paginator(token, execute)
139        }
140
141        /// Streams each item in the collection.
142        pub fn by_item(
143            self,
144        ) -> impl google_cloud_gax::paginator::ItemPaginator<
145            crate::model::ListExecutionsResponse,
146            crate::Error,
147        > {
148            use google_cloud_gax::paginator::Paginator;
149            self.by_page().items()
150        }
151
152        /// Sets the value of [parent][crate::model::ListExecutionsRequest::parent].
153        ///
154        /// This is a **required** field for requests.
155        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
156            self.0.request.parent = v.into();
157            self
158        }
159
160        /// Sets the value of [page_size][crate::model::ListExecutionsRequest::page_size].
161        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
162            self.0.request.page_size = v.into();
163            self
164        }
165
166        /// Sets the value of [page_token][crate::model::ListExecutionsRequest::page_token].
167        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
168            self.0.request.page_token = v.into();
169            self
170        }
171
172        /// Sets the value of [view][crate::model::ListExecutionsRequest::view].
173        pub fn set_view<T: Into<crate::model::ExecutionView>>(mut self, v: T) -> Self {
174            self.0.request.view = v.into();
175            self
176        }
177
178        /// Sets the value of [filter][crate::model::ListExecutionsRequest::filter].
179        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
180            self.0.request.filter = v.into();
181            self
182        }
183
184        /// Sets the value of [order_by][crate::model::ListExecutionsRequest::order_by].
185        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
186            self.0.request.order_by = v.into();
187            self
188        }
189    }
190
191    #[doc(hidden)]
192    impl crate::RequestBuilder for ListExecutions {
193        fn request_options(&mut self) -> &mut crate::RequestOptions {
194            &mut self.0.options
195        }
196    }
197
198    /// The request builder for [Executions::create_execution][crate::client::Executions::create_execution] calls.
199    ///
200    /// # Example
201    /// ```
202    /// # use google_cloud_workflows_executions_v1::builder::executions::CreateExecution;
203    /// # async fn sample() -> google_cloud_workflows_executions_v1::Result<()> {
204    ///
205    /// let builder = prepare_request_builder();
206    /// let response = builder.send().await?;
207    /// # Ok(()) }
208    ///
209    /// fn prepare_request_builder() -> CreateExecution {
210    ///   # panic!();
211    ///   // ... details omitted ...
212    /// }
213    /// ```
214    #[derive(Clone, Debug)]
215    pub struct CreateExecution(RequestBuilder<crate::model::CreateExecutionRequest>);
216
217    impl CreateExecution {
218        pub(crate) fn new(
219            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
220        ) -> Self {
221            Self(RequestBuilder::new(stub))
222        }
223
224        /// Sets the full request, replacing any prior values.
225        pub fn with_request<V: Into<crate::model::CreateExecutionRequest>>(mut self, v: V) -> Self {
226            self.0.request = v.into();
227            self
228        }
229
230        /// Sets all the options, replacing any prior values.
231        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
232            self.0.options = v.into();
233            self
234        }
235
236        /// Sends the request.
237        pub async fn send(self) -> Result<crate::model::Execution> {
238            (*self.0.stub)
239                .create_execution(self.0.request, self.0.options)
240                .await
241                .map(crate::Response::into_body)
242        }
243
244        /// Sets the value of [parent][crate::model::CreateExecutionRequest::parent].
245        ///
246        /// This is a **required** field for requests.
247        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
248            self.0.request.parent = v.into();
249            self
250        }
251
252        /// Sets the value of [execution][crate::model::CreateExecutionRequest::execution].
253        ///
254        /// This is a **required** field for requests.
255        pub fn set_execution<T>(mut self, v: T) -> Self
256        where
257            T: std::convert::Into<crate::model::Execution>,
258        {
259            self.0.request.execution = std::option::Option::Some(v.into());
260            self
261        }
262
263        /// Sets or clears the value of [execution][crate::model::CreateExecutionRequest::execution].
264        ///
265        /// This is a **required** field for requests.
266        pub fn set_or_clear_execution<T>(mut self, v: std::option::Option<T>) -> Self
267        where
268            T: std::convert::Into<crate::model::Execution>,
269        {
270            self.0.request.execution = v.map(|x| x.into());
271            self
272        }
273    }
274
275    #[doc(hidden)]
276    impl crate::RequestBuilder for CreateExecution {
277        fn request_options(&mut self) -> &mut crate::RequestOptions {
278            &mut self.0.options
279        }
280    }
281
282    /// The request builder for [Executions::get_execution][crate::client::Executions::get_execution] calls.
283    ///
284    /// # Example
285    /// ```
286    /// # use google_cloud_workflows_executions_v1::builder::executions::GetExecution;
287    /// # async fn sample() -> google_cloud_workflows_executions_v1::Result<()> {
288    ///
289    /// let builder = prepare_request_builder();
290    /// let response = builder.send().await?;
291    /// # Ok(()) }
292    ///
293    /// fn prepare_request_builder() -> GetExecution {
294    ///   # panic!();
295    ///   // ... details omitted ...
296    /// }
297    /// ```
298    #[derive(Clone, Debug)]
299    pub struct GetExecution(RequestBuilder<crate::model::GetExecutionRequest>);
300
301    impl GetExecution {
302        pub(crate) fn new(
303            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
304        ) -> Self {
305            Self(RequestBuilder::new(stub))
306        }
307
308        /// Sets the full request, replacing any prior values.
309        pub fn with_request<V: Into<crate::model::GetExecutionRequest>>(mut self, v: V) -> Self {
310            self.0.request = v.into();
311            self
312        }
313
314        /// Sets all the options, replacing any prior values.
315        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
316            self.0.options = v.into();
317            self
318        }
319
320        /// Sends the request.
321        pub async fn send(self) -> Result<crate::model::Execution> {
322            (*self.0.stub)
323                .get_execution(self.0.request, self.0.options)
324                .await
325                .map(crate::Response::into_body)
326        }
327
328        /// Sets the value of [name][crate::model::GetExecutionRequest::name].
329        ///
330        /// This is a **required** field for requests.
331        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
332            self.0.request.name = v.into();
333            self
334        }
335
336        /// Sets the value of [view][crate::model::GetExecutionRequest::view].
337        pub fn set_view<T: Into<crate::model::ExecutionView>>(mut self, v: T) -> Self {
338            self.0.request.view = v.into();
339            self
340        }
341    }
342
343    #[doc(hidden)]
344    impl crate::RequestBuilder for GetExecution {
345        fn request_options(&mut self) -> &mut crate::RequestOptions {
346            &mut self.0.options
347        }
348    }
349
350    /// The request builder for [Executions::cancel_execution][crate::client::Executions::cancel_execution] calls.
351    ///
352    /// # Example
353    /// ```
354    /// # use google_cloud_workflows_executions_v1::builder::executions::CancelExecution;
355    /// # async fn sample() -> google_cloud_workflows_executions_v1::Result<()> {
356    ///
357    /// let builder = prepare_request_builder();
358    /// let response = builder.send().await?;
359    /// # 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<crate::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(crate::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 crate::RequestBuilder for CancelExecution {
407        fn request_options(&mut self) -> &mut crate::RequestOptions {
408            &mut self.0.options
409        }
410    }
411}