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() -> 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 =
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 /// ```
78 /// # use google_cloud_workflows_executions_v1::builder::executions::ListExecutions;
79 /// # async fn sample() -> gax::Result<()> {
80 /// use 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<gax::options::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(gax::response::Response::into_body)
122 }
123
124 /// Streams each page in the collection.
125 pub fn by_page(
126 self,
127 ) -> impl gax::paginator::Paginator<crate::model::ListExecutionsResponse, gax::error::Error>
128 {
129 use std::clone::Clone;
130 let token = self.0.request.page_token.clone();
131 let execute = move |token: String| {
132 let mut builder = self.clone();
133 builder.0.request = builder.0.request.set_page_token(token);
134 builder.send()
135 };
136 gax::paginator::internal::new_paginator(token, execute)
137 }
138
139 /// Streams each item in the collection.
140 pub fn by_item(
141 self,
142 ) -> impl gax::paginator::ItemPaginator<crate::model::ListExecutionsResponse, gax::error::Error>
143 {
144 use gax::paginator::Paginator;
145 self.by_page().items()
146 }
147
148 /// Sets the value of [parent][crate::model::ListExecutionsRequest::parent].
149 ///
150 /// This is a **required** field for requests.
151 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
152 self.0.request.parent = v.into();
153 self
154 }
155
156 /// Sets the value of [page_size][crate::model::ListExecutionsRequest::page_size].
157 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
158 self.0.request.page_size = v.into();
159 self
160 }
161
162 /// Sets the value of [page_token][crate::model::ListExecutionsRequest::page_token].
163 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
164 self.0.request.page_token = v.into();
165 self
166 }
167
168 /// Sets the value of [view][crate::model::ListExecutionsRequest::view].
169 pub fn set_view<T: Into<crate::model::ExecutionView>>(mut self, v: T) -> Self {
170 self.0.request.view = v.into();
171 self
172 }
173
174 /// Sets the value of [filter][crate::model::ListExecutionsRequest::filter].
175 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
176 self.0.request.filter = v.into();
177 self
178 }
179
180 /// Sets the value of [order_by][crate::model::ListExecutionsRequest::order_by].
181 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
182 self.0.request.order_by = v.into();
183 self
184 }
185 }
186
187 #[doc(hidden)]
188 impl gax::options::internal::RequestBuilder for ListExecutions {
189 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
190 &mut self.0.options
191 }
192 }
193
194 /// The request builder for [Executions::create_execution][crate::client::Executions::create_execution] calls.
195 ///
196 /// # Example
197 /// ```
198 /// # use google_cloud_workflows_executions_v1::builder::executions::CreateExecution;
199 /// # async fn sample() -> gax::Result<()> {
200 ///
201 /// let builder = prepare_request_builder();
202 /// let response = builder.send().await?;
203 /// # Ok(()) }
204 ///
205 /// fn prepare_request_builder() -> CreateExecution {
206 /// # panic!();
207 /// // ... details omitted ...
208 /// }
209 /// ```
210 #[derive(Clone, Debug)]
211 pub struct CreateExecution(RequestBuilder<crate::model::CreateExecutionRequest>);
212
213 impl CreateExecution {
214 pub(crate) fn new(
215 stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
216 ) -> Self {
217 Self(RequestBuilder::new(stub))
218 }
219
220 /// Sets the full request, replacing any prior values.
221 pub fn with_request<V: Into<crate::model::CreateExecutionRequest>>(mut self, v: V) -> Self {
222 self.0.request = v.into();
223 self
224 }
225
226 /// Sets all the options, replacing any prior values.
227 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
228 self.0.options = v.into();
229 self
230 }
231
232 /// Sends the request.
233 pub async fn send(self) -> Result<crate::model::Execution> {
234 (*self.0.stub)
235 .create_execution(self.0.request, self.0.options)
236 .await
237 .map(gax::response::Response::into_body)
238 }
239
240 /// Sets the value of [parent][crate::model::CreateExecutionRequest::parent].
241 ///
242 /// This is a **required** field for requests.
243 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
244 self.0.request.parent = v.into();
245 self
246 }
247
248 /// Sets the value of [execution][crate::model::CreateExecutionRequest::execution].
249 ///
250 /// This is a **required** field for requests.
251 pub fn set_execution<T>(mut self, v: T) -> Self
252 where
253 T: std::convert::Into<crate::model::Execution>,
254 {
255 self.0.request.execution = std::option::Option::Some(v.into());
256 self
257 }
258
259 /// Sets or clears the value of [execution][crate::model::CreateExecutionRequest::execution].
260 ///
261 /// This is a **required** field for requests.
262 pub fn set_or_clear_execution<T>(mut self, v: std::option::Option<T>) -> Self
263 where
264 T: std::convert::Into<crate::model::Execution>,
265 {
266 self.0.request.execution = v.map(|x| x.into());
267 self
268 }
269 }
270
271 #[doc(hidden)]
272 impl gax::options::internal::RequestBuilder for CreateExecution {
273 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
274 &mut self.0.options
275 }
276 }
277
278 /// The request builder for [Executions::get_execution][crate::client::Executions::get_execution] calls.
279 ///
280 /// # Example
281 /// ```
282 /// # use google_cloud_workflows_executions_v1::builder::executions::GetExecution;
283 /// # async fn sample() -> gax::Result<()> {
284 ///
285 /// let builder = prepare_request_builder();
286 /// let response = builder.send().await?;
287 /// # Ok(()) }
288 ///
289 /// fn prepare_request_builder() -> GetExecution {
290 /// # panic!();
291 /// // ... details omitted ...
292 /// }
293 /// ```
294 #[derive(Clone, Debug)]
295 pub struct GetExecution(RequestBuilder<crate::model::GetExecutionRequest>);
296
297 impl GetExecution {
298 pub(crate) fn new(
299 stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
300 ) -> Self {
301 Self(RequestBuilder::new(stub))
302 }
303
304 /// Sets the full request, replacing any prior values.
305 pub fn with_request<V: Into<crate::model::GetExecutionRequest>>(mut self, v: V) -> Self {
306 self.0.request = v.into();
307 self
308 }
309
310 /// Sets all the options, replacing any prior values.
311 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
312 self.0.options = v.into();
313 self
314 }
315
316 /// Sends the request.
317 pub async fn send(self) -> Result<crate::model::Execution> {
318 (*self.0.stub)
319 .get_execution(self.0.request, self.0.options)
320 .await
321 .map(gax::response::Response::into_body)
322 }
323
324 /// Sets the value of [name][crate::model::GetExecutionRequest::name].
325 ///
326 /// This is a **required** field for requests.
327 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
328 self.0.request.name = v.into();
329 self
330 }
331
332 /// Sets the value of [view][crate::model::GetExecutionRequest::view].
333 pub fn set_view<T: Into<crate::model::ExecutionView>>(mut self, v: T) -> Self {
334 self.0.request.view = v.into();
335 self
336 }
337 }
338
339 #[doc(hidden)]
340 impl gax::options::internal::RequestBuilder for GetExecution {
341 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
342 &mut self.0.options
343 }
344 }
345
346 /// The request builder for [Executions::cancel_execution][crate::client::Executions::cancel_execution] calls.
347 ///
348 /// # Example
349 /// ```
350 /// # use google_cloud_workflows_executions_v1::builder::executions::CancelExecution;
351 /// # async fn sample() -> gax::Result<()> {
352 ///
353 /// let builder = prepare_request_builder();
354 /// let response = builder.send().await?;
355 /// # Ok(()) }
356 ///
357 /// fn prepare_request_builder() -> CancelExecution {
358 /// # panic!();
359 /// // ... details omitted ...
360 /// }
361 /// ```
362 #[derive(Clone, Debug)]
363 pub struct CancelExecution(RequestBuilder<crate::model::CancelExecutionRequest>);
364
365 impl CancelExecution {
366 pub(crate) fn new(
367 stub: std::sync::Arc<dyn super::super::stub::dynamic::Executions>,
368 ) -> Self {
369 Self(RequestBuilder::new(stub))
370 }
371
372 /// Sets the full request, replacing any prior values.
373 pub fn with_request<V: Into<crate::model::CancelExecutionRequest>>(mut self, v: V) -> Self {
374 self.0.request = v.into();
375 self
376 }
377
378 /// Sets all the options, replacing any prior values.
379 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
380 self.0.options = v.into();
381 self
382 }
383
384 /// Sends the request.
385 pub async fn send(self) -> Result<crate::model::Execution> {
386 (*self.0.stub)
387 .cancel_execution(self.0.request, self.0.options)
388 .await
389 .map(gax::response::Response::into_body)
390 }
391
392 /// Sets the value of [name][crate::model::CancelExecutionRequest::name].
393 ///
394 /// This is a **required** field for requests.
395 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
396 self.0.request.name = v.into();
397 self
398 }
399 }
400
401 #[doc(hidden)]
402 impl gax::options::internal::RequestBuilder for CancelExecution {
403 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
404 &mut self.0.options
405 }
406 }
407}