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/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
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/// # 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 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
75 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
76 /// let client = AnalyticsHubService::builder().build().await?;
77 /// # Ok(()) }
78 /// ```
79 pub fn builder() -> super::builder::analytics_hub_service::ClientBuilder {
80 crate::new_client_builder(super::builder::analytics_hub_service::client::Factory)
81 }
82
83 /// Creates a new client from the provided stub.
84 ///
85 /// The most common case for calling this function is in tests mocking the
86 /// client's behavior.
87 pub fn from_stub<T>(stub: T) -> Self
88 where
89 T: super::stub::AnalyticsHubService + 'static,
90 {
91 Self {
92 inner: std::sync::Arc::new(stub),
93 }
94 }
95
96 pub(crate) async fn new(
97 config: gaxi::options::ClientConfig,
98 ) -> crate::ClientBuilderResult<Self> {
99 let inner = Self::build_inner(config).await?;
100 Ok(Self { inner })
101 }
102
103 async fn build_inner(
104 conf: gaxi::options::ClientConfig,
105 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::AnalyticsHubService>>
106 {
107 if gaxi::options::tracing_enabled(&conf) {
108 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
109 }
110 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
111 }
112
113 async fn build_transport(
114 conf: gaxi::options::ClientConfig,
115 ) -> crate::ClientBuilderResult<impl super::stub::AnalyticsHubService> {
116 super::transport::AnalyticsHubService::new(conf).await
117 }
118
119 async fn build_with_tracing(
120 conf: gaxi::options::ClientConfig,
121 ) -> crate::ClientBuilderResult<impl super::stub::AnalyticsHubService> {
122 Self::build_transport(conf)
123 .await
124 .map(super::tracing::AnalyticsHubService::new)
125 }
126
127 /// Lists all data exchanges in a given project and location.
128 pub fn list_data_exchanges(&self) -> super::builder::analytics_hub_service::ListDataExchanges {
129 super::builder::analytics_hub_service::ListDataExchanges::new(self.inner.clone())
130 }
131
132 /// Lists all data exchanges from projects in a given organization and
133 /// location.
134 pub fn list_org_data_exchanges(
135 &self,
136 ) -> super::builder::analytics_hub_service::ListOrgDataExchanges {
137 super::builder::analytics_hub_service::ListOrgDataExchanges::new(self.inner.clone())
138 }
139
140 /// Gets the details of a data exchange.
141 pub fn get_data_exchange(&self) -> super::builder::analytics_hub_service::GetDataExchange {
142 super::builder::analytics_hub_service::GetDataExchange::new(self.inner.clone())
143 }
144
145 /// Creates a new data exchange.
146 pub fn create_data_exchange(
147 &self,
148 ) -> super::builder::analytics_hub_service::CreateDataExchange {
149 super::builder::analytics_hub_service::CreateDataExchange::new(self.inner.clone())
150 }
151
152 /// Updates an existing data exchange.
153 pub fn update_data_exchange(
154 &self,
155 ) -> super::builder::analytics_hub_service::UpdateDataExchange {
156 super::builder::analytics_hub_service::UpdateDataExchange::new(self.inner.clone())
157 }
158
159 /// Deletes an existing data exchange.
160 pub fn delete_data_exchange(
161 &self,
162 ) -> super::builder::analytics_hub_service::DeleteDataExchange {
163 super::builder::analytics_hub_service::DeleteDataExchange::new(self.inner.clone())
164 }
165
166 /// Lists all listings in a given project and location.
167 pub fn list_listings(&self) -> super::builder::analytics_hub_service::ListListings {
168 super::builder::analytics_hub_service::ListListings::new(self.inner.clone())
169 }
170
171 /// Gets the details of a listing.
172 pub fn get_listing(&self) -> super::builder::analytics_hub_service::GetListing {
173 super::builder::analytics_hub_service::GetListing::new(self.inner.clone())
174 }
175
176 /// Creates a new listing.
177 pub fn create_listing(&self) -> super::builder::analytics_hub_service::CreateListing {
178 super::builder::analytics_hub_service::CreateListing::new(self.inner.clone())
179 }
180
181 /// Updates an existing listing.
182 pub fn update_listing(&self) -> super::builder::analytics_hub_service::UpdateListing {
183 super::builder::analytics_hub_service::UpdateListing::new(self.inner.clone())
184 }
185
186 /// Deletes a listing.
187 pub fn delete_listing(&self) -> super::builder::analytics_hub_service::DeleteListing {
188 super::builder::analytics_hub_service::DeleteListing::new(self.inner.clone())
189 }
190
191 /// Subscribes to a listing.
192 ///
193 /// Currently, with Analytics Hub, you can create listings that
194 /// reference only BigQuery datasets.
195 /// Upon subscription to a listing for a BigQuery dataset, Analytics Hub
196 /// creates a linked dataset in the subscriber's project.
197 pub fn subscribe_listing(&self) -> super::builder::analytics_hub_service::SubscribeListing {
198 super::builder::analytics_hub_service::SubscribeListing::new(self.inner.clone())
199 }
200
201 /// Creates a Subscription to a Data Clean Room. This is a
202 /// long-running operation as it will create one or more linked datasets.
203 /// Throws a Bad Request error if the Data Exchange does not contain any
204 /// listings.
205 ///
206 /// # Long running operations
207 ///
208 /// This method is used to start, and/or poll a [long-running Operation].
209 /// The [Working with long-running operations] chapter in the [user guide]
210 /// covers these operations in detail.
211 ///
212 /// [long-running operation]: https://google.aip.dev/151
213 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
214 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
215 pub fn subscribe_data_exchange(
216 &self,
217 ) -> super::builder::analytics_hub_service::SubscribeDataExchange {
218 super::builder::analytics_hub_service::SubscribeDataExchange::new(self.inner.clone())
219 }
220
221 /// Refreshes a Subscription to a Data Exchange. A Data Exchange can become
222 /// stale when a publisher adds or removes data. This is a long-running
223 /// operation as it may create many linked datasets.
224 ///
225 /// # Long running operations
226 ///
227 /// This method is used to start, and/or poll a [long-running Operation].
228 /// The [Working with long-running operations] chapter in the [user guide]
229 /// covers these operations in detail.
230 ///
231 /// [long-running operation]: https://google.aip.dev/151
232 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
233 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
234 pub fn refresh_subscription(
235 &self,
236 ) -> super::builder::analytics_hub_service::RefreshSubscription {
237 super::builder::analytics_hub_service::RefreshSubscription::new(self.inner.clone())
238 }
239
240 /// Gets the details of a Subscription.
241 pub fn get_subscription(&self) -> super::builder::analytics_hub_service::GetSubscription {
242 super::builder::analytics_hub_service::GetSubscription::new(self.inner.clone())
243 }
244
245 /// Lists all subscriptions in a given project and location.
246 pub fn list_subscriptions(&self) -> super::builder::analytics_hub_service::ListSubscriptions {
247 super::builder::analytics_hub_service::ListSubscriptions::new(self.inner.clone())
248 }
249
250 /// Lists all subscriptions on a given Data Exchange or Listing.
251 pub fn list_shared_resource_subscriptions(
252 &self,
253 ) -> super::builder::analytics_hub_service::ListSharedResourceSubscriptions {
254 super::builder::analytics_hub_service::ListSharedResourceSubscriptions::new(
255 self.inner.clone(),
256 )
257 }
258
259 /// Revokes a given subscription.
260 pub fn revoke_subscription(&self) -> super::builder::analytics_hub_service::RevokeSubscription {
261 super::builder::analytics_hub_service::RevokeSubscription::new(self.inner.clone())
262 }
263
264 /// Deletes a subscription.
265 ///
266 /// # Long running operations
267 ///
268 /// This method is used to start, and/or poll a [long-running Operation].
269 /// The [Working with long-running operations] chapter in the [user guide]
270 /// covers these operations in detail.
271 ///
272 /// [long-running operation]: https://google.aip.dev/151
273 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
274 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
275 pub fn delete_subscription(&self) -> super::builder::analytics_hub_service::DeleteSubscription {
276 super::builder::analytics_hub_service::DeleteSubscription::new(self.inner.clone())
277 }
278
279 /// Gets the IAM policy.
280 pub fn get_iam_policy(&self) -> super::builder::analytics_hub_service::GetIamPolicy {
281 super::builder::analytics_hub_service::GetIamPolicy::new(self.inner.clone())
282 }
283
284 /// Sets the IAM policy.
285 pub fn set_iam_policy(&self) -> super::builder::analytics_hub_service::SetIamPolicy {
286 super::builder::analytics_hub_service::SetIamPolicy::new(self.inner.clone())
287 }
288
289 /// Returns the permissions that a caller has.
290 pub fn test_iam_permissions(
291 &self,
292 ) -> super::builder::analytics_hub_service::TestIamPermissions {
293 super::builder::analytics_hub_service::TestIamPermissions::new(self.inner.clone())
294 }
295
296 /// Creates a new QueryTemplate
297 pub fn create_query_template(
298 &self,
299 ) -> super::builder::analytics_hub_service::CreateQueryTemplate {
300 super::builder::analytics_hub_service::CreateQueryTemplate::new(self.inner.clone())
301 }
302
303 /// Gets a QueryTemplate
304 pub fn get_query_template(&self) -> super::builder::analytics_hub_service::GetQueryTemplate {
305 super::builder::analytics_hub_service::GetQueryTemplate::new(self.inner.clone())
306 }
307
308 /// Lists all QueryTemplates in a given project and location.
309 pub fn list_query_templates(
310 &self,
311 ) -> super::builder::analytics_hub_service::ListQueryTemplates {
312 super::builder::analytics_hub_service::ListQueryTemplates::new(self.inner.clone())
313 }
314
315 /// Updates an existing QueryTemplate
316 pub fn update_query_template(
317 &self,
318 ) -> super::builder::analytics_hub_service::UpdateQueryTemplate {
319 super::builder::analytics_hub_service::UpdateQueryTemplate::new(self.inner.clone())
320 }
321
322 /// Deletes a query template.
323 pub fn delete_query_template(
324 &self,
325 ) -> super::builder::analytics_hub_service::DeleteQueryTemplate {
326 super::builder::analytics_hub_service::DeleteQueryTemplate::new(self.inner.clone())
327 }
328
329 /// Submits a query template for approval.
330 pub fn submit_query_template(
331 &self,
332 ) -> super::builder::analytics_hub_service::SubmitQueryTemplate {
333 super::builder::analytics_hub_service::SubmitQueryTemplate::new(self.inner.clone())
334 }
335
336 /// Approves a query template.
337 pub fn approve_query_template(
338 &self,
339 ) -> super::builder::analytics_hub_service::ApproveQueryTemplate {
340 super::builder::analytics_hub_service::ApproveQueryTemplate::new(self.inner.clone())
341 }
342
343 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
344 ///
345 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
346 pub fn get_operation(&self) -> super::builder::analytics_hub_service::GetOperation {
347 super::builder::analytics_hub_service::GetOperation::new(self.inner.clone())
348 }
349}