google_cloud_workflows_v1/
client.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#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::bare_urls)]
20
21/// Implements a client for the Workflows API.
22///
23/// # Example
24/// ```
25/// # tokio_test::block_on(async {
26/// # use google_cloud_workflows_v1::client::Workflows;
27/// let client = Workflows::builder().build().await?;
28/// // use `client` to make requests to the Workflows API.
29/// # gax::client_builder::Result::<()>::Ok(()) });
30/// ```
31///
32/// # Service Description
33///
34/// Workflows is used to deploy and execute workflow programs.
35/// Workflows makes sure the program executes reliably, despite hardware and
36/// networking interruptions.
37///
38/// # Configuration
39///
40/// To configure `Workflows` use the `with_*` methods in the type returned
41/// by [builder()][Workflows::builder]. The default configuration should
42/// work for most applications. Common configuration changes include
43///
44/// * [with_endpoint()]: by default this client uses the global default endpoint
45///   (`https://workflows.googleapis.com`). Applications using regional
46///   endpoints or running in restricted networks (e.g. a network configured
47//    with [Private Google Access with VPC Service Controls]) may want to
48///   override this default.
49/// * [with_credentials()]: by default this client uses
50///   [Application Default Credentials]. Applications using custom
51///   authentication may need to override this default.
52///
53/// [with_endpoint()]: super::builder::workflows::ClientBuilder::with_endpoint
54/// [with_credentials()]: super::builder::workflows::ClientBuilder::credentials
55/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
56/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
57///
58/// # Pooling and Cloning
59///
60/// `Workflows` holds a connection pool internally, it is advised to
61/// create one and the reuse it.  You do not need to wrap `Workflows` in
62/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
63/// already uses an `Arc` internally.
64#[derive(Clone, Debug)]
65pub struct Workflows {
66    inner: std::sync::Arc<dyn super::stub::dynamic::Workflows>,
67}
68
69impl Workflows {
70    /// Returns a builder for [Workflows].
71    ///
72    /// ```
73    /// # tokio_test::block_on(async {
74    /// # use google_cloud_workflows_v1::client::Workflows;
75    /// let client = Workflows::builder().build().await?;
76    /// # gax::client_builder::Result::<()>::Ok(()) });
77    /// ```
78    pub fn builder() -> super::builder::workflows::ClientBuilder {
79        gax::client_builder::internal::new_builder(super::builder::workflows::client::Factory)
80    }
81
82    /// Creates a new client from the provided stub.
83    ///
84    /// The most common case for calling this function is in tests mocking the
85    /// client's behavior.
86    pub fn from_stub<T>(stub: T) -> Self
87    where
88        T: super::stub::Workflows + 'static,
89    {
90        Self {
91            inner: std::sync::Arc::new(stub),
92        }
93    }
94
95    pub(crate) async fn new(
96        config: gaxi::options::ClientConfig,
97    ) -> gax::client_builder::Result<Self> {
98        let inner = Self::build_inner(config).await?;
99        Ok(Self { inner })
100    }
101
102    async fn build_inner(
103        conf: gaxi::options::ClientConfig,
104    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Workflows>> {
105        if gaxi::options::tracing_enabled(&conf) {
106            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
107        }
108        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
109    }
110
111    async fn build_transport(
112        conf: gaxi::options::ClientConfig,
113    ) -> gax::client_builder::Result<impl super::stub::Workflows> {
114        super::transport::Workflows::new(conf).await
115    }
116
117    async fn build_with_tracing(
118        conf: gaxi::options::ClientConfig,
119    ) -> gax::client_builder::Result<impl super::stub::Workflows> {
120        Self::build_transport(conf)
121            .await
122            .map(super::tracing::Workflows::new)
123    }
124
125    /// Lists workflows in a given project and location.
126    /// The default order is not specified.
127    pub fn list_workflows(&self) -> super::builder::workflows::ListWorkflows {
128        super::builder::workflows::ListWorkflows::new(self.inner.clone())
129    }
130
131    /// Gets details of a single workflow.
132    pub fn get_workflow(&self) -> super::builder::workflows::GetWorkflow {
133        super::builder::workflows::GetWorkflow::new(self.inner.clone())
134    }
135
136    /// Creates a new workflow. If a workflow with the specified name already
137    /// exists in the specified project and location, the long running operation
138    /// returns a [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error.
139    ///
140    /// # Long running operations
141    ///
142    /// This method is used to start, and/or poll a [long-running Operation].
143    /// The [Working with long-running operations] chapter in the [user guide]
144    /// covers these operations in detail.
145    ///
146    /// [long-running operation]: https://google.aip.dev/151
147    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
148    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
149    pub fn create_workflow(&self) -> super::builder::workflows::CreateWorkflow {
150        super::builder::workflows::CreateWorkflow::new(self.inner.clone())
151    }
152
153    /// Deletes a workflow with the specified name.
154    /// This method also cancels and deletes all running executions of the
155    /// workflow.
156    ///
157    /// # Long running operations
158    ///
159    /// This method is used to start, and/or poll a [long-running Operation].
160    /// The [Working with long-running operations] chapter in the [user guide]
161    /// covers these operations in detail.
162    ///
163    /// [long-running operation]: https://google.aip.dev/151
164    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
165    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
166    pub fn delete_workflow(&self) -> super::builder::workflows::DeleteWorkflow {
167        super::builder::workflows::DeleteWorkflow::new(self.inner.clone())
168    }
169
170    /// Updates an existing workflow.
171    /// Running this method has no impact on already running executions of the
172    /// workflow. A new revision of the workflow might be created as a result of a
173    /// successful update operation. In that case, the new revision is used
174    /// in new workflow executions.
175    ///
176    /// # Long running operations
177    ///
178    /// This method is used to start, and/or poll a [long-running Operation].
179    /// The [Working with long-running operations] chapter in the [user guide]
180    /// covers these operations in detail.
181    ///
182    /// [long-running operation]: https://google.aip.dev/151
183    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
184    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
185    pub fn update_workflow(&self) -> super::builder::workflows::UpdateWorkflow {
186        super::builder::workflows::UpdateWorkflow::new(self.inner.clone())
187    }
188
189    /// Lists revisions for a given workflow.
190    pub fn list_workflow_revisions(&self) -> super::builder::workflows::ListWorkflowRevisions {
191        super::builder::workflows::ListWorkflowRevisions::new(self.inner.clone())
192    }
193
194    /// Lists information about the supported locations for this service.
195    pub fn list_locations(&self) -> super::builder::workflows::ListLocations {
196        super::builder::workflows::ListLocations::new(self.inner.clone())
197    }
198
199    /// Gets information about a location.
200    pub fn get_location(&self) -> super::builder::workflows::GetLocation {
201        super::builder::workflows::GetLocation::new(self.inner.clone())
202    }
203
204    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
205    ///
206    /// [google.longrunning.Operations]: longrunning::client::Operations
207    pub fn list_operations(&self) -> super::builder::workflows::ListOperations {
208        super::builder::workflows::ListOperations::new(self.inner.clone())
209    }
210
211    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
212    ///
213    /// [google.longrunning.Operations]: longrunning::client::Operations
214    pub fn get_operation(&self) -> super::builder::workflows::GetOperation {
215        super::builder::workflows::GetOperation::new(self.inner.clone())
216    }
217
218    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
219    ///
220    /// [google.longrunning.Operations]: longrunning::client::Operations
221    pub fn delete_operation(&self) -> super::builder::workflows::DeleteOperation {
222        super::builder::workflows::DeleteOperation::new(self.inner.clone())
223    }
224}