Skip to main content

google_cloud_bigquery_v2/
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 BigQuery API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_bigquery_v2::client::DatasetService;
26/// async fn sample(
27/// ) -> anyhow::Result<()> {
28///     let client = DatasetService::builder().build().await?;
29///     let response = client.get_dataset()
30///         /* set fields */
31///         .send().await?;
32///     println!("response {:?}", response);
33///     Ok(())
34/// }
35/// ```
36///
37/// # Service Description
38///
39/// DatasetService provides methods for managing BigQuery datasets.
40///
41/// # Configuration
42///
43/// To configure `DatasetService` use the `with_*` methods in the type returned
44/// by [builder()][DatasetService::builder]. The default configuration should
45/// work for most applications. Common configuration changes include
46///
47/// * [with_endpoint()]: by default this client uses the global default endpoint
48///   (`https://bigquery.googleapis.com`). Applications using regional
49///   endpoints or running in restricted networks (e.g. a network configured
50///   with [Private Google Access with VPC Service Controls]) may want to
51///   override this default.
52/// * [with_credentials()]: by default this client uses
53///   [Application Default Credentials]. Applications using custom
54///   authentication may need to override this default.
55///
56/// [with_endpoint()]: super::builder::dataset_service::ClientBuilder::with_endpoint
57/// [with_credentials()]: super::builder::dataset_service::ClientBuilder::with_credentials
58/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
59/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
60///
61/// # Pooling and Cloning
62///
63/// `DatasetService` holds a connection pool internally, it is advised to
64/// create one and reuse it. You do not need to wrap `DatasetService` in
65/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
66/// already uses an `Arc` internally.
67#[derive(Clone, Debug)]
68pub struct DatasetService {
69    inner: std::sync::Arc<dyn super::stub::dynamic::DatasetService>,
70}
71
72impl DatasetService {
73    /// Returns a builder for [DatasetService].
74    ///
75    /// ```
76    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
77    /// # use google_cloud_bigquery_v2::client::DatasetService;
78    /// let client = DatasetService::builder().build().await?;
79    /// # Ok(()) }
80    /// ```
81    pub fn builder() -> super::builder::dataset_service::ClientBuilder {
82        crate::new_client_builder(super::builder::dataset_service::client::Factory)
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: impl Into<std::sync::Arc<T>>) -> Self
90    where
91        T: super::stub::DatasetService + 'static,
92    {
93        Self { inner: stub.into() }
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::DatasetService>> {
106        if gaxi::options::tracing_enabled(&conf) {
107            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
108        }
109        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
110    }
111
112    async fn build_transport(
113        conf: gaxi::options::ClientConfig,
114    ) -> crate::ClientBuilderResult<impl super::stub::DatasetService> {
115        super::transport::DatasetService::new(conf).await
116    }
117
118    async fn build_with_tracing(
119        conf: gaxi::options::ClientConfig,
120    ) -> crate::ClientBuilderResult<impl super::stub::DatasetService> {
121        Self::build_transport(conf)
122            .await
123            .map(super::tracing::DatasetService::new)
124    }
125
126    /// Returns the dataset specified by datasetID.
127    ///
128    /// # IAM Permissions
129    ///
130    /// Requires the `bigquery.datasets.get` permission on the dataset.
131    ///
132    /// # Example
133    /// ```
134    /// # use google_cloud_bigquery_v2::client::DatasetService;
135    /// use google_cloud_bigquery_v2::Result;
136    /// async fn sample(
137    ///    client: &DatasetService
138    /// ) -> Result<()> {
139    ///     let response = client.get_dataset()
140    ///         /* set fields */
141    ///         .send().await?;
142    ///     println!("response {:?}", response);
143    ///     Ok(())
144    /// }
145    /// ```
146    pub fn get_dataset(&self) -> super::builder::dataset_service::GetDataset {
147        super::builder::dataset_service::GetDataset::new(self.inner.clone())
148    }
149
150    /// Creates a new empty dataset.
151    ///
152    /// # IAM Permissions
153    ///
154    /// Requires the `bigquery.datasets.create` permission on the project.
155    ///
156    /// # Example
157    /// ```
158    /// # use google_cloud_bigquery_v2::client::DatasetService;
159    /// use google_cloud_bigquery_v2::Result;
160    /// async fn sample(
161    ///    client: &DatasetService
162    /// ) -> Result<()> {
163    ///     let response = client.insert_dataset()
164    ///         /* set fields */
165    ///         .send().await?;
166    ///     println!("response {:?}", response);
167    ///     Ok(())
168    /// }
169    /// ```
170    pub fn insert_dataset(&self) -> super::builder::dataset_service::InsertDataset {
171        super::builder::dataset_service::InsertDataset::new(self.inner.clone())
172    }
173
174    /// Updates information in an existing dataset. The update method replaces the
175    /// entire dataset resource, whereas the patch method only replaces fields that
176    /// are provided in the submitted dataset resource.
177    /// This method supports RFC5789 patch semantics.
178    ///
179    /// # IAM Permissions
180    ///
181    /// Requires the following IAM permission(s) to use this method:
182    ///
183    /// - `bigquery.datasets.update` on the dataset.
184    /// - `bigquery.datasets.get` on the dataset.
185    ///
186    /// # Example
187    /// ```
188    /// # use google_cloud_bigquery_v2::client::DatasetService;
189    /// use google_cloud_bigquery_v2::Result;
190    /// async fn sample(
191    ///    client: &DatasetService
192    /// ) -> Result<()> {
193    ///     let response = client.patch_dataset()
194    ///         /* set fields */
195    ///         .send().await?;
196    ///     println!("response {:?}", response);
197    ///     Ok(())
198    /// }
199    /// ```
200    pub fn patch_dataset(&self) -> super::builder::dataset_service::PatchDataset {
201        super::builder::dataset_service::PatchDataset::new(self.inner.clone())
202    }
203
204    /// Updates information in an existing dataset. The update method replaces the
205    /// entire dataset resource, whereas the patch method only replaces fields that
206    /// are provided in the submitted dataset resource.
207    ///
208    /// # IAM Permissions
209    ///
210    /// Requires the `bigquery.datasets.update` permission on the dataset.
211    ///
212    /// # Example
213    /// ```
214    /// # use google_cloud_bigquery_v2::client::DatasetService;
215    /// use google_cloud_bigquery_v2::Result;
216    /// async fn sample(
217    ///    client: &DatasetService
218    /// ) -> Result<()> {
219    ///     let response = client.update_dataset()
220    ///         /* set fields */
221    ///         .send().await?;
222    ///     println!("response {:?}", response);
223    ///     Ok(())
224    /// }
225    /// ```
226    pub fn update_dataset(&self) -> super::builder::dataset_service::UpdateDataset {
227        super::builder::dataset_service::UpdateDataset::new(self.inner.clone())
228    }
229
230    /// Deletes the dataset specified by the datasetId value. Before you can delete
231    /// a dataset, you must delete all its tables, either manually or by specifying
232    /// deleteContents. Immediately after deletion, you can create another dataset
233    /// with the same name.
234    ///
235    /// # IAM Permissions
236    ///
237    /// Requires the `bigquery.datasets.delete` permission on the dataset.
238    ///
239    /// # Example
240    /// ```
241    /// # use google_cloud_bigquery_v2::client::DatasetService;
242    /// use google_cloud_bigquery_v2::Result;
243    /// async fn sample(
244    ///    client: &DatasetService
245    /// ) -> Result<()> {
246    ///     client.delete_dataset()
247    ///         /* set fields */
248    ///         .send().await?;
249    ///     Ok(())
250    /// }
251    /// ```
252    pub fn delete_dataset(&self) -> super::builder::dataset_service::DeleteDataset {
253        super::builder::dataset_service::DeleteDataset::new(self.inner.clone())
254    }
255
256    /// Lists all datasets in the specified project to which the user has been
257    /// granted the READER dataset role.
258    ///
259    /// # IAM Permissions
260    ///
261    /// Requires no specific IAM permission(s) to use this method.
262    /// Results are filtered to only include datasets on which the caller has the
263    /// `bigquery.datasets.get` permission.
264    ///
265    /// # Example
266    /// ```
267    /// # use google_cloud_bigquery_v2::client::DatasetService;
268    /// use google_cloud_gax::paginator::ItemPaginator as _;
269    /// use google_cloud_bigquery_v2::Result;
270    /// async fn sample(
271    ///    client: &DatasetService
272    /// ) -> Result<()> {
273    ///     let mut list = client.list_datasets()
274    ///         /* set fields */
275    ///         .by_item();
276    ///     while let Some(item) = list.next().await.transpose()? {
277    ///         println!("{:?}", item);
278    ///     }
279    ///     Ok(())
280    /// }
281    /// ```
282    pub fn list_datasets(&self) -> super::builder::dataset_service::ListDatasets {
283        super::builder::dataset_service::ListDatasets::new(self.inner.clone())
284    }
285
286    /// Undeletes a dataset which is within time travel window based on datasetId.
287    /// If a time is specified, the dataset version deleted at that time is
288    /// undeleted, else the last live version is undeleted.
289    ///
290    /// # IAM Permissions
291    ///
292    /// Requires the following IAM permission(s) to use this method:
293    ///
294    /// - `bigquery.datasets.create` on the project.
295    /// - `bigquery.datasets.get` on the dataset.
296    ///
297    /// # Example
298    /// ```
299    /// # use google_cloud_bigquery_v2::client::DatasetService;
300    /// use google_cloud_bigquery_v2::Result;
301    /// async fn sample(
302    ///    client: &DatasetService
303    /// ) -> Result<()> {
304    ///     let response = client.undelete_dataset()
305    ///         /* set fields */
306    ///         .send().await?;
307    ///     println!("response {:?}", response);
308    ///     Ok(())
309    /// }
310    /// ```
311    pub fn undelete_dataset(&self) -> super::builder::dataset_service::UndeleteDataset {
312        super::builder::dataset_service::UndeleteDataset::new(self.inner.clone())
313    }
314}
315
316/// Implements a client for the BigQuery API.
317///
318/// # Example
319/// ```
320/// # use google_cloud_bigquery_v2::client::JobService;
321/// async fn sample(
322/// ) -> anyhow::Result<()> {
323///     let client = JobService::builder().build().await?;
324///     let response = client.cancel_job()
325///         /* set fields */
326///         .send().await?;
327///     println!("response {:?}", response);
328///     Ok(())
329/// }
330/// ```
331///
332/// # Service Description
333///
334///
335/// # Configuration
336///
337/// To configure `JobService` use the `with_*` methods in the type returned
338/// by [builder()][JobService::builder]. The default configuration should
339/// work for most applications. Common configuration changes include
340///
341/// * [with_endpoint()]: by default this client uses the global default endpoint
342///   (`https://bigquery.googleapis.com`). Applications using regional
343///   endpoints or running in restricted networks (e.g. a network configured
344///   with [Private Google Access with VPC Service Controls]) may want to
345///   override this default.
346/// * [with_credentials()]: by default this client uses
347///   [Application Default Credentials]. Applications using custom
348///   authentication may need to override this default.
349///
350/// [with_endpoint()]: super::builder::job_service::ClientBuilder::with_endpoint
351/// [with_credentials()]: super::builder::job_service::ClientBuilder::with_credentials
352/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
353/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
354///
355/// # Pooling and Cloning
356///
357/// `JobService` holds a connection pool internally, it is advised to
358/// create one and reuse it. You do not need to wrap `JobService` in
359/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
360/// already uses an `Arc` internally.
361#[derive(Clone, Debug)]
362pub struct JobService {
363    inner: std::sync::Arc<dyn super::stub::dynamic::JobService>,
364}
365
366impl JobService {
367    /// Returns a builder for [JobService].
368    ///
369    /// ```
370    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
371    /// # use google_cloud_bigquery_v2::client::JobService;
372    /// let client = JobService::builder().build().await?;
373    /// # Ok(()) }
374    /// ```
375    pub fn builder() -> super::builder::job_service::ClientBuilder {
376        crate::new_client_builder(super::builder::job_service::client::Factory)
377    }
378
379    /// Creates a new client from the provided stub.
380    ///
381    /// The most common case for calling this function is in tests mocking the
382    /// client's behavior.
383    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
384    where
385        T: super::stub::JobService + 'static,
386    {
387        Self { inner: stub.into() }
388    }
389
390    pub(crate) async fn new(
391        config: gaxi::options::ClientConfig,
392    ) -> crate::ClientBuilderResult<Self> {
393        let inner = Self::build_inner(config).await?;
394        Ok(Self { inner })
395    }
396
397    async fn build_inner(
398        conf: gaxi::options::ClientConfig,
399    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::JobService>> {
400        if gaxi::options::tracing_enabled(&conf) {
401            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
402        }
403        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
404    }
405
406    async fn build_transport(
407        conf: gaxi::options::ClientConfig,
408    ) -> crate::ClientBuilderResult<impl super::stub::JobService> {
409        super::transport::JobService::new(conf).await
410    }
411
412    async fn build_with_tracing(
413        conf: gaxi::options::ClientConfig,
414    ) -> crate::ClientBuilderResult<impl super::stub::JobService> {
415        Self::build_transport(conf)
416            .await
417            .map(super::tracing::JobService::new)
418    }
419
420    /// Requests that a job be cancelled. This call will return immediately, and
421    /// the client will need to poll for the job status to see if the cancel
422    /// completed successfully. Cancelled jobs may still incur costs.
423    ///
424    /// # IAM Permissions
425    ///
426    /// Requires the `bigquery.jobs.update` permission on the job resource.
427    /// If the user matches the creator of the job, the `bigquery.jobs.create`
428    /// permission on the project is required instead.
429    ///
430    /// # Example
431    /// ```
432    /// # use google_cloud_bigquery_v2::client::JobService;
433    /// use google_cloud_bigquery_v2::Result;
434    /// async fn sample(
435    ///    client: &JobService
436    /// ) -> Result<()> {
437    ///     let response = client.cancel_job()
438    ///         /* set fields */
439    ///         .send().await?;
440    ///     println!("response {:?}", response);
441    ///     Ok(())
442    /// }
443    /// ```
444    pub fn cancel_job(&self) -> super::builder::job_service::CancelJob {
445        super::builder::job_service::CancelJob::new(self.inner.clone())
446    }
447
448    /// Returns information about a specific job. Job information is available for
449    /// a six month period after creation. Requires that you're the person who ran
450    /// the job, or have the Is Owner project role.
451    ///
452    /// # IAM Permissions
453    ///
454    /// Requires the `bigquery.jobs.get` permission on the job resource.
455    /// If the user matches the creator of the job, the `bigquery.jobs.create`
456    /// permission on the project is required instead.
457    ///
458    /// # Example
459    /// ```
460    /// # use google_cloud_bigquery_v2::client::JobService;
461    /// use google_cloud_bigquery_v2::Result;
462    /// async fn sample(
463    ///    client: &JobService
464    /// ) -> Result<()> {
465    ///     let response = client.get_job()
466    ///         /* set fields */
467    ///         .send().await?;
468    ///     println!("response {:?}", response);
469    ///     Ok(())
470    /// }
471    /// ```
472    pub fn get_job(&self) -> super::builder::job_service::GetJob {
473        super::builder::job_service::GetJob::new(self.inner.clone())
474    }
475
476    /// Starts a new asynchronous job.
477    ///
478    /// This API has two different kinds of endpoint URIs, as this method supports
479    /// a variety of use cases.
480    ///
481    /// * The *Metadata* URI is used for most interactions, as it accepts the job
482    ///   configuration directly.
483    /// * The *Upload* URI is ONLY for the case when you're sending both a load job
484    ///   configuration and a data stream together.  In this case, the Upload URI
485    ///   accepts the job configuration and the data as two distinct multipart MIME
486    ///   parts.
487    ///
488    /// # IAM Permissions
489    ///
490    /// Requires the `bigquery.jobs.create` permission on the project resource.
491    ///
492    /// Additional permissions are required depending on the job type:
493    ///
494    /// - **Load, Export, and Copy jobs**: Generally require data-level
495    ///   permissions such as `bigquery.tables.export` or access to external
496    ///   storage.
497    /// - **Query jobs**: Permissions are dependent on the SQL statement.
498    ///   Complex queries (DDL, DCL) may require additional permissions to
499    ///   create reservations, modify IAM policies, or update project settings.
500    ///
501    /// # Example
502    /// ```
503    /// # use google_cloud_bigquery_v2::client::JobService;
504    /// use google_cloud_bigquery_v2::Result;
505    /// async fn sample(
506    ///    client: &JobService
507    /// ) -> Result<()> {
508    ///     let response = client.insert_job()
509    ///         /* set fields */
510    ///         .send().await?;
511    ///     println!("response {:?}", response);
512    ///     Ok(())
513    /// }
514    /// ```
515    pub fn insert_job(&self) -> super::builder::job_service::InsertJob {
516        super::builder::job_service::InsertJob::new(self.inner.clone())
517    }
518
519    /// Requests the deletion of the metadata of a job. This call returns when the
520    /// job's metadata is deleted.
521    ///
522    /// # IAM Permissions
523    ///
524    /// Requires the `bigquery.jobs.delete` permission on the job resource.
525    ///
526    /// # Example
527    /// ```
528    /// # use google_cloud_bigquery_v2::client::JobService;
529    /// use google_cloud_bigquery_v2::Result;
530    /// async fn sample(
531    ///    client: &JobService
532    /// ) -> Result<()> {
533    ///     client.delete_job()
534    ///         /* set fields */
535    ///         .send().await?;
536    ///     Ok(())
537    /// }
538    /// ```
539    pub fn delete_job(&self) -> super::builder::job_service::DeleteJob {
540        super::builder::job_service::DeleteJob::new(self.inner.clone())
541    }
542
543    /// Lists all jobs that you started in the specified project. Job information
544    /// is available for a six month period after creation. The job list is sorted
545    /// in reverse chronological order, by job creation time. Requires the Can View
546    /// project role, or the Is Owner project role if you set the allUsers
547    /// property.
548    ///
549    /// # IAM Permissions
550    ///
551    /// Requires no specific IAM permission(s) to use this method. Users are able
552    /// to list the jobs they created.
553    ///
554    /// Additional access is granted based on the following permissions:
555    ///
556    /// - Users with the `bigquery.jobs.listAll` permission can list all jobs with
557    ///   all metadata.
558    /// - Users with the `bigquery.jobs.list` permission can list all jobs, but
559    ///   with redacted information for jobs they did not create.
560    ///
561    /// # Example
562    /// ```
563    /// # use google_cloud_bigquery_v2::client::JobService;
564    /// use google_cloud_gax::paginator::ItemPaginator as _;
565    /// use google_cloud_bigquery_v2::Result;
566    /// async fn sample(
567    ///    client: &JobService
568    /// ) -> Result<()> {
569    ///     let mut list = client.list_jobs()
570    ///         /* set fields */
571    ///         .by_item();
572    ///     while let Some(item) = list.next().await.transpose()? {
573    ///         println!("{:?}", item);
574    ///     }
575    ///     Ok(())
576    /// }
577    /// ```
578    pub fn list_jobs(&self) -> super::builder::job_service::ListJobs {
579        super::builder::job_service::ListJobs::new(self.inner.clone())
580    }
581
582    /// RPC to get the results of a query job.
583    ///
584    /// # IAM Permissions
585    ///
586    /// Requires the following IAM permission(s) to use this method:
587    ///
588    /// - `bigquery.jobs.get` on the job.
589    /// - `bigquery.tables.getData` on the destination table.
590    ///
591    /// If the user matches the creator of the job, the following IAM permission(s)
592    /// are required instead:
593    ///
594    /// - `bigquery.jobs.create` on the project.
595    /// - `bigquery.tables.getData` on the destination table.
596    ///
597    /// # Example
598    /// ```
599    /// # use google_cloud_bigquery_v2::client::JobService;
600    /// use google_cloud_bigquery_v2::Result;
601    /// async fn sample(
602    ///    client: &JobService
603    /// ) -> Result<()> {
604    ///     let response = client.get_query_results()
605    ///         /* set fields */
606    ///         .send().await?;
607    ///     println!("response {:?}", response);
608    ///     Ok(())
609    /// }
610    /// ```
611    pub fn get_query_results(&self) -> super::builder::job_service::GetQueryResults {
612        super::builder::job_service::GetQueryResults::new(self.inner.clone())
613    }
614
615    /// Runs a BigQuery SQL query synchronously and returns query results if the
616    /// query completes within a specified timeout.
617    ///
618    /// # IAM Permissions
619    ///
620    /// Requires the `bigquery.jobs.create` permission on the project resource.
621    ///
622    /// Data-level permissions are highly dependent on the SQL statement being
623    /// executed. While standard queries require data access (such as
624    /// `bigquery.tables.getData`), complex operations like DDL or DCL may require
625    /// permissions to manage reservations, IAM policies, or project settings.
626    ///
627    /// # Example
628    /// ```
629    /// # use google_cloud_bigquery_v2::client::JobService;
630    /// use google_cloud_bigquery_v2::Result;
631    /// async fn sample(
632    ///    client: &JobService
633    /// ) -> Result<()> {
634    ///     let response = client.query()
635    ///         /* set fields */
636    ///         .send().await?;
637    ///     println!("response {:?}", response);
638    ///     Ok(())
639    /// }
640    /// ```
641    pub fn query(&self) -> super::builder::job_service::Query {
642        super::builder::job_service::Query::new(self.inner.clone())
643    }
644}
645
646/// Implements a client for the BigQuery API.
647///
648/// # Example
649/// ```
650/// # use google_cloud_bigquery_v2::client::ModelService;
651/// async fn sample(
652/// ) -> anyhow::Result<()> {
653///     let client = ModelService::builder().build().await?;
654///     let response = client.get_model()
655///         /* set fields */
656///         .send().await?;
657///     println!("response {:?}", response);
658///     Ok(())
659/// }
660/// ```
661///
662/// # Service Description
663///
664/// Model Service for BigQuery ML
665///
666/// # Configuration
667///
668/// To configure `ModelService` use the `with_*` methods in the type returned
669/// by [builder()][ModelService::builder]. The default configuration should
670/// work for most applications. Common configuration changes include
671///
672/// * [with_endpoint()]: by default this client uses the global default endpoint
673///   (`https://bigquery.googleapis.com`). Applications using regional
674///   endpoints or running in restricted networks (e.g. a network configured
675///   with [Private Google Access with VPC Service Controls]) may want to
676///   override this default.
677/// * [with_credentials()]: by default this client uses
678///   [Application Default Credentials]. Applications using custom
679///   authentication may need to override this default.
680///
681/// [with_endpoint()]: super::builder::model_service::ClientBuilder::with_endpoint
682/// [with_credentials()]: super::builder::model_service::ClientBuilder::with_credentials
683/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
684/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
685///
686/// # Pooling and Cloning
687///
688/// `ModelService` holds a connection pool internally, it is advised to
689/// create one and reuse it. You do not need to wrap `ModelService` in
690/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
691/// already uses an `Arc` internally.
692#[derive(Clone, Debug)]
693pub struct ModelService {
694    inner: std::sync::Arc<dyn super::stub::dynamic::ModelService>,
695}
696
697impl ModelService {
698    /// Returns a builder for [ModelService].
699    ///
700    /// ```
701    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
702    /// # use google_cloud_bigquery_v2::client::ModelService;
703    /// let client = ModelService::builder().build().await?;
704    /// # Ok(()) }
705    /// ```
706    pub fn builder() -> super::builder::model_service::ClientBuilder {
707        crate::new_client_builder(super::builder::model_service::client::Factory)
708    }
709
710    /// Creates a new client from the provided stub.
711    ///
712    /// The most common case for calling this function is in tests mocking the
713    /// client's behavior.
714    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
715    where
716        T: super::stub::ModelService + 'static,
717    {
718        Self { inner: stub.into() }
719    }
720
721    pub(crate) async fn new(
722        config: gaxi::options::ClientConfig,
723    ) -> crate::ClientBuilderResult<Self> {
724        let inner = Self::build_inner(config).await?;
725        Ok(Self { inner })
726    }
727
728    async fn build_inner(
729        conf: gaxi::options::ClientConfig,
730    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ModelService>> {
731        if gaxi::options::tracing_enabled(&conf) {
732            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
733        }
734        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
735    }
736
737    async fn build_transport(
738        conf: gaxi::options::ClientConfig,
739    ) -> crate::ClientBuilderResult<impl super::stub::ModelService> {
740        super::transport::ModelService::new(conf).await
741    }
742
743    async fn build_with_tracing(
744        conf: gaxi::options::ClientConfig,
745    ) -> crate::ClientBuilderResult<impl super::stub::ModelService> {
746        Self::build_transport(conf)
747            .await
748            .map(super::tracing::ModelService::new)
749    }
750
751    /// Gets the specified model resource by model ID.
752    ///
753    /// # IAM Permissions
754    ///
755    /// Requires the `bigquery.models.getMetadata` permission on the model.
756    ///
757    /// # Example
758    /// ```
759    /// # use google_cloud_bigquery_v2::client::ModelService;
760    /// use google_cloud_bigquery_v2::Result;
761    /// async fn sample(
762    ///    client: &ModelService
763    /// ) -> Result<()> {
764    ///     let response = client.get_model()
765    ///         /* set fields */
766    ///         .send().await?;
767    ///     println!("response {:?}", response);
768    ///     Ok(())
769    /// }
770    /// ```
771    pub fn get_model(&self) -> super::builder::model_service::GetModel {
772        super::builder::model_service::GetModel::new(self.inner.clone())
773    }
774
775    /// Lists all models in the specified dataset. Requires the READER dataset
776    /// role. After retrieving the list of models, you can get information about a
777    /// particular model by calling the models.get method.
778    ///
779    /// # IAM Permissions
780    ///
781    /// Requires the `bigquery.models.list` permission on the dataset.
782    ///
783    /// # Example
784    /// ```
785    /// # use google_cloud_bigquery_v2::client::ModelService;
786    /// use google_cloud_gax::paginator::ItemPaginator as _;
787    /// use google_cloud_bigquery_v2::Result;
788    /// async fn sample(
789    ///    client: &ModelService
790    /// ) -> Result<()> {
791    ///     let mut list = client.list_models()
792    ///         /* set fields */
793    ///         .by_item();
794    ///     while let Some(item) = list.next().await.transpose()? {
795    ///         println!("{:?}", item);
796    ///     }
797    ///     Ok(())
798    /// }
799    /// ```
800    pub fn list_models(&self) -> super::builder::model_service::ListModels {
801        super::builder::model_service::ListModels::new(self.inner.clone())
802    }
803
804    /// Patch specific fields in the specified model.
805    ///
806    /// # IAM Permissions
807    ///
808    /// Requires the `bigquery.models.updateMetadata` permission on the model.
809    ///
810    /// # Example
811    /// ```
812    /// # use google_cloud_bigquery_v2::client::ModelService;
813    /// use google_cloud_bigquery_v2::Result;
814    /// async fn sample(
815    ///    client: &ModelService
816    /// ) -> Result<()> {
817    ///     let response = client.patch_model()
818    ///         /* set fields */
819    ///         .send().await?;
820    ///     println!("response {:?}", response);
821    ///     Ok(())
822    /// }
823    /// ```
824    pub fn patch_model(&self) -> super::builder::model_service::PatchModel {
825        super::builder::model_service::PatchModel::new(self.inner.clone())
826    }
827
828    /// Deletes the model specified by modelId from the dataset.
829    ///
830    /// # IAM Permissions
831    ///
832    /// Requires the `bigquery.models.delete` permission on the model.
833    ///
834    /// # Example
835    /// ```
836    /// # use google_cloud_bigquery_v2::client::ModelService;
837    /// use google_cloud_bigquery_v2::Result;
838    /// async fn sample(
839    ///    client: &ModelService
840    /// ) -> Result<()> {
841    ///     client.delete_model()
842    ///         /* set fields */
843    ///         .send().await?;
844    ///     Ok(())
845    /// }
846    /// ```
847    pub fn delete_model(&self) -> super::builder::model_service::DeleteModel {
848        super::builder::model_service::DeleteModel::new(self.inner.clone())
849    }
850}
851
852/// Implements a client for the BigQuery API.
853///
854/// # Example
855/// ```
856/// # use google_cloud_bigquery_v2::client::ProjectService;
857/// async fn sample(
858/// ) -> anyhow::Result<()> {
859///     let client = ProjectService::builder().build().await?;
860///     let response = client.get_service_account()
861///         /* set fields */
862///         .send().await?;
863///     println!("response {:?}", response);
864///     Ok(())
865/// }
866/// ```
867///
868/// # Service Description
869///
870/// This service provides access to BigQuery functionality related to projects.
871///
872/// # Configuration
873///
874/// To configure `ProjectService` use the `with_*` methods in the type returned
875/// by [builder()][ProjectService::builder]. The default configuration should
876/// work for most applications. Common configuration changes include
877///
878/// * [with_endpoint()]: by default this client uses the global default endpoint
879///   (`https://bigquery.googleapis.com`). Applications using regional
880///   endpoints or running in restricted networks (e.g. a network configured
881///   with [Private Google Access with VPC Service Controls]) may want to
882///   override this default.
883/// * [with_credentials()]: by default this client uses
884///   [Application Default Credentials]. Applications using custom
885///   authentication may need to override this default.
886///
887/// [with_endpoint()]: super::builder::project_service::ClientBuilder::with_endpoint
888/// [with_credentials()]: super::builder::project_service::ClientBuilder::with_credentials
889/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
890/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
891///
892/// # Pooling and Cloning
893///
894/// `ProjectService` holds a connection pool internally, it is advised to
895/// create one and reuse it. You do not need to wrap `ProjectService` in
896/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
897/// already uses an `Arc` internally.
898#[derive(Clone, Debug)]
899pub struct ProjectService {
900    inner: std::sync::Arc<dyn super::stub::dynamic::ProjectService>,
901}
902
903impl ProjectService {
904    /// Returns a builder for [ProjectService].
905    ///
906    /// ```
907    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
908    /// # use google_cloud_bigquery_v2::client::ProjectService;
909    /// let client = ProjectService::builder().build().await?;
910    /// # Ok(()) }
911    /// ```
912    pub fn builder() -> super::builder::project_service::ClientBuilder {
913        crate::new_client_builder(super::builder::project_service::client::Factory)
914    }
915
916    /// Creates a new client from the provided stub.
917    ///
918    /// The most common case for calling this function is in tests mocking the
919    /// client's behavior.
920    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
921    where
922        T: super::stub::ProjectService + 'static,
923    {
924        Self { inner: stub.into() }
925    }
926
927    pub(crate) async fn new(
928        config: gaxi::options::ClientConfig,
929    ) -> crate::ClientBuilderResult<Self> {
930        let inner = Self::build_inner(config).await?;
931        Ok(Self { inner })
932    }
933
934    async fn build_inner(
935        conf: gaxi::options::ClientConfig,
936    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ProjectService>> {
937        if gaxi::options::tracing_enabled(&conf) {
938            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
939        }
940        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
941    }
942
943    async fn build_transport(
944        conf: gaxi::options::ClientConfig,
945    ) -> crate::ClientBuilderResult<impl super::stub::ProjectService> {
946        super::transport::ProjectService::new(conf).await
947    }
948
949    async fn build_with_tracing(
950        conf: gaxi::options::ClientConfig,
951    ) -> crate::ClientBuilderResult<impl super::stub::ProjectService> {
952        Self::build_transport(conf)
953            .await
954            .map(super::tracing::ProjectService::new)
955    }
956
957    /// RPC to get the service account for a project used for interactions with
958    /// Google Cloud KMS. Requires the `bigquery.jobs.create` permission on the
959    /// project resource. This permission is required to authorize the retrieval
960    /// of the project's service identity for technical management tasks like
961    /// encryption configuration.
962    ///
963    /// # Example
964    /// ```
965    /// # use google_cloud_bigquery_v2::client::ProjectService;
966    /// use google_cloud_bigquery_v2::Result;
967    /// async fn sample(
968    ///    client: &ProjectService
969    /// ) -> Result<()> {
970    ///     let response = client.get_service_account()
971    ///         /* set fields */
972    ///         .send().await?;
973    ///     println!("response {:?}", response);
974    ///     Ok(())
975    /// }
976    /// ```
977    pub fn get_service_account(&self) -> super::builder::project_service::GetServiceAccount {
978        super::builder::project_service::GetServiceAccount::new(self.inner.clone())
979    }
980}
981
982/// Implements a client for the BigQuery API.
983///
984/// # Example
985/// ```
986/// # use google_cloud_bigquery_v2::client::RoutineService;
987/// async fn sample(
988/// ) -> anyhow::Result<()> {
989///     let client = RoutineService::builder().build().await?;
990///     let response = client.get_routine()
991///         /* set fields */
992///         .send().await?;
993///     println!("response {:?}", response);
994///     Ok(())
995/// }
996/// ```
997///
998/// # Service Description
999///
1000/// RoutineService provides management access to BigQuery routines.
1001///
1002/// # Configuration
1003///
1004/// To configure `RoutineService` use the `with_*` methods in the type returned
1005/// by [builder()][RoutineService::builder]. The default configuration should
1006/// work for most applications. Common configuration changes include
1007///
1008/// * [with_endpoint()]: by default this client uses the global default endpoint
1009///   (`https://bigquery.googleapis.com`). Applications using regional
1010///   endpoints or running in restricted networks (e.g. a network configured
1011///   with [Private Google Access with VPC Service Controls]) may want to
1012///   override this default.
1013/// * [with_credentials()]: by default this client uses
1014///   [Application Default Credentials]. Applications using custom
1015///   authentication may need to override this default.
1016///
1017/// [with_endpoint()]: super::builder::routine_service::ClientBuilder::with_endpoint
1018/// [with_credentials()]: super::builder::routine_service::ClientBuilder::with_credentials
1019/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1020/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1021///
1022/// # Pooling and Cloning
1023///
1024/// `RoutineService` holds a connection pool internally, it is advised to
1025/// create one and reuse it. You do not need to wrap `RoutineService` in
1026/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1027/// already uses an `Arc` internally.
1028#[derive(Clone, Debug)]
1029pub struct RoutineService {
1030    inner: std::sync::Arc<dyn super::stub::dynamic::RoutineService>,
1031}
1032
1033impl RoutineService {
1034    /// Returns a builder for [RoutineService].
1035    ///
1036    /// ```
1037    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1038    /// # use google_cloud_bigquery_v2::client::RoutineService;
1039    /// let client = RoutineService::builder().build().await?;
1040    /// # Ok(()) }
1041    /// ```
1042    pub fn builder() -> super::builder::routine_service::ClientBuilder {
1043        crate::new_client_builder(super::builder::routine_service::client::Factory)
1044    }
1045
1046    /// Creates a new client from the provided stub.
1047    ///
1048    /// The most common case for calling this function is in tests mocking the
1049    /// client's behavior.
1050    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1051    where
1052        T: super::stub::RoutineService + 'static,
1053    {
1054        Self { inner: stub.into() }
1055    }
1056
1057    pub(crate) async fn new(
1058        config: gaxi::options::ClientConfig,
1059    ) -> crate::ClientBuilderResult<Self> {
1060        let inner = Self::build_inner(config).await?;
1061        Ok(Self { inner })
1062    }
1063
1064    async fn build_inner(
1065        conf: gaxi::options::ClientConfig,
1066    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::RoutineService>> {
1067        if gaxi::options::tracing_enabled(&conf) {
1068            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1069        }
1070        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1071    }
1072
1073    async fn build_transport(
1074        conf: gaxi::options::ClientConfig,
1075    ) -> crate::ClientBuilderResult<impl super::stub::RoutineService> {
1076        super::transport::RoutineService::new(conf).await
1077    }
1078
1079    async fn build_with_tracing(
1080        conf: gaxi::options::ClientConfig,
1081    ) -> crate::ClientBuilderResult<impl super::stub::RoutineService> {
1082        Self::build_transport(conf)
1083            .await
1084            .map(super::tracing::RoutineService::new)
1085    }
1086
1087    /// Gets the specified routine resource by routine ID.
1088    ///
1089    /// # IAM Permissions
1090    ///
1091    /// Requires the `bigquery.routines.get` permission on the routine.
1092    ///
1093    /// # Example
1094    /// ```
1095    /// # use google_cloud_bigquery_v2::client::RoutineService;
1096    /// use google_cloud_bigquery_v2::Result;
1097    /// async fn sample(
1098    ///    client: &RoutineService
1099    /// ) -> Result<()> {
1100    ///     let response = client.get_routine()
1101    ///         /* set fields */
1102    ///         .send().await?;
1103    ///     println!("response {:?}", response);
1104    ///     Ok(())
1105    /// }
1106    /// ```
1107    pub fn get_routine(&self) -> super::builder::routine_service::GetRoutine {
1108        super::builder::routine_service::GetRoutine::new(self.inner.clone())
1109    }
1110
1111    /// Creates a new routine in the dataset.
1112    ///
1113    /// # IAM Permissions
1114    ///
1115    /// Requires the `bigquery.routines.create` permission on the dataset.
1116    ///
1117    /// # Example
1118    /// ```
1119    /// # use google_cloud_bigquery_v2::client::RoutineService;
1120    /// use google_cloud_bigquery_v2::Result;
1121    /// async fn sample(
1122    ///    client: &RoutineService
1123    /// ) -> Result<()> {
1124    ///     let response = client.insert_routine()
1125    ///         /* set fields */
1126    ///         .send().await?;
1127    ///     println!("response {:?}", response);
1128    ///     Ok(())
1129    /// }
1130    /// ```
1131    pub fn insert_routine(&self) -> super::builder::routine_service::InsertRoutine {
1132        super::builder::routine_service::InsertRoutine::new(self.inner.clone())
1133    }
1134
1135    /// Updates information in an existing routine. The update method replaces the
1136    /// entire Routine resource.
1137    ///
1138    /// # IAM Permissions
1139    ///
1140    /// Requires the `bigquery.routines.update` permission on the routine.
1141    ///
1142    /// # Example
1143    /// ```
1144    /// # use google_cloud_bigquery_v2::client::RoutineService;
1145    /// use google_cloud_bigquery_v2::Result;
1146    /// async fn sample(
1147    ///    client: &RoutineService
1148    /// ) -> Result<()> {
1149    ///     let response = client.update_routine()
1150    ///         /* set fields */
1151    ///         .send().await?;
1152    ///     println!("response {:?}", response);
1153    ///     Ok(())
1154    /// }
1155    /// ```
1156    pub fn update_routine(&self) -> super::builder::routine_service::UpdateRoutine {
1157        super::builder::routine_service::UpdateRoutine::new(self.inner.clone())
1158    }
1159
1160    /// Deletes the routine specified by routineId from the dataset.
1161    ///
1162    /// # IAM Permissions
1163    ///
1164    /// Requires the `bigquery.routines.delete` permission on the routine.
1165    ///
1166    /// # Example
1167    /// ```
1168    /// # use google_cloud_bigquery_v2::client::RoutineService;
1169    /// use google_cloud_bigquery_v2::Result;
1170    /// async fn sample(
1171    ///    client: &RoutineService
1172    /// ) -> Result<()> {
1173    ///     client.delete_routine()
1174    ///         /* set fields */
1175    ///         .send().await?;
1176    ///     Ok(())
1177    /// }
1178    /// ```
1179    pub fn delete_routine(&self) -> super::builder::routine_service::DeleteRoutine {
1180        super::builder::routine_service::DeleteRoutine::new(self.inner.clone())
1181    }
1182
1183    /// Lists all routines in the specified dataset. Requires the READER dataset
1184    /// role.
1185    ///
1186    /// # IAM Permissions
1187    ///
1188    /// Requires the `bigquery.routines.list` permission on the dataset.
1189    ///
1190    /// # Example
1191    /// ```
1192    /// # use google_cloud_bigquery_v2::client::RoutineService;
1193    /// use google_cloud_gax::paginator::ItemPaginator as _;
1194    /// use google_cloud_bigquery_v2::Result;
1195    /// async fn sample(
1196    ///    client: &RoutineService
1197    /// ) -> Result<()> {
1198    ///     let mut list = client.list_routines()
1199    ///         /* set fields */
1200    ///         .by_item();
1201    ///     while let Some(item) = list.next().await.transpose()? {
1202    ///         println!("{:?}", item);
1203    ///     }
1204    ///     Ok(())
1205    /// }
1206    /// ```
1207    pub fn list_routines(&self) -> super::builder::routine_service::ListRoutines {
1208        super::builder::routine_service::ListRoutines::new(self.inner.clone())
1209    }
1210}
1211
1212/// Implements a client for the BigQuery API.
1213///
1214/// # Example
1215/// ```
1216/// # use google_cloud_bigquery_v2::client::RowAccessPolicyService;
1217/// async fn sample(
1218/// ) -> anyhow::Result<()> {
1219///     let client = RowAccessPolicyService::builder().build().await?;
1220///     let response = client.get_row_access_policy()
1221///         /* set fields */
1222///         .send().await?;
1223///     println!("response {:?}", response);
1224///     Ok(())
1225/// }
1226/// ```
1227///
1228/// # Service Description
1229///
1230/// Service for interacting with row access policies.
1231///
1232/// # Configuration
1233///
1234/// To configure `RowAccessPolicyService` use the `with_*` methods in the type returned
1235/// by [builder()][RowAccessPolicyService::builder]. The default configuration should
1236/// work for most applications. Common configuration changes include
1237///
1238/// * [with_endpoint()]: by default this client uses the global default endpoint
1239///   (`https://bigquery.googleapis.com`). Applications using regional
1240///   endpoints or running in restricted networks (e.g. a network configured
1241///   with [Private Google Access with VPC Service Controls]) may want to
1242///   override this default.
1243/// * [with_credentials()]: by default this client uses
1244///   [Application Default Credentials]. Applications using custom
1245///   authentication may need to override this default.
1246///
1247/// [with_endpoint()]: super::builder::row_access_policy_service::ClientBuilder::with_endpoint
1248/// [with_credentials()]: super::builder::row_access_policy_service::ClientBuilder::with_credentials
1249/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1250/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1251///
1252/// # Pooling and Cloning
1253///
1254/// `RowAccessPolicyService` holds a connection pool internally, it is advised to
1255/// create one and reuse it. You do not need to wrap `RowAccessPolicyService` in
1256/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1257/// already uses an `Arc` internally.
1258#[derive(Clone, Debug)]
1259pub struct RowAccessPolicyService {
1260    inner: std::sync::Arc<dyn super::stub::dynamic::RowAccessPolicyService>,
1261}
1262
1263impl RowAccessPolicyService {
1264    /// Returns a builder for [RowAccessPolicyService].
1265    ///
1266    /// ```
1267    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1268    /// # use google_cloud_bigquery_v2::client::RowAccessPolicyService;
1269    /// let client = RowAccessPolicyService::builder().build().await?;
1270    /// # Ok(()) }
1271    /// ```
1272    pub fn builder() -> super::builder::row_access_policy_service::ClientBuilder {
1273        crate::new_client_builder(super::builder::row_access_policy_service::client::Factory)
1274    }
1275
1276    /// Creates a new client from the provided stub.
1277    ///
1278    /// The most common case for calling this function is in tests mocking the
1279    /// client's behavior.
1280    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1281    where
1282        T: super::stub::RowAccessPolicyService + 'static,
1283    {
1284        Self { inner: stub.into() }
1285    }
1286
1287    pub(crate) async fn new(
1288        config: gaxi::options::ClientConfig,
1289    ) -> crate::ClientBuilderResult<Self> {
1290        let inner = Self::build_inner(config).await?;
1291        Ok(Self { inner })
1292    }
1293
1294    async fn build_inner(
1295        conf: gaxi::options::ClientConfig,
1296    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::RowAccessPolicyService>>
1297    {
1298        if gaxi::options::tracing_enabled(&conf) {
1299            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1300        }
1301        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1302    }
1303
1304    async fn build_transport(
1305        conf: gaxi::options::ClientConfig,
1306    ) -> crate::ClientBuilderResult<impl super::stub::RowAccessPolicyService> {
1307        super::transport::RowAccessPolicyService::new(conf).await
1308    }
1309
1310    async fn build_with_tracing(
1311        conf: gaxi::options::ClientConfig,
1312    ) -> crate::ClientBuilderResult<impl super::stub::RowAccessPolicyService> {
1313        Self::build_transport(conf)
1314            .await
1315            .map(super::tracing::RowAccessPolicyService::new)
1316    }
1317
1318    /// Lists all row access policies on the specified table.
1319    ///
1320    /// # IAM Permissions
1321    ///
1322    /// Requires the `bigquery.rowAccessPolicies.list` permission on the table.
1323    ///
1324    /// # Example
1325    /// ```
1326    /// # use google_cloud_bigquery_v2::client::RowAccessPolicyService;
1327    /// use google_cloud_gax::paginator::ItemPaginator as _;
1328    /// use google_cloud_bigquery_v2::Result;
1329    /// async fn sample(
1330    ///    client: &RowAccessPolicyService
1331    /// ) -> Result<()> {
1332    ///     let mut list = client.list_row_access_policies()
1333    ///         /* set fields */
1334    ///         .by_item();
1335    ///     while let Some(item) = list.next().await.transpose()? {
1336    ///         println!("{:?}", item);
1337    ///     }
1338    ///     Ok(())
1339    /// }
1340    /// ```
1341    pub fn list_row_access_policies(
1342        &self,
1343    ) -> super::builder::row_access_policy_service::ListRowAccessPolicies {
1344        super::builder::row_access_policy_service::ListRowAccessPolicies::new(self.inner.clone())
1345    }
1346
1347    /// Gets the specified row access policy by policy ID.
1348    ///
1349    /// # IAM Permissions
1350    ///
1351    /// Requires the `bigquery.rowAccessPolicies.get` permission on the table.
1352    ///
1353    /// # Example
1354    /// ```
1355    /// # use google_cloud_bigquery_v2::client::RowAccessPolicyService;
1356    /// use google_cloud_bigquery_v2::Result;
1357    /// async fn sample(
1358    ///    client: &RowAccessPolicyService
1359    /// ) -> Result<()> {
1360    ///     let response = client.get_row_access_policy()
1361    ///         /* set fields */
1362    ///         .send().await?;
1363    ///     println!("response {:?}", response);
1364    ///     Ok(())
1365    /// }
1366    /// ```
1367    pub fn get_row_access_policy(
1368        &self,
1369    ) -> super::builder::row_access_policy_service::GetRowAccessPolicy {
1370        super::builder::row_access_policy_service::GetRowAccessPolicy::new(self.inner.clone())
1371    }
1372
1373    /// Creates a row access policy.
1374    ///
1375    /// # IAM Permissions
1376    ///
1377    /// Requires the following IAM permission(s) on the table:
1378    ///
1379    /// - `bigquery.rowAccessPolicies.create`
1380    /// - `bigquery.rowAccessPolicies.setIamPolicy`
1381    /// - `bigquery.tables.getData`
1382    ///
1383    /// # Example
1384    /// ```
1385    /// # use google_cloud_bigquery_v2::client::RowAccessPolicyService;
1386    /// use google_cloud_bigquery_v2::Result;
1387    /// async fn sample(
1388    ///    client: &RowAccessPolicyService
1389    /// ) -> Result<()> {
1390    ///     let response = client.create_row_access_policy()
1391    ///         /* set fields */
1392    ///         .send().await?;
1393    ///     println!("response {:?}", response);
1394    ///     Ok(())
1395    /// }
1396    /// ```
1397    pub fn create_row_access_policy(
1398        &self,
1399    ) -> super::builder::row_access_policy_service::CreateRowAccessPolicy {
1400        super::builder::row_access_policy_service::CreateRowAccessPolicy::new(self.inner.clone())
1401    }
1402
1403    /// Updates a row access policy.
1404    ///
1405    /// # IAM Permissions
1406    ///
1407    /// Requires the following IAM permission(s) on the table:
1408    ///
1409    /// - `bigquery.rowAccessPolicies.update`
1410    /// - `bigquery.rowAccessPolicies.setIamPolicy`
1411    /// - `bigquery.tables.getData`
1412    ///
1413    /// # Example
1414    /// ```
1415    /// # use google_cloud_bigquery_v2::client::RowAccessPolicyService;
1416    /// use google_cloud_bigquery_v2::Result;
1417    /// async fn sample(
1418    ///    client: &RowAccessPolicyService
1419    /// ) -> Result<()> {
1420    ///     let response = client.update_row_access_policy()
1421    ///         /* set fields */
1422    ///         .send().await?;
1423    ///     println!("response {:?}", response);
1424    ///     Ok(())
1425    /// }
1426    /// ```
1427    pub fn update_row_access_policy(
1428        &self,
1429    ) -> super::builder::row_access_policy_service::UpdateRowAccessPolicy {
1430        super::builder::row_access_policy_service::UpdateRowAccessPolicy::new(self.inner.clone())
1431    }
1432
1433    /// Deletes a row access policy.
1434    ///
1435    /// # IAM Permissions
1436    ///
1437    /// Requires the following IAM permission(s) on the table:
1438    ///
1439    /// - `bigquery.rowAccessPolicies.delete`
1440    /// - `bigquery.rowAccessPolicies.setIamPolicy`
1441    ///
1442    /// # Example
1443    /// ```
1444    /// # use google_cloud_bigquery_v2::client::RowAccessPolicyService;
1445    /// use google_cloud_bigquery_v2::Result;
1446    /// async fn sample(
1447    ///    client: &RowAccessPolicyService
1448    /// ) -> Result<()> {
1449    ///     client.delete_row_access_policy()
1450    ///         /* set fields */
1451    ///         .send().await?;
1452    ///     Ok(())
1453    /// }
1454    /// ```
1455    pub fn delete_row_access_policy(
1456        &self,
1457    ) -> super::builder::row_access_policy_service::DeleteRowAccessPolicy {
1458        super::builder::row_access_policy_service::DeleteRowAccessPolicy::new(self.inner.clone())
1459    }
1460
1461    /// Deletes provided row access policies.
1462    ///
1463    /// # IAM Permissions
1464    ///
1465    /// Requires the following IAM permission(s) on the table:
1466    ///
1467    /// - `bigquery.rowAccessPolicies.delete`
1468    /// - `bigquery.rowAccessPolicies.setIamPolicy`
1469    ///
1470    /// # Example
1471    /// ```
1472    /// # use google_cloud_bigquery_v2::client::RowAccessPolicyService;
1473    /// use google_cloud_bigquery_v2::Result;
1474    /// async fn sample(
1475    ///    client: &RowAccessPolicyService
1476    /// ) -> Result<()> {
1477    ///     client.batch_delete_row_access_policies()
1478    ///         /* set fields */
1479    ///         .send().await?;
1480    ///     Ok(())
1481    /// }
1482    /// ```
1483    pub fn batch_delete_row_access_policies(
1484        &self,
1485    ) -> super::builder::row_access_policy_service::BatchDeleteRowAccessPolicies {
1486        super::builder::row_access_policy_service::BatchDeleteRowAccessPolicies::new(
1487            self.inner.clone(),
1488        )
1489    }
1490}
1491
1492/// Implements a client for the BigQuery API.
1493///
1494/// # Example
1495/// ```
1496/// # use google_cloud_bigquery_v2::client::TableService;
1497/// async fn sample(
1498/// ) -> anyhow::Result<()> {
1499///     let client = TableService::builder().build().await?;
1500///     let response = client.get_table()
1501///         /* set fields */
1502///         .send().await?;
1503///     println!("response {:?}", response);
1504///     Ok(())
1505/// }
1506/// ```
1507///
1508/// # Service Description
1509///
1510/// TableService provides methods for managing BigQuery tables and table-like
1511/// entities such as views and snapshots.
1512///
1513/// # Configuration
1514///
1515/// To configure `TableService` use the `with_*` methods in the type returned
1516/// by [builder()][TableService::builder]. The default configuration should
1517/// work for most applications. Common configuration changes include
1518///
1519/// * [with_endpoint()]: by default this client uses the global default endpoint
1520///   (`https://bigquery.googleapis.com`). Applications using regional
1521///   endpoints or running in restricted networks (e.g. a network configured
1522///   with [Private Google Access with VPC Service Controls]) may want to
1523///   override this default.
1524/// * [with_credentials()]: by default this client uses
1525///   [Application Default Credentials]. Applications using custom
1526///   authentication may need to override this default.
1527///
1528/// [with_endpoint()]: super::builder::table_service::ClientBuilder::with_endpoint
1529/// [with_credentials()]: super::builder::table_service::ClientBuilder::with_credentials
1530/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1531/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1532///
1533/// # Pooling and Cloning
1534///
1535/// `TableService` holds a connection pool internally, it is advised to
1536/// create one and reuse it. You do not need to wrap `TableService` in
1537/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1538/// already uses an `Arc` internally.
1539#[derive(Clone, Debug)]
1540pub struct TableService {
1541    inner: std::sync::Arc<dyn super::stub::dynamic::TableService>,
1542}
1543
1544impl TableService {
1545    /// Returns a builder for [TableService].
1546    ///
1547    /// ```
1548    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1549    /// # use google_cloud_bigquery_v2::client::TableService;
1550    /// let client = TableService::builder().build().await?;
1551    /// # Ok(()) }
1552    /// ```
1553    pub fn builder() -> super::builder::table_service::ClientBuilder {
1554        crate::new_client_builder(super::builder::table_service::client::Factory)
1555    }
1556
1557    /// Creates a new client from the provided stub.
1558    ///
1559    /// The most common case for calling this function is in tests mocking the
1560    /// client's behavior.
1561    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1562    where
1563        T: super::stub::TableService + 'static,
1564    {
1565        Self { inner: stub.into() }
1566    }
1567
1568    pub(crate) async fn new(
1569        config: gaxi::options::ClientConfig,
1570    ) -> crate::ClientBuilderResult<Self> {
1571        let inner = Self::build_inner(config).await?;
1572        Ok(Self { inner })
1573    }
1574
1575    async fn build_inner(
1576        conf: gaxi::options::ClientConfig,
1577    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::TableService>> {
1578        if gaxi::options::tracing_enabled(&conf) {
1579            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1580        }
1581        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1582    }
1583
1584    async fn build_transport(
1585        conf: gaxi::options::ClientConfig,
1586    ) -> crate::ClientBuilderResult<impl super::stub::TableService> {
1587        super::transport::TableService::new(conf).await
1588    }
1589
1590    async fn build_with_tracing(
1591        conf: gaxi::options::ClientConfig,
1592    ) -> crate::ClientBuilderResult<impl super::stub::TableService> {
1593        Self::build_transport(conf)
1594            .await
1595            .map(super::tracing::TableService::new)
1596    }
1597
1598    /// Gets the specified table resource by table ID.
1599    /// This method does not return the data in the table, it only returns the
1600    /// table resource, which describes the structure of this table.
1601    ///
1602    /// # IAM Permissions
1603    ///
1604    /// Requires the `bigquery.tables.get` permission on the table.
1605    ///
1606    /// # Example
1607    /// ```
1608    /// # use google_cloud_bigquery_v2::client::TableService;
1609    /// use google_cloud_bigquery_v2::Result;
1610    /// async fn sample(
1611    ///    client: &TableService
1612    /// ) -> Result<()> {
1613    ///     let response = client.get_table()
1614    ///         /* set fields */
1615    ///         .send().await?;
1616    ///     println!("response {:?}", response);
1617    ///     Ok(())
1618    /// }
1619    /// ```
1620    pub fn get_table(&self) -> super::builder::table_service::GetTable {
1621        super::builder::table_service::GetTable::new(self.inner.clone())
1622    }
1623
1624    /// Creates a new, empty table in the dataset.
1625    ///
1626    /// # IAM Permissions
1627    ///
1628    /// Requires the `bigquery.tables.create` permission on the dataset.
1629    ///
1630    /// # Example
1631    /// ```
1632    /// # use google_cloud_bigquery_v2::client::TableService;
1633    /// use google_cloud_bigquery_v2::Result;
1634    /// async fn sample(
1635    ///    client: &TableService
1636    /// ) -> Result<()> {
1637    ///     let response = client.insert_table()
1638    ///         /* set fields */
1639    ///         .send().await?;
1640    ///     println!("response {:?}", response);
1641    ///     Ok(())
1642    /// }
1643    /// ```
1644    pub fn insert_table(&self) -> super::builder::table_service::InsertTable {
1645        super::builder::table_service::InsertTable::new(self.inner.clone())
1646    }
1647
1648    /// Updates information in an existing table. The update method replaces the
1649    /// entire table resource, whereas the patch method only replaces fields that
1650    /// are provided in the submitted table resource.
1651    /// This method supports RFC5789 patch semantics.
1652    ///
1653    /// # IAM Permissions
1654    ///
1655    /// Requires the following IAM permission(s) on the table:
1656    ///
1657    /// - `bigquery.tables.update`
1658    /// - `bigquery.tables.get`
1659    ///
1660    /// # Example
1661    /// ```
1662    /// # use google_cloud_bigquery_v2::client::TableService;
1663    /// use google_cloud_bigquery_v2::Result;
1664    /// async fn sample(
1665    ///    client: &TableService
1666    /// ) -> Result<()> {
1667    ///     let response = client.patch_table()
1668    ///         /* set fields */
1669    ///         .send().await?;
1670    ///     println!("response {:?}", response);
1671    ///     Ok(())
1672    /// }
1673    /// ```
1674    pub fn patch_table(&self) -> super::builder::table_service::PatchTable {
1675        super::builder::table_service::PatchTable::new(self.inner.clone())
1676    }
1677
1678    /// Updates information in an existing table. The update method replaces the
1679    /// entire Table resource, whereas the patch method only replaces fields that
1680    /// are provided in the submitted Table resource.
1681    ///
1682    /// # IAM Permissions
1683    ///
1684    /// Requires the `bigquery.tables.update` permission on the table.
1685    ///
1686    /// # Example
1687    /// ```
1688    /// # use google_cloud_bigquery_v2::client::TableService;
1689    /// use google_cloud_bigquery_v2::Result;
1690    /// async fn sample(
1691    ///    client: &TableService
1692    /// ) -> Result<()> {
1693    ///     let response = client.update_table()
1694    ///         /* set fields */
1695    ///         .send().await?;
1696    ///     println!("response {:?}", response);
1697    ///     Ok(())
1698    /// }
1699    /// ```
1700    pub fn update_table(&self) -> super::builder::table_service::UpdateTable {
1701        super::builder::table_service::UpdateTable::new(self.inner.clone())
1702    }
1703
1704    /// Deletes the table specified by tableId from the dataset.
1705    /// If the table contains data, all the data will be deleted.
1706    ///
1707    /// # IAM Permissions
1708    ///
1709    /// Requires the `bigquery.tables.delete` permission on the table.
1710    ///
1711    /// # Example
1712    /// ```
1713    /// # use google_cloud_bigquery_v2::client::TableService;
1714    /// use google_cloud_bigquery_v2::Result;
1715    /// async fn sample(
1716    ///    client: &TableService
1717    /// ) -> Result<()> {
1718    ///     client.delete_table()
1719    ///         /* set fields */
1720    ///         .send().await?;
1721    ///     Ok(())
1722    /// }
1723    /// ```
1724    pub fn delete_table(&self) -> super::builder::table_service::DeleteTable {
1725        super::builder::table_service::DeleteTable::new(self.inner.clone())
1726    }
1727
1728    /// Lists all tables in the specified dataset. Requires the READER dataset
1729    /// role.
1730    ///
1731    /// # IAM Permissions
1732    ///
1733    /// Requires the `bigquery.tables.list` permission on the dataset.
1734    ///
1735    /// # Example
1736    /// ```
1737    /// # use google_cloud_bigquery_v2::client::TableService;
1738    /// use google_cloud_gax::paginator::ItemPaginator as _;
1739    /// use google_cloud_bigquery_v2::Result;
1740    /// async fn sample(
1741    ///    client: &TableService
1742    /// ) -> Result<()> {
1743    ///     let mut list = client.list_tables()
1744    ///         /* set fields */
1745    ///         .by_item();
1746    ///     while let Some(item) = list.next().await.transpose()? {
1747    ///         println!("{:?}", item);
1748    ///     }
1749    ///     Ok(())
1750    /// }
1751    /// ```
1752    pub fn list_tables(&self) -> super::builder::table_service::ListTables {
1753        super::builder::table_service::ListTables::new(self.inner.clone())
1754    }
1755}