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
17pub mod executions {
18    use crate::Result;
19
20    /// A builder for [Executions][crate::client::Executions].
21    ///
22    /// ```
23    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
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    /// # 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::Executions;
37        pub struct Factory;
38        impl crate::ClientFactory for Factory {
39            type Client = Executions;
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::Executions] 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::Executions>,
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(
63            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
64        ) -> Self {
65            Self {
66                stub,
67                request: R::default(),
68                options: crate::RequestOptions::default(),
69            }
70        }
71    }
72
73    /// The request builder for [Executions::list_executions][crate::client::Executions::list_executions] calls.
74    ///
75    /// # Example
76    /// ```
77    /// # use google_cloud_workflows_executions_v1::builder::executions::ListExecutions;
78    /// # async fn sample() -> google_cloud_workflows_executions_v1::Result<()> {
79    /// use google_cloud_gax::paginator::ItemPaginator;
80    ///
81    /// let builder = prepare_request_builder();
82    /// let mut items = builder.by_item();
83    /// while let Some(result) = items.next().await {
84    ///   let item = result?;
85    /// }
86    /// # Ok(()) }
87    ///
88    /// fn prepare_request_builder() -> ListExecutions {
89    ///   # panic!();
90    ///   // ... details omitted ...
91    /// }
92    /// ```
93    #[derive(Clone, Debug)]
94    pub struct ListExecutions(RequestBuilder<crate::model::ListExecutionsRequest>);
95
96    impl ListExecutions {
97        pub(crate) fn new(
98            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
99        ) -> Self {
100            Self(RequestBuilder::new(stub))
101        }
102
103        /// Sets the full request, replacing any prior values.
104        pub fn with_request<V: Into<crate::model::ListExecutionsRequest>>(mut self, v: V) -> Self {
105            self.0.request = v.into();
106            self
107        }
108
109        /// Sets all the options, replacing any prior values.
110        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
111            self.0.options = v.into();
112            self
113        }
114
115        /// Sends the request.
116        pub async fn send(self) -> Result<crate::model::ListExecutionsResponse> {
117            (*self.0.stub)
118                .list_executions(self.0.request, self.0.options)
119                .await
120                .map(crate::Response::into_body)
121        }
122
123        /// Streams each page in the collection.
124        pub fn by_page(
125            self,
126        ) -> impl google_cloud_gax::paginator::Paginator<
127            crate::model::ListExecutionsResponse,
128            crate::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            google_cloud_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 google_cloud_gax::paginator::ItemPaginator<
144            crate::model::ListExecutionsResponse,
145            crate::Error,
146        > {
147            use google_cloud_gax::paginator::Paginator;
148            self.by_page().items()
149        }
150
151        /// Sets the value of [parent][crate::model::ListExecutionsRequest::parent].
152        ///
153        /// This is a **required** field for requests.
154        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
155            self.0.request.parent = v.into();
156            self
157        }
158
159        /// Sets the value of [page_size][crate::model::ListExecutionsRequest::page_size].
160        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
161            self.0.request.page_size = v.into();
162            self
163        }
164
165        /// Sets the value of [page_token][crate::model::ListExecutionsRequest::page_token].
166        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
167            self.0.request.page_token = v.into();
168            self
169        }
170
171        /// Sets the value of [view][crate::model::ListExecutionsRequest::view].
172        pub fn set_view<T: Into<crate::model::ExecutionView>>(mut self, v: T) -> Self {
173            self.0.request.view = v.into();
174            self
175        }
176
177        /// Sets the value of [filter][crate::model::ListExecutionsRequest::filter].
178        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
179            self.0.request.filter = v.into();
180            self
181        }
182
183        /// Sets the value of [order_by][crate::model::ListExecutionsRequest::order_by].
184        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
185            self.0.request.order_by = v.into();
186            self
187        }
188    }
189
190    #[doc(hidden)]
191    impl crate::RequestBuilder for ListExecutions {
192        fn request_options(&mut self) -> &mut crate::RequestOptions {
193            &mut self.0.options
194        }
195    }
196
197    /// The request builder for [Executions::create_execution][crate::client::Executions::create_execution] calls.
198    ///
199    /// # Example
200    /// ```
201    /// # use google_cloud_workflows_executions_v1::builder::executions::CreateExecution;
202    /// # async fn sample() -> google_cloud_workflows_executions_v1::Result<()> {
203    ///
204    /// let builder = prepare_request_builder();
205    /// let response = builder.send().await?;
206    /// # Ok(()) }
207    ///
208    /// fn prepare_request_builder() -> CreateExecution {
209    ///   # panic!();
210    ///   // ... details omitted ...
211    /// }
212    /// ```
213    #[derive(Clone, Debug)]
214    pub struct CreateExecution(RequestBuilder<crate::model::CreateExecutionRequest>);
215
216    impl CreateExecution {
217        pub(crate) fn new(
218            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
219        ) -> Self {
220            Self(RequestBuilder::new(stub))
221        }
222
223        /// Sets the full request, replacing any prior values.
224        pub fn with_request<V: Into<crate::model::CreateExecutionRequest>>(mut self, v: V) -> Self {
225            self.0.request = v.into();
226            self
227        }
228
229        /// Sets all the options, replacing any prior values.
230        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
231            self.0.options = v.into();
232            self
233        }
234
235        /// Sends the request.
236        pub async fn send(self) -> Result<crate::model::Execution> {
237            (*self.0.stub)
238                .create_execution(self.0.request, self.0.options)
239                .await
240                .map(crate::Response::into_body)
241        }
242
243        /// Sets the value of [parent][crate::model::CreateExecutionRequest::parent].
244        ///
245        /// This is a **required** field for requests.
246        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
247            self.0.request.parent = v.into();
248            self
249        }
250
251        /// Sets the value of [execution][crate::model::CreateExecutionRequest::execution].
252        ///
253        /// This is a **required** field for requests.
254        pub fn set_execution<T>(mut self, v: T) -> Self
255        where
256            T: std::convert::Into<crate::model::Execution>,
257        {
258            self.0.request.execution = std::option::Option::Some(v.into());
259            self
260        }
261
262        /// Sets or clears the value of [execution][crate::model::CreateExecutionRequest::execution].
263        ///
264        /// This is a **required** field for requests.
265        pub fn set_or_clear_execution<T>(mut self, v: std::option::Option<T>) -> Self
266        where
267            T: std::convert::Into<crate::model::Execution>,
268        {
269            self.0.request.execution = v.map(|x| x.into());
270            self
271        }
272    }
273
274    #[doc(hidden)]
275    impl crate::RequestBuilder for CreateExecution {
276        fn request_options(&mut self) -> &mut crate::RequestOptions {
277            &mut self.0.options
278        }
279    }
280
281    /// The request builder for [Executions::get_execution][crate::client::Executions::get_execution] calls.
282    ///
283    /// # Example
284    /// ```
285    /// # use google_cloud_workflows_executions_v1::builder::executions::GetExecution;
286    /// # async fn sample() -> google_cloud_workflows_executions_v1::Result<()> {
287    ///
288    /// let builder = prepare_request_builder();
289    /// let response = builder.send().await?;
290    /// # 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<crate::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(crate::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 crate::RequestBuilder for GetExecution {
344        fn request_options(&mut self) -> &mut crate::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    /// ```
353    /// # use google_cloud_workflows_executions_v1::builder::executions::CancelExecution;
354    /// # async fn sample() -> google_cloud_workflows_executions_v1::Result<()> {
355    ///
356    /// let builder = prepare_request_builder();
357    /// let response = builder.send().await?;
358    /// # Ok(()) }
359    ///
360    /// fn prepare_request_builder() -> CancelExecution {
361    ///   # panic!();
362    ///   // ... details omitted ...
363    /// }
364    /// ```
365    #[derive(Clone, Debug)]
366    pub struct CancelExecution(RequestBuilder<crate::model::CancelExecutionRequest>);
367
368    impl CancelExecution {
369        pub(crate) fn new(
370            stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
371        ) -> Self {
372            Self(RequestBuilder::new(stub))
373        }
374
375        /// Sets the full request, replacing any prior values.
376        pub fn with_request<V: Into<crate::model::CancelExecutionRequest>>(mut self, v: V) -> Self {
377            self.0.request = v.into();
378            self
379        }
380
381        /// Sets all the options, replacing any prior values.
382        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
383            self.0.options = v.into();
384            self
385        }
386
387        /// Sends the request.
388        pub async fn send(self) -> Result<crate::model::Execution> {
389            (*self.0.stub)
390                .cancel_execution(self.0.request, self.0.options)
391                .await
392                .map(crate::Response::into_body)
393        }
394
395        /// Sets the value of [name][crate::model::CancelExecutionRequest::name].
396        ///
397        /// This is a **required** field for requests.
398        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
399            self.0.request.name = v.into();
400            self
401        }
402    }
403
404    #[doc(hidden)]
405    impl crate::RequestBuilder for CancelExecution {
406        fn request_options(&mut self) -> &mut crate::RequestOptions {
407            &mut self.0.options
408        }
409    }
410}