google_cloud_timeseriesinsights_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
19/// Implements a client for the Timeseries Insights API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_timeseriesinsights_v1::client::TimeseriesInsightsController;
25/// let client = TimeseriesInsightsController::builder().build().await?;
26/// // use `client` to make requests to the Timeseries Insights API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32///
33/// # Configuration
34///
35/// To configure `TimeseriesInsightsController` use the `with_*` methods in the type returned
36/// by [builder()][TimeseriesInsightsController::builder]. The default configuration should
37/// work for most applications. Common configuration changes include
38///
39/// * [with_endpoint()]: by default this client uses the global default endpoint
40///   (`https://timeseriesinsights.googleapis.com`). Applications using regional
41///   endpoints or running in restricted networks (e.g. a network configured
42//    with [Private Google Access with VPC Service Controls]) may want to
43///   override this default.
44/// * [with_credentials()]: by default this client uses
45///   [Application Default Credentials]. Applications using custom
46///   authentication may need to override this default.
47///
48/// [with_endpoint()]: super::builder::timeseries_insights_controller::ClientBuilder::with_endpoint
49/// [with_credentials()]: super::builder::timeseries_insights_controller::ClientBuilder::credentials
50/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
51/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
52///
53/// # Pooling and Cloning
54///
55/// `TimeseriesInsightsController` holds a connection pool internally, it is advised to
56/// create one and the reuse it.  You do not need to wrap `TimeseriesInsightsController` in
57/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
58/// already uses an `Arc` internally.
59#[derive(Clone, Debug)]
60pub struct TimeseriesInsightsController {
61    inner: std::sync::Arc<dyn super::stub::dynamic::TimeseriesInsightsController>,
62}
63
64impl TimeseriesInsightsController {
65    /// Returns a builder for [TimeseriesInsightsController].
66    ///
67    /// ```
68    /// # tokio_test::block_on(async {
69    /// # use google_cloud_timeseriesinsights_v1::client::TimeseriesInsightsController;
70    /// let client = TimeseriesInsightsController::builder().build().await?;
71    /// # gax::client_builder::Result::<()>::Ok(()) });
72    /// ```
73    pub fn builder() -> super::builder::timeseries_insights_controller::ClientBuilder {
74        gax::client_builder::internal::new_builder(
75            super::builder::timeseries_insights_controller::client::Factory,
76        )
77    }
78
79    /// Creates a new client from the provided stub.
80    ///
81    /// The most common case for calling this function is in tests mocking the
82    /// client's behavior.
83    pub fn from_stub<T>(stub: T) -> Self
84    where
85        T: super::stub::TimeseriesInsightsController + 'static,
86    {
87        Self {
88            inner: std::sync::Arc::new(stub),
89        }
90    }
91
92    pub(crate) async fn new(
93        config: gaxi::options::ClientConfig,
94    ) -> gax::client_builder::Result<Self> {
95        let inner = Self::build_inner(config).await?;
96        Ok(Self { inner })
97    }
98
99    async fn build_inner(
100        conf: gaxi::options::ClientConfig,
101    ) -> gax::client_builder::Result<
102        std::sync::Arc<dyn super::stub::dynamic::TimeseriesInsightsController>,
103    > {
104        if gaxi::options::tracing_enabled(&conf) {
105            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
106        }
107        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
108    }
109
110    async fn build_transport(
111        conf: gaxi::options::ClientConfig,
112    ) -> gax::client_builder::Result<impl super::stub::TimeseriesInsightsController> {
113        super::transport::TimeseriesInsightsController::new(conf).await
114    }
115
116    async fn build_with_tracing(
117        conf: gaxi::options::ClientConfig,
118    ) -> gax::client_builder::Result<impl super::stub::TimeseriesInsightsController> {
119        Self::build_transport(conf)
120            .await
121            .map(super::tracing::TimeseriesInsightsController::new)
122    }
123
124    /// Lists [DataSets][google.cloud.timeseriesinsights.v1.DataSet] under the project.
125    ///
126    /// The order of the results is unspecified but deterministic. Newly created
127    /// [DataSets][google.cloud.timeseriesinsights.v1.DataSet] will not necessarily be added to the end
128    /// of this list.
129    ///
130    /// [google.cloud.timeseriesinsights.v1.DataSet]: crate::model::DataSet
131    pub fn list_data_sets(&self) -> super::builder::timeseries_insights_controller::ListDataSets {
132        super::builder::timeseries_insights_controller::ListDataSets::new(self.inner.clone())
133    }
134
135    /// Create a [DataSet][google.cloud.timeseriesinsights.v1.DataSet] from data stored on Cloud
136    /// Storage.
137    ///
138    /// The data must stay immutable while we process the
139    /// [DataSet][google.cloud.timeseriesinsights.v1.DataSet] creation; otherwise, undefined outcomes
140    /// might result.  For more information, see [DataSet][google.cloud.timeseriesinsights.v1.DataSet].
141    ///
142    /// [google.cloud.timeseriesinsights.v1.DataSet]: crate::model::DataSet
143    pub fn create_data_set(&self) -> super::builder::timeseries_insights_controller::CreateDataSet {
144        super::builder::timeseries_insights_controller::CreateDataSet::new(self.inner.clone())
145    }
146
147    /// Delete a [DataSet][google.cloud.timeseriesinsights.v1.DataSet] from the system.
148    ///
149    /// **NOTE**: If the [DataSet][google.cloud.timeseriesinsights.v1.DataSet] is still being
150    /// processed, it will be aborted and deleted.
151    ///
152    /// [google.cloud.timeseriesinsights.v1.DataSet]: crate::model::DataSet
153    pub fn delete_data_set(&self) -> super::builder::timeseries_insights_controller::DeleteDataSet {
154        super::builder::timeseries_insights_controller::DeleteDataSet::new(self.inner.clone())
155    }
156
157    /// Append events to a `LOADED` [DataSet][google.cloud.timeseriesinsights.v1.DataSet].
158    ///
159    /// [google.cloud.timeseriesinsights.v1.DataSet]: crate::model::DataSet
160    pub fn append_events(&self) -> super::builder::timeseries_insights_controller::AppendEvents {
161        super::builder::timeseries_insights_controller::AppendEvents::new(self.inner.clone())
162    }
163
164    /// Execute a Timeseries Insights query over a loaded
165    /// [DataSet][google.cloud.timeseriesinsights.v1.DataSet].
166    ///
167    /// [google.cloud.timeseriesinsights.v1.DataSet]: crate::model::DataSet
168    pub fn query_data_set(&self) -> super::builder::timeseries_insights_controller::QueryDataSet {
169        super::builder::timeseries_insights_controller::QueryDataSet::new(self.inner.clone())
170    }
171
172    /// Evaluate an explicit slice from a loaded [DataSet][google.cloud.timeseriesinsights.v1.DataSet].
173    ///
174    /// [google.cloud.timeseriesinsights.v1.DataSet]: crate::model::DataSet
175    pub fn evaluate_slice(&self) -> super::builder::timeseries_insights_controller::EvaluateSlice {
176        super::builder::timeseries_insights_controller::EvaluateSlice::new(self.inner.clone())
177    }
178
179    /// Evaluate an explicit timeseries.
180    pub fn evaluate_timeseries(
181        &self,
182    ) -> super::builder::timeseries_insights_controller::EvaluateTimeseries {
183        super::builder::timeseries_insights_controller::EvaluateTimeseries::new(self.inner.clone())
184    }
185}