google_cloud_bigquery_analyticshub_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 Analytics Hub API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
25/// let client = AnalyticsHubService::builder().build().await?;
26/// // use `client` to make requests to the Analytics Hub API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// The `AnalyticsHubService` API facilitates data sharing within and across
33/// organizations. It allows data providers to publish listings that reference
34/// shared datasets. With Analytics Hub, users can discover and search for
35/// listings that they have access to. Subscribers can view and subscribe to
36/// listings. When you subscribe to a listing, Analytics Hub creates a linked
37/// dataset in your project.
38///
39/// # Configuration
40///
41/// To configure `AnalyticsHubService` use the `with_*` methods in the type returned
42/// by [builder()][AnalyticsHubService::builder]. The default configuration should
43/// work for most applications. Common configuration changes include
44///
45/// * [with_endpoint()]: by default this client uses the global default endpoint
46///   (`https://analyticshub.googleapis.com`). Applications using regional
47///   endpoints or running in restricted networks (e.g. a network configured
48//    with [Private Google Access with VPC Service Controls]) may want to
49///   override this default.
50/// * [with_credentials()]: by default this client uses
51///   [Application Default Credentials]. Applications using custom
52///   authentication may need to override this default.
53///
54/// [with_endpoint()]: super::builder::analytics_hub_service::ClientBuilder::with_endpoint
55/// [with_credentials()]: super::builder::analytics_hub_service::ClientBuilder::credentials
56/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
57/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
58///
59/// # Pooling and Cloning
60///
61/// `AnalyticsHubService` holds a connection pool internally, it is advised to
62/// create one and the reuse it.  You do not need to wrap `AnalyticsHubService` in
63/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
64/// already uses an `Arc` internally.
65#[derive(Clone, Debug)]
66pub struct AnalyticsHubService {
67    inner: std::sync::Arc<dyn super::stub::dynamic::AnalyticsHubService>,
68}
69
70impl AnalyticsHubService {
71    /// Returns a builder for [AnalyticsHubService].
72    ///
73    /// ```
74    /// # tokio_test::block_on(async {
75    /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
76    /// let client = AnalyticsHubService::builder().build().await?;
77    /// # gax::client_builder::Result::<()>::Ok(()) });
78    /// ```
79    pub fn builder() -> super::builder::analytics_hub_service::ClientBuilder {
80        gax::client_builder::internal::new_builder(
81            super::builder::analytics_hub_service::client::Factory,
82        )
83    }
84
85    /// Creates a new client from the provided stub.
86    ///
87    /// The most common case for calling this function is in tests mocking the
88    /// client's behavior.
89    pub fn from_stub<T>(stub: T) -> Self
90    where
91        T: super::stub::AnalyticsHubService + 'static,
92    {
93        Self {
94            inner: std::sync::Arc::new(stub),
95        }
96    }
97
98    pub(crate) async fn new(
99        config: gaxi::options::ClientConfig,
100    ) -> gax::client_builder::Result<Self> {
101        let inner = Self::build_inner(config).await?;
102        Ok(Self { inner })
103    }
104
105    async fn build_inner(
106        conf: gaxi::options::ClientConfig,
107    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::AnalyticsHubService>>
108    {
109        if gaxi::options::tracing_enabled(&conf) {
110            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
111        }
112        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
113    }
114
115    async fn build_transport(
116        conf: gaxi::options::ClientConfig,
117    ) -> gax::client_builder::Result<impl super::stub::AnalyticsHubService> {
118        super::transport::AnalyticsHubService::new(conf).await
119    }
120
121    async fn build_with_tracing(
122        conf: gaxi::options::ClientConfig,
123    ) -> gax::client_builder::Result<impl super::stub::AnalyticsHubService> {
124        Self::build_transport(conf)
125            .await
126            .map(super::tracing::AnalyticsHubService::new)
127    }
128
129    /// Lists all data exchanges in a given project and location.
130    pub fn list_data_exchanges(&self) -> super::builder::analytics_hub_service::ListDataExchanges {
131        super::builder::analytics_hub_service::ListDataExchanges::new(self.inner.clone())
132    }
133
134    /// Lists all data exchanges from projects in a given organization and
135    /// location.
136    pub fn list_org_data_exchanges(
137        &self,
138    ) -> super::builder::analytics_hub_service::ListOrgDataExchanges {
139        super::builder::analytics_hub_service::ListOrgDataExchanges::new(self.inner.clone())
140    }
141
142    /// Gets the details of a data exchange.
143    pub fn get_data_exchange(&self) -> super::builder::analytics_hub_service::GetDataExchange {
144        super::builder::analytics_hub_service::GetDataExchange::new(self.inner.clone())
145    }
146
147    /// Creates a new data exchange.
148    pub fn create_data_exchange(
149        &self,
150    ) -> super::builder::analytics_hub_service::CreateDataExchange {
151        super::builder::analytics_hub_service::CreateDataExchange::new(self.inner.clone())
152    }
153
154    /// Updates an existing data exchange.
155    pub fn update_data_exchange(
156        &self,
157    ) -> super::builder::analytics_hub_service::UpdateDataExchange {
158        super::builder::analytics_hub_service::UpdateDataExchange::new(self.inner.clone())
159    }
160
161    /// Deletes an existing data exchange.
162    pub fn delete_data_exchange(
163        &self,
164    ) -> super::builder::analytics_hub_service::DeleteDataExchange {
165        super::builder::analytics_hub_service::DeleteDataExchange::new(self.inner.clone())
166    }
167
168    /// Lists all listings in a given project and location.
169    pub fn list_listings(&self) -> super::builder::analytics_hub_service::ListListings {
170        super::builder::analytics_hub_service::ListListings::new(self.inner.clone())
171    }
172
173    /// Gets the details of a listing.
174    pub fn get_listing(&self) -> super::builder::analytics_hub_service::GetListing {
175        super::builder::analytics_hub_service::GetListing::new(self.inner.clone())
176    }
177
178    /// Creates a new listing.
179    pub fn create_listing(&self) -> super::builder::analytics_hub_service::CreateListing {
180        super::builder::analytics_hub_service::CreateListing::new(self.inner.clone())
181    }
182
183    /// Updates an existing listing.
184    pub fn update_listing(&self) -> super::builder::analytics_hub_service::UpdateListing {
185        super::builder::analytics_hub_service::UpdateListing::new(self.inner.clone())
186    }
187
188    /// Deletes a listing.
189    pub fn delete_listing(&self) -> super::builder::analytics_hub_service::DeleteListing {
190        super::builder::analytics_hub_service::DeleteListing::new(self.inner.clone())
191    }
192
193    /// Subscribes to a listing.
194    ///
195    /// Currently, with Analytics Hub, you can create listings that
196    /// reference only BigQuery datasets.
197    /// Upon subscription to a listing for a BigQuery dataset, Analytics Hub
198    /// creates a linked dataset in the subscriber's project.
199    pub fn subscribe_listing(&self) -> super::builder::analytics_hub_service::SubscribeListing {
200        super::builder::analytics_hub_service::SubscribeListing::new(self.inner.clone())
201    }
202
203    /// Creates a Subscription to a Data Clean Room. This is a
204    /// long-running operation as it will create one or more linked datasets.
205    /// Throws a Bad Request error if the Data Exchange does not contain any
206    /// listings.
207    ///
208    /// # Long running operations
209    ///
210    /// This method is used to start, and/or poll a [long-running Operation].
211    /// The [Working with long-running operations] chapter in the [user guide]
212    /// covers these operations in detail.
213    ///
214    /// [long-running operation]: https://google.aip.dev/151
215    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
216    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
217    pub fn subscribe_data_exchange(
218        &self,
219    ) -> super::builder::analytics_hub_service::SubscribeDataExchange {
220        super::builder::analytics_hub_service::SubscribeDataExchange::new(self.inner.clone())
221    }
222
223    /// Refreshes a Subscription to a Data Exchange. A Data Exchange can become
224    /// stale when a publisher adds or removes data. This is a long-running
225    /// operation as it may create many linked datasets.
226    ///
227    /// # Long running operations
228    ///
229    /// This method is used to start, and/or poll a [long-running Operation].
230    /// The [Working with long-running operations] chapter in the [user guide]
231    /// covers these operations in detail.
232    ///
233    /// [long-running operation]: https://google.aip.dev/151
234    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
235    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
236    pub fn refresh_subscription(
237        &self,
238    ) -> super::builder::analytics_hub_service::RefreshSubscription {
239        super::builder::analytics_hub_service::RefreshSubscription::new(self.inner.clone())
240    }
241
242    /// Gets the details of a Subscription.
243    pub fn get_subscription(&self) -> super::builder::analytics_hub_service::GetSubscription {
244        super::builder::analytics_hub_service::GetSubscription::new(self.inner.clone())
245    }
246
247    /// Lists all subscriptions in a given project and location.
248    pub fn list_subscriptions(&self) -> super::builder::analytics_hub_service::ListSubscriptions {
249        super::builder::analytics_hub_service::ListSubscriptions::new(self.inner.clone())
250    }
251
252    /// Lists all subscriptions on a given Data Exchange or Listing.
253    pub fn list_shared_resource_subscriptions(
254        &self,
255    ) -> super::builder::analytics_hub_service::ListSharedResourceSubscriptions {
256        super::builder::analytics_hub_service::ListSharedResourceSubscriptions::new(
257            self.inner.clone(),
258        )
259    }
260
261    /// Revokes a given subscription.
262    pub fn revoke_subscription(&self) -> super::builder::analytics_hub_service::RevokeSubscription {
263        super::builder::analytics_hub_service::RevokeSubscription::new(self.inner.clone())
264    }
265
266    /// Deletes a subscription.
267    ///
268    /// # Long running operations
269    ///
270    /// This method is used to start, and/or poll a [long-running Operation].
271    /// The [Working with long-running operations] chapter in the [user guide]
272    /// covers these operations in detail.
273    ///
274    /// [long-running operation]: https://google.aip.dev/151
275    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
276    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
277    pub fn delete_subscription(&self) -> super::builder::analytics_hub_service::DeleteSubscription {
278        super::builder::analytics_hub_service::DeleteSubscription::new(self.inner.clone())
279    }
280
281    /// Gets the IAM policy.
282    pub fn get_iam_policy(&self) -> super::builder::analytics_hub_service::GetIamPolicy {
283        super::builder::analytics_hub_service::GetIamPolicy::new(self.inner.clone())
284    }
285
286    /// Sets the IAM policy.
287    pub fn set_iam_policy(&self) -> super::builder::analytics_hub_service::SetIamPolicy {
288        super::builder::analytics_hub_service::SetIamPolicy::new(self.inner.clone())
289    }
290
291    /// Returns the permissions that a caller has.
292    pub fn test_iam_permissions(
293        &self,
294    ) -> super::builder::analytics_hub_service::TestIamPermissions {
295        super::builder::analytics_hub_service::TestIamPermissions::new(self.inner.clone())
296    }
297
298    /// Creates a new QueryTemplate
299    pub fn create_query_template(
300        &self,
301    ) -> super::builder::analytics_hub_service::CreateQueryTemplate {
302        super::builder::analytics_hub_service::CreateQueryTemplate::new(self.inner.clone())
303    }
304
305    /// Gets a QueryTemplate
306    pub fn get_query_template(&self) -> super::builder::analytics_hub_service::GetQueryTemplate {
307        super::builder::analytics_hub_service::GetQueryTemplate::new(self.inner.clone())
308    }
309
310    /// Lists all QueryTemplates in a given project and location.
311    pub fn list_query_templates(
312        &self,
313    ) -> super::builder::analytics_hub_service::ListQueryTemplates {
314        super::builder::analytics_hub_service::ListQueryTemplates::new(self.inner.clone())
315    }
316
317    /// Updates an existing QueryTemplate
318    pub fn update_query_template(
319        &self,
320    ) -> super::builder::analytics_hub_service::UpdateQueryTemplate {
321        super::builder::analytics_hub_service::UpdateQueryTemplate::new(self.inner.clone())
322    }
323
324    /// Deletes a query template.
325    pub fn delete_query_template(
326        &self,
327    ) -> super::builder::analytics_hub_service::DeleteQueryTemplate {
328        super::builder::analytics_hub_service::DeleteQueryTemplate::new(self.inner.clone())
329    }
330
331    /// Submits a query template for approval.
332    pub fn submit_query_template(
333        &self,
334    ) -> super::builder::analytics_hub_service::SubmitQueryTemplate {
335        super::builder::analytics_hub_service::SubmitQueryTemplate::new(self.inner.clone())
336    }
337
338    /// Approves a query template.
339    pub fn approve_query_template(
340        &self,
341    ) -> super::builder::analytics_hub_service::ApproveQueryTemplate {
342        super::builder::analytics_hub_service::ApproveQueryTemplate::new(self.inner.clone())
343    }
344
345    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
346    ///
347    /// [google.longrunning.Operations]: longrunning::client::Operations
348    pub fn get_operation(&self) -> super::builder::analytics_hub_service::GetOperation {
349        super::builder::analytics_hub_service::GetOperation::new(self.inner.clone())
350    }
351}