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::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Analytics Hub API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28/// project_id: &str,
29/// location_id: &str,
30/// ) -> anyhow::Result<()> {
31/// let client = AnalyticsHubService::builder().build().await?;
32/// let mut list = client.list_data_exchanges()
33/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
34/// .by_item();
35/// while let Some(item) = list.next().await.transpose()? {
36/// println!("{:?}", item);
37/// }
38/// Ok(())
39/// }
40/// ```
41///
42/// # Service Description
43///
44/// The `AnalyticsHubService` API facilitates data sharing within and across
45/// organizations. It allows data providers to publish listings that reference
46/// shared datasets. With Analytics Hub, users can discover and search for
47/// listings that they have access to. Subscribers can view and subscribe to
48/// listings. When you subscribe to a listing, Analytics Hub creates a linked
49/// dataset in your project.
50///
51/// # Configuration
52///
53/// To configure `AnalyticsHubService` use the `with_*` methods in the type returned
54/// by [builder()][AnalyticsHubService::builder]. The default configuration should
55/// work for most applications. Common configuration changes include
56///
57/// * [with_endpoint()]: by default this client uses the global default endpoint
58/// (`https://analyticshub.googleapis.com`). Applications using regional
59/// endpoints or running in restricted networks (e.g. a network configured
60/// with [Private Google Access with VPC Service Controls]) may want to
61/// override this default.
62/// * [with_credentials()]: by default this client uses
63/// [Application Default Credentials]. Applications using custom
64/// authentication may need to override this default.
65///
66/// [with_endpoint()]: super::builder::analytics_hub_service::ClientBuilder::with_endpoint
67/// [with_credentials()]: super::builder::analytics_hub_service::ClientBuilder::with_credentials
68/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
69/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
70///
71/// # Pooling and Cloning
72///
73/// `AnalyticsHubService` holds a connection pool internally, it is advised to
74/// create one and reuse it. You do not need to wrap `AnalyticsHubService` in
75/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
76/// already uses an `Arc` internally.
77#[derive(Clone, Debug)]
78pub struct AnalyticsHubService {
79 inner: std::sync::Arc<dyn super::stub::dynamic::AnalyticsHubService>,
80}
81
82impl AnalyticsHubService {
83 /// Returns a builder for [AnalyticsHubService].
84 ///
85 /// ```
86 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
87 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
88 /// let client = AnalyticsHubService::builder().build().await?;
89 /// # Ok(()) }
90 /// ```
91 pub fn builder() -> super::builder::analytics_hub_service::ClientBuilder {
92 crate::new_client_builder(super::builder::analytics_hub_service::client::Factory)
93 }
94
95 /// Creates a new client from the provided stub.
96 ///
97 /// The most common case for calling this function is in tests mocking the
98 /// client's behavior.
99 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
100 where
101 T: super::stub::AnalyticsHubService + 'static,
102 {
103 Self { inner: stub.into() }
104 }
105
106 pub(crate) async fn new(
107 config: gaxi::options::ClientConfig,
108 ) -> crate::ClientBuilderResult<Self> {
109 let inner = Self::build_inner(config).await?;
110 Ok(Self { inner })
111 }
112
113 async fn build_inner(
114 conf: gaxi::options::ClientConfig,
115 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::AnalyticsHubService>>
116 {
117 if gaxi::options::tracing_enabled(&conf) {
118 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
119 }
120 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
121 }
122
123 async fn build_transport(
124 conf: gaxi::options::ClientConfig,
125 ) -> crate::ClientBuilderResult<impl super::stub::AnalyticsHubService> {
126 super::transport::AnalyticsHubService::new(conf).await
127 }
128
129 async fn build_with_tracing(
130 conf: gaxi::options::ClientConfig,
131 ) -> crate::ClientBuilderResult<impl super::stub::AnalyticsHubService> {
132 Self::build_transport(conf)
133 .await
134 .map(super::tracing::AnalyticsHubService::new)
135 }
136
137 /// Lists all data exchanges in a given project and location.
138 ///
139 /// # Example
140 /// ```
141 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
142 /// use google_cloud_gax::paginator::ItemPaginator as _;
143 /// use google_cloud_bigquery_analyticshub_v1::Result;
144 /// async fn sample(
145 /// client: &AnalyticsHubService, project_id: &str, location_id: &str
146 /// ) -> Result<()> {
147 /// let mut list = client.list_data_exchanges()
148 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
149 /// .by_item();
150 /// while let Some(item) = list.next().await.transpose()? {
151 /// println!("{:?}", item);
152 /// }
153 /// Ok(())
154 /// }
155 /// ```
156 pub fn list_data_exchanges(&self) -> super::builder::analytics_hub_service::ListDataExchanges {
157 super::builder::analytics_hub_service::ListDataExchanges::new(self.inner.clone())
158 }
159
160 /// Lists all data exchanges from projects in a given organization and
161 /// location.
162 ///
163 /// # Example
164 /// ```
165 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
166 /// use google_cloud_gax::paginator::ItemPaginator as _;
167 /// use google_cloud_bigquery_analyticshub_v1::Result;
168 /// async fn sample(
169 /// client: &AnalyticsHubService
170 /// ) -> Result<()> {
171 /// let mut list = client.list_org_data_exchanges()
172 /// /* set fields */
173 /// .by_item();
174 /// while let Some(item) = list.next().await.transpose()? {
175 /// println!("{:?}", item);
176 /// }
177 /// Ok(())
178 /// }
179 /// ```
180 pub fn list_org_data_exchanges(
181 &self,
182 ) -> super::builder::analytics_hub_service::ListOrgDataExchanges {
183 super::builder::analytics_hub_service::ListOrgDataExchanges::new(self.inner.clone())
184 }
185
186 /// Gets the details of a data exchange.
187 ///
188 /// # Example
189 /// ```
190 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
191 /// use google_cloud_bigquery_analyticshub_v1::Result;
192 /// async fn sample(
193 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str
194 /// ) -> Result<()> {
195 /// let response = client.get_data_exchange()
196 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}"))
197 /// .send().await?;
198 /// println!("response {:?}", response);
199 /// Ok(())
200 /// }
201 /// ```
202 pub fn get_data_exchange(&self) -> super::builder::analytics_hub_service::GetDataExchange {
203 super::builder::analytics_hub_service::GetDataExchange::new(self.inner.clone())
204 }
205
206 /// Creates a new data exchange.
207 ///
208 /// # Example
209 /// ```
210 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
211 /// use google_cloud_bigquery_analyticshub_v1::model::DataExchange;
212 /// use google_cloud_bigquery_analyticshub_v1::Result;
213 /// async fn sample(
214 /// client: &AnalyticsHubService, project_id: &str, location_id: &str
215 /// ) -> Result<()> {
216 /// let response = client.create_data_exchange()
217 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
218 /// .set_data_exchange(
219 /// DataExchange::new()/* set fields */
220 /// )
221 /// .send().await?;
222 /// println!("response {:?}", response);
223 /// Ok(())
224 /// }
225 /// ```
226 pub fn create_data_exchange(
227 &self,
228 ) -> super::builder::analytics_hub_service::CreateDataExchange {
229 super::builder::analytics_hub_service::CreateDataExchange::new(self.inner.clone())
230 }
231
232 /// Updates an existing data exchange.
233 ///
234 /// # Example
235 /// ```
236 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
237 /// # extern crate wkt as google_cloud_wkt;
238 /// use google_cloud_wkt::FieldMask;
239 /// use google_cloud_bigquery_analyticshub_v1::model::DataExchange;
240 /// use google_cloud_bigquery_analyticshub_v1::Result;
241 /// async fn sample(
242 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str
243 /// ) -> Result<()> {
244 /// let response = client.update_data_exchange()
245 /// .set_data_exchange(
246 /// DataExchange::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}"))/* set fields */
247 /// )
248 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
249 /// .send().await?;
250 /// println!("response {:?}", response);
251 /// Ok(())
252 /// }
253 /// ```
254 pub fn update_data_exchange(
255 &self,
256 ) -> super::builder::analytics_hub_service::UpdateDataExchange {
257 super::builder::analytics_hub_service::UpdateDataExchange::new(self.inner.clone())
258 }
259
260 /// Deletes an existing data exchange.
261 ///
262 /// # Example
263 /// ```
264 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
265 /// use google_cloud_bigquery_analyticshub_v1::Result;
266 /// async fn sample(
267 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str
268 /// ) -> Result<()> {
269 /// client.delete_data_exchange()
270 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}"))
271 /// .send().await?;
272 /// Ok(())
273 /// }
274 /// ```
275 pub fn delete_data_exchange(
276 &self,
277 ) -> super::builder::analytics_hub_service::DeleteDataExchange {
278 super::builder::analytics_hub_service::DeleteDataExchange::new(self.inner.clone())
279 }
280
281 /// Lists all listings in a given project and location.
282 ///
283 /// # Example
284 /// ```
285 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
286 /// use google_cloud_gax::paginator::ItemPaginator as _;
287 /// use google_cloud_bigquery_analyticshub_v1::Result;
288 /// async fn sample(
289 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str
290 /// ) -> Result<()> {
291 /// let mut list = client.list_listings()
292 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}"))
293 /// .by_item();
294 /// while let Some(item) = list.next().await.transpose()? {
295 /// println!("{:?}", item);
296 /// }
297 /// Ok(())
298 /// }
299 /// ```
300 pub fn list_listings(&self) -> super::builder::analytics_hub_service::ListListings {
301 super::builder::analytics_hub_service::ListListings::new(self.inner.clone())
302 }
303
304 /// Gets the details of a listing.
305 ///
306 /// # Example
307 /// ```
308 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
309 /// use google_cloud_bigquery_analyticshub_v1::Result;
310 /// async fn sample(
311 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str, listing_id: &str
312 /// ) -> Result<()> {
313 /// let response = client.get_listing()
314 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}/listings/{listing_id}"))
315 /// .send().await?;
316 /// println!("response {:?}", response);
317 /// Ok(())
318 /// }
319 /// ```
320 pub fn get_listing(&self) -> super::builder::analytics_hub_service::GetListing {
321 super::builder::analytics_hub_service::GetListing::new(self.inner.clone())
322 }
323
324 /// Creates a new listing.
325 ///
326 /// # Example
327 /// ```
328 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
329 /// use google_cloud_bigquery_analyticshub_v1::model::Listing;
330 /// use google_cloud_bigquery_analyticshub_v1::Result;
331 /// async fn sample(
332 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str
333 /// ) -> Result<()> {
334 /// let response = client.create_listing()
335 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}"))
336 /// .set_listing_id("listing_id_value")
337 /// .set_listing(
338 /// Listing::new()/* set fields */
339 /// )
340 /// .send().await?;
341 /// println!("response {:?}", response);
342 /// Ok(())
343 /// }
344 /// ```
345 pub fn create_listing(&self) -> super::builder::analytics_hub_service::CreateListing {
346 super::builder::analytics_hub_service::CreateListing::new(self.inner.clone())
347 }
348
349 /// Updates an existing listing.
350 ///
351 /// # Example
352 /// ```
353 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
354 /// # extern crate wkt as google_cloud_wkt;
355 /// use google_cloud_wkt::FieldMask;
356 /// use google_cloud_bigquery_analyticshub_v1::model::Listing;
357 /// use google_cloud_bigquery_analyticshub_v1::Result;
358 /// async fn sample(
359 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str, listing_id: &str
360 /// ) -> Result<()> {
361 /// let response = client.update_listing()
362 /// .set_listing(
363 /// Listing::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}/listings/{listing_id}"))/* set fields */
364 /// )
365 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
366 /// .send().await?;
367 /// println!("response {:?}", response);
368 /// Ok(())
369 /// }
370 /// ```
371 pub fn update_listing(&self) -> super::builder::analytics_hub_service::UpdateListing {
372 super::builder::analytics_hub_service::UpdateListing::new(self.inner.clone())
373 }
374
375 /// Deletes a listing.
376 ///
377 /// # Example
378 /// ```
379 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
380 /// use google_cloud_bigquery_analyticshub_v1::Result;
381 /// async fn sample(
382 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str, listing_id: &str
383 /// ) -> Result<()> {
384 /// client.delete_listing()
385 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}/listings/{listing_id}"))
386 /// .send().await?;
387 /// Ok(())
388 /// }
389 /// ```
390 pub fn delete_listing(&self) -> super::builder::analytics_hub_service::DeleteListing {
391 super::builder::analytics_hub_service::DeleteListing::new(self.inner.clone())
392 }
393
394 /// Subscribes to a listing.
395 ///
396 /// Currently, with Analytics Hub, you can create listings that
397 /// reference only BigQuery datasets.
398 /// Upon subscription to a listing for a BigQuery dataset, Analytics Hub
399 /// creates a linked dataset in the subscriber's project.
400 ///
401 /// # Example
402 /// ```
403 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
404 /// use google_cloud_bigquery_analyticshub_v1::Result;
405 /// async fn sample(
406 /// client: &AnalyticsHubService
407 /// ) -> Result<()> {
408 /// let response = client.subscribe_listing()
409 /// /* set fields */
410 /// .send().await?;
411 /// println!("response {:?}", response);
412 /// Ok(())
413 /// }
414 /// ```
415 pub fn subscribe_listing(&self) -> super::builder::analytics_hub_service::SubscribeListing {
416 super::builder::analytics_hub_service::SubscribeListing::new(self.inner.clone())
417 }
418
419 /// Creates a Subscription to a Data Clean Room. This is a
420 /// long-running operation as it will create one or more linked datasets.
421 /// Throws a Bad Request error if the Data Exchange does not contain any
422 /// listings.
423 ///
424 /// # Long running operations
425 ///
426 /// This method is used to start, and/or poll a [long-running Operation].
427 /// The [Working with long-running operations] chapter in the [user guide]
428 /// covers these operations in detail.
429 ///
430 /// [long-running operation]: https://google.aip.dev/151
431 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
432 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
433 ///
434 /// # Example
435 /// ```
436 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
437 /// use google_cloud_lro::Poller;
438 /// use google_cloud_bigquery_analyticshub_v1::Result;
439 /// async fn sample(
440 /// client: &AnalyticsHubService
441 /// ) -> Result<()> {
442 /// let response = client.subscribe_data_exchange()
443 /// /* set fields */
444 /// .poller().until_done().await?;
445 /// println!("response {:?}", response);
446 /// Ok(())
447 /// }
448 /// ```
449 pub fn subscribe_data_exchange(
450 &self,
451 ) -> super::builder::analytics_hub_service::SubscribeDataExchange {
452 super::builder::analytics_hub_service::SubscribeDataExchange::new(self.inner.clone())
453 }
454
455 /// Refreshes a Subscription to a Data Exchange. A Data Exchange can become
456 /// stale when a publisher adds or removes data. This is a long-running
457 /// operation as it may create many linked datasets.
458 ///
459 /// # Long running operations
460 ///
461 /// This method is used to start, and/or poll a [long-running Operation].
462 /// The [Working with long-running operations] chapter in the [user guide]
463 /// covers these operations in detail.
464 ///
465 /// [long-running operation]: https://google.aip.dev/151
466 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
467 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
468 ///
469 /// # Example
470 /// ```
471 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
472 /// use google_cloud_lro::Poller;
473 /// use google_cloud_bigquery_analyticshub_v1::Result;
474 /// async fn sample(
475 /// client: &AnalyticsHubService
476 /// ) -> Result<()> {
477 /// let response = client.refresh_subscription()
478 /// /* set fields */
479 /// .poller().until_done().await?;
480 /// println!("response {:?}", response);
481 /// Ok(())
482 /// }
483 /// ```
484 pub fn refresh_subscription(
485 &self,
486 ) -> super::builder::analytics_hub_service::RefreshSubscription {
487 super::builder::analytics_hub_service::RefreshSubscription::new(self.inner.clone())
488 }
489
490 /// Gets the details of a Subscription.
491 ///
492 /// # Example
493 /// ```
494 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
495 /// use google_cloud_bigquery_analyticshub_v1::Result;
496 /// async fn sample(
497 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, subscription_id: &str
498 /// ) -> Result<()> {
499 /// let response = client.get_subscription()
500 /// .set_name(format!("projects/{project_id}/locations/{location_id}/subscriptions/{subscription_id}"))
501 /// .send().await?;
502 /// println!("response {:?}", response);
503 /// Ok(())
504 /// }
505 /// ```
506 pub fn get_subscription(&self) -> super::builder::analytics_hub_service::GetSubscription {
507 super::builder::analytics_hub_service::GetSubscription::new(self.inner.clone())
508 }
509
510 /// Lists all subscriptions in a given project and location.
511 ///
512 /// # Example
513 /// ```
514 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
515 /// use google_cloud_gax::paginator::ItemPaginator as _;
516 /// use google_cloud_bigquery_analyticshub_v1::Result;
517 /// async fn sample(
518 /// client: &AnalyticsHubService, project_id: &str, location_id: &str
519 /// ) -> Result<()> {
520 /// let mut list = client.list_subscriptions()
521 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
522 /// .by_item();
523 /// while let Some(item) = list.next().await.transpose()? {
524 /// println!("{:?}", item);
525 /// }
526 /// Ok(())
527 /// }
528 /// ```
529 pub fn list_subscriptions(&self) -> super::builder::analytics_hub_service::ListSubscriptions {
530 super::builder::analytics_hub_service::ListSubscriptions::new(self.inner.clone())
531 }
532
533 /// Lists all subscriptions on a given Data Exchange or Listing.
534 ///
535 /// # Example
536 /// ```
537 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
538 /// use google_cloud_gax::paginator::ItemPaginator as _;
539 /// use google_cloud_bigquery_analyticshub_v1::Result;
540 /// async fn sample(
541 /// client: &AnalyticsHubService
542 /// ) -> Result<()> {
543 /// let mut list = client.list_shared_resource_subscriptions()
544 /// /* set fields */
545 /// .by_item();
546 /// while let Some(item) = list.next().await.transpose()? {
547 /// println!("{:?}", item);
548 /// }
549 /// Ok(())
550 /// }
551 /// ```
552 pub fn list_shared_resource_subscriptions(
553 &self,
554 ) -> super::builder::analytics_hub_service::ListSharedResourceSubscriptions {
555 super::builder::analytics_hub_service::ListSharedResourceSubscriptions::new(
556 self.inner.clone(),
557 )
558 }
559
560 /// Revokes a given subscription.
561 ///
562 /// # Example
563 /// ```
564 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
565 /// use google_cloud_bigquery_analyticshub_v1::Result;
566 /// async fn sample(
567 /// client: &AnalyticsHubService
568 /// ) -> Result<()> {
569 /// let response = client.revoke_subscription()
570 /// /* set fields */
571 /// .send().await?;
572 /// println!("response {:?}", response);
573 /// Ok(())
574 /// }
575 /// ```
576 pub fn revoke_subscription(&self) -> super::builder::analytics_hub_service::RevokeSubscription {
577 super::builder::analytics_hub_service::RevokeSubscription::new(self.inner.clone())
578 }
579
580 /// Deletes a subscription.
581 ///
582 /// # Long running operations
583 ///
584 /// This method is used to start, and/or poll a [long-running Operation].
585 /// The [Working with long-running operations] chapter in the [user guide]
586 /// covers these operations in detail.
587 ///
588 /// [long-running operation]: https://google.aip.dev/151
589 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
590 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
591 ///
592 /// # Example
593 /// ```
594 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
595 /// use google_cloud_lro::Poller;
596 /// use google_cloud_bigquery_analyticshub_v1::Result;
597 /// async fn sample(
598 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, subscription_id: &str
599 /// ) -> Result<()> {
600 /// client.delete_subscription()
601 /// .set_name(format!("projects/{project_id}/locations/{location_id}/subscriptions/{subscription_id}"))
602 /// .poller().until_done().await?;
603 /// Ok(())
604 /// }
605 /// ```
606 pub fn delete_subscription(&self) -> super::builder::analytics_hub_service::DeleteSubscription {
607 super::builder::analytics_hub_service::DeleteSubscription::new(self.inner.clone())
608 }
609
610 /// Gets the IAM policy.
611 ///
612 /// # Example
613 /// ```
614 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
615 /// use google_cloud_bigquery_analyticshub_v1::Result;
616 /// async fn sample(
617 /// client: &AnalyticsHubService
618 /// ) -> Result<()> {
619 /// let response = client.get_iam_policy()
620 /// /* set fields */
621 /// .send().await?;
622 /// println!("response {:?}", response);
623 /// Ok(())
624 /// }
625 /// ```
626 pub fn get_iam_policy(&self) -> super::builder::analytics_hub_service::GetIamPolicy {
627 super::builder::analytics_hub_service::GetIamPolicy::new(self.inner.clone())
628 }
629
630 /// Sets the IAM policy.
631 ///
632 /// # Example
633 /// ```
634 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
635 /// use google_cloud_bigquery_analyticshub_v1::Result;
636 /// async fn sample(
637 /// client: &AnalyticsHubService
638 /// ) -> Result<()> {
639 /// let response = client.set_iam_policy()
640 /// /* set fields */
641 /// .send().await?;
642 /// println!("response {:?}", response);
643 /// Ok(())
644 /// }
645 /// ```
646 pub fn set_iam_policy(&self) -> super::builder::analytics_hub_service::SetIamPolicy {
647 super::builder::analytics_hub_service::SetIamPolicy::new(self.inner.clone())
648 }
649
650 /// Returns the permissions that a caller has.
651 ///
652 /// # Example
653 /// ```
654 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
655 /// use google_cloud_bigquery_analyticshub_v1::Result;
656 /// async fn sample(
657 /// client: &AnalyticsHubService
658 /// ) -> Result<()> {
659 /// let response = client.test_iam_permissions()
660 /// /* set fields */
661 /// .send().await?;
662 /// println!("response {:?}", response);
663 /// Ok(())
664 /// }
665 /// ```
666 pub fn test_iam_permissions(
667 &self,
668 ) -> super::builder::analytics_hub_service::TestIamPermissions {
669 super::builder::analytics_hub_service::TestIamPermissions::new(self.inner.clone())
670 }
671
672 /// Creates a new QueryTemplate
673 ///
674 /// # Example
675 /// ```
676 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
677 /// use google_cloud_bigquery_analyticshub_v1::model::QueryTemplate;
678 /// use google_cloud_bigquery_analyticshub_v1::Result;
679 /// async fn sample(
680 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str
681 /// ) -> Result<()> {
682 /// let response = client.create_query_template()
683 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}"))
684 /// .set_query_template(
685 /// QueryTemplate::new()/* set fields */
686 /// )
687 /// .send().await?;
688 /// println!("response {:?}", response);
689 /// Ok(())
690 /// }
691 /// ```
692 pub fn create_query_template(
693 &self,
694 ) -> super::builder::analytics_hub_service::CreateQueryTemplate {
695 super::builder::analytics_hub_service::CreateQueryTemplate::new(self.inner.clone())
696 }
697
698 /// Gets a QueryTemplate
699 ///
700 /// # Example
701 /// ```
702 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
703 /// use google_cloud_bigquery_analyticshub_v1::Result;
704 /// async fn sample(
705 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str, query_template_id: &str
706 /// ) -> Result<()> {
707 /// let response = client.get_query_template()
708 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}/queryTemplates/{query_template_id}"))
709 /// .send().await?;
710 /// println!("response {:?}", response);
711 /// Ok(())
712 /// }
713 /// ```
714 pub fn get_query_template(&self) -> super::builder::analytics_hub_service::GetQueryTemplate {
715 super::builder::analytics_hub_service::GetQueryTemplate::new(self.inner.clone())
716 }
717
718 /// Lists all QueryTemplates in a given project and location.
719 ///
720 /// # Example
721 /// ```
722 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
723 /// use google_cloud_gax::paginator::ItemPaginator as _;
724 /// use google_cloud_bigquery_analyticshub_v1::Result;
725 /// async fn sample(
726 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str
727 /// ) -> Result<()> {
728 /// let mut list = client.list_query_templates()
729 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}"))
730 /// .by_item();
731 /// while let Some(item) = list.next().await.transpose()? {
732 /// println!("{:?}", item);
733 /// }
734 /// Ok(())
735 /// }
736 /// ```
737 pub fn list_query_templates(
738 &self,
739 ) -> super::builder::analytics_hub_service::ListQueryTemplates {
740 super::builder::analytics_hub_service::ListQueryTemplates::new(self.inner.clone())
741 }
742
743 /// Updates an existing QueryTemplate
744 ///
745 /// # Example
746 /// ```
747 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
748 /// # extern crate wkt as google_cloud_wkt;
749 /// use google_cloud_wkt::FieldMask;
750 /// use google_cloud_bigquery_analyticshub_v1::model::QueryTemplate;
751 /// use google_cloud_bigquery_analyticshub_v1::Result;
752 /// async fn sample(
753 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str, query_template_id: &str
754 /// ) -> Result<()> {
755 /// let response = client.update_query_template()
756 /// .set_query_template(
757 /// QueryTemplate::new().set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}/queryTemplates/{query_template_id}"))/* set fields */
758 /// )
759 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
760 /// .send().await?;
761 /// println!("response {:?}", response);
762 /// Ok(())
763 /// }
764 /// ```
765 pub fn update_query_template(
766 &self,
767 ) -> super::builder::analytics_hub_service::UpdateQueryTemplate {
768 super::builder::analytics_hub_service::UpdateQueryTemplate::new(self.inner.clone())
769 }
770
771 /// Deletes a query template.
772 ///
773 /// # Example
774 /// ```
775 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
776 /// use google_cloud_bigquery_analyticshub_v1::Result;
777 /// async fn sample(
778 /// client: &AnalyticsHubService, project_id: &str, location_id: &str, data_exchange_id: &str, query_template_id: &str
779 /// ) -> Result<()> {
780 /// client.delete_query_template()
781 /// .set_name(format!("projects/{project_id}/locations/{location_id}/dataExchanges/{data_exchange_id}/queryTemplates/{query_template_id}"))
782 /// .send().await?;
783 /// Ok(())
784 /// }
785 /// ```
786 pub fn delete_query_template(
787 &self,
788 ) -> super::builder::analytics_hub_service::DeleteQueryTemplate {
789 super::builder::analytics_hub_service::DeleteQueryTemplate::new(self.inner.clone())
790 }
791
792 /// Submits a query template for approval.
793 ///
794 /// # Example
795 /// ```
796 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
797 /// use google_cloud_bigquery_analyticshub_v1::Result;
798 /// async fn sample(
799 /// client: &AnalyticsHubService
800 /// ) -> Result<()> {
801 /// let response = client.submit_query_template()
802 /// /* set fields */
803 /// .send().await?;
804 /// println!("response {:?}", response);
805 /// Ok(())
806 /// }
807 /// ```
808 pub fn submit_query_template(
809 &self,
810 ) -> super::builder::analytics_hub_service::SubmitQueryTemplate {
811 super::builder::analytics_hub_service::SubmitQueryTemplate::new(self.inner.clone())
812 }
813
814 /// Approves a query template.
815 ///
816 /// # Example
817 /// ```
818 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
819 /// use google_cloud_bigquery_analyticshub_v1::Result;
820 /// async fn sample(
821 /// client: &AnalyticsHubService
822 /// ) -> Result<()> {
823 /// let response = client.approve_query_template()
824 /// /* set fields */
825 /// .send().await?;
826 /// println!("response {:?}", response);
827 /// Ok(())
828 /// }
829 /// ```
830 pub fn approve_query_template(
831 &self,
832 ) -> super::builder::analytics_hub_service::ApproveQueryTemplate {
833 super::builder::analytics_hub_service::ApproveQueryTemplate::new(self.inner.clone())
834 }
835
836 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
837 ///
838 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
839 ///
840 /// # Example
841 /// ```
842 /// # use google_cloud_bigquery_analyticshub_v1::client::AnalyticsHubService;
843 /// use google_cloud_bigquery_analyticshub_v1::Result;
844 /// async fn sample(
845 /// client: &AnalyticsHubService
846 /// ) -> Result<()> {
847 /// let response = client.get_operation()
848 /// /* set fields */
849 /// .send().await?;
850 /// println!("response {:?}", response);
851 /// Ok(())
852 /// }
853 /// ```
854 pub fn get_operation(&self) -> super::builder::analytics_hub_service::GetOperation {
855 super::builder::analytics_hub_service::GetOperation::new(self.inner.clone())
856 }
857}