diff --git a/.typos.toml b/.typos.toml index 96f3e420d..5a636313d 100644 --- a/.typos.toml +++ b/.typos.toml @@ -236,6 +236,10 @@ extend-ignore-re = [ "VerticaDialect", "\\W[Vv]ertica\\W", "vertica_dialect", + # src/generated/cloud/bigquery/v2 uses `ALS` which is a false positive typo + # for `ALSO` + "weighted-ALS", + "weighted-als", # src/generated/cloud/config/v1 has false positives on a product name. "HashiCorp", # src/generated/cloud/dialogflow/v2 has some typos, ignoring "whe" everywhere diff --git a/Cargo.lock b/Cargo.lock index f7472a2ab..8922fcc67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1458,6 +1458,24 @@ dependencies = [ "tracing", ] +[[package]] +name = "google-cloud-bigquery-v2" +version = "0.2.0" +dependencies = [ + "async-trait", + "bytes", + "google-cloud-gax", + "google-cloud-gax-internal", + "google-cloud-type", + "google-cloud-wkt", + "lazy_static", + "reqwest", + "serde", + "serde_json", + "serde_with", + "tracing", +] + [[package]] name = "google-cloud-bigtable-admin-v2" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index fb0770a4c..3fc116a98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,6 +76,7 @@ members = [ "src/generated/cloud/bigquery/datatransfer/v1", "src/generated/cloud/bigquery/migration/v2", "src/generated/cloud/bigquery/reservation/v1", + "src/generated/cloud/bigquery/v2", "src/generated/cloud/billing/v1", "src/generated/cloud/binaryauthorization/v1", "src/generated/cloud/certificatemanager/v1", diff --git a/src/generated/cloud/bigquery/v2/.repo-metadata.json b/src/generated/cloud/bigquery/v2/.repo-metadata.json new file mode 100755 index 000000000..461ca2b93 --- /dev/null +++ b/src/generated/cloud/bigquery/v2/.repo-metadata.json @@ -0,0 +1,11 @@ +{ + "api_id": "bigquery.googleapis.com", + "api_shortname": "bigquery", + "client_documentation": "https://docs.rs/google-cloud-bigquery-v2/latest", + "distribution_name": "google-cloud-rust", + "language": "rust", + "library_type": "GAPIC_AUTO", + "name_pretty": "BigQuery API", + "release_level": "preview", + "repo": "googleapis/google-cloud-rust" +} diff --git a/src/generated/cloud/bigquery/v2/.sidekick.toml b/src/generated/cloud/bigquery/v2/.sidekick.toml new file mode 100644 index 000000000..19437e34d --- /dev/null +++ b/src/generated/cloud/bigquery/v2/.sidekick.toml @@ -0,0 +1,35 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[general] +specification-source = 'google/cloud/bigquery/v2' +service-config = 'google/cloud/bigquery/v2/bigquery_v2.yaml' + +[source] +exclude-list = """\ +data_format_options.proto,\ +job_config.proto,\ +job_creation_reason.proto,\ +job_reference.proto,\ +job_stats.proto,\ +job_status.proto,\ +job.proto, +query_parameter.proto,\ +session_info.proto,\ +""" + +[codec] +copyright-year = '2025' +package-name-override = 'google-cloud-bigquery-v2' +not-for-publication = 'true' diff --git a/src/generated/cloud/bigquery/v2/Cargo.toml b/src/generated/cloud/bigquery/v2/Cargo.toml new file mode 100644 index 000000000..8fc1408e7 --- /dev/null +++ b/src/generated/cloud/bigquery/v2/Cargo.toml @@ -0,0 +1,42 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Code generated by sidekick. DO NOT EDIT. + +[package] +name = "google-cloud-bigquery-v2" +version = "0.2.0" +description = "Google Cloud Client Libraries for Rust - BigQuery API" +edition.workspace = true +authors.workspace = true +license.workspace = true +repository.workspace = true +keywords.workspace = true +categories.workspace = true +rust-version.workspace = true +publish = false + +[dependencies] +async-trait = { version = "0.1" } +bytes = { version = "1", features = ["serde"] } +gax = { version = "0.21", path = "../../../../../src/gax", package = "google-cloud-gax", features = ["unstable-sdk-client"] } +gaxi = { version = "0.1", path = "../../../../../src/gax-internal", package = "google-cloud-gax-internal", features = ["_internal_http_client"] } +gtype = { version = "0.2", path = "../../../../../src/generated/type", package = "google-cloud-type" } +lazy_static = { version = "1" } +reqwest = { version = "0.12", features = ["json"] } +serde = { version = "1", features = ["serde_derive"] } +serde_json = { version = "1" } +serde_with = { version = "3", default-features = false, features = ["base64", "macros", "std"] } +tracing = { version = "0.1" } +wkt = { version = "0.2", path = "../../../../../src/wkt", package = "google-cloud-wkt" } diff --git a/src/generated/cloud/bigquery/v2/README.md b/src/generated/cloud/bigquery/v2/README.md new file mode 100755 index 000000000..b34086e80 --- /dev/null +++ b/src/generated/cloud/bigquery/v2/README.md @@ -0,0 +1,25 @@ +# Google Cloud Client Libraries for Rust - BigQuery API + + + +**WARNING:** this crate is under active development. We expect multiple breaking +changes in the upcoming releases. Testing is also incomplete, we do **not** +recommend that you use this crate in production. We welcome feedback about the +APIs, documentation, missing features, bugs, etc. + +A data platform for customers to create, manage, share and query data. + +## Quickstart + +The main types to work with this crate are the clients: + +* [DatasetService](https://docs.rs/google-cloud-bigquery-v2/latest/google_cloud_bigquery_v2/client/struct.DatasetService.html) +* [ModelService](https://docs.rs/google-cloud-bigquery-v2/latest/google_cloud_bigquery_v2/client/struct.ModelService.html) +* [ProjectService](https://docs.rs/google-cloud-bigquery-v2/latest/google_cloud_bigquery_v2/client/struct.ProjectService.html) +* [RoutineService](https://docs.rs/google-cloud-bigquery-v2/latest/google_cloud_bigquery_v2/client/struct.RoutineService.html) +* [RowAccessPolicyService](https://docs.rs/google-cloud-bigquery-v2/latest/google_cloud_bigquery_v2/client/struct.RowAccessPolicyService.html) +* [TableService](https://docs.rs/google-cloud-bigquery-v2/latest/google_cloud_bigquery_v2/client/struct.TableService.html) + +## More Information + +* Read the [crate's documentation](https://docs.rs/google-cloud-bigquery-v2/latest/google-cloud-bigquery-v2) diff --git a/src/generated/cloud/bigquery/v2/src/builders.rs b/src/generated/cloud/bigquery/v2/src/builders.rs new file mode 100755 index 000000000..ae9127337 --- /dev/null +++ b/src/generated/cloud/bigquery/v2/src/builders.rs @@ -0,0 +1,1985 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by sidekick. DO NOT EDIT. + +pub mod dataset_service { + use crate::Result; + use std::sync::Arc; + + /// Common implementation for [super::super::client::DatasetService] request builders. + #[derive(Clone, Debug)] + pub struct RequestBuilder { + stub: Arc, + request: R, + options: gax::options::RequestOptions, + } + + impl RequestBuilder + where + R: std::default::Default, + { + pub(crate) fn new(stub: Arc) -> Self { + Self { + stub, + request: R::default(), + options: gax::options::RequestOptions::default(), + } + } + } + + /// The request builder for a DatasetService::get_dataset call. + #[derive(Clone, Debug)] + pub struct GetDataset(RequestBuilder); + + impl GetDataset { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .get_dataset(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::GetDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [dataset_view][crate::model::GetDatasetRequest::dataset_view]. + pub fn set_dataset_view>( + mut self, + v: T, + ) -> Self { + self.0.request.dataset_view = v.into(); + self + } + + /// Sets the value of [access_policy_version][crate::model::GetDatasetRequest::access_policy_version]. + pub fn set_access_policy_version>(mut self, v: T) -> Self { + self.0.request.access_policy_version = v.into(); + self + } + } + + impl gax::options::RequestBuilder for GetDataset { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a DatasetService::insert_dataset call. + #[derive(Clone, Debug)] + pub struct InsertDataset(RequestBuilder); + + impl InsertDataset { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .insert_dataset(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::InsertDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset][crate::model::InsertDatasetRequest::dataset]. + pub fn set_dataset>>( + mut self, + v: T, + ) -> Self { + self.0.request.dataset = v.into(); + self + } + + /// Sets the value of [access_policy_version][crate::model::InsertDatasetRequest::access_policy_version]. + pub fn set_access_policy_version>(mut self, v: T) -> Self { + self.0.request.access_policy_version = v.into(); + self + } + } + + impl gax::options::RequestBuilder for InsertDataset { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a DatasetService::patch_dataset call. + #[derive(Clone, Debug)] + pub struct PatchDataset(RequestBuilder); + + impl PatchDataset { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .patch_dataset(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::UpdateOrPatchDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateOrPatchDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [dataset][crate::model::UpdateOrPatchDatasetRequest::dataset]. + pub fn set_dataset>>( + mut self, + v: T, + ) -> Self { + self.0.request.dataset = v.into(); + self + } + + /// Sets the value of [access_policy_version][crate::model::UpdateOrPatchDatasetRequest::access_policy_version]. + pub fn set_access_policy_version>(mut self, v: T) -> Self { + self.0.request.access_policy_version = v.into(); + self + } + } + + impl gax::options::RequestBuilder for PatchDataset { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a DatasetService::update_dataset call. + #[derive(Clone, Debug)] + pub struct UpdateDataset(RequestBuilder); + + impl UpdateDataset { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .update_dataset(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::UpdateOrPatchDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateOrPatchDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [dataset][crate::model::UpdateOrPatchDatasetRequest::dataset]. + pub fn set_dataset>>( + mut self, + v: T, + ) -> Self { + self.0.request.dataset = v.into(); + self + } + + /// Sets the value of [access_policy_version][crate::model::UpdateOrPatchDatasetRequest::access_policy_version]. + pub fn set_access_policy_version>(mut self, v: T) -> Self { + self.0.request.access_policy_version = v.into(); + self + } + } + + impl gax::options::RequestBuilder for UpdateDataset { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a DatasetService::delete_dataset call. + #[derive(Clone, Debug)] + pub struct DeleteDataset(RequestBuilder); + + impl DeleteDataset { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .delete_dataset(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::DeleteDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [delete_contents][crate::model::DeleteDatasetRequest::delete_contents]. + pub fn set_delete_contents>(mut self, v: T) -> Self { + self.0.request.delete_contents = v.into(); + self + } + } + + impl gax::options::RequestBuilder for DeleteDataset { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a DatasetService::list_datasets call. + #[derive(Clone, Debug)] + pub struct ListDatasets(RequestBuilder); + + impl ListDatasets { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .list_datasets(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::ListDatasetsRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [max_results][crate::model::ListDatasetsRequest::max_results]. + pub fn set_max_results>>( + mut self, + v: T, + ) -> Self { + self.0.request.max_results = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListDatasetsRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.0.request.page_token = v.into(); + self + } + + /// Sets the value of [all][crate::model::ListDatasetsRequest::all]. + pub fn set_all>(mut self, v: T) -> Self { + self.0.request.all = v.into(); + self + } + + /// Sets the value of [filter][crate::model::ListDatasetsRequest::filter]. + pub fn set_filter>(mut self, v: T) -> Self { + self.0.request.filter = v.into(); + self + } + } + + impl gax::options::RequestBuilder for ListDatasets { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a DatasetService::undelete_dataset call. + #[derive(Clone, Debug)] + pub struct UndeleteDataset(RequestBuilder); + + impl UndeleteDataset { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .undelete_dataset(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::UndeleteDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UndeleteDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [deletion_time][crate::model::UndeleteDatasetRequest::deletion_time]. + pub fn set_deletion_time>>( + mut self, + v: T, + ) -> Self { + self.0.request.deletion_time = v.into(); + self + } + } + + impl gax::options::RequestBuilder for UndeleteDataset { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } +} + +pub mod model_service { + use crate::Result; + use std::sync::Arc; + + /// Common implementation for [super::super::client::ModelService] request builders. + #[derive(Clone, Debug)] + pub struct RequestBuilder { + stub: Arc, + request: R, + options: gax::options::RequestOptions, + } + + impl RequestBuilder + where + R: std::default::Default, + { + pub(crate) fn new(stub: Arc) -> Self { + Self { + stub, + request: R::default(), + options: gax::options::RequestOptions::default(), + } + } + } + + /// The request builder for a ModelService::get_model call. + #[derive(Clone, Debug)] + pub struct GetModel(RequestBuilder); + + impl GetModel { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .get_model(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::GetModelRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetModelRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [model_id][crate::model::GetModelRequest::model_id]. + pub fn set_model_id>(mut self, v: T) -> Self { + self.0.request.model_id = v.into(); + self + } + } + + impl gax::options::RequestBuilder for GetModel { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a ModelService::list_models call. + #[derive(Clone, Debug)] + pub struct ListModels(RequestBuilder); + + impl ListModels { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .list_models(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::ListModelsRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ListModelsRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [max_results][crate::model::ListModelsRequest::max_results]. + pub fn set_max_results>>( + mut self, + v: T, + ) -> Self { + self.0.request.max_results = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListModelsRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.0.request.page_token = v.into(); + self + } + } + + impl gax::options::RequestBuilder for ListModels { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a ModelService::patch_model call. + #[derive(Clone, Debug)] + pub struct PatchModel(RequestBuilder); + + impl PatchModel { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .patch_model(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::PatchModelRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::PatchModelRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [model_id][crate::model::PatchModelRequest::model_id]. + pub fn set_model_id>(mut self, v: T) -> Self { + self.0.request.model_id = v.into(); + self + } + + /// Sets the value of [model][crate::model::PatchModelRequest::model]. + pub fn set_model>>( + mut self, + v: T, + ) -> Self { + self.0.request.model = v.into(); + self + } + } + + impl gax::options::RequestBuilder for PatchModel { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a ModelService::delete_model call. + #[derive(Clone, Debug)] + pub struct DeleteModel(RequestBuilder); + + impl DeleteModel { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .delete_model(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::DeleteModelRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteModelRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [model_id][crate::model::DeleteModelRequest::model_id]. + pub fn set_model_id>(mut self, v: T) -> Self { + self.0.request.model_id = v.into(); + self + } + } + + impl gax::options::RequestBuilder for DeleteModel { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } +} + +pub mod project_service { + use crate::Result; + use std::sync::Arc; + + /// Common implementation for [super::super::client::ProjectService] request builders. + #[derive(Clone, Debug)] + pub struct RequestBuilder { + stub: Arc, + request: R, + options: gax::options::RequestOptions, + } + + impl RequestBuilder + where + R: std::default::Default, + { + pub(crate) fn new(stub: Arc) -> Self { + Self { + stub, + request: R::default(), + options: gax::options::RequestOptions::default(), + } + } + } + + /// The request builder for a ProjectService::get_service_account call. + #[derive(Clone, Debug)] + pub struct GetServiceAccount(RequestBuilder); + + impl GetServiceAccount { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .get_service_account(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::GetServiceAccountRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + } + + impl gax::options::RequestBuilder for GetServiceAccount { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } +} + +pub mod routine_service { + use crate::Result; + use std::sync::Arc; + + /// Common implementation for [super::super::client::RoutineService] request builders. + #[derive(Clone, Debug)] + pub struct RequestBuilder { + stub: Arc, + request: R, + options: gax::options::RequestOptions, + } + + impl RequestBuilder + where + R: std::default::Default, + { + pub(crate) fn new(stub: Arc) -> Self { + Self { + stub, + request: R::default(), + options: gax::options::RequestOptions::default(), + } + } + } + + /// The request builder for a RoutineService::get_routine call. + #[derive(Clone, Debug)] + pub struct GetRoutine(RequestBuilder); + + impl GetRoutine { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .get_routine(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::GetRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [routine_id][crate::model::GetRoutineRequest::routine_id]. + pub fn set_routine_id>(mut self, v: T) -> Self { + self.0.request.routine_id = v.into(); + self + } + } + + impl gax::options::RequestBuilder for GetRoutine { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RoutineService::insert_routine call. + #[derive(Clone, Debug)] + pub struct InsertRoutine(RequestBuilder); + + impl InsertRoutine { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .insert_routine(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::InsertRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::InsertRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [routine][crate::model::InsertRoutineRequest::routine]. + pub fn set_routine>>( + mut self, + v: T, + ) -> Self { + self.0.request.routine = v.into(); + self + } + } + + impl gax::options::RequestBuilder for InsertRoutine { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RoutineService::update_routine call. + #[derive(Clone, Debug)] + pub struct UpdateRoutine(RequestBuilder); + + impl UpdateRoutine { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .update_routine(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::UpdateRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [routine_id][crate::model::UpdateRoutineRequest::routine_id]. + pub fn set_routine_id>(mut self, v: T) -> Self { + self.0.request.routine_id = v.into(); + self + } + + /// Sets the value of [routine][crate::model::UpdateRoutineRequest::routine]. + pub fn set_routine>>( + mut self, + v: T, + ) -> Self { + self.0.request.routine = v.into(); + self + } + } + + impl gax::options::RequestBuilder for UpdateRoutine { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RoutineService::delete_routine call. + #[derive(Clone, Debug)] + pub struct DeleteRoutine(RequestBuilder); + + impl DeleteRoutine { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .delete_routine(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::DeleteRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [routine_id][crate::model::DeleteRoutineRequest::routine_id]. + pub fn set_routine_id>(mut self, v: T) -> Self { + self.0.request.routine_id = v.into(); + self + } + } + + impl gax::options::RequestBuilder for DeleteRoutine { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RoutineService::list_routines call. + #[derive(Clone, Debug)] + pub struct ListRoutines(RequestBuilder); + + impl ListRoutines { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .list_routines(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::ListRoutinesRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ListRoutinesRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [max_results][crate::model::ListRoutinesRequest::max_results]. + pub fn set_max_results>>( + mut self, + v: T, + ) -> Self { + self.0.request.max_results = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListRoutinesRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.0.request.page_token = v.into(); + self + } + + /// Sets the value of [filter][crate::model::ListRoutinesRequest::filter]. + pub fn set_filter>(mut self, v: T) -> Self { + self.0.request.filter = v.into(); + self + } + } + + impl gax::options::RequestBuilder for ListRoutines { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } +} + +pub mod row_access_policy_service { + use crate::Result; + use std::sync::Arc; + + /// Common implementation for [super::super::client::RowAccessPolicyService] request builders. + #[derive(Clone, Debug)] + pub struct RequestBuilder { + stub: Arc, + request: R, + options: gax::options::RequestOptions, + } + + impl RequestBuilder + where + R: std::default::Default, + { + pub(crate) fn new( + stub: Arc, + ) -> Self { + Self { + stub, + request: R::default(), + options: gax::options::RequestOptions::default(), + } + } + } + + /// The request builder for a RowAccessPolicyService::list_row_access_policies call. + #[derive(Clone, Debug)] + pub struct ListRowAccessPolicies(RequestBuilder); + + impl ListRowAccessPolicies { + pub(crate) fn new( + stub: Arc, + ) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .list_row_access_policies(self.0.request, self.0.options) + .await + } + + /// Streams the responses back. + pub async fn paginator( + self, + ) -> gax::paginator::Paginator + { + use std::clone::Clone; + let token = self.0.request.page_token.clone(); + let execute = move |token: String| { + let mut builder = self.clone(); + builder.0.request = builder.0.request.set_page_token(token); + builder.send() + }; + gax::paginator::Paginator::new(token, execute) + } + + /// Sets the value of [project_id][crate::model::ListRowAccessPoliciesRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ListRowAccessPoliciesRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::ListRowAccessPoliciesRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListRowAccessPoliciesRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.0.request.page_token = v.into(); + self + } + + /// Sets the value of [page_size][crate::model::ListRowAccessPoliciesRequest::page_size]. + pub fn set_page_size>(mut self, v: T) -> Self { + self.0.request.page_size = v.into(); + self + } + } + + impl gax::options::RequestBuilder for ListRowAccessPolicies { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RowAccessPolicyService::get_row_access_policy call. + #[derive(Clone, Debug)] + pub struct GetRowAccessPolicy(RequestBuilder); + + impl GetRowAccessPolicy { + pub(crate) fn new( + stub: Arc, + ) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .get_row_access_policy(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::GetRowAccessPolicyRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetRowAccessPolicyRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::GetRowAccessPolicyRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [policy_id][crate::model::GetRowAccessPolicyRequest::policy_id]. + pub fn set_policy_id>(mut self, v: T) -> Self { + self.0.request.policy_id = v.into(); + self + } + } + + impl gax::options::RequestBuilder for GetRowAccessPolicy { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RowAccessPolicyService::create_row_access_policy call. + #[derive(Clone, Debug)] + pub struct CreateRowAccessPolicy(RequestBuilder); + + impl CreateRowAccessPolicy { + pub(crate) fn new( + stub: Arc, + ) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .create_row_access_policy(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::CreateRowAccessPolicyRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::CreateRowAccessPolicyRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::CreateRowAccessPolicyRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [row_access_policy][crate::model::CreateRowAccessPolicyRequest::row_access_policy]. + pub fn set_row_access_policy< + T: Into>, + >( + mut self, + v: T, + ) -> Self { + self.0.request.row_access_policy = v.into(); + self + } + } + + impl gax::options::RequestBuilder for CreateRowAccessPolicy { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RowAccessPolicyService::update_row_access_policy call. + #[derive(Clone, Debug)] + pub struct UpdateRowAccessPolicy(RequestBuilder); + + impl UpdateRowAccessPolicy { + pub(crate) fn new( + stub: Arc, + ) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .update_row_access_policy(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::UpdateRowAccessPolicyRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateRowAccessPolicyRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::UpdateRowAccessPolicyRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [policy_id][crate::model::UpdateRowAccessPolicyRequest::policy_id]. + pub fn set_policy_id>(mut self, v: T) -> Self { + self.0.request.policy_id = v.into(); + self + } + + /// Sets the value of [row_access_policy][crate::model::UpdateRowAccessPolicyRequest::row_access_policy]. + pub fn set_row_access_policy< + T: Into>, + >( + mut self, + v: T, + ) -> Self { + self.0.request.row_access_policy = v.into(); + self + } + } + + impl gax::options::RequestBuilder for UpdateRowAccessPolicy { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RowAccessPolicyService::delete_row_access_policy call. + #[derive(Clone, Debug)] + pub struct DeleteRowAccessPolicy(RequestBuilder); + + impl DeleteRowAccessPolicy { + pub(crate) fn new( + stub: Arc, + ) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .delete_row_access_policy(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::DeleteRowAccessPolicyRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteRowAccessPolicyRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::DeleteRowAccessPolicyRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [policy_id][crate::model::DeleteRowAccessPolicyRequest::policy_id]. + pub fn set_policy_id>(mut self, v: T) -> Self { + self.0.request.policy_id = v.into(); + self + } + + /// Sets the value of [force][crate::model::DeleteRowAccessPolicyRequest::force]. + pub fn set_force>>(mut self, v: T) -> Self { + self.0.request.force = v.into(); + self + } + } + + impl gax::options::RequestBuilder for DeleteRowAccessPolicy { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a RowAccessPolicyService::batch_delete_row_access_policies call. + #[derive(Clone, Debug)] + pub struct BatchDeleteRowAccessPolicies( + RequestBuilder, + ); + + impl BatchDeleteRowAccessPolicies { + pub(crate) fn new( + stub: Arc, + ) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .batch_delete_row_access_policies(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::BatchDeleteRowAccessPoliciesRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::BatchDeleteRowAccessPoliciesRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::BatchDeleteRowAccessPoliciesRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [force][crate::model::BatchDeleteRowAccessPoliciesRequest::force]. + pub fn set_force>>(mut self, v: T) -> Self { + self.0.request.force = v.into(); + self + } + + /// Sets the value of [policy_ids][crate::model::BatchDeleteRowAccessPoliciesRequest::policy_ids]. + pub fn set_policy_ids(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.0.request.policy_ids = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl gax::options::RequestBuilder for BatchDeleteRowAccessPolicies { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } +} + +pub mod table_service { + use crate::Result; + use std::sync::Arc; + + /// Common implementation for [super::super::client::TableService] request builders. + #[derive(Clone, Debug)] + pub struct RequestBuilder { + stub: Arc, + request: R, + options: gax::options::RequestOptions, + } + + impl RequestBuilder + where + R: std::default::Default, + { + pub(crate) fn new(stub: Arc) -> Self { + Self { + stub, + request: R::default(), + options: gax::options::RequestOptions::default(), + } + } + } + + /// The request builder for a TableService::get_table call. + #[derive(Clone, Debug)] + pub struct GetTable(RequestBuilder); + + impl GetTable { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .get_table(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::GetTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::GetTableRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [selected_fields][crate::model::GetTableRequest::selected_fields]. + pub fn set_selected_fields>(mut self, v: T) -> Self { + self.0.request.selected_fields = v.into(); + self + } + + /// Sets the value of [view][crate::model::GetTableRequest::view]. + pub fn set_view>( + mut self, + v: T, + ) -> Self { + self.0.request.view = v.into(); + self + } + } + + impl gax::options::RequestBuilder for GetTable { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a TableService::insert_table call. + #[derive(Clone, Debug)] + pub struct InsertTable(RequestBuilder); + + impl InsertTable { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .insert_table(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::InsertTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::InsertTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table][crate::model::InsertTableRequest::table]. + pub fn set_table>>( + mut self, + v: T, + ) -> Self { + self.0.request.table = v.into(); + self + } + } + + impl gax::options::RequestBuilder for InsertTable { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a TableService::patch_table call. + #[derive(Clone, Debug)] + pub struct PatchTable(RequestBuilder); + + impl PatchTable { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .patch_table(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::UpdateOrPatchTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateOrPatchTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::UpdateOrPatchTableRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [table][crate::model::UpdateOrPatchTableRequest::table]. + pub fn set_table>>( + mut self, + v: T, + ) -> Self { + self.0.request.table = v.into(); + self + } + + /// Sets the value of [autodetect_schema][crate::model::UpdateOrPatchTableRequest::autodetect_schema]. + pub fn set_autodetect_schema>(mut self, v: T) -> Self { + self.0.request.autodetect_schema = v.into(); + self + } + } + + impl gax::options::RequestBuilder for PatchTable { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a TableService::update_table call. + #[derive(Clone, Debug)] + pub struct UpdateTable(RequestBuilder); + + impl UpdateTable { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>( + mut self, + v: V, + ) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .update_table(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::UpdateOrPatchTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateOrPatchTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::UpdateOrPatchTableRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + + /// Sets the value of [table][crate::model::UpdateOrPatchTableRequest::table]. + pub fn set_table>>( + mut self, + v: T, + ) -> Self { + self.0.request.table = v.into(); + self + } + + /// Sets the value of [autodetect_schema][crate::model::UpdateOrPatchTableRequest::autodetect_schema]. + pub fn set_autodetect_schema>(mut self, v: T) -> Self { + self.0.request.autodetect_schema = v.into(); + self + } + } + + impl gax::options::RequestBuilder for UpdateTable { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a TableService::delete_table call. + #[derive(Clone, Debug)] + pub struct DeleteTable(RequestBuilder); + + impl DeleteTable { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .delete_table(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::DeleteTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::DeleteTableRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.0.request.table_id = v.into(); + self + } + } + + impl gax::options::RequestBuilder for DeleteTable { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } + + /// The request builder for a TableService::list_tables call. + #[derive(Clone, Debug)] + pub struct ListTables(RequestBuilder); + + impl ListTables { + pub(crate) fn new(stub: Arc) -> Self { + Self(RequestBuilder::new(stub)) + } + + /// Sets the full request, replacing any prior values. + pub fn with_request>(mut self, v: V) -> Self { + self.0.request = v.into(); + self + } + + /// Sets all the options, replacing any prior values. + pub fn with_options>(mut self, v: V) -> Self { + self.0.options = v.into(); + self + } + + /// Sends the request. + pub async fn send(self) -> Result { + (*self.0.stub) + .list_tables(self.0.request, self.0.options) + .await + } + + /// Sets the value of [project_id][crate::model::ListTablesRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.0.request.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ListTablesRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.0.request.dataset_id = v.into(); + self + } + + /// Sets the value of [max_results][crate::model::ListTablesRequest::max_results]. + pub fn set_max_results>>( + mut self, + v: T, + ) -> Self { + self.0.request.max_results = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListTablesRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.0.request.page_token = v.into(); + self + } + } + + impl gax::options::RequestBuilder for ListTables { + fn request_options(&mut self) -> &mut gax::options::RequestOptions { + &mut self.0.options + } + } +} diff --git a/src/generated/cloud/bigquery/v2/src/client.rs b/src/generated/cloud/bigquery/v2/src/client.rs new file mode 100755 index 000000000..ab8782202 --- /dev/null +++ b/src/generated/cloud/bigquery/v2/src/client.rs @@ -0,0 +1,825 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by sidekick. DO NOT EDIT. +#![allow(rustdoc::redundant_explicit_links)] +#![allow(rustdoc::broken_intra_doc_links)] + +use crate::Result; +use std::sync::Arc; + +/// Implements a client for the BigQuery API. +/// +/// # Service Description +/// +/// DatasetService provides methods for managing BigQuery datasets. +/// +/// # Configuration +/// +/// `DatasetService` has various configuration parameters, the defaults should +/// work with most applications. +/// +/// # Pooling and Cloning +/// +/// `DatasetService` holds a connection pool internally, it is advised to +/// create one and the reuse it. You do not need to wrap `DatasetService` in +/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc` +/// internally. +#[derive(Clone, Debug)] +pub struct DatasetService { + inner: Arc, +} + +impl DatasetService { + /// Creates a new client with the default configuration. + pub async fn new() -> Result { + Self::new_with_config(gax::options::ClientConfig::default()).await + } + + /// Creates a new client with the specified configuration. + pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result { + let inner = Self::build_inner(conf).await?; + Ok(Self { inner }) + } + + /// Creates a new client from the provided stub. + /// + /// The most common case for calling this function is when mocking the + /// client. + pub fn from_stub(stub: T) -> Self + where + T: super::stubs::DatasetService + 'static, + { + Self { + inner: Arc::new(stub), + } + } + + async fn build_inner( + conf: gax::options::ClientConfig, + ) -> Result> { + if conf.tracing_enabled() { + return Ok(Arc::new(Self::build_with_tracing(conf).await?)); + } + Ok(Arc::new(Self::build_transport(conf).await?)) + } + + async fn build_transport( + conf: gax::options::ClientConfig, + ) -> Result { + super::transport::DatasetService::new(conf).await + } + + async fn build_with_tracing( + conf: gax::options::ClientConfig, + ) -> Result { + Self::build_transport(conf) + .await + .map(super::tracing::DatasetService::new) + } + + /// Returns the dataset specified by datasetID. + pub fn get_dataset( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::dataset_service::GetDataset { + super::builders::dataset_service::GetDataset::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } + + /// Creates a new empty dataset. + pub fn insert_dataset( + &self, + project_id: impl Into, + ) -> super::builders::dataset_service::InsertDataset { + super::builders::dataset_service::InsertDataset::new(self.inner.clone()) + .set_project_id(project_id.into()) + } + + /// Updates information in an existing dataset. The update method replaces the + /// entire dataset resource, whereas the patch method only replaces fields that + /// are provided in the submitted dataset resource. + /// This method supports RFC5789 patch semantics. + pub fn patch_dataset( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::dataset_service::PatchDataset { + super::builders::dataset_service::PatchDataset::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } + + /// Updates information in an existing dataset. The update method replaces the + /// entire dataset resource, whereas the patch method only replaces fields that + /// are provided in the submitted dataset resource. + pub fn update_dataset( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::dataset_service::UpdateDataset { + super::builders::dataset_service::UpdateDataset::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } + + /// Deletes the dataset specified by the datasetId value. Before you can delete + /// a dataset, you must delete all its tables, either manually or by specifying + /// deleteContents. Immediately after deletion, you can create another dataset + /// with the same name. + pub fn delete_dataset( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::dataset_service::DeleteDataset { + super::builders::dataset_service::DeleteDataset::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } + + /// Lists all datasets in the specified project to which the user has been + /// granted the READER dataset role. + pub fn list_datasets( + &self, + project_id: impl Into, + ) -> super::builders::dataset_service::ListDatasets { + super::builders::dataset_service::ListDatasets::new(self.inner.clone()) + .set_project_id(project_id.into()) + } + + /// Undeletes a dataset which is within time travel window based on datasetId. + /// If a time is specified, the dataset version deleted at that time is + /// undeleted, else the last live version is undeleted. + pub fn undelete_dataset( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::dataset_service::UndeleteDataset { + super::builders::dataset_service::UndeleteDataset::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } +} + +/// Implements a client for the BigQuery API. +/// +/// # Service Description +/// +/// Model Service for BigQuery ML +/// +/// # Configuration +/// +/// `ModelService` has various configuration parameters, the defaults should +/// work with most applications. +/// +/// # Pooling and Cloning +/// +/// `ModelService` holds a connection pool internally, it is advised to +/// create one and the reuse it. You do not need to wrap `ModelService` in +/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc` +/// internally. +#[derive(Clone, Debug)] +pub struct ModelService { + inner: Arc, +} + +impl ModelService { + /// Creates a new client with the default configuration. + pub async fn new() -> Result { + Self::new_with_config(gax::options::ClientConfig::default()).await + } + + /// Creates a new client with the specified configuration. + pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result { + let inner = Self::build_inner(conf).await?; + Ok(Self { inner }) + } + + /// Creates a new client from the provided stub. + /// + /// The most common case for calling this function is when mocking the + /// client. + pub fn from_stub(stub: T) -> Self + where + T: super::stubs::ModelService + 'static, + { + Self { + inner: Arc::new(stub), + } + } + + async fn build_inner( + conf: gax::options::ClientConfig, + ) -> Result> { + if conf.tracing_enabled() { + return Ok(Arc::new(Self::build_with_tracing(conf).await?)); + } + Ok(Arc::new(Self::build_transport(conf).await?)) + } + + async fn build_transport( + conf: gax::options::ClientConfig, + ) -> Result { + super::transport::ModelService::new(conf).await + } + + async fn build_with_tracing( + conf: gax::options::ClientConfig, + ) -> Result { + Self::build_transport(conf) + .await + .map(super::tracing::ModelService::new) + } + + /// Gets the specified model resource by model ID. + pub fn get_model( + &self, + project_id: impl Into, + dataset_id: impl Into, + model_id: impl Into, + ) -> super::builders::model_service::GetModel { + super::builders::model_service::GetModel::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_model_id(model_id.into()) + } + + /// Lists all models in the specified dataset. Requires the READER dataset + /// role. After retrieving the list of models, you can get information about a + /// particular model by calling the models.get method. + pub fn list_models( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::model_service::ListModels { + super::builders::model_service::ListModels::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } + + /// Patch specific fields in the specified model. + pub fn patch_model( + &self, + project_id: impl Into, + dataset_id: impl Into, + model_id: impl Into, + ) -> super::builders::model_service::PatchModel { + super::builders::model_service::PatchModel::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_model_id(model_id.into()) + } + + /// Deletes the model specified by modelId from the dataset. + pub fn delete_model( + &self, + project_id: impl Into, + dataset_id: impl Into, + model_id: impl Into, + ) -> super::builders::model_service::DeleteModel { + super::builders::model_service::DeleteModel::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_model_id(model_id.into()) + } +} + +/// Implements a client for the BigQuery API. +/// +/// # Service Description +/// +/// This service provides access to BigQuery functionality related to projects. +/// +/// # Configuration +/// +/// `ProjectService` has various configuration parameters, the defaults should +/// work with most applications. +/// +/// # Pooling and Cloning +/// +/// `ProjectService` holds a connection pool internally, it is advised to +/// create one and the reuse it. You do not need to wrap `ProjectService` in +/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc` +/// internally. +#[derive(Clone, Debug)] +pub struct ProjectService { + inner: Arc, +} + +impl ProjectService { + /// Creates a new client with the default configuration. + pub async fn new() -> Result { + Self::new_with_config(gax::options::ClientConfig::default()).await + } + + /// Creates a new client with the specified configuration. + pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result { + let inner = Self::build_inner(conf).await?; + Ok(Self { inner }) + } + + /// Creates a new client from the provided stub. + /// + /// The most common case for calling this function is when mocking the + /// client. + pub fn from_stub(stub: T) -> Self + where + T: super::stubs::ProjectService + 'static, + { + Self { + inner: Arc::new(stub), + } + } + + async fn build_inner( + conf: gax::options::ClientConfig, + ) -> Result> { + if conf.tracing_enabled() { + return Ok(Arc::new(Self::build_with_tracing(conf).await?)); + } + Ok(Arc::new(Self::build_transport(conf).await?)) + } + + async fn build_transport( + conf: gax::options::ClientConfig, + ) -> Result { + super::transport::ProjectService::new(conf).await + } + + async fn build_with_tracing( + conf: gax::options::ClientConfig, + ) -> Result { + Self::build_transport(conf) + .await + .map(super::tracing::ProjectService::new) + } + + /// RPC to get the service account for a project used for interactions with + /// Google Cloud KMS + pub fn get_service_account( + &self, + project_id: impl Into, + ) -> super::builders::project_service::GetServiceAccount { + super::builders::project_service::GetServiceAccount::new(self.inner.clone()) + .set_project_id(project_id.into()) + } +} + +/// Implements a client for the BigQuery API. +/// +/// # Service Description +/// +/// RoutineService provides management access to BigQuery routines. +/// +/// # Configuration +/// +/// `RoutineService` has various configuration parameters, the defaults should +/// work with most applications. +/// +/// # Pooling and Cloning +/// +/// `RoutineService` holds a connection pool internally, it is advised to +/// create one and the reuse it. You do not need to wrap `RoutineService` in +/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc` +/// internally. +#[derive(Clone, Debug)] +pub struct RoutineService { + inner: Arc, +} + +impl RoutineService { + /// Creates a new client with the default configuration. + pub async fn new() -> Result { + Self::new_with_config(gax::options::ClientConfig::default()).await + } + + /// Creates a new client with the specified configuration. + pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result { + let inner = Self::build_inner(conf).await?; + Ok(Self { inner }) + } + + /// Creates a new client from the provided stub. + /// + /// The most common case for calling this function is when mocking the + /// client. + pub fn from_stub(stub: T) -> Self + where + T: super::stubs::RoutineService + 'static, + { + Self { + inner: Arc::new(stub), + } + } + + async fn build_inner( + conf: gax::options::ClientConfig, + ) -> Result> { + if conf.tracing_enabled() { + return Ok(Arc::new(Self::build_with_tracing(conf).await?)); + } + Ok(Arc::new(Self::build_transport(conf).await?)) + } + + async fn build_transport( + conf: gax::options::ClientConfig, + ) -> Result { + super::transport::RoutineService::new(conf).await + } + + async fn build_with_tracing( + conf: gax::options::ClientConfig, + ) -> Result { + Self::build_transport(conf) + .await + .map(super::tracing::RoutineService::new) + } + + /// Gets the specified routine resource by routine ID. + pub fn get_routine( + &self, + project_id: impl Into, + dataset_id: impl Into, + routine_id: impl Into, + ) -> super::builders::routine_service::GetRoutine { + super::builders::routine_service::GetRoutine::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_routine_id(routine_id.into()) + } + + /// Creates a new routine in the dataset. + pub fn insert_routine( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::routine_service::InsertRoutine { + super::builders::routine_service::InsertRoutine::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } + + /// Updates information in an existing routine. The update method replaces the + /// entire Routine resource. + pub fn update_routine( + &self, + project_id: impl Into, + dataset_id: impl Into, + routine_id: impl Into, + ) -> super::builders::routine_service::UpdateRoutine { + super::builders::routine_service::UpdateRoutine::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_routine_id(routine_id.into()) + } + + /// Deletes the routine specified by routineId from the dataset. + pub fn delete_routine( + &self, + project_id: impl Into, + dataset_id: impl Into, + routine_id: impl Into, + ) -> super::builders::routine_service::DeleteRoutine { + super::builders::routine_service::DeleteRoutine::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_routine_id(routine_id.into()) + } + + /// Lists all routines in the specified dataset. Requires the READER dataset + /// role. + pub fn list_routines( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::routine_service::ListRoutines { + super::builders::routine_service::ListRoutines::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } +} + +/// Implements a client for the BigQuery API. +/// +/// # Service Description +/// +/// Service for interacting with row access policies. +/// +/// # Configuration +/// +/// `RowAccessPolicyService` has various configuration parameters, the defaults should +/// work with most applications. +/// +/// # Pooling and Cloning +/// +/// `RowAccessPolicyService` holds a connection pool internally, it is advised to +/// create one and the reuse it. You do not need to wrap `RowAccessPolicyService` in +/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc` +/// internally. +#[derive(Clone, Debug)] +pub struct RowAccessPolicyService { + inner: Arc, +} + +impl RowAccessPolicyService { + /// Creates a new client with the default configuration. + pub async fn new() -> Result { + Self::new_with_config(gax::options::ClientConfig::default()).await + } + + /// Creates a new client with the specified configuration. + pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result { + let inner = Self::build_inner(conf).await?; + Ok(Self { inner }) + } + + /// Creates a new client from the provided stub. + /// + /// The most common case for calling this function is when mocking the + /// client. + pub fn from_stub(stub: T) -> Self + where + T: super::stubs::RowAccessPolicyService + 'static, + { + Self { + inner: Arc::new(stub), + } + } + + async fn build_inner( + conf: gax::options::ClientConfig, + ) -> Result> { + if conf.tracing_enabled() { + return Ok(Arc::new(Self::build_with_tracing(conf).await?)); + } + Ok(Arc::new(Self::build_transport(conf).await?)) + } + + async fn build_transport( + conf: gax::options::ClientConfig, + ) -> Result { + super::transport::RowAccessPolicyService::new(conf).await + } + + async fn build_with_tracing( + conf: gax::options::ClientConfig, + ) -> Result { + Self::build_transport(conf) + .await + .map(super::tracing::RowAccessPolicyService::new) + } + + /// Lists all row access policies on the specified table. + pub fn list_row_access_policies( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + ) -> super::builders::row_access_policy_service::ListRowAccessPolicies { + super::builders::row_access_policy_service::ListRowAccessPolicies::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + } + + /// Gets the specified row access policy by policy ID. + pub fn get_row_access_policy( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + policy_id: impl Into, + ) -> super::builders::row_access_policy_service::GetRowAccessPolicy { + super::builders::row_access_policy_service::GetRowAccessPolicy::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + .set_policy_id(policy_id.into()) + } + + /// Creates a row access policy. + pub fn create_row_access_policy( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + ) -> super::builders::row_access_policy_service::CreateRowAccessPolicy { + super::builders::row_access_policy_service::CreateRowAccessPolicy::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + } + + /// Updates a row access policy. + pub fn update_row_access_policy( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + policy_id: impl Into, + ) -> super::builders::row_access_policy_service::UpdateRowAccessPolicy { + super::builders::row_access_policy_service::UpdateRowAccessPolicy::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + .set_policy_id(policy_id.into()) + } + + /// Deletes a row access policy. + pub fn delete_row_access_policy( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + policy_id: impl Into, + ) -> super::builders::row_access_policy_service::DeleteRowAccessPolicy { + super::builders::row_access_policy_service::DeleteRowAccessPolicy::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + .set_policy_id(policy_id.into()) + } + + /// Deletes provided row access policies. + pub fn batch_delete_row_access_policies( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + ) -> super::builders::row_access_policy_service::BatchDeleteRowAccessPolicies { + super::builders::row_access_policy_service::BatchDeleteRowAccessPolicies::new( + self.inner.clone(), + ) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + } +} + +/// Implements a client for the BigQuery API. +/// +/// # Service Description +/// +/// TableService provides methods for managing BigQuery tables and table-like +/// entities such as views and snapshots. +/// +/// # Configuration +/// +/// `TableService` has various configuration parameters, the defaults should +/// work with most applications. +/// +/// # Pooling and Cloning +/// +/// `TableService` holds a connection pool internally, it is advised to +/// create one and the reuse it. You do not need to wrap `TableService` in +/// an [Rc](std::rc::Rc) or [Arc] to reuse it, because it already uses an `Arc` +/// internally. +#[derive(Clone, Debug)] +pub struct TableService { + inner: Arc, +} + +impl TableService { + /// Creates a new client with the default configuration. + pub async fn new() -> Result { + Self::new_with_config(gax::options::ClientConfig::default()).await + } + + /// Creates a new client with the specified configuration. + pub async fn new_with_config(conf: gax::options::ClientConfig) -> Result { + let inner = Self::build_inner(conf).await?; + Ok(Self { inner }) + } + + /// Creates a new client from the provided stub. + /// + /// The most common case for calling this function is when mocking the + /// client. + pub fn from_stub(stub: T) -> Self + where + T: super::stubs::TableService + 'static, + { + Self { + inner: Arc::new(stub), + } + } + + async fn build_inner( + conf: gax::options::ClientConfig, + ) -> Result> { + if conf.tracing_enabled() { + return Ok(Arc::new(Self::build_with_tracing(conf).await?)); + } + Ok(Arc::new(Self::build_transport(conf).await?)) + } + + async fn build_transport( + conf: gax::options::ClientConfig, + ) -> Result { + super::transport::TableService::new(conf).await + } + + async fn build_with_tracing( + conf: gax::options::ClientConfig, + ) -> Result { + Self::build_transport(conf) + .await + .map(super::tracing::TableService::new) + } + + /// Gets the specified table resource by table ID. + /// This method does not return the data in the table, it only returns the + /// table resource, which describes the structure of this table. + pub fn get_table( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + ) -> super::builders::table_service::GetTable { + super::builders::table_service::GetTable::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + } + + /// Creates a new, empty table in the dataset. + pub fn insert_table( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::table_service::InsertTable { + super::builders::table_service::InsertTable::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } + + /// Updates information in an existing table. The update method replaces the + /// entire table resource, whereas the patch method only replaces fields that + /// are provided in the submitted table resource. + /// This method supports RFC5789 patch semantics. + pub fn patch_table( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + ) -> super::builders::table_service::PatchTable { + super::builders::table_service::PatchTable::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + } + + /// Updates information in an existing table. The update method replaces the + /// entire Table resource, whereas the patch method only replaces fields that + /// are provided in the submitted Table resource. + pub fn update_table( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + ) -> super::builders::table_service::UpdateTable { + super::builders::table_service::UpdateTable::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + } + + /// Deletes the table specified by tableId from the dataset. + /// If the table contains data, all the data will be deleted. + pub fn delete_table( + &self, + project_id: impl Into, + dataset_id: impl Into, + table_id: impl Into, + ) -> super::builders::table_service::DeleteTable { + super::builders::table_service::DeleteTable::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + .set_table_id(table_id.into()) + } + + /// Lists all tables in the specified dataset. Requires the READER dataset + /// role. + pub fn list_tables( + &self, + project_id: impl Into, + dataset_id: impl Into, + ) -> super::builders::table_service::ListTables { + super::builders::table_service::ListTables::new(self.inner.clone()) + .set_project_id(project_id.into()) + .set_dataset_id(dataset_id.into()) + } +} diff --git a/src/generated/cloud/bigquery/v2/src/lib.rs b/src/generated/cloud/bigquery/v2/src/lib.rs new file mode 100644 index 000000000..2b0260f63 --- /dev/null +++ b/src/generated/cloud/bigquery/v2/src/lib.rs @@ -0,0 +1,74 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by sidekick. DO NOT EDIT. + +//! Google Cloud Client Libraries for Rust - BigQuery API +//! +//! **WARNING:** this crate is under active development. We expect multiple +//! breaking changes in the upcoming releases. Testing is also incomplete, we do +//! **not** recommend that you use this crate in production. We welcome feedback +//! about the APIs, documentation, missing features, bugs, etc. +//! +//! This crate contains traits, types, and functions to interact with BigQuery API +//! Most applications will use the structs defined in the [client] module. +//! More specifically: +//! +//! * [DatasetService](client/struct.DatasetService.html) +//! * [ModelService](client/struct.ModelService.html) +//! * [ProjectService](client/struct.ProjectService.html) +//! * [RoutineService](client/struct.RoutineService.html) +//! * [RowAccessPolicyService](client/struct.RowAccessPolicyService.html) +//! * [TableService](client/struct.TableService.html) + +/// The messages and enums that are part of this client library. +#[allow(clippy::module_inception)] +pub mod model; + +pub use gax::error::Error; +pub use gax::Result; + +#[allow(rustdoc::invalid_html_tags)] +#[allow(rustdoc::redundant_explicit_links)] +pub mod stubs; + +/// Concrete implementations of this client library traits. +pub mod client; + +/// Request builders. +pub mod builders; + +#[doc(hidden)] +pub(crate) mod tracing; + +#[doc(hidden)] +pub(crate) mod transport; + +/// The default host used by the service. +const DEFAULT_HOST: &str = "https://bigquery.googleapis.com/"; + +pub(crate) mod info { + const NAME: &str = env!("CARGO_PKG_NAME"); + const VERSION: &str = env!("CARGO_PKG_VERSION"); + lazy_static::lazy_static! { + pub(crate) static ref X_GOOG_API_CLIENT_HEADER: String = { + let ac = gax::api_header::XGoogApiClient{ + name: NAME, + version: VERSION, + library_type: gax::api_header::GAPIC, + }; + ac.header_value() + }; + } +} diff --git a/src/generated/cloud/bigquery/v2/src/model.rs b/src/generated/cloud/bigquery/v2/src/model.rs new file mode 100755 index 000000000..949a5375f --- /dev/null +++ b/src/generated/cloud/bigquery/v2/src/model.rs @@ -0,0 +1,19115 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by sidekick. DO NOT EDIT. + +#![allow(rustdoc::redundant_explicit_links)] +#![allow(rustdoc::broken_intra_doc_links)] +#![no_implicit_prelude] +extern crate async_trait; +extern crate bytes; +extern crate gax; +extern crate gaxi; +extern crate gtype; +extern crate lazy_static; +extern crate reqwest; +extern crate serde; +extern crate serde_json; +extern crate serde_with; +extern crate std; +extern crate tracing; +extern crate wkt; + +/// Configuration for BigLake managed tables. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct BigLakeConfiguration { + /// Optional. The connection specifying the credentials to be used to read and + /// write to external storage, such as Cloud Storage. The connection_id can + /// have the form `{project}.{location}.{connection_id}` or + /// `projects/{project}/locations/{location}/connections/{connection_id}". + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub connection_id: std::string::String, + + /// Optional. The fully qualified location prefix of the external folder where + /// table data is stored. The '*' wildcard character is not allowed. The URI + /// should be in the format `gs://bucket/path_to_table/` + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub storage_uri: std::string::String, + + /// Optional. The file format the table data is stored in. + pub file_format: crate::model::big_lake_configuration::FileFormat, + + /// Optional. The table format the metadata only snapshots are stored in. + pub table_format: crate::model::big_lake_configuration::TableFormat, +} + +impl BigLakeConfiguration { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [connection_id][crate::model::BigLakeConfiguration::connection_id]. + pub fn set_connection_id>(mut self, v: T) -> Self { + self.connection_id = v.into(); + self + } + + /// Sets the value of [storage_uri][crate::model::BigLakeConfiguration::storage_uri]. + pub fn set_storage_uri>(mut self, v: T) -> Self { + self.storage_uri = v.into(); + self + } + + /// Sets the value of [file_format][crate::model::BigLakeConfiguration::file_format]. + pub fn set_file_format< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.file_format = v.into(); + self + } + + /// Sets the value of [table_format][crate::model::BigLakeConfiguration::table_format]. + pub fn set_table_format< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.table_format = v.into(); + self + } +} + +impl wkt::message::Message for BigLakeConfiguration { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.BigLakeConfiguration" + } +} + +/// Defines additional types related to BigLakeConfiguration +pub mod big_lake_configuration { + #[allow(unused_imports)] + use super::*; + + /// Supported file formats for BigLake tables. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct FileFormat(i32); + + impl FileFormat { + /// Default Value. + pub const FILE_FORMAT_UNSPECIFIED: FileFormat = FileFormat::new(0); + + /// Apache Parquet format. + pub const PARQUET: FileFormat = FileFormat::new(1); + + /// Creates a new FileFormat instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("FILE_FORMAT_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("PARQUET"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "FILE_FORMAT_UNSPECIFIED" => { + std::option::Option::Some(Self::FILE_FORMAT_UNSPECIFIED) + } + "PARQUET" => std::option::Option::Some(Self::PARQUET), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for FileFormat { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for FileFormat { + fn default() -> Self { + Self::new(0) + } + } + + /// Supported table formats for BigLake tables. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct TableFormat(i32); + + impl TableFormat { + /// Default Value. + pub const TABLE_FORMAT_UNSPECIFIED: TableFormat = TableFormat::new(0); + + /// Apache Iceberg format. + pub const ICEBERG: TableFormat = TableFormat::new(1); + + /// Creates a new TableFormat instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("TABLE_FORMAT_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("ICEBERG"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "TABLE_FORMAT_UNSPECIFIED" => { + std::option::Option::Some(Self::TABLE_FORMAT_UNSPECIFIED) + } + "ICEBERG" => std::option::Option::Some(Self::ICEBERG), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for TableFormat { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for TableFormat { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Configures table clustering. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Clustering { + /// One or more fields on which data should be clustered. Only top-level, + /// non-repeated, simple-type fields are supported. The ordering of the + /// clustering fields should be prioritized from most to least important + /// for filtering purposes. + /// + /// For additional information, see + /// [Introduction to clustered + /// tables](https://cloud.google.com/bigquery/docs/clustered-tables#limitations). + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub fields: std::vec::Vec, +} + +impl Clustering { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [fields][crate::model::Clustering::fields]. + pub fn set_fields(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.fields = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for Clustering { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Clustering" + } +} + +/// Grants all resources of particular types in a particular dataset read access +/// to the current dataset. +/// +/// Similar to how individually authorized views work, updates to any resource +/// granted through its dataset (including creation of new resources) requires +/// read permission to referenced resources, plus write permission to the +/// authorizing dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DatasetAccessEntry { + /// The dataset this entry applies to + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dataset: std::option::Option, + + /// Which resources in the dataset this entry applies to. Currently, only + /// views are supported, but additional target types may be added in the + /// future. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub target_types: std::vec::Vec, +} + +impl DatasetAccessEntry { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [dataset][crate::model::DatasetAccessEntry::dataset]. + pub fn set_dataset< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.dataset = v.into(); + self + } + + /// Sets the value of [target_types][crate::model::DatasetAccessEntry::target_types]. + pub fn set_target_types(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.target_types = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for DatasetAccessEntry { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DatasetAccessEntry" + } +} + +/// Defines additional types related to DatasetAccessEntry +pub mod dataset_access_entry { + #[allow(unused_imports)] + use super::*; + + /// Indicates the type of resources in a dataset that the entry applies to. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct TargetType(i32); + + impl TargetType { + /// Do not use. You must set a target type explicitly. + pub const TARGET_TYPE_UNSPECIFIED: TargetType = TargetType::new(0); + + /// This entry applies to views in the dataset. + pub const VIEWS: TargetType = TargetType::new(1); + + /// This entry applies to routines in the dataset. + pub const ROUTINES: TargetType = TargetType::new(2); + + /// Creates a new TargetType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("TARGET_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("VIEWS"), + 2 => std::borrow::Cow::Borrowed("ROUTINES"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "TARGET_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::TARGET_TYPE_UNSPECIFIED) + } + "VIEWS" => std::option::Option::Some(Self::VIEWS), + "ROUTINES" => std::option::Option::Some(Self::ROUTINES), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for TargetType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for TargetType { + fn default() -> Self { + Self::new(0) + } + } +} + +/// An object that defines dataset access for an entity. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Access { + /// An IAM role ID that should be granted to the user, group, + /// or domain specified in this access entry. + /// The following legacy mappings will be applied: + /// + /// * `OWNER`: `roles/bigquery.dataOwner` + /// * `WRITER`: `roles/bigquery.dataEditor` + /// * `READER`: `roles/bigquery.dataViewer` + /// + /// This field will accept any of the above formats, but will return only + /// the legacy format. For example, if you set this field to + /// "roles/bigquery.dataOwner", it will be returned back as "OWNER". + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub role: std::string::String, + + /// [Pick one] An email address of a user to grant access to. For example: + /// fred@example.com. Maps to IAM policy member "user:EMAIL" or + /// "serviceAccount:EMAIL". + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub user_by_email: std::string::String, + + /// [Pick one] An email address of a Google Group to grant access to. + /// Maps to IAM policy member "group:GROUP". + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub group_by_email: std::string::String, + + /// [Pick one] A domain to grant access to. Any users signed in with the domain + /// specified will be granted the specified access. Example: "example.com". + /// Maps to IAM policy member "domain:DOMAIN". + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub domain: std::string::String, + + /// [Pick one] A special group to grant access to. Possible values include: + /// + /// * projectOwners: Owners of the enclosing project. + /// * projectReaders: Readers of the enclosing project. + /// * projectWriters: Writers of the enclosing project. + /// * allAuthenticatedUsers: All authenticated BigQuery users. + /// + /// Maps to similarly-named IAM members. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub special_group: std::string::String, + + /// [Pick one] Some other type of member that appears in the IAM Policy but + /// isn't a user, group, domain, or special group. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub iam_member: std::string::String, + + /// [Pick one] A view from a different dataset to grant access to. Queries + /// executed against that view will have read access to views/tables/routines + /// in this dataset. + /// The role field is not required when this field is set. If that view is + /// updated by any user, access to the view needs to be granted again via an + /// update operation. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub view: std::option::Option, + + /// [Pick one] A routine from a different dataset to grant access to. Queries + /// executed against that routine will have read access to + /// views/tables/routines in this dataset. Only UDF is supported for now. + /// The role field is not required when this field is set. If that routine is + /// updated by any user, access to the routine needs to be granted again via + /// an update operation. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub routine: std::option::Option, + + /// [Pick one] A grant authorizing all resources of a particular type in a + /// particular dataset access to this dataset. Only views are supported for + /// now. The role field is not required when this field is set. If that dataset + /// is deleted and re-created, its access needs to be granted again via an + /// update operation. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dataset: std::option::Option, + + /// Optional. condition for the binding. If CEL expression in this field is + /// true, this access binding will be considered + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub condition: std::option::Option, +} + +impl Access { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [role][crate::model::Access::role]. + pub fn set_role>(mut self, v: T) -> Self { + self.role = v.into(); + self + } + + /// Sets the value of [user_by_email][crate::model::Access::user_by_email]. + pub fn set_user_by_email>(mut self, v: T) -> Self { + self.user_by_email = v.into(); + self + } + + /// Sets the value of [group_by_email][crate::model::Access::group_by_email]. + pub fn set_group_by_email>(mut self, v: T) -> Self { + self.group_by_email = v.into(); + self + } + + /// Sets the value of [domain][crate::model::Access::domain]. + pub fn set_domain>(mut self, v: T) -> Self { + self.domain = v.into(); + self + } + + /// Sets the value of [special_group][crate::model::Access::special_group]. + pub fn set_special_group>(mut self, v: T) -> Self { + self.special_group = v.into(); + self + } + + /// Sets the value of [iam_member][crate::model::Access::iam_member]. + pub fn set_iam_member>(mut self, v: T) -> Self { + self.iam_member = v.into(); + self + } + + /// Sets the value of [view][crate::model::Access::view]. + pub fn set_view>>( + mut self, + v: T, + ) -> Self { + self.view = v.into(); + self + } + + /// Sets the value of [routine][crate::model::Access::routine]. + pub fn set_routine< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.routine = v.into(); + self + } + + /// Sets the value of [dataset][crate::model::Access::dataset]. + pub fn set_dataset< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.dataset = v.into(); + self + } + + /// Sets the value of [condition][crate::model::Access::condition]. + pub fn set_condition>>( + mut self, + v: T, + ) -> Self { + self.condition = v.into(); + self + } +} + +impl wkt::message::Message for Access { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Access" + } +} + +/// Represents a BigQuery dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Dataset { + /// Output only. The resource type. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub kind: std::string::String, + + /// Output only. A hash of the resource. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub etag: std::string::String, + + /// Output only. The fully-qualified unique name of the dataset in the format + /// projectId:datasetId. The dataset name without the project name is given in + /// the datasetId field. When creating a new dataset, leave this field blank, + /// and instead specify the datasetId field. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub id: std::string::String, + + /// Output only. A URL that can be used to access the resource again. You can + /// use this URL in Get or Update requests to the resource. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub self_link: std::string::String, + + /// Required. A reference that identifies the dataset. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dataset_reference: std::option::Option, + + /// Optional. A descriptive name for the dataset. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub friendly_name: std::option::Option, + + /// Optional. A user-friendly description of the dataset. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub description: std::option::Option, + + /// Optional. The default lifetime of all tables in the dataset, in + /// milliseconds. The minimum lifetime value is 3600000 milliseconds (one + /// hour). To clear an existing default expiration with a PATCH request, set to + /// 0. Once this property is set, all newly-created tables in the dataset will + /// have an expirationTime property set to the creation time plus the value in + /// this property, and changing the value will only affect new tables, not + /// existing ones. When the expirationTime for a given table is reached, that + /// table will be deleted automatically. + /// If a table's expirationTime is modified or removed before the table + /// expires, or if you provide an explicit expirationTime when creating a + /// table, that value takes precedence over the default expiration time + /// indicated by this property. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub default_table_expiration_ms: std::option::Option, + + /// This default partition expiration, expressed in milliseconds. + /// + /// When new time-partitioned tables are created in a dataset where this + /// property is set, the table will inherit this value, propagated as the + /// `TimePartitioning.expirationMs` property on the new table. If you set + /// `TimePartitioning.expirationMs` explicitly when creating a table, + /// the `defaultPartitionExpirationMs` of the containing dataset is ignored. + /// + /// When creating a partitioned table, if `defaultPartitionExpirationMs` + /// is set, the `defaultTableExpirationMs` value is ignored and the table + /// will not be inherit a table expiration deadline. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub default_partition_expiration_ms: std::option::Option, + + /// The labels associated with this dataset. You can use these + /// to organize and group your datasets. + /// You can set this property when inserting or updating a dataset. + /// See [Creating and Updating Dataset + /// Labels](https://cloud.google.com/bigquery/docs/creating-managing-labels#creating_and_updating_dataset_labels) + /// for more information. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub labels: std::collections::HashMap, + + /// Optional. An array of objects that define dataset access for one or more + /// entities. You can set this property when inserting or updating a dataset in + /// order to control who is allowed to access the data. If unspecified at + /// dataset creation time, BigQuery adds default dataset access for the + /// following entities: access.specialGroup: projectReaders; access.role: + /// READER; access.specialGroup: projectWriters; access.role: WRITER; + /// access.specialGroup: projectOwners; access.role: OWNER; + /// access.userByEmail: [dataset creator email]; access.role: OWNER; + /// If you patch a dataset, then this field is overwritten by the patched + /// dataset's access field. To add entities, you must supply the entire + /// existing access array in addition to any new entities that you want to add. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub access: std::vec::Vec, + + /// Output only. The time when this dataset was created, in milliseconds since + /// the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub creation_time: i64, + + /// Output only. The date when this dataset was last modified, in milliseconds + /// since the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub last_modified_time: i64, + + /// The geographic location where the dataset should reside. See + /// for supported + /// locations. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub location: std::string::String, + + /// The default encryption key for all tables in the dataset. + /// After this property is set, the encryption key of all newly-created tables + /// in the dataset is set to this value unless the table creation request or + /// query explicitly overrides the key. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub default_encryption_configuration: + std::option::Option, + + /// Output only. Reserved for future use. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub satisfies_pzs: std::option::Option, + + /// Output only. Reserved for future use. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub satisfies_pzi: std::option::Option, + + /// Output only. Same as `type` in `ListFormatDataset`. + /// The type of the dataset, one of: + /// + /// * DEFAULT - only accessible by owner and authorized accounts, + /// * PUBLIC - accessible by everyone, + /// * LINKED - linked dataset, + /// * EXTERNAL - dataset with definition in external metadata catalog. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + + /// Optional. The source dataset reference when the dataset is of type LINKED. + /// For all other dataset types it is not set. This field cannot be updated + /// once it is set. Any attempt to update this field using Update and Patch API + /// Operations will be ignored. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub linked_dataset_source: std::option::Option, + + /// Output only. Metadata about the LinkedDataset. Filled out when the dataset + /// type is LINKED. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub linked_dataset_metadata: std::option::Option, + + /// Optional. Reference to a read-only external dataset defined in data + /// catalogs outside of BigQuery. Filled out when the dataset type is EXTERNAL. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub external_dataset_reference: std::option::Option, + + /// Optional. Options defining open source compatible datasets living in the + /// BigQuery catalog. Contains metadata of open source database, schema or + /// namespace represented by the current dataset. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub external_catalog_dataset_options: + std::option::Option, + + /// Optional. TRUE if the dataset and its table names are case-insensitive, + /// otherwise FALSE. By default, this is FALSE, which means the dataset and its + /// table names are case-sensitive. This field does not affect routine + /// references. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub is_case_insensitive: std::option::Option, + + /// Optional. Defines the default collation specification of future tables + /// created in the dataset. If a table is created in this dataset without + /// table-level default collation, then the table inherits the dataset default + /// collation, which is applied to the string fields that do not have explicit + /// collation specified. A change to this field affects only tables created + /// afterwards, and does not alter the existing tables. + /// The following values are supported: + /// + /// * 'und:ci': undetermined locale, case insensitive. + /// * '': empty string. Default to case-sensitive behavior. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub default_collation: std::option::Option, + + /// Optional. Defines the default rounding mode specification of new tables + /// created within this dataset. During table creation, if this field is + /// specified, the table within this dataset will inherit the default rounding + /// mode of the dataset. Setting the default rounding mode on a table overrides + /// this option. Existing tables in the dataset are unaffected. + /// If columns are defined during that table creation, + /// they will immediately inherit the table's default rounding mode, + /// unless otherwise specified. + pub default_rounding_mode: crate::model::table_field_schema::RoundingMode, + + /// Optional. Defines the time travel window in hours. The value can be from 48 + /// to 168 hours (2 to 7 days). The default value is 168 hours if this is not + /// set. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub max_time_travel_hours: std::option::Option, + + /// Output only. Tags for the dataset. To provide tags as inputs, use the + /// `resourceTags` field. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub tags: std::vec::Vec, + + /// Optional. Updates storage_billing_model for the dataset. + pub storage_billing_model: crate::model::dataset::StorageBillingModel, + + /// Optional. Output only. Restriction config for all tables and dataset. If + /// set, restrict certain accesses on the dataset and all its tables based on + /// the config. See [Data + /// egress](https://cloud.google.com/bigquery/docs/analytics-hub-introduction#data_egress) + /// for more details. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub restrictions: std::option::Option, + + /// Optional. The [tags](https://cloud.google.com/bigquery/docs/tags) attached + /// to this dataset. Tag keys are globally unique. Tag key is expected to be in + /// the namespaced format, for example "123456789012/environment" where + /// 123456789012 is the ID of the parent organization or project resource for + /// this tag key. Tag value is expected to be the short name, for example + /// "Production". See [Tag + /// definitions](https://cloud.google.com/iam/docs/tags-access-control#definitions) + /// for more details. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub resource_tags: std::collections::HashMap, +} + +impl Dataset { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [kind][crate::model::Dataset::kind]. + pub fn set_kind>(mut self, v: T) -> Self { + self.kind = v.into(); + self + } + + /// Sets the value of [etag][crate::model::Dataset::etag]. + pub fn set_etag>(mut self, v: T) -> Self { + self.etag = v.into(); + self + } + + /// Sets the value of [id][crate::model::Dataset::id]. + pub fn set_id>(mut self, v: T) -> Self { + self.id = v.into(); + self + } + + /// Sets the value of [self_link][crate::model::Dataset::self_link]. + pub fn set_self_link>(mut self, v: T) -> Self { + self.self_link = v.into(); + self + } + + /// Sets the value of [dataset_reference][crate::model::Dataset::dataset_reference]. + pub fn set_dataset_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.dataset_reference = v.into(); + self + } + + /// Sets the value of [friendly_name][crate::model::Dataset::friendly_name]. + pub fn set_friendly_name>>( + mut self, + v: T, + ) -> Self { + self.friendly_name = v.into(); + self + } + + /// Sets the value of [description][crate::model::Dataset::description]. + pub fn set_description>>( + mut self, + v: T, + ) -> Self { + self.description = v.into(); + self + } + + /// Sets the value of [default_table_expiration_ms][crate::model::Dataset::default_table_expiration_ms]. + pub fn set_default_table_expiration_ms< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.default_table_expiration_ms = v.into(); + self + } + + /// Sets the value of [default_partition_expiration_ms][crate::model::Dataset::default_partition_expiration_ms]. + pub fn set_default_partition_expiration_ms< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.default_partition_expiration_ms = v.into(); + self + } + + /// Sets the value of [creation_time][crate::model::Dataset::creation_time]. + pub fn set_creation_time>(mut self, v: T) -> Self { + self.creation_time = v.into(); + self + } + + /// Sets the value of [last_modified_time][crate::model::Dataset::last_modified_time]. + pub fn set_last_modified_time>(mut self, v: T) -> Self { + self.last_modified_time = v.into(); + self + } + + /// Sets the value of [location][crate::model::Dataset::location]. + pub fn set_location>(mut self, v: T) -> Self { + self.location = v.into(); + self + } + + /// Sets the value of [default_encryption_configuration][crate::model::Dataset::default_encryption_configuration]. + pub fn set_default_encryption_configuration< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.default_encryption_configuration = v.into(); + self + } + + /// Sets the value of [satisfies_pzs][crate::model::Dataset::satisfies_pzs]. + pub fn set_satisfies_pzs>>( + mut self, + v: T, + ) -> Self { + self.satisfies_pzs = v.into(); + self + } + + /// Sets the value of [satisfies_pzi][crate::model::Dataset::satisfies_pzi]. + pub fn set_satisfies_pzi>>( + mut self, + v: T, + ) -> Self { + self.satisfies_pzi = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::Dataset::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [linked_dataset_source][crate::model::Dataset::linked_dataset_source]. + pub fn set_linked_dataset_source< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.linked_dataset_source = v.into(); + self + } + + /// Sets the value of [linked_dataset_metadata][crate::model::Dataset::linked_dataset_metadata]. + pub fn set_linked_dataset_metadata< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.linked_dataset_metadata = v.into(); + self + } + + /// Sets the value of [external_dataset_reference][crate::model::Dataset::external_dataset_reference]. + pub fn set_external_dataset_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.external_dataset_reference = v.into(); + self + } + + /// Sets the value of [external_catalog_dataset_options][crate::model::Dataset::external_catalog_dataset_options]. + pub fn set_external_catalog_dataset_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.external_catalog_dataset_options = v.into(); + self + } + + /// Sets the value of [is_case_insensitive][crate::model::Dataset::is_case_insensitive]. + pub fn set_is_case_insensitive>>( + mut self, + v: T, + ) -> Self { + self.is_case_insensitive = v.into(); + self + } + + /// Sets the value of [default_collation][crate::model::Dataset::default_collation]. + pub fn set_default_collation>>( + mut self, + v: T, + ) -> Self { + self.default_collation = v.into(); + self + } + + /// Sets the value of [default_rounding_mode][crate::model::Dataset::default_rounding_mode]. + pub fn set_default_rounding_mode< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.default_rounding_mode = v.into(); + self + } + + /// Sets the value of [max_time_travel_hours][crate::model::Dataset::max_time_travel_hours]. + pub fn set_max_time_travel_hours< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.max_time_travel_hours = v.into(); + self + } + + /// Sets the value of [storage_billing_model][crate::model::Dataset::storage_billing_model]. + pub fn set_storage_billing_model< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.storage_billing_model = v.into(); + self + } + + /// Sets the value of [restrictions][crate::model::Dataset::restrictions]. + pub fn set_restrictions< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.restrictions = v.into(); + self + } + + /// Sets the value of [access][crate::model::Dataset::access]. + pub fn set_access(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.access = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [tags][crate::model::Dataset::tags]. + pub fn set_tags(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.tags = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [labels][crate::model::Dataset::labels]. + pub fn set_labels(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } + + /// Sets the value of [resource_tags][crate::model::Dataset::resource_tags]. + pub fn set_resource_tags(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.resource_tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for Dataset { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Dataset" + } +} + +/// Defines additional types related to Dataset +pub mod dataset { + #[allow(unused_imports)] + use super::*; + + /// Indicates the billing model that will be applied to the dataset. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct StorageBillingModel(i32); + + impl StorageBillingModel { + /// Value not set. + pub const STORAGE_BILLING_MODEL_UNSPECIFIED: StorageBillingModel = + StorageBillingModel::new(0); + + /// Billing for logical bytes. + pub const LOGICAL: StorageBillingModel = StorageBillingModel::new(1); + + /// Billing for physical bytes. + pub const PHYSICAL: StorageBillingModel = StorageBillingModel::new(2); + + /// Creates a new StorageBillingModel instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("STORAGE_BILLING_MODEL_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("LOGICAL"), + 2 => std::borrow::Cow::Borrowed("PHYSICAL"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "STORAGE_BILLING_MODEL_UNSPECIFIED" => { + std::option::Option::Some(Self::STORAGE_BILLING_MODEL_UNSPECIFIED) + } + "LOGICAL" => std::option::Option::Some(Self::LOGICAL), + "PHYSICAL" => std::option::Option::Some(Self::PHYSICAL), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for StorageBillingModel { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for StorageBillingModel { + fn default() -> Self { + Self::new(0) + } + } +} + +/// A global tag managed by Resource Manager. +/// +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GcpTag { + /// Required. The namespaced friendly name of the tag key, e.g. + /// "12345/environment" where 12345 is org id. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub tag_key: std::string::String, + + /// Required. The friendly short name of the tag value, e.g. "production". + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub tag_value: std::string::String, +} + +impl GcpTag { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [tag_key][crate::model::GcpTag::tag_key]. + pub fn set_tag_key>(mut self, v: T) -> Self { + self.tag_key = v.into(); + self + } + + /// Sets the value of [tag_value][crate::model::GcpTag::tag_value]. + pub fn set_tag_value>(mut self, v: T) -> Self { + self.tag_value = v.into(); + self + } +} + +impl wkt::message::Message for GcpTag { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GcpTag" + } +} + +/// A dataset source type which refers to another BigQuery dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct LinkedDatasetSource { + /// The source dataset reference contains project numbers and not project ids. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub source_dataset: std::option::Option, +} + +impl LinkedDatasetSource { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [source_dataset][crate::model::LinkedDatasetSource::source_dataset]. + pub fn set_source_dataset< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.source_dataset = v.into(); + self + } +} + +impl wkt::message::Message for LinkedDatasetSource { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.LinkedDatasetSource" + } +} + +/// Metadata about the Linked Dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct LinkedDatasetMetadata { + /// Output only. Specifies whether Linked Dataset is currently in a linked + /// state or not. + pub link_state: crate::model::linked_dataset_metadata::LinkState, +} + +impl LinkedDatasetMetadata { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [link_state][crate::model::LinkedDatasetMetadata::link_state]. + pub fn set_link_state< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.link_state = v.into(); + self + } +} + +impl wkt::message::Message for LinkedDatasetMetadata { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.LinkedDatasetMetadata" + } +} + +/// Defines additional types related to LinkedDatasetMetadata +pub mod linked_dataset_metadata { + #[allow(unused_imports)] + use super::*; + + /// Specifies whether Linked Dataset is currently in a linked state or not. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct LinkState(i32); + + impl LinkState { + /// The default value. + /// Default to the LINKED state. + pub const LINK_STATE_UNSPECIFIED: LinkState = LinkState::new(0); + + /// Normal Linked Dataset state. Data is queryable via the Linked Dataset. + pub const LINKED: LinkState = LinkState::new(1); + + /// Data publisher or owner has unlinked this Linked Dataset. It means you + /// can no longer query or see the data in the Linked Dataset. + pub const UNLINKED: LinkState = LinkState::new(2); + + /// Creates a new LinkState instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("LINK_STATE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("LINKED"), + 2 => std::borrow::Cow::Borrowed("UNLINKED"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "LINK_STATE_UNSPECIFIED" => std::option::Option::Some(Self::LINK_STATE_UNSPECIFIED), + "LINKED" => std::option::Option::Some(Self::LINKED), + "UNLINKED" => std::option::Option::Some(Self::UNLINKED), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for LinkState { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for LinkState { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Request format for getting information about a dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GetDatasetRequest { + /// Required. Project ID of the requested dataset + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the requested dataset + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Optional. Specifies the view that determines which dataset information is + /// returned. By default, metadata and ACL information are returned. + pub dataset_view: crate::model::get_dataset_request::DatasetView, + + /// Optional. The version of the access policy schema to fetch. + /// Valid values are 0, 1, and 3. Requests specifying an invalid value will be + /// rejected. + /// + /// Requests for conditional access policy binding in datasets must specify + /// version 3. Dataset with no conditional role bindings in access policy may + /// specify any valid value or leave the field unset. + /// + /// This field will be mapped to [IAM Policy version] + /// () and will be used to + /// fetch policy from IAM. + /// + /// If unset or if 0 or 1 value is used for dataset with conditional bindings, + /// access entry with condition will have role string appended by + /// 'withcond' string followed by a hash value. For example : + /// { + /// "access": [ + /// { + /// "role": + /// "roles/bigquery.dataViewer_with_conditionalbinding_7a34awqsda", + /// "userByEmail": "user@example.com", + /// } + /// ] + /// } + /// Please refer for + /// more details. + pub access_policy_version: i32, +} + +impl GetDatasetRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::GetDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [dataset_view][crate::model::GetDatasetRequest::dataset_view]. + pub fn set_dataset_view< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.dataset_view = v.into(); + self + } + + /// Sets the value of [access_policy_version][crate::model::GetDatasetRequest::access_policy_version]. + pub fn set_access_policy_version>(mut self, v: T) -> Self { + self.access_policy_version = v.into(); + self + } +} + +impl wkt::message::Message for GetDatasetRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GetDatasetRequest" + } +} + +/// Defines additional types related to GetDatasetRequest +pub mod get_dataset_request { + #[allow(unused_imports)] + use super::*; + + /// DatasetView specifies which dataset information is returned. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct DatasetView(i32); + + impl DatasetView { + /// The default value. + /// Default to the FULL view. + pub const DATASET_VIEW_UNSPECIFIED: DatasetView = DatasetView::new(0); + + /// Includes metadata information for the dataset, such as location, + /// etag, lastModifiedTime, etc. + pub const METADATA: DatasetView = DatasetView::new(1); + + /// Includes ACL information for the dataset, which defines dataset access + /// for one or more entities. + pub const ACL: DatasetView = DatasetView::new(2); + + /// Includes both dataset metadata and ACL information. + pub const FULL: DatasetView = DatasetView::new(3); + + /// Creates a new DatasetView instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("DATASET_VIEW_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("METADATA"), + 2 => std::borrow::Cow::Borrowed("ACL"), + 3 => std::borrow::Cow::Borrowed("FULL"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "DATASET_VIEW_UNSPECIFIED" => { + std::option::Option::Some(Self::DATASET_VIEW_UNSPECIFIED) + } + "METADATA" => std::option::Option::Some(Self::METADATA), + "ACL" => std::option::Option::Some(Self::ACL), + "FULL" => std::option::Option::Some(Self::FULL), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for DatasetView { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for DatasetView { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Request format for inserting a dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct InsertDatasetRequest { + /// Required. Project ID of the new dataset + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Datasets resource to use for the new dataset + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dataset: std::option::Option, + + /// Optional. The version of the provided access policy schema. + /// Valid values are 0, 1, and 3. Requests specifying an invalid value will be + /// rejected. + /// + /// This version refers to the schema version of the access policy and not the + /// version of access policy. This field's value can be equal or more + /// than the access policy schema provided in the request. + /// For example, + /// + /// * Requests with conditional access policy binding in datasets must + /// specify + /// version 3. + /// * But dataset with no conditional role bindings in access policy + /// may specify any valid value or leave the field unset. + /// If unset or if 0 or 1 value is used for dataset with conditional + /// bindings, request will be rejected. + /// + /// This field will be mapped to IAM Policy version + /// () and will be used to + /// set policy in IAM. + pub access_policy_version: i32, +} + +impl InsertDatasetRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::InsertDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset][crate::model::InsertDatasetRequest::dataset]. + pub fn set_dataset>>( + mut self, + v: T, + ) -> Self { + self.dataset = v.into(); + self + } + + /// Sets the value of [access_policy_version][crate::model::InsertDatasetRequest::access_policy_version]. + pub fn set_access_policy_version>(mut self, v: T) -> Self { + self.access_policy_version = v.into(); + self + } +} + +impl wkt::message::Message for InsertDatasetRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.InsertDatasetRequest" + } +} + +/// Message for updating or patching a dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct UpdateOrPatchDatasetRequest { + /// Required. Project ID of the dataset being updated + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the dataset being updated + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Datasets resource which will replace or patch the specified + /// dataset. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dataset: std::option::Option, + + /// Optional. The version of the provided access policy schema. + /// Valid values are 0, 1, and 3. Requests specifying an invalid value will be + /// rejected. + /// + /// This version refers to the schema version of the access policy and not the + /// version of access policy. This field's value can be equal or more + /// than the access policy schema provided in the request. + /// For example, + /// + /// * Operations updating conditional access policy binding in datasets must + /// specify + /// version 3. Some of the operations are : + /// - Adding a new access policy entry with condition. + /// - Removing an access policy entry with condition. + /// - Updating an access policy entry with condition. + /// * But dataset with no conditional role bindings in access policy + /// may specify any valid value or leave the field unset. + /// If unset or if 0 or 1 value is used for dataset with conditional + /// bindings, request will be rejected. + /// + /// This field will be mapped to IAM Policy version + /// () and will be used to + /// set policy in IAM. + pub access_policy_version: i32, +} + +impl UpdateOrPatchDatasetRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::UpdateOrPatchDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateOrPatchDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [dataset][crate::model::UpdateOrPatchDatasetRequest::dataset]. + pub fn set_dataset>>( + mut self, + v: T, + ) -> Self { + self.dataset = v.into(); + self + } + + /// Sets the value of [access_policy_version][crate::model::UpdateOrPatchDatasetRequest::access_policy_version]. + pub fn set_access_policy_version>(mut self, v: T) -> Self { + self.access_policy_version = v.into(); + self + } +} + +impl wkt::message::Message for UpdateOrPatchDatasetRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.UpdateOrPatchDatasetRequest" + } +} + +/// Request format for deleting a dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DeleteDatasetRequest { + /// Required. Project ID of the dataset being deleted + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of dataset being deleted + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// If True, delete all the tables in the dataset. + /// If False and the dataset contains tables, the request will fail. + /// Default is False + pub delete_contents: bool, +} + +impl DeleteDatasetRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::DeleteDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [delete_contents][crate::model::DeleteDatasetRequest::delete_contents]. + pub fn set_delete_contents>(mut self, v: T) -> Self { + self.delete_contents = v.into(); + self + } +} + +impl wkt::message::Message for DeleteDatasetRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DeleteDatasetRequest" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListDatasetsRequest { + /// Required. Project ID of the datasets to be listed + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// The maximum number of results to return in a single response page. + /// Leverage the page tokens to iterate through the entire collection. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub max_results: std::option::Option, + + /// Page token, returned by a previous call, to request the next page of + /// results + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub page_token: std::string::String, + + /// Whether to list all datasets, including hidden ones + pub all: bool, + + /// An expression for filtering the results of the request by label. + /// The syntax is `labels.[:]`. + /// Multiple filters can be AND-ed together by connecting with a space. + /// Example: `labels.department:receiving labels.active`. + /// See [Filtering datasets using + /// labels](https://cloud.google.com/bigquery/docs/filtering-labels#filtering_datasets_using_labels) + /// for details. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub filter: std::string::String, +} + +impl ListDatasetsRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::ListDatasetsRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [max_results][crate::model::ListDatasetsRequest::max_results]. + pub fn set_max_results>>( + mut self, + v: T, + ) -> Self { + self.max_results = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListDatasetsRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.page_token = v.into(); + self + } + + /// Sets the value of [all][crate::model::ListDatasetsRequest::all]. + pub fn set_all>(mut self, v: T) -> Self { + self.all = v.into(); + self + } + + /// Sets the value of [filter][crate::model::ListDatasetsRequest::filter]. + pub fn set_filter>(mut self, v: T) -> Self { + self.filter = v.into(); + self + } +} + +impl wkt::message::Message for ListDatasetsRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListDatasetsRequest" + } +} + +/// A dataset resource with only a subset of fields, to be returned in a list of +/// datasets. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListFormatDataset { + /// The resource type. + /// This property always returns the value "bigquery#dataset" + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub kind: std::string::String, + + /// The fully-qualified, unique, opaque ID of the dataset. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub id: std::string::String, + + /// The dataset reference. + /// Use this property to access specific parts of the dataset's ID, such as + /// project ID or dataset ID. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dataset_reference: std::option::Option, + + /// The labels associated with this dataset. + /// You can use these to organize and group your datasets. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub labels: std::collections::HashMap, + + /// An alternate name for the dataset. The friendly name is purely + /// decorative in nature. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub friendly_name: std::option::Option, + + /// The geographic location where the dataset resides. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub location: std::string::String, +} + +impl ListFormatDataset { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [kind][crate::model::ListFormatDataset::kind]. + pub fn set_kind>(mut self, v: T) -> Self { + self.kind = v.into(); + self + } + + /// Sets the value of [id][crate::model::ListFormatDataset::id]. + pub fn set_id>(mut self, v: T) -> Self { + self.id = v.into(); + self + } + + /// Sets the value of [dataset_reference][crate::model::ListFormatDataset::dataset_reference]. + pub fn set_dataset_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.dataset_reference = v.into(); + self + } + + /// Sets the value of [friendly_name][crate::model::ListFormatDataset::friendly_name]. + pub fn set_friendly_name>>( + mut self, + v: T, + ) -> Self { + self.friendly_name = v.into(); + self + } + + /// Sets the value of [location][crate::model::ListFormatDataset::location]. + pub fn set_location>(mut self, v: T) -> Self { + self.location = v.into(); + self + } + + /// Sets the value of [labels][crate::model::ListFormatDataset::labels]. + pub fn set_labels(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for ListFormatDataset { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListFormatDataset" + } +} + +/// Response format for a page of results when listing datasets. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DatasetList { + /// Output only. The resource type. + /// This property always returns the value "bigquery#datasetList" + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub kind: std::string::String, + + /// Output only. A hash value of the results page. You can use this property to + /// determine if the page has changed since the last request. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub etag: std::string::String, + + /// A token that can be used to request the next results page. This property is + /// omitted on the final results page. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub next_page_token: std::string::String, + + /// An array of the dataset resources in the project. + /// Each resource contains basic information. + /// For full information about a particular dataset resource, use the Datasets: + /// get method. This property is omitted when there are no datasets in the + /// project. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub datasets: std::vec::Vec, + + /// A list of skipped locations that were unreachable. For more information + /// about BigQuery locations, see: + /// . Example: "europe-west5" + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub unreachable: std::vec::Vec, +} + +impl DatasetList { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [kind][crate::model::DatasetList::kind]. + pub fn set_kind>(mut self, v: T) -> Self { + self.kind = v.into(); + self + } + + /// Sets the value of [etag][crate::model::DatasetList::etag]. + pub fn set_etag>(mut self, v: T) -> Self { + self.etag = v.into(); + self + } + + /// Sets the value of [next_page_token][crate::model::DatasetList::next_page_token]. + pub fn set_next_page_token>(mut self, v: T) -> Self { + self.next_page_token = v.into(); + self + } + + /// Sets the value of [datasets][crate::model::DatasetList::datasets]. + pub fn set_datasets(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.datasets = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [unreachable][crate::model::DatasetList::unreachable]. + pub fn set_unreachable(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.unreachable = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for DatasetList { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DatasetList" + } +} + +/// Request format for undeleting a dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct UndeleteDatasetRequest { + /// Required. Project ID of the dataset to be undeleted + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of dataset being deleted + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Optional. The exact time when the dataset was deleted. If not specified, + /// the most recently deleted version is undeleted. Undeleting a dataset + /// using deletion time is not supported. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub deletion_time: std::option::Option, +} + +impl UndeleteDatasetRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::UndeleteDatasetRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UndeleteDatasetRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [deletion_time][crate::model::UndeleteDatasetRequest::deletion_time]. + pub fn set_deletion_time>>( + mut self, + v: T, + ) -> Self { + self.deletion_time = v.into(); + self + } +} + +impl wkt::message::Message for UndeleteDatasetRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.UndeleteDatasetRequest" + } +} + +/// Identifier for a dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DatasetReference { + /// Required. A unique ID for this dataset, without the project name. The ID + /// must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). + /// The maximum length is 1,024 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Optional. The ID of the project containing this dataset. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, +} + +impl DatasetReference { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [dataset_id][crate::model::DatasetReference::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [project_id][crate::model::DatasetReference::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } +} + +impl wkt::message::Message for DatasetReference { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DatasetReference" + } +} + +/// Configuration for Cloud KMS encryption settings. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct EncryptionConfiguration { + /// Optional. Describes the Cloud KMS encryption key that will be used to + /// protect destination BigQuery table. The BigQuery Service Account associated + /// with your project requires access to this encryption key. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub kms_key_name: std::option::Option, +} + +impl EncryptionConfiguration { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [kms_key_name][crate::model::EncryptionConfiguration::kms_key_name]. + pub fn set_kms_key_name>>( + mut self, + v: T, + ) -> Self { + self.kms_key_name = v.into(); + self + } +} + +impl wkt::message::Message for EncryptionConfiguration { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.EncryptionConfiguration" + } +} + +/// Error details. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ErrorProto { + /// A short error code that summarizes the error. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub reason: std::string::String, + + /// Specifies where the error occurred, if present. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub location: std::string::String, + + /// Debugging information. This property is internal to Google and should not + /// be used. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub debug_info: std::string::String, + + /// A human-readable description of the error. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub message: std::string::String, +} + +impl ErrorProto { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [reason][crate::model::ErrorProto::reason]. + pub fn set_reason>(mut self, v: T) -> Self { + self.reason = v.into(); + self + } + + /// Sets the value of [location][crate::model::ErrorProto::location]. + pub fn set_location>(mut self, v: T) -> Self { + self.location = v.into(); + self + } + + /// Sets the value of [debug_info][crate::model::ErrorProto::debug_info]. + pub fn set_debug_info>(mut self, v: T) -> Self { + self.debug_info = v.into(); + self + } + + /// Sets the value of [message][crate::model::ErrorProto::message]. + pub fn set_message>(mut self, v: T) -> Self { + self.message = v.into(); + self + } +} + +impl wkt::message::Message for ErrorProto { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ErrorProto" + } +} + +/// Options defining open source compatible datasets living in the BigQuery +/// catalog. Contains metadata of open source database, schema, +/// or namespace represented by the current dataset. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ExternalCatalogDatasetOptions { + /// Optional. A map of key value pairs defining the parameters and properties + /// of the open source schema. Maximum size of 2MiB. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub parameters: std::collections::HashMap, + + /// Optional. The storage location URI for all tables in the dataset. + /// Equivalent to hive metastore's database locationUri. Maximum length of 1024 + /// characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub default_storage_location_uri: std::string::String, +} + +impl ExternalCatalogDatasetOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [default_storage_location_uri][crate::model::ExternalCatalogDatasetOptions::default_storage_location_uri]. + pub fn set_default_storage_location_uri>( + mut self, + v: T, + ) -> Self { + self.default_storage_location_uri = v.into(); + self + } + + /// Sets the value of [parameters][crate::model::ExternalCatalogDatasetOptions::parameters]. + pub fn set_parameters(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.parameters = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for ExternalCatalogDatasetOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ExternalCatalogDatasetOptions" + } +} + +/// Metadata about open source compatible table. The fields contained in +/// these options correspond to Hive metastore's table-level properties. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ExternalCatalogTableOptions { + /// Optional. A map of the key-value pairs defining the parameters and + /// properties of the open source table. Corresponds with Hive metastore table + /// parameters. Maximum size of 4MiB. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub parameters: std::collections::HashMap, + + /// Optional. A storage descriptor containing information about the physical + /// storage of this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub storage_descriptor: std::option::Option, + + /// Optional. A connection ID that specifies the credentials to be used to read + /// external storage, such as Azure Blob, Cloud Storage, or Amazon S3. This + /// connection is needed to read the open source table from BigQuery. The + /// connection_id format must be either + /// `..` or + /// `projects//locations//connections/`. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub connection_id: std::string::String, +} + +impl ExternalCatalogTableOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [storage_descriptor][crate::model::ExternalCatalogTableOptions::storage_descriptor]. + pub fn set_storage_descriptor< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.storage_descriptor = v.into(); + self + } + + /// Sets the value of [connection_id][crate::model::ExternalCatalogTableOptions::connection_id]. + pub fn set_connection_id>(mut self, v: T) -> Self { + self.connection_id = v.into(); + self + } + + /// Sets the value of [parameters][crate::model::ExternalCatalogTableOptions::parameters]. + pub fn set_parameters(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.parameters = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for ExternalCatalogTableOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ExternalCatalogTableOptions" + } +} + +/// Contains information about how a table's data is stored and accessed by open +/// source query engines. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct StorageDescriptor { + /// Optional. The physical location of the table + /// (e.g. `gs://spark-dataproc-data/pangea-data/case_sensitive/` or + /// `gs://spark-dataproc-data/pangea-data/*`). + /// The maximum length is 2056 bytes. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub location_uri: std::string::String, + + /// Optional. Specifies the fully qualified class name of the InputFormat + /// (e.g. "org.apache.hadoop.hive.ql.io.orc.OrcInputFormat"). + /// The maximum length is 128 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub input_format: std::string::String, + + /// Optional. Specifies the fully qualified class name of the OutputFormat + /// (e.g. "org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat"). + /// The maximum length is 128 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub output_format: std::string::String, + + /// Optional. Serializer and deserializer information. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub serde_info: std::option::Option, +} + +impl StorageDescriptor { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [location_uri][crate::model::StorageDescriptor::location_uri]. + pub fn set_location_uri>(mut self, v: T) -> Self { + self.location_uri = v.into(); + self + } + + /// Sets the value of [input_format][crate::model::StorageDescriptor::input_format]. + pub fn set_input_format>(mut self, v: T) -> Self { + self.input_format = v.into(); + self + } + + /// Sets the value of [output_format][crate::model::StorageDescriptor::output_format]. + pub fn set_output_format>(mut self, v: T) -> Self { + self.output_format = v.into(); + self + } + + /// Sets the value of [serde_info][crate::model::StorageDescriptor::serde_info]. + pub fn set_serde_info>>( + mut self, + v: T, + ) -> Self { + self.serde_info = v.into(); + self + } +} + +impl wkt::message::Message for StorageDescriptor { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.StorageDescriptor" + } +} + +/// Serializer and deserializer information. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct SerDeInfo { + /// Optional. Name of the SerDe. + /// The maximum length is 256 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub name: std::string::String, + + /// Required. Specifies a fully-qualified class name of the serialization + /// library that is responsible for the translation of data between table + /// representation and the underlying low-level input and output format + /// structures. The maximum length is 256 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub serialization_library: std::string::String, + + /// Optional. Key-value pairs that define the initialization parameters for the + /// serialization library. + /// Maximum size 10 Kib. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub parameters: std::collections::HashMap, +} + +impl SerDeInfo { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::SerDeInfo::name]. + pub fn set_name>(mut self, v: T) -> Self { + self.name = v.into(); + self + } + + /// Sets the value of [serialization_library][crate::model::SerDeInfo::serialization_library]. + pub fn set_serialization_library>( + mut self, + v: T, + ) -> Self { + self.serialization_library = v.into(); + self + } + + /// Sets the value of [parameters][crate::model::SerDeInfo::parameters]. + pub fn set_parameters(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.parameters = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for SerDeInfo { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.SerDeInfo" + } +} + +/// Options for external data sources. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct AvroOptions { + /// Optional. If sourceFormat is set to "AVRO", indicates whether to interpret + /// logical types as the corresponding BigQuery data type (for example, + /// TIMESTAMP), instead of using the raw type (for example, INTEGER). + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub use_avro_logical_types: std::option::Option, +} + +impl AvroOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [use_avro_logical_types][crate::model::AvroOptions::use_avro_logical_types]. + pub fn set_use_avro_logical_types< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.use_avro_logical_types = v.into(); + self + } +} + +impl wkt::message::Message for AvroOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.AvroOptions" + } +} + +/// Parquet Options for load and make external tables. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ParquetOptions { + /// Optional. Indicates whether to infer Parquet ENUM logical type as STRING + /// instead of BYTES by default. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub enum_as_string: std::option::Option, + + /// Optional. Indicates whether to use schema inference specifically for + /// Parquet LIST logical type. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub enable_list_inference: std::option::Option, + + /// Optional. Indicates how to represent a Parquet map if present. + pub map_target_type: crate::model::MapTargetType, +} + +impl ParquetOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [enum_as_string][crate::model::ParquetOptions::enum_as_string]. + pub fn set_enum_as_string>>( + mut self, + v: T, + ) -> Self { + self.enum_as_string = v.into(); + self + } + + /// Sets the value of [enable_list_inference][crate::model::ParquetOptions::enable_list_inference]. + pub fn set_enable_list_inference>>( + mut self, + v: T, + ) -> Self { + self.enable_list_inference = v.into(); + self + } + + /// Sets the value of [map_target_type][crate::model::ParquetOptions::map_target_type]. + pub fn set_map_target_type>( + mut self, + v: T, + ) -> Self { + self.map_target_type = v.into(); + self + } +} + +impl wkt::message::Message for ParquetOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ParquetOptions" + } +} + +/// Information related to a CSV data source. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct CsvOptions { + /// Optional. The separator character for fields in a CSV file. The separator + /// is interpreted as a single byte. For files encoded in ISO-8859-1, any + /// single character can be used as a separator. For files encoded in UTF-8, + /// characters represented in decimal range 1-127 (U+0001-U+007F) can be used + /// without any modification. UTF-8 characters encoded with multiple bytes + /// (i.e. U+0080 and above) will have only the first byte used for separating + /// fields. The remaining bytes will be treated as a part of the field. + /// BigQuery also supports the escape sequence "\t" (U+0009) to specify a tab + /// separator. The default value is comma (",", U+002C). + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub field_delimiter: std::string::String, + + /// Optional. The number of rows at the top of a CSV file that BigQuery will + /// skip when reading the data. The default value is 0. This property is + /// useful if you have header rows in the file that should be skipped. + /// When autodetect is on, the behavior is the following: + /// + /// * skipLeadingRows unspecified - Autodetect tries to detect headers in the + /// first row. If they are not detected, the row is read as data. Otherwise + /// data is read starting from the second row. + /// * skipLeadingRows is 0 - Instructs autodetect that there are no headers and + /// data should be read starting from the first row. + /// * skipLeadingRows = N > 0 - Autodetect skips N-1 rows and tries to detect + /// headers in row N. If headers are not detected, row N is just skipped. + /// Otherwise row N is used to extract column names for the detected schema. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub skip_leading_rows: std::option::Option, + + /// Optional. The value that is used to quote data sections in a CSV file. + /// BigQuery converts the string to ISO-8859-1 encoding, and then uses the + /// first byte of the encoded string to split the data in its raw, binary + /// state. + /// The default value is a double-quote ("). + /// If your data does not contain quoted sections, + /// set the property value to an empty string. + /// If your data contains quoted newline characters, you must also set the + /// allowQuotedNewlines property to true. + /// To include the specific quote character within a quoted value, precede it + /// with an additional matching quote character. For example, if you want to + /// escape the default character ' " ', use ' "" '. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub quote: std::option::Option, + + /// Optional. Indicates if BigQuery should allow quoted data sections that + /// contain newline characters in a CSV file. The default value is false. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub allow_quoted_newlines: std::option::Option, + + /// Optional. Indicates if BigQuery should accept rows that are missing + /// trailing optional columns. If true, BigQuery treats missing trailing + /// columns as null values. + /// If false, records with missing trailing columns are treated as bad records, + /// and if there are too many bad records, an invalid error is returned in the + /// job result. The default value is false. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub allow_jagged_rows: std::option::Option, + + /// Optional. The character encoding of the data. + /// The supported values are UTF-8, ISO-8859-1, UTF-16BE, UTF-16LE, UTF-32BE, + /// and UTF-32LE. The default value is UTF-8. + /// BigQuery decodes the data after the raw, binary data has been split using + /// the values of the quote and fieldDelimiter properties. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub encoding: std::string::String, + + /// Optional. Indicates if the embedded ASCII control characters (the first 32 + /// characters in the ASCII-table, from '\x00' to '\x1F') are preserved. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub preserve_ascii_control_characters: std::option::Option, + + /// Optional. Specifies a string that represents a null value in a CSV file. + /// For example, if you specify "\N", BigQuery interprets "\N" as a null value + /// when querying a CSV file. + /// The default value is the empty string. If you set this property to a custom + /// value, BigQuery throws an error if an empty string is present for all data + /// types except for STRING and BYTE. For STRING and BYTE columns, BigQuery + /// interprets the empty string as an empty value. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub null_marker: std::option::Option, +} + +impl CsvOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [field_delimiter][crate::model::CsvOptions::field_delimiter]. + pub fn set_field_delimiter>(mut self, v: T) -> Self { + self.field_delimiter = v.into(); + self + } + + /// Sets the value of [skip_leading_rows][crate::model::CsvOptions::skip_leading_rows]. + pub fn set_skip_leading_rows>>( + mut self, + v: T, + ) -> Self { + self.skip_leading_rows = v.into(); + self + } + + /// Sets the value of [quote][crate::model::CsvOptions::quote]. + pub fn set_quote>>( + mut self, + v: T, + ) -> Self { + self.quote = v.into(); + self + } + + /// Sets the value of [allow_quoted_newlines][crate::model::CsvOptions::allow_quoted_newlines]. + pub fn set_allow_quoted_newlines>>( + mut self, + v: T, + ) -> Self { + self.allow_quoted_newlines = v.into(); + self + } + + /// Sets the value of [allow_jagged_rows][crate::model::CsvOptions::allow_jagged_rows]. + pub fn set_allow_jagged_rows>>( + mut self, + v: T, + ) -> Self { + self.allow_jagged_rows = v.into(); + self + } + + /// Sets the value of [encoding][crate::model::CsvOptions::encoding]. + pub fn set_encoding>(mut self, v: T) -> Self { + self.encoding = v.into(); + self + } + + /// Sets the value of [preserve_ascii_control_characters][crate::model::CsvOptions::preserve_ascii_control_characters]. + pub fn set_preserve_ascii_control_characters< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.preserve_ascii_control_characters = v.into(); + self + } + + /// Sets the value of [null_marker][crate::model::CsvOptions::null_marker]. + pub fn set_null_marker>>( + mut self, + v: T, + ) -> Self { + self.null_marker = v.into(); + self + } +} + +impl wkt::message::Message for CsvOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.CsvOptions" + } +} + +/// Json Options for load and make external tables. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct JsonOptions { + /// Optional. The character encoding of the data. + /// The supported values are UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, + /// and UTF-32LE. The default value is UTF-8. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub encoding: std::string::String, +} + +impl JsonOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [encoding][crate::model::JsonOptions::encoding]. + pub fn set_encoding>(mut self, v: T) -> Self { + self.encoding = v.into(); + self + } +} + +impl wkt::message::Message for JsonOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.JsonOptions" + } +} + +/// Information related to a Bigtable column. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct BigtableColumn { + /// [Required] Qualifier of the column. + /// Columns in the parent column family that has this exact qualifier are + /// exposed as `.` field. + /// If the qualifier is valid UTF-8 string, it can be specified in the + /// qualifier_string field. Otherwise, a base-64 encoded value must be set to + /// qualifier_encoded. + /// The column field name is the same as the column qualifier. However, if the + /// qualifier is not a valid BigQuery field identifier i.e. does not match + /// [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as field_name. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub qualifier_encoded: std::option::Option, + + /// Qualifier string. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub qualifier_string: std::option::Option, + + /// Optional. If the qualifier is not a valid BigQuery field identifier i.e. + /// does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided + /// as the column field name and is used as field name in queries. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub field_name: std::string::String, + + /// Optional. The type to convert the value in cells of this column. + /// The values are expected to be encoded using HBase Bytes.toBytes function + /// when using the BINARY encoding value. + /// Following BigQuery types are allowed (case-sensitive): + /// + /// * BYTES + /// * STRING + /// * INTEGER + /// * FLOAT + /// * BOOLEAN + /// * JSON + /// + /// Default type is BYTES. + /// 'type' can also be set at the column family level. However, the setting at + /// this level takes precedence if 'type' is set at both levels. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + + /// Optional. The encoding of the values when the type is not STRING. + /// Acceptable encoding values are: + /// TEXT - indicates values are alphanumeric text strings. + /// BINARY - indicates values are encoded using HBase Bytes.toBytes family of + /// functions. + /// 'encoding' can also be set at the column family level. However, the setting + /// at this level takes precedence if 'encoding' is set at both levels. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub encoding: std::string::String, + + /// Optional. If this is set, only the latest version of value in this column + /// are exposed. + /// 'onlyReadLatest' can also be set at the column family level. However, the + /// setting at this level takes precedence if 'onlyReadLatest' is set at both + /// levels. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub only_read_latest: std::option::Option, +} + +impl BigtableColumn { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [qualifier_encoded][crate::model::BigtableColumn::qualifier_encoded]. + pub fn set_qualifier_encoded>>( + mut self, + v: T, + ) -> Self { + self.qualifier_encoded = v.into(); + self + } + + /// Sets the value of [qualifier_string][crate::model::BigtableColumn::qualifier_string]. + pub fn set_qualifier_string>>( + mut self, + v: T, + ) -> Self { + self.qualifier_string = v.into(); + self + } + + /// Sets the value of [field_name][crate::model::BigtableColumn::field_name]. + pub fn set_field_name>(mut self, v: T) -> Self { + self.field_name = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::BigtableColumn::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [encoding][crate::model::BigtableColumn::encoding]. + pub fn set_encoding>(mut self, v: T) -> Self { + self.encoding = v.into(); + self + } + + /// Sets the value of [only_read_latest][crate::model::BigtableColumn::only_read_latest]. + pub fn set_only_read_latest>>( + mut self, + v: T, + ) -> Self { + self.only_read_latest = v.into(); + self + } +} + +impl wkt::message::Message for BigtableColumn { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.BigtableColumn" + } +} + +/// Information related to a Bigtable column family. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct BigtableColumnFamily { + /// Identifier of the column family. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub family_id: std::string::String, + + /// Optional. The type to convert the value in cells of this column family. + /// The values are expected to be encoded using HBase Bytes.toBytes function + /// when using the BINARY encoding value. + /// Following BigQuery types are allowed (case-sensitive): + /// + /// * BYTES + /// * STRING + /// * INTEGER + /// * FLOAT + /// * BOOLEAN + /// * JSON + /// + /// Default type is BYTES. + /// This can be overridden for a specific column by listing that column in + /// 'columns' and specifying a type for it. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + + /// Optional. The encoding of the values when the type is not STRING. + /// Acceptable encoding values are: + /// TEXT - indicates values are alphanumeric text strings. + /// BINARY - indicates values are encoded using HBase Bytes.toBytes family of + /// functions. + /// This can be overridden for a specific column by listing that column in + /// 'columns' and specifying an encoding for it. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub encoding: std::string::String, + + /// Optional. Lists of columns that should be exposed as individual fields as + /// opposed to a list of (column name, value) pairs. + /// All columns whose qualifier matches a qualifier in this list can be + /// accessed as `.`. + /// Other columns can be accessed as a list through + /// the `.Column` field. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub columns: std::vec::Vec, + + /// Optional. If this is set only the latest version of value are exposed for + /// all columns in this column family. + /// This can be overridden for a specific column by listing that column in + /// 'columns' and specifying a different setting + /// for that column. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub only_read_latest: std::option::Option, +} + +impl BigtableColumnFamily { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [family_id][crate::model::BigtableColumnFamily::family_id]. + pub fn set_family_id>(mut self, v: T) -> Self { + self.family_id = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::BigtableColumnFamily::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [encoding][crate::model::BigtableColumnFamily::encoding]. + pub fn set_encoding>(mut self, v: T) -> Self { + self.encoding = v.into(); + self + } + + /// Sets the value of [only_read_latest][crate::model::BigtableColumnFamily::only_read_latest]. + pub fn set_only_read_latest>>( + mut self, + v: T, + ) -> Self { + self.only_read_latest = v.into(); + self + } + + /// Sets the value of [columns][crate::model::BigtableColumnFamily::columns]. + pub fn set_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.columns = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for BigtableColumnFamily { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.BigtableColumnFamily" + } +} + +/// Options specific to Google Cloud Bigtable data sources. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct BigtableOptions { + /// Optional. List of column families to expose in the table schema along with + /// their types. + /// This list restricts the column families that can be referenced in queries + /// and specifies their value types. + /// You can use this list to do type conversions - see the 'type' field for + /// more details. + /// If you leave this list empty, all column families are present in the table + /// schema and their values are read as BYTES. + /// During a query only the column families referenced in that query are read + /// from Bigtable. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub column_families: std::vec::Vec, + + /// Optional. If field is true, then the column families that are not + /// specified in columnFamilies list are not exposed in the table schema. + /// Otherwise, they are read with BYTES type values. + /// The default value is false. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub ignore_unspecified_column_families: std::option::Option, + + /// Optional. If field is true, then the rowkey column families will be read + /// and converted to string. Otherwise they are read with BYTES type values and + /// users need to manually cast them with CAST if necessary. + /// The default value is false. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub read_rowkey_as_string: std::option::Option, + + /// Optional. If field is true, then each column family will be read as a + /// single JSON column. Otherwise they are read as a repeated cell structure + /// containing timestamp/value tuples. The default value is false. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub output_column_families_as_json: std::option::Option, +} + +impl BigtableOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [ignore_unspecified_column_families][crate::model::BigtableOptions::ignore_unspecified_column_families]. + pub fn set_ignore_unspecified_column_families< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.ignore_unspecified_column_families = v.into(); + self + } + + /// Sets the value of [read_rowkey_as_string][crate::model::BigtableOptions::read_rowkey_as_string]. + pub fn set_read_rowkey_as_string>>( + mut self, + v: T, + ) -> Self { + self.read_rowkey_as_string = v.into(); + self + } + + /// Sets the value of [output_column_families_as_json][crate::model::BigtableOptions::output_column_families_as_json]. + pub fn set_output_column_families_as_json< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.output_column_families_as_json = v.into(); + self + } + + /// Sets the value of [column_families][crate::model::BigtableOptions::column_families]. + pub fn set_column_families(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.column_families = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for BigtableOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.BigtableOptions" + } +} + +/// Options specific to Google Sheets data sources. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GoogleSheetsOptions { + /// Optional. The number of rows at the top of a sheet that BigQuery will skip + /// when reading the data. The default value is 0. This property is useful if + /// you have header rows that should be skipped. When autodetect is on, + /// the behavior is the following: + /// + /// * skipLeadingRows unspecified - Autodetect tries to detect headers in the + /// first row. If they are not detected, the row is read as data. Otherwise + /// data is read starting from the second row. + /// * skipLeadingRows is 0 - Instructs autodetect that there are no headers and + /// data should be read starting from the first row. + /// * skipLeadingRows = N > 0 - Autodetect skips N-1 rows and tries to detect + /// headers in row N. If headers are not detected, row N is just skipped. + /// Otherwise row N is used to extract column names for the detected schema. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub skip_leading_rows: std::option::Option, + + /// Optional. Range of a sheet to query from. Only used when non-empty. + /// Typical format: sheet_name!top_left_cell_id:bottom_right_cell_id + /// For example: sheet1!A1:B20 + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub range: std::string::String, +} + +impl GoogleSheetsOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [skip_leading_rows][crate::model::GoogleSheetsOptions::skip_leading_rows]. + pub fn set_skip_leading_rows>>( + mut self, + v: T, + ) -> Self { + self.skip_leading_rows = v.into(); + self + } + + /// Sets the value of [range][crate::model::GoogleSheetsOptions::range]. + pub fn set_range>(mut self, v: T) -> Self { + self.range = v.into(); + self + } +} + +impl wkt::message::Message for GoogleSheetsOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GoogleSheetsOptions" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ExternalDataConfiguration { + /// [Required] The fully-qualified URIs that point to your data in Google + /// Cloud. For Google Cloud Storage URIs: + /// Each URI can contain one '*' wildcard character and it must come after + /// the 'bucket' name. + /// Size limits related to load jobs apply to external data sources. + /// For Google Cloud Bigtable URIs: + /// Exactly one URI can be specified and it has be a fully specified and + /// valid HTTPS URL for a Google Cloud Bigtable table. + /// For Google Cloud Datastore backups, exactly one URI can be specified. Also, + /// the '*' wildcard character is not allowed. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub source_uris: std::vec::Vec, + + /// Optional. Specifies how source URIs are interpreted for constructing the + /// file set to load. By default source URIs are expanded against the + /// underlying storage. Other options include specifying manifest files. Only + /// applicable to object storage systems. + pub file_set_spec_type: crate::model::FileSetSpecType, + + /// Optional. The schema for the data. + /// Schema is required for CSV and JSON formats if autodetect is not on. + /// Schema is disallowed for Google Cloud Bigtable, Cloud Datastore backups, + /// Avro, ORC and Parquet formats. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub schema: std::option::Option, + + /// [Required] The data format. + /// For CSV files, specify "CSV". + /// For Google sheets, specify "GOOGLE_SHEETS". + /// For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". + /// For Avro files, specify "AVRO". + /// For Google Cloud Datastore backups, specify "DATASTORE_BACKUP". + /// For Apache Iceberg tables, specify "ICEBERG". + /// For ORC files, specify "ORC". + /// For Parquet files, specify "PARQUET". + /// [Beta] For Google Cloud Bigtable, specify "BIGTABLE". + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub source_format: std::string::String, + + /// Optional. The maximum number of bad records that BigQuery can ignore when + /// reading data. If the number of bad records exceeds this value, an invalid + /// error is returned in the job result. The default value is 0, which requires + /// that all records are valid. This setting is ignored for Google Cloud + /// Bigtable, Google Cloud Datastore backups, Avro, ORC and Parquet formats. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub max_bad_records: std::option::Option, + + /// Try to detect schema and format options automatically. + /// Any option specified explicitly will be honored. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub autodetect: std::option::Option, + + /// Optional. Indicates if BigQuery should allow extra values that are not + /// represented in the table schema. + /// If true, the extra values are ignored. + /// If false, records with extra columns are treated as bad records, and if + /// there are too many bad records, an invalid error is returned in the job + /// result. + /// The default value is false. + /// The sourceFormat property determines what BigQuery treats as an extra + /// value: + /// CSV: Trailing columns + /// JSON: Named values that don't match any column names + /// Google Cloud Bigtable: This setting is ignored. + /// Google Cloud Datastore backups: This setting is ignored. + /// Avro: This setting is ignored. + /// ORC: This setting is ignored. + /// Parquet: This setting is ignored. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub ignore_unknown_values: std::option::Option, + + /// Optional. The compression type of the data source. + /// Possible values include GZIP and NONE. The default value is NONE. + /// This setting is ignored for Google Cloud Bigtable, Google Cloud Datastore + /// backups, Avro, ORC and Parquet + /// formats. An empty string is an invalid value. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub compression: std::string::String, + + /// Optional. Additional properties to set if sourceFormat is set to CSV. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub csv_options: std::option::Option, + + /// Optional. Additional properties to set if sourceFormat is set to JSON. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub json_options: std::option::Option, + + /// Optional. Additional options if sourceFormat is set to BIGTABLE. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub bigtable_options: std::option::Option, + + /// Optional. Additional options if sourceFormat is set to GOOGLE_SHEETS. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub google_sheets_options: std::option::Option, + + /// Optional. When set, configures hive partitioning support. Not all storage + /// formats support hive partitioning -- requesting hive partitioning on an + /// unsupported format will lead to an error, as will providing an invalid + /// specification. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub hive_partitioning_options: std::option::Option, + + /// Optional. The connection specifying the credentials to be used to read + /// external storage, such as Azure Blob, Cloud Storage, or S3. The + /// connection_id can have the form + /// `{project_id}.{location_id};{connection_id}` or + /// `projects/{project_id}/locations/{location_id}/connections/{connection_id}`. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub connection_id: std::string::String, + + /// Defines the list of possible SQL data types to which the source decimal + /// values are converted. This list and the precision and the scale parameters + /// of the decimal field determine the target type. In the order of NUMERIC, + /// BIGNUMERIC, and STRING, a + /// type is picked if it is in the specified list and if it supports the + /// precision and the scale. STRING supports all precision and scale values. + /// If none of the listed types supports the precision and the scale, the type + /// supporting the widest range in the specified list is picked, and if a value + /// exceeds the supported range when reading the data, an error will be thrown. + /// + /// Example: Suppose the value of this field is ["NUMERIC", "BIGNUMERIC"]. + /// If (precision,scale) is: + /// + /// * (38,9) -> NUMERIC; + /// * (39,9) -> BIGNUMERIC (NUMERIC cannot hold 30 integer digits); + /// * (38,10) -> BIGNUMERIC (NUMERIC cannot hold 10 fractional digits); + /// * (76,38) -> BIGNUMERIC; + /// * (77,38) -> BIGNUMERIC (error if value exceeds supported range). + /// + /// This field cannot contain duplicate types. The order of the types in this + /// field is ignored. For example, ["BIGNUMERIC", "NUMERIC"] is the same as + /// ["NUMERIC", "BIGNUMERIC"] and NUMERIC always takes precedence over + /// BIGNUMERIC. + /// + /// Defaults to ["NUMERIC", "STRING"] for ORC and ["NUMERIC"] for the other + /// file formats. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub decimal_target_types: std::vec::Vec, + + /// Optional. Additional properties to set if sourceFormat is set to AVRO. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub avro_options: std::option::Option, + + /// Optional. Load option to be used together with source_format + /// newline-delimited JSON to indicate that a variant of JSON is being loaded. + /// To load newline-delimited GeoJSON, specify GEOJSON (and source_format must + /// be set to NEWLINE_DELIMITED_JSON). + pub json_extension: crate::model::JsonExtension, + + /// Optional. Additional properties to set if sourceFormat is set to PARQUET. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub parquet_options: std::option::Option, + + /// Optional. ObjectMetadata is used to create Object Tables. Object Tables + /// contain a listing of objects (with their metadata) found at the + /// source_uris. If ObjectMetadata is set, source_format should be omitted. + /// + /// Currently SIMPLE is the only supported Object Metadata type. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub object_metadata: + std::option::Option, + + /// Optional. When creating an external table, the user can provide a reference + /// file with the table schema. This is enabled for the following formats: + /// AVRO, PARQUET, ORC. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub reference_file_schema_uri: std::option::Option, + + /// Optional. Metadata Cache Mode for the table. Set this to enable caching of + /// metadata from external data source. + pub metadata_cache_mode: crate::model::external_data_configuration::MetadataCacheMode, +} + +impl ExternalDataConfiguration { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [file_set_spec_type][crate::model::ExternalDataConfiguration::file_set_spec_type]. + pub fn set_file_set_spec_type>( + mut self, + v: T, + ) -> Self { + self.file_set_spec_type = v.into(); + self + } + + /// Sets the value of [schema][crate::model::ExternalDataConfiguration::schema]. + pub fn set_schema>>( + mut self, + v: T, + ) -> Self { + self.schema = v.into(); + self + } + + /// Sets the value of [source_format][crate::model::ExternalDataConfiguration::source_format]. + pub fn set_source_format>(mut self, v: T) -> Self { + self.source_format = v.into(); + self + } + + /// Sets the value of [max_bad_records][crate::model::ExternalDataConfiguration::max_bad_records]. + pub fn set_max_bad_records>>( + mut self, + v: T, + ) -> Self { + self.max_bad_records = v.into(); + self + } + + /// Sets the value of [autodetect][crate::model::ExternalDataConfiguration::autodetect]. + pub fn set_autodetect>>( + mut self, + v: T, + ) -> Self { + self.autodetect = v.into(); + self + } + + /// Sets the value of [ignore_unknown_values][crate::model::ExternalDataConfiguration::ignore_unknown_values]. + pub fn set_ignore_unknown_values>>( + mut self, + v: T, + ) -> Self { + self.ignore_unknown_values = v.into(); + self + } + + /// Sets the value of [compression][crate::model::ExternalDataConfiguration::compression]. + pub fn set_compression>(mut self, v: T) -> Self { + self.compression = v.into(); + self + } + + /// Sets the value of [csv_options][crate::model::ExternalDataConfiguration::csv_options]. + pub fn set_csv_options>>( + mut self, + v: T, + ) -> Self { + self.csv_options = v.into(); + self + } + + /// Sets the value of [json_options][crate::model::ExternalDataConfiguration::json_options]. + pub fn set_json_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.json_options = v.into(); + self + } + + /// Sets the value of [bigtable_options][crate::model::ExternalDataConfiguration::bigtable_options]. + pub fn set_bigtable_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.bigtable_options = v.into(); + self + } + + /// Sets the value of [google_sheets_options][crate::model::ExternalDataConfiguration::google_sheets_options]. + pub fn set_google_sheets_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.google_sheets_options = v.into(); + self + } + + /// Sets the value of [hive_partitioning_options][crate::model::ExternalDataConfiguration::hive_partitioning_options]. + pub fn set_hive_partitioning_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.hive_partitioning_options = v.into(); + self + } + + /// Sets the value of [connection_id][crate::model::ExternalDataConfiguration::connection_id]. + pub fn set_connection_id>(mut self, v: T) -> Self { + self.connection_id = v.into(); + self + } + + /// Sets the value of [avro_options][crate::model::ExternalDataConfiguration::avro_options]. + pub fn set_avro_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.avro_options = v.into(); + self + } + + /// Sets the value of [json_extension][crate::model::ExternalDataConfiguration::json_extension]. + pub fn set_json_extension>( + mut self, + v: T, + ) -> Self { + self.json_extension = v.into(); + self + } + + /// Sets the value of [parquet_options][crate::model::ExternalDataConfiguration::parquet_options]. + pub fn set_parquet_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.parquet_options = v.into(); + self + } + + /// Sets the value of [object_metadata][crate::model::ExternalDataConfiguration::object_metadata]. + pub fn set_object_metadata< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.object_metadata = v.into(); + self + } + + /// Sets the value of [reference_file_schema_uri][crate::model::ExternalDataConfiguration::reference_file_schema_uri]. + pub fn set_reference_file_schema_uri< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.reference_file_schema_uri = v.into(); + self + } + + /// Sets the value of [metadata_cache_mode][crate::model::ExternalDataConfiguration::metadata_cache_mode]. + pub fn set_metadata_cache_mode< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.metadata_cache_mode = v.into(); + self + } + + /// Sets the value of [source_uris][crate::model::ExternalDataConfiguration::source_uris]. + pub fn set_source_uris(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.source_uris = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [decimal_target_types][crate::model::ExternalDataConfiguration::decimal_target_types]. + pub fn set_decimal_target_types(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.decimal_target_types = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for ExternalDataConfiguration { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ExternalDataConfiguration" + } +} + +/// Defines additional types related to ExternalDataConfiguration +pub mod external_data_configuration { + #[allow(unused_imports)] + use super::*; + + /// Supported Object Metadata Types. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct ObjectMetadata(i32); + + impl ObjectMetadata { + /// Unspecified by default. + pub const OBJECT_METADATA_UNSPECIFIED: ObjectMetadata = ObjectMetadata::new(0); + + /// A synonym for `SIMPLE`. + pub const DIRECTORY: ObjectMetadata = ObjectMetadata::new(1); + + /// Directory listing of objects. + pub const SIMPLE: ObjectMetadata = ObjectMetadata::new(2); + + /// Creates a new ObjectMetadata instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("OBJECT_METADATA_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("DIRECTORY"), + 2 => std::borrow::Cow::Borrowed("SIMPLE"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "OBJECT_METADATA_UNSPECIFIED" => { + std::option::Option::Some(Self::OBJECT_METADATA_UNSPECIFIED) + } + "DIRECTORY" => std::option::Option::Some(Self::DIRECTORY), + "SIMPLE" => std::option::Option::Some(Self::SIMPLE), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for ObjectMetadata { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for ObjectMetadata { + fn default() -> Self { + Self::new(0) + } + } + + /// MetadataCacheMode identifies if the table should use metadata caching for + /// files from external source (eg Google Cloud Storage). + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct MetadataCacheMode(i32); + + impl MetadataCacheMode { + /// Unspecified metadata cache mode. + pub const METADATA_CACHE_MODE_UNSPECIFIED: MetadataCacheMode = MetadataCacheMode::new(0); + + /// Set this mode to trigger automatic background refresh of metadata cache + /// from the external source. Queries will use the latest available cache + /// version within the table's maxStaleness interval. + pub const AUTOMATIC: MetadataCacheMode = MetadataCacheMode::new(1); + + /// Set this mode to enable triggering manual refresh of the metadata cache + /// from external source. Queries will use the latest manually triggered + /// cache version within the table's maxStaleness interval. + pub const MANUAL: MetadataCacheMode = MetadataCacheMode::new(2); + + /// Creates a new MetadataCacheMode instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("METADATA_CACHE_MODE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("AUTOMATIC"), + 2 => std::borrow::Cow::Borrowed("MANUAL"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "METADATA_CACHE_MODE_UNSPECIFIED" => { + std::option::Option::Some(Self::METADATA_CACHE_MODE_UNSPECIFIED) + } + "AUTOMATIC" => std::option::Option::Some(Self::AUTOMATIC), + "MANUAL" => std::option::Option::Some(Self::MANUAL), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for MetadataCacheMode { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for MetadataCacheMode { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Configures the access a dataset defined in an external metadata storage. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ExternalDatasetReference { + /// Required. External source that backs this dataset. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub external_source: std::string::String, + + /// Required. The connection id that is used to access the external_source. + /// + /// Format: + /// projects/{project_id}/locations/{location_id}/connections/{connection_id} + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub connection: std::string::String, +} + +impl ExternalDatasetReference { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [external_source][crate::model::ExternalDatasetReference::external_source]. + pub fn set_external_source>(mut self, v: T) -> Self { + self.external_source = v.into(); + self + } + + /// Sets the value of [connection][crate::model::ExternalDatasetReference::connection]. + pub fn set_connection>(mut self, v: T) -> Self { + self.connection = v.into(); + self + } +} + +impl wkt::message::Message for ExternalDatasetReference { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ExternalDatasetReference" + } +} + +/// Options for configuring hive partitioning detect. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct HivePartitioningOptions { + /// Optional. When set, what mode of hive partitioning to use when reading + /// data. The following modes are supported: + /// + /// * AUTO: automatically infer partition key name(s) and type(s). + /// + /// * STRINGS: automatically infer partition key name(s). All types are + /// strings. + /// + /// * CUSTOM: partition key schema is encoded in the source URI prefix. + /// + /// + /// Not all storage formats support hive partitioning. Requesting hive + /// partitioning on an unsupported format will lead to an error. + /// Currently supported formats are: JSON, CSV, ORC, Avro and Parquet. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub mode: std::string::String, + + /// Optional. When hive partition detection is requested, a common prefix for + /// all source uris must be required. The prefix must end immediately before + /// the partition key encoding begins. For example, consider files following + /// this data layout: + /// + /// gs://bucket/path_to_table/dt=2019-06-01/country=USA/id=7/file.avro + /// + /// gs://bucket/path_to_table/dt=2019-05-31/country=CA/id=3/file.avro + /// + /// When hive partitioning is requested with either AUTO or STRINGS detection, + /// the common prefix can be either of gs://bucket/path_to_table or + /// gs://bucket/path_to_table/. + /// + /// CUSTOM detection requires encoding the partitioning schema immediately + /// after the common prefix. For CUSTOM, any of + /// + /// * gs://bucket/path_to_table/{dt:DATE}/{country:STRING}/{id:INTEGER} + /// + /// * gs://bucket/path_to_table/{dt:STRING}/{country:STRING}/{id:INTEGER} + /// + /// * gs://bucket/path_to_table/{dt:DATE}/{country:STRING}/{id:STRING} + /// + /// + /// would all be valid source URI prefixes. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub source_uri_prefix: std::string::String, + + /// Optional. If set to true, queries over this table require a partition + /// filter that can be used for partition elimination to be specified. + /// + /// Note that this field should only be true when creating a permanent + /// external table or querying a temporary external table. + /// + /// Hive-partitioned loads with require_partition_filter explicitly set to + /// true will fail. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub require_partition_filter: std::option::Option, + + /// Output only. For permanent external tables, this field is populated with + /// the hive partition keys in the order they were inferred. The types of the + /// partition keys can be deduced by checking the table schema (which will + /// include the partition keys). Not every API will populate this field in the + /// output. For example, Tables.Get will populate it, but Tables.List will not + /// contain this field. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub fields: std::vec::Vec, +} + +impl HivePartitioningOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [mode][crate::model::HivePartitioningOptions::mode]. + pub fn set_mode>(mut self, v: T) -> Self { + self.mode = v.into(); + self + } + + /// Sets the value of [source_uri_prefix][crate::model::HivePartitioningOptions::source_uri_prefix]. + pub fn set_source_uri_prefix>( + mut self, + v: T, + ) -> Self { + self.source_uri_prefix = v.into(); + self + } + + /// Sets the value of [require_partition_filter][crate::model::HivePartitioningOptions::require_partition_filter]. + pub fn set_require_partition_filter< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.require_partition_filter = v.into(); + self + } + + /// Sets the value of [fields][crate::model::HivePartitioningOptions::fields]. + pub fn set_fields(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.fields = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for HivePartitioningOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.HivePartitioningOptions" + } +} + +/// BigQuery-specific metadata about a location. This will be set on +/// google.cloud.location.Location.metadata in Cloud Location API +/// responses. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct LocationMetadata { + /// The legacy BigQuery location ID, e.g. “EU” for the “europe” location. + /// This is for any API consumers that need the legacy “US” and “EU” locations. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub legacy_location_id: std::string::String, +} + +impl LocationMetadata { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [legacy_location_id][crate::model::LocationMetadata::legacy_location_id]. + pub fn set_legacy_location_id>( + mut self, + v: T, + ) -> Self { + self.legacy_location_id = v.into(); + self + } +} + +impl wkt::message::Message for LocationMetadata { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.LocationMetadata" + } +} + +/// Remote Model Info +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct RemoteModelInfo { + /// Output only. Fully qualified name of the user-provided connection object of + /// the remote model. Format: + /// ```"projects/{project_id}/locations/{location_id}/connections/{connection_id}"``` + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub connection: std::string::String, + + /// Output only. Max number of rows in each batch sent to the remote service. + /// If unset, the number of rows in each batch is set dynamically. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub max_batching_rows: i64, + + /// Output only. The model version for LLM. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub remote_model_version: std::string::String, + + /// Output only. The name of the speech recognizer to use for speech + /// recognition. The expected format is + /// `projects/{project}/locations/{location}/recognizers/{recognizer}`. + /// Customers can specify this field at model creation. If not specified, a + /// default recognizer `projects/{model + /// project}/locations/global/recognizers/_` will be used. See more details at + /// [recognizers](https://cloud.google.com/speech-to-text/v2/docs/reference/rest/v2/projects.locations.recognizers) + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub speech_recognizer: std::string::String, + + /// Remote services are services outside of BigQuery used by remote models for + /// predictions. A remote service is backed by either an arbitrary endpoint or + /// a selected remote service type, but not both. + #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")] + pub remote_service: std::option::Option, +} + +impl RemoteModelInfo { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [connection][crate::model::RemoteModelInfo::connection]. + pub fn set_connection>(mut self, v: T) -> Self { + self.connection = v.into(); + self + } + + /// Sets the value of [max_batching_rows][crate::model::RemoteModelInfo::max_batching_rows]. + pub fn set_max_batching_rows>(mut self, v: T) -> Self { + self.max_batching_rows = v.into(); + self + } + + /// Sets the value of [remote_model_version][crate::model::RemoteModelInfo::remote_model_version]. + pub fn set_remote_model_version>( + mut self, + v: T, + ) -> Self { + self.remote_model_version = v.into(); + self + } + + /// Sets the value of [speech_recognizer][crate::model::RemoteModelInfo::speech_recognizer]. + pub fn set_speech_recognizer>( + mut self, + v: T, + ) -> Self { + self.speech_recognizer = v.into(); + self + } + + /// Sets the value of `remote_service`. + pub fn set_remote_service< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.remote_service = v.into(); + self + } + + /// The value of [remote_service][crate::model::RemoteModelInfo::remote_service] + /// if it holds a `Endpoint`, `None` if the field is not set or + /// holds a different branch. + pub fn get_endpoint(&self) -> std::option::Option<&std::string::String> { + #[allow(unreachable_patterns)] + self.remote_service.as_ref().and_then(|v| match v { + crate::model::remote_model_info::RemoteService::Endpoint(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [remote_service][crate::model::RemoteModelInfo::remote_service] + /// if it holds a `RemoteServiceType`, `None` if the field is not set or + /// holds a different branch. + pub fn get_remote_service_type( + &self, + ) -> std::option::Option<&crate::model::remote_model_info::RemoteServiceType> { + #[allow(unreachable_patterns)] + self.remote_service.as_ref().and_then(|v| match v { + crate::model::remote_model_info::RemoteService::RemoteServiceType(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// Sets the value of [remote_service][crate::model::RemoteModelInfo::remote_service] + /// to hold a `Endpoint`. + /// + /// Note that all the setters affecting `remote_service` are + /// mutually exclusive. + pub fn set_endpoint>(mut self, v: T) -> Self { + self.remote_service = std::option::Option::Some( + crate::model::remote_model_info::RemoteService::Endpoint(v.into()), + ); + self + } + + /// Sets the value of [remote_service][crate::model::RemoteModelInfo::remote_service] + /// to hold a `RemoteServiceType`. + /// + /// Note that all the setters affecting `remote_service` are + /// mutually exclusive. + pub fn set_remote_service_type< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.remote_service = std::option::Option::Some( + crate::model::remote_model_info::RemoteService::RemoteServiceType(v.into()), + ); + self + } +} + +impl wkt::message::Message for RemoteModelInfo { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.RemoteModelInfo" + } +} + +/// Defines additional types related to RemoteModelInfo +pub mod remote_model_info { + #[allow(unused_imports)] + use super::*; + + /// Supported service type for remote model. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct RemoteServiceType(i32); + + impl RemoteServiceType { + /// Unspecified remote service type. + pub const REMOTE_SERVICE_TYPE_UNSPECIFIED: RemoteServiceType = RemoteServiceType::new(0); + + /// V3 Cloud AI Translation API. See more details at [Cloud Translation API] + /// (). + pub const CLOUD_AI_TRANSLATE_V3: RemoteServiceType = RemoteServiceType::new(1); + + /// V1 Cloud AI Vision API See more details at [Cloud Vision API] + /// (). + pub const CLOUD_AI_VISION_V1: RemoteServiceType = RemoteServiceType::new(2); + + /// V1 Cloud AI Natural Language API. See more details at [REST Resource: + /// documents](https://cloud.google.com/natural-language/docs/reference/rest/v1/documents). + pub const CLOUD_AI_NATURAL_LANGUAGE_V1: RemoteServiceType = RemoteServiceType::new(3); + + /// V2 Speech-to-Text API. See more details at [Google Cloud Speech-to-Text + /// V2 API](https://cloud.google.com/speech-to-text/v2/docs) + pub const CLOUD_AI_SPEECH_TO_TEXT_V2: RemoteServiceType = RemoteServiceType::new(7); + + /// Creates a new RemoteServiceType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("REMOTE_SERVICE_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("CLOUD_AI_TRANSLATE_V3"), + 2 => std::borrow::Cow::Borrowed("CLOUD_AI_VISION_V1"), + 3 => std::borrow::Cow::Borrowed("CLOUD_AI_NATURAL_LANGUAGE_V1"), + 7 => std::borrow::Cow::Borrowed("CLOUD_AI_SPEECH_TO_TEXT_V2"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "REMOTE_SERVICE_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::REMOTE_SERVICE_TYPE_UNSPECIFIED) + } + "CLOUD_AI_TRANSLATE_V3" => std::option::Option::Some(Self::CLOUD_AI_TRANSLATE_V3), + "CLOUD_AI_VISION_V1" => std::option::Option::Some(Self::CLOUD_AI_VISION_V1), + "CLOUD_AI_NATURAL_LANGUAGE_V1" => { + std::option::Option::Some(Self::CLOUD_AI_NATURAL_LANGUAGE_V1) + } + "CLOUD_AI_SPEECH_TO_TEXT_V2" => { + std::option::Option::Some(Self::CLOUD_AI_SPEECH_TO_TEXT_V2) + } + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for RemoteServiceType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for RemoteServiceType { + fn default() -> Self { + Self::new(0) + } + } + + /// Remote services are services outside of BigQuery used by remote models for + /// predictions. A remote service is backed by either an arbitrary endpoint or + /// a selected remote service type, but not both. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(rename_all = "camelCase")] + #[non_exhaustive] + pub enum RemoteService { + /// Output only. The endpoint for remote model. + Endpoint(std::string::String), + /// Output only. The remote service type for remote model. + RemoteServiceType(crate::model::remote_model_info::RemoteServiceType), + } +} + +/// Information about a single transform column. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct TransformColumn { + /// Output only. Name of the column. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub name: std::string::String, + + /// Output only. Data type of the column after the transform. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub r#type: std::option::Option, + + /// Output only. The SQL expression used in the column transform. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub transform_sql: std::string::String, +} + +impl TransformColumn { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::TransformColumn::name]. + pub fn set_name>(mut self, v: T) -> Self { + self.name = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::TransformColumn::type]. + pub fn set_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [transform_sql][crate::model::TransformColumn::transform_sql]. + pub fn set_transform_sql>(mut self, v: T) -> Self { + self.transform_sql = v.into(); + self + } +} + +impl wkt::message::Message for TransformColumn { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TransformColumn" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Model { + /// Output only. A hash of this resource. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub etag: std::string::String, + + /// Required. Unique identifier for this model. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub model_reference: std::option::Option, + + /// Output only. The time when this model was created, in millisecs since the + /// epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub creation_time: i64, + + /// Output only. The time when this model was last modified, in millisecs since + /// the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub last_modified_time: i64, + + /// Optional. A user-friendly description of this model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub description: std::string::String, + + /// Optional. A descriptive name for this model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub friendly_name: std::string::String, + + /// The labels associated with this model. You can use these to organize + /// and group your models. Label keys and values can be no longer + /// than 63 characters, can only contain lowercase letters, numeric + /// characters, underscores and dashes. International characters are allowed. + /// Label values are optional. Label keys must start with a letter and each + /// label in the list must have a different key. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub labels: std::collections::HashMap, + + /// Optional. The time when this model expires, in milliseconds since the + /// epoch. If not present, the model will persist indefinitely. Expired models + /// will be deleted and their storage reclaimed. The defaultTableExpirationMs + /// property of the encapsulating dataset can be used to set a default + /// expirationTime on newly created models. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub expiration_time: i64, + + /// Output only. The geographic location where the model resides. This value + /// is inherited from the dataset. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub location: std::string::String, + + /// Custom encryption configuration (e.g., Cloud KMS keys). This shows the + /// encryption configuration of the model data while stored in BigQuery + /// storage. This field can be used with PatchModel to update encryption key + /// for an already encrypted model. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub encryption_configuration: std::option::Option, + + /// Output only. Type of the model resource. + pub model_type: crate::model::model::ModelType, + + /// Information for all training runs in increasing order of start_time. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub training_runs: std::vec::Vec, + + /// Output only. Input feature columns for the model inference. If the model is + /// trained with TRANSFORM clause, these are the input of the TRANSFORM clause. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub feature_columns: std::vec::Vec, + + /// Output only. Label columns that were used to train this model. + /// The output of the model will have a "predicted_" prefix to these columns. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub label_columns: std::vec::Vec, + + /// Output only. This field will be populated if a TRANSFORM clause was used to + /// train a model. TRANSFORM clause (if used) takes feature_columns as input + /// and outputs transform_columns. transform_columns then are used to train the + /// model. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub transform_columns: std::vec::Vec, + + /// Output only. All hyperparameter search spaces in this model. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub hparam_search_spaces: std::option::Option, + + /// Output only. The default trial_id to use in TVFs when the trial_id is not + /// passed in. For single-objective [hyperparameter + /// tuning](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-hp-tuning-overview) + /// models, this is the best trial ID. For multi-objective [hyperparameter + /// tuning](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-hp-tuning-overview) + /// models, this is the smallest trial ID among all Pareto optimal trials. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub default_trial_id: i64, + + /// Output only. Trials of a [hyperparameter + /// tuning](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-hp-tuning-overview) + /// model sorted by trial_id. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub hparam_trials: std::vec::Vec, + + /// Output only. For single-objective [hyperparameter + /// tuning](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-hp-tuning-overview) + /// models, it only contains the best trial. For multi-objective + /// [hyperparameter + /// tuning](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-hp-tuning-overview) + /// models, it contains all Pareto optimal trials sorted by trial_id. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + #[serde_as(as = "std::vec::Vec")] + pub optimal_trial_ids: std::vec::Vec, + + /// Output only. Remote model info + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub remote_model_info: std::option::Option, +} + +impl Model { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [etag][crate::model::Model::etag]. + pub fn set_etag>(mut self, v: T) -> Self { + self.etag = v.into(); + self + } + + /// Sets the value of [model_reference][crate::model::Model::model_reference]. + pub fn set_model_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.model_reference = v.into(); + self + } + + /// Sets the value of [creation_time][crate::model::Model::creation_time]. + pub fn set_creation_time>(mut self, v: T) -> Self { + self.creation_time = v.into(); + self + } + + /// Sets the value of [last_modified_time][crate::model::Model::last_modified_time]. + pub fn set_last_modified_time>(mut self, v: T) -> Self { + self.last_modified_time = v.into(); + self + } + + /// Sets the value of [description][crate::model::Model::description]. + pub fn set_description>(mut self, v: T) -> Self { + self.description = v.into(); + self + } + + /// Sets the value of [friendly_name][crate::model::Model::friendly_name]. + pub fn set_friendly_name>(mut self, v: T) -> Self { + self.friendly_name = v.into(); + self + } + + /// Sets the value of [expiration_time][crate::model::Model::expiration_time]. + pub fn set_expiration_time>(mut self, v: T) -> Self { + self.expiration_time = v.into(); + self + } + + /// Sets the value of [location][crate::model::Model::location]. + pub fn set_location>(mut self, v: T) -> Self { + self.location = v.into(); + self + } + + /// Sets the value of [encryption_configuration][crate::model::Model::encryption_configuration]. + pub fn set_encryption_configuration< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.encryption_configuration = v.into(); + self + } + + /// Sets the value of [model_type][crate::model::Model::model_type]. + pub fn set_model_type>( + mut self, + v: T, + ) -> Self { + self.model_type = v.into(); + self + } + + /// Sets the value of [hparam_search_spaces][crate::model::Model::hparam_search_spaces]. + pub fn set_hparam_search_spaces< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.hparam_search_spaces = v.into(); + self + } + + /// Sets the value of [default_trial_id][crate::model::Model::default_trial_id]. + pub fn set_default_trial_id>(mut self, v: T) -> Self { + self.default_trial_id = v.into(); + self + } + + /// Sets the value of [remote_model_info][crate::model::Model::remote_model_info]. + pub fn set_remote_model_info< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.remote_model_info = v.into(); + self + } + + /// Sets the value of [training_runs][crate::model::Model::training_runs]. + pub fn set_training_runs(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.training_runs = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [feature_columns][crate::model::Model::feature_columns]. + pub fn set_feature_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.feature_columns = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [label_columns][crate::model::Model::label_columns]. + pub fn set_label_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.label_columns = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [transform_columns][crate::model::Model::transform_columns]. + pub fn set_transform_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.transform_columns = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [hparam_trials][crate::model::Model::hparam_trials]. + pub fn set_hparam_trials(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.hparam_trials = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [optimal_trial_ids][crate::model::Model::optimal_trial_ids]. + pub fn set_optimal_trial_ids(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.optimal_trial_ids = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [labels][crate::model::Model::labels]. + pub fn set_labels(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for Model { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model" + } +} + +/// Defines additional types related to Model +pub mod model { + #[allow(unused_imports)] + use super::*; + + /// Enums for seasonal period. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct SeasonalPeriod {} + + impl SeasonalPeriod { + pub fn new() -> Self { + std::default::Default::default() + } + } + + impl wkt::message::Message for SeasonalPeriod { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.SeasonalPeriod" + } + } + + /// Defines additional types related to SeasonalPeriod + pub mod seasonal_period { + #[allow(unused_imports)] + use super::*; + + /// Seasonal period type. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct SeasonalPeriodType(i32); + + impl SeasonalPeriodType { + /// Unspecified seasonal period. + pub const SEASONAL_PERIOD_TYPE_UNSPECIFIED: SeasonalPeriodType = + SeasonalPeriodType::new(0); + + /// No seasonality + pub const NO_SEASONALITY: SeasonalPeriodType = SeasonalPeriodType::new(1); + + /// Daily period, 24 hours. + pub const DAILY: SeasonalPeriodType = SeasonalPeriodType::new(2); + + /// Weekly period, 7 days. + pub const WEEKLY: SeasonalPeriodType = SeasonalPeriodType::new(3); + + /// Monthly period, 30 days or irregular. + pub const MONTHLY: SeasonalPeriodType = SeasonalPeriodType::new(4); + + /// Quarterly period, 90 days or irregular. + pub const QUARTERLY: SeasonalPeriodType = SeasonalPeriodType::new(5); + + /// Yearly period, 365 days or irregular. + pub const YEARLY: SeasonalPeriodType = SeasonalPeriodType::new(6); + + /// Creates a new SeasonalPeriodType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("SEASONAL_PERIOD_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("NO_SEASONALITY"), + 2 => std::borrow::Cow::Borrowed("DAILY"), + 3 => std::borrow::Cow::Borrowed("WEEKLY"), + 4 => std::borrow::Cow::Borrowed("MONTHLY"), + 5 => std::borrow::Cow::Borrowed("QUARTERLY"), + 6 => std::borrow::Cow::Borrowed("YEARLY"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "SEASONAL_PERIOD_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::SEASONAL_PERIOD_TYPE_UNSPECIFIED) + } + "NO_SEASONALITY" => std::option::Option::Some(Self::NO_SEASONALITY), + "DAILY" => std::option::Option::Some(Self::DAILY), + "WEEKLY" => std::option::Option::Some(Self::WEEKLY), + "MONTHLY" => std::option::Option::Some(Self::MONTHLY), + "QUARTERLY" => std::option::Option::Some(Self::QUARTERLY), + "YEARLY" => std::option::Option::Some(Self::YEARLY), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for SeasonalPeriodType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for SeasonalPeriodType { + fn default() -> Self { + Self::new(0) + } + } + } + + /// Enums for kmeans model type. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct KmeansEnums {} + + impl KmeansEnums { + pub fn new() -> Self { + std::default::Default::default() + } + } + + impl wkt::message::Message for KmeansEnums { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.KmeansEnums" + } + } + + /// Defines additional types related to KmeansEnums + pub mod kmeans_enums { + #[allow(unused_imports)] + use super::*; + + /// Indicates the method used to initialize the centroids for KMeans + /// clustering algorithm. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct KmeansInitializationMethod(i32); + + impl KmeansInitializationMethod { + /// Unspecified initialization method. + pub const KMEANS_INITIALIZATION_METHOD_UNSPECIFIED: KmeansInitializationMethod = + KmeansInitializationMethod::new(0); + + /// Initializes the centroids randomly. + pub const RANDOM: KmeansInitializationMethod = KmeansInitializationMethod::new(1); + + /// Initializes the centroids using data specified in + /// kmeans_initialization_column. + pub const CUSTOM: KmeansInitializationMethod = KmeansInitializationMethod::new(2); + + /// Initializes with kmeans++. + pub const KMEANS_PLUS_PLUS: KmeansInitializationMethod = + KmeansInitializationMethod::new(3); + + /// Creates a new KmeansInitializationMethod instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("KMEANS_INITIALIZATION_METHOD_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("RANDOM"), + 2 => std::borrow::Cow::Borrowed("CUSTOM"), + 3 => std::borrow::Cow::Borrowed("KMEANS_PLUS_PLUS"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "KMEANS_INITIALIZATION_METHOD_UNSPECIFIED" => { + std::option::Option::Some(Self::KMEANS_INITIALIZATION_METHOD_UNSPECIFIED) + } + "RANDOM" => std::option::Option::Some(Self::RANDOM), + "CUSTOM" => std::option::Option::Some(Self::CUSTOM), + "KMEANS_PLUS_PLUS" => std::option::Option::Some(Self::KMEANS_PLUS_PLUS), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for KmeansInitializationMethod { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for KmeansInitializationMethod { + fn default() -> Self { + Self::new(0) + } + } + } + + /// Enums for XGBoost model type. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct BoostedTreeOptionEnums {} + + impl BoostedTreeOptionEnums { + pub fn new() -> Self { + std::default::Default::default() + } + } + + impl wkt::message::Message for BoostedTreeOptionEnums { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.BoostedTreeOptionEnums" + } + } + + /// Defines additional types related to BoostedTreeOptionEnums + pub mod boosted_tree_option_enums { + #[allow(unused_imports)] + use super::*; + + /// Booster types supported. Refer to booster parameter in XGBoost. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct BoosterType(i32); + + impl BoosterType { + /// Unspecified booster type. + pub const BOOSTER_TYPE_UNSPECIFIED: BoosterType = BoosterType::new(0); + + /// Gbtree booster. + pub const GBTREE: BoosterType = BoosterType::new(1); + + /// Dart booster. + pub const DART: BoosterType = BoosterType::new(2); + + /// Creates a new BoosterType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("BOOSTER_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("GBTREE"), + 2 => std::borrow::Cow::Borrowed("DART"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "BOOSTER_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::BOOSTER_TYPE_UNSPECIFIED) + } + "GBTREE" => std::option::Option::Some(Self::GBTREE), + "DART" => std::option::Option::Some(Self::DART), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for BoosterType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for BoosterType { + fn default() -> Self { + Self::new(0) + } + } + + /// Type of normalization algorithm for boosted tree models using dart + /// booster. Refer to normalize_type in XGBoost. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct DartNormalizeType(i32); + + impl DartNormalizeType { + /// Unspecified dart normalize type. + pub const DART_NORMALIZE_TYPE_UNSPECIFIED: DartNormalizeType = + DartNormalizeType::new(0); + + /// New trees have the same weight of each of dropped trees. + pub const TREE: DartNormalizeType = DartNormalizeType::new(1); + + /// New trees have the same weight of sum of dropped trees. + pub const FOREST: DartNormalizeType = DartNormalizeType::new(2); + + /// Creates a new DartNormalizeType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("DART_NORMALIZE_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("TREE"), + 2 => std::borrow::Cow::Borrowed("FOREST"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "DART_NORMALIZE_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::DART_NORMALIZE_TYPE_UNSPECIFIED) + } + "TREE" => std::option::Option::Some(Self::TREE), + "FOREST" => std::option::Option::Some(Self::FOREST), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for DartNormalizeType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for DartNormalizeType { + fn default() -> Self { + Self::new(0) + } + } + + /// Tree construction algorithm used in boosted tree models. + /// Refer to tree_method in XGBoost. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct TreeMethod(i32); + + impl TreeMethod { + /// Unspecified tree method. + pub const TREE_METHOD_UNSPECIFIED: TreeMethod = TreeMethod::new(0); + + /// Use heuristic to choose the fastest method. + pub const AUTO: TreeMethod = TreeMethod::new(1); + + /// Exact greedy algorithm. + pub const EXACT: TreeMethod = TreeMethod::new(2); + + /// Approximate greedy algorithm using quantile sketch and gradient + /// histogram. + pub const APPROX: TreeMethod = TreeMethod::new(3); + + /// Fast histogram optimized approximate greedy algorithm. + pub const HIST: TreeMethod = TreeMethod::new(4); + + /// Creates a new TreeMethod instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("TREE_METHOD_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("AUTO"), + 2 => std::borrow::Cow::Borrowed("EXACT"), + 3 => std::borrow::Cow::Borrowed("APPROX"), + 4 => std::borrow::Cow::Borrowed("HIST"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "TREE_METHOD_UNSPECIFIED" => { + std::option::Option::Some(Self::TREE_METHOD_UNSPECIFIED) + } + "AUTO" => std::option::Option::Some(Self::AUTO), + "EXACT" => std::option::Option::Some(Self::EXACT), + "APPROX" => std::option::Option::Some(Self::APPROX), + "HIST" => std::option::Option::Some(Self::HIST), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for TreeMethod { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for TreeMethod { + fn default() -> Self { + Self::new(0) + } + } + } + + /// Enums for hyperparameter tuning. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct HparamTuningEnums {} + + impl HparamTuningEnums { + pub fn new() -> Self { + std::default::Default::default() + } + } + + impl wkt::message::Message for HparamTuningEnums { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.HparamTuningEnums" + } + } + + /// Defines additional types related to HparamTuningEnums + pub mod hparam_tuning_enums { + #[allow(unused_imports)] + use super::*; + + /// Available evaluation metrics used as hyperparameter tuning objectives. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct HparamTuningObjective(i32); + + impl HparamTuningObjective { + /// Unspecified evaluation metric. + pub const HPARAM_TUNING_OBJECTIVE_UNSPECIFIED: HparamTuningObjective = + HparamTuningObjective::new(0); + + /// Mean absolute error. + /// mean_absolute_error = AVG(ABS(label - predicted)) + pub const MEAN_ABSOLUTE_ERROR: HparamTuningObjective = HparamTuningObjective::new(1); + + /// Mean squared error. + /// mean_squared_error = AVG(POW(label - predicted, 2)) + pub const MEAN_SQUARED_ERROR: HparamTuningObjective = HparamTuningObjective::new(2); + + /// Mean squared log error. + /// mean_squared_log_error = AVG(POW(LN(1 + label) - LN(1 + predicted), 2)) + pub const MEAN_SQUARED_LOG_ERROR: HparamTuningObjective = HparamTuningObjective::new(3); + + /// Mean absolute error. + /// median_absolute_error = APPROX_QUANTILES(absolute_error, 2)[OFFSET(1)] + pub const MEDIAN_ABSOLUTE_ERROR: HparamTuningObjective = HparamTuningObjective::new(4); + + /// R^2 score. This corresponds to r2_score in ML.EVALUATE. + /// r_squared = 1 - SUM(squared_error)/(COUNT(label)*VAR_POP(label)) + pub const R_SQUARED: HparamTuningObjective = HparamTuningObjective::new(5); + + /// Explained variance. + /// explained_variance = 1 - VAR_POP(label_error)/VAR_POP(label) + pub const EXPLAINED_VARIANCE: HparamTuningObjective = HparamTuningObjective::new(6); + + /// Precision is the fraction of actual positive predictions that had + /// positive actual labels. For multiclass this is a macro-averaged metric + /// treating each class as a binary classifier. + pub const PRECISION: HparamTuningObjective = HparamTuningObjective::new(7); + + /// Recall is the fraction of actual positive labels that were given a + /// positive prediction. For multiclass this is a macro-averaged metric. + pub const RECALL: HparamTuningObjective = HparamTuningObjective::new(8); + + /// Accuracy is the fraction of predictions given the correct label. For + /// multiclass this is a globally micro-averaged metric. + pub const ACCURACY: HparamTuningObjective = HparamTuningObjective::new(9); + + /// The F1 score is an average of recall and precision. For multiclass this + /// is a macro-averaged metric. + pub const F1_SCORE: HparamTuningObjective = HparamTuningObjective::new(10); + + /// Logarithmic Loss. For multiclass this is a macro-averaged metric. + pub const LOG_LOSS: HparamTuningObjective = HparamTuningObjective::new(11); + + /// Area Under an ROC Curve. For multiclass this is a macro-averaged + /// metric. + pub const ROC_AUC: HparamTuningObjective = HparamTuningObjective::new(12); + + /// Davies-Bouldin Index. + pub const DAVIES_BOULDIN_INDEX: HparamTuningObjective = HparamTuningObjective::new(13); + + /// Mean Average Precision. + pub const MEAN_AVERAGE_PRECISION: HparamTuningObjective = + HparamTuningObjective::new(14); + + /// Normalized Discounted Cumulative Gain. + pub const NORMALIZED_DISCOUNTED_CUMULATIVE_GAIN: HparamTuningObjective = + HparamTuningObjective::new(15); + + /// Average Rank. + pub const AVERAGE_RANK: HparamTuningObjective = HparamTuningObjective::new(16); + + /// Creates a new HparamTuningObjective instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("HPARAM_TUNING_OBJECTIVE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("MEAN_ABSOLUTE_ERROR"), + 2 => std::borrow::Cow::Borrowed("MEAN_SQUARED_ERROR"), + 3 => std::borrow::Cow::Borrowed("MEAN_SQUARED_LOG_ERROR"), + 4 => std::borrow::Cow::Borrowed("MEDIAN_ABSOLUTE_ERROR"), + 5 => std::borrow::Cow::Borrowed("R_SQUARED"), + 6 => std::borrow::Cow::Borrowed("EXPLAINED_VARIANCE"), + 7 => std::borrow::Cow::Borrowed("PRECISION"), + 8 => std::borrow::Cow::Borrowed("RECALL"), + 9 => std::borrow::Cow::Borrowed("ACCURACY"), + 10 => std::borrow::Cow::Borrowed("F1_SCORE"), + 11 => std::borrow::Cow::Borrowed("LOG_LOSS"), + 12 => std::borrow::Cow::Borrowed("ROC_AUC"), + 13 => std::borrow::Cow::Borrowed("DAVIES_BOULDIN_INDEX"), + 14 => std::borrow::Cow::Borrowed("MEAN_AVERAGE_PRECISION"), + 15 => std::borrow::Cow::Borrowed("NORMALIZED_DISCOUNTED_CUMULATIVE_GAIN"), + 16 => std::borrow::Cow::Borrowed("AVERAGE_RANK"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "HPARAM_TUNING_OBJECTIVE_UNSPECIFIED" => { + std::option::Option::Some(Self::HPARAM_TUNING_OBJECTIVE_UNSPECIFIED) + } + "MEAN_ABSOLUTE_ERROR" => std::option::Option::Some(Self::MEAN_ABSOLUTE_ERROR), + "MEAN_SQUARED_ERROR" => std::option::Option::Some(Self::MEAN_SQUARED_ERROR), + "MEAN_SQUARED_LOG_ERROR" => { + std::option::Option::Some(Self::MEAN_SQUARED_LOG_ERROR) + } + "MEDIAN_ABSOLUTE_ERROR" => { + std::option::Option::Some(Self::MEDIAN_ABSOLUTE_ERROR) + } + "R_SQUARED" => std::option::Option::Some(Self::R_SQUARED), + "EXPLAINED_VARIANCE" => std::option::Option::Some(Self::EXPLAINED_VARIANCE), + "PRECISION" => std::option::Option::Some(Self::PRECISION), + "RECALL" => std::option::Option::Some(Self::RECALL), + "ACCURACY" => std::option::Option::Some(Self::ACCURACY), + "F1_SCORE" => std::option::Option::Some(Self::F1_SCORE), + "LOG_LOSS" => std::option::Option::Some(Self::LOG_LOSS), + "ROC_AUC" => std::option::Option::Some(Self::ROC_AUC), + "DAVIES_BOULDIN_INDEX" => std::option::Option::Some(Self::DAVIES_BOULDIN_INDEX), + "MEAN_AVERAGE_PRECISION" => { + std::option::Option::Some(Self::MEAN_AVERAGE_PRECISION) + } + "NORMALIZED_DISCOUNTED_CUMULATIVE_GAIN" => { + std::option::Option::Some(Self::NORMALIZED_DISCOUNTED_CUMULATIVE_GAIN) + } + "AVERAGE_RANK" => std::option::Option::Some(Self::AVERAGE_RANK), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for HparamTuningObjective { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for HparamTuningObjective { + fn default() -> Self { + Self::new(0) + } + } + } + + /// Evaluation metrics for regression and explicit feedback type matrix + /// factorization models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct RegressionMetrics { + /// Mean absolute error. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub mean_absolute_error: std::option::Option, + + /// Mean squared error. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub mean_squared_error: std::option::Option, + + /// Mean squared log error. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub mean_squared_log_error: std::option::Option, + + /// Median absolute error. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub median_absolute_error: std::option::Option, + + /// R^2 score. This corresponds to r2_score in ML.EVALUATE. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub r_squared: std::option::Option, + } + + impl RegressionMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [mean_absolute_error][crate::model::model::RegressionMetrics::mean_absolute_error]. + pub fn set_mean_absolute_error< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.mean_absolute_error = v.into(); + self + } + + /// Sets the value of [mean_squared_error][crate::model::model::RegressionMetrics::mean_squared_error]. + pub fn set_mean_squared_error< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.mean_squared_error = v.into(); + self + } + + /// Sets the value of [mean_squared_log_error][crate::model::model::RegressionMetrics::mean_squared_log_error]. + pub fn set_mean_squared_log_error< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.mean_squared_log_error = v.into(); + self + } + + /// Sets the value of [median_absolute_error][crate::model::model::RegressionMetrics::median_absolute_error]. + pub fn set_median_absolute_error< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.median_absolute_error = v.into(); + self + } + + /// Sets the value of [r_squared][crate::model::model::RegressionMetrics::r_squared]. + pub fn set_r_squared>>( + mut self, + v: T, + ) -> Self { + self.r_squared = v.into(); + self + } + } + + impl wkt::message::Message for RegressionMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.RegressionMetrics" + } + } + + /// Aggregate metrics for classification/classifier models. For multi-class + /// models, the metrics are either macro-averaged or micro-averaged. When + /// macro-averaged, the metrics are calculated for each label and then an + /// unweighted average is taken of those values. When micro-averaged, the + /// metric is calculated globally by counting the total number of correctly + /// predicted rows. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct AggregateClassificationMetrics { + /// Precision is the fraction of actual positive predictions that had + /// positive actual labels. For multiclass this is a macro-averaged + /// metric treating each class as a binary classifier. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub precision: std::option::Option, + + /// Recall is the fraction of actual positive labels that were given a + /// positive prediction. For multiclass this is a macro-averaged metric. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub recall: std::option::Option, + + /// Accuracy is the fraction of predictions given the correct label. For + /// multiclass this is a micro-averaged metric. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub accuracy: std::option::Option, + + /// Threshold at which the metrics are computed. For binary + /// classification models this is the positive class threshold. + /// For multi-class classification models this is the confidence + /// threshold. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub threshold: std::option::Option, + + /// The F1 score is an average of recall and precision. For multiclass + /// this is a macro-averaged metric. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub f1_score: std::option::Option, + + /// Logarithmic Loss. For multiclass this is a macro-averaged metric. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub log_loss: std::option::Option, + + /// Area Under a ROC Curve. For multiclass this is a macro-averaged + /// metric. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub roc_auc: std::option::Option, + } + + impl AggregateClassificationMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [precision][crate::model::model::AggregateClassificationMetrics::precision]. + pub fn set_precision>>( + mut self, + v: T, + ) -> Self { + self.precision = v.into(); + self + } + + /// Sets the value of [recall][crate::model::model::AggregateClassificationMetrics::recall]. + pub fn set_recall>>( + mut self, + v: T, + ) -> Self { + self.recall = v.into(); + self + } + + /// Sets the value of [accuracy][crate::model::model::AggregateClassificationMetrics::accuracy]. + pub fn set_accuracy>>( + mut self, + v: T, + ) -> Self { + self.accuracy = v.into(); + self + } + + /// Sets the value of [threshold][crate::model::model::AggregateClassificationMetrics::threshold]. + pub fn set_threshold>>( + mut self, + v: T, + ) -> Self { + self.threshold = v.into(); + self + } + + /// Sets the value of [f1_score][crate::model::model::AggregateClassificationMetrics::f1_score]. + pub fn set_f1_score>>( + mut self, + v: T, + ) -> Self { + self.f1_score = v.into(); + self + } + + /// Sets the value of [log_loss][crate::model::model::AggregateClassificationMetrics::log_loss]. + pub fn set_log_loss>>( + mut self, + v: T, + ) -> Self { + self.log_loss = v.into(); + self + } + + /// Sets the value of [roc_auc][crate::model::model::AggregateClassificationMetrics::roc_auc]. + pub fn set_roc_auc>>( + mut self, + v: T, + ) -> Self { + self.roc_auc = v.into(); + self + } + } + + impl wkt::message::Message for AggregateClassificationMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.AggregateClassificationMetrics" + } + } + + /// Evaluation metrics for binary classification/classifier models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct BinaryClassificationMetrics { + /// Aggregate classification metrics. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub aggregate_classification_metrics: + std::option::Option, + + /// Binary confusion matrix at multiple thresholds. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub binary_confusion_matrix_list: std::vec::Vec< + crate::model::model::binary_classification_metrics::BinaryConfusionMatrix, + >, + + /// Label representing the positive class. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub positive_label: std::string::String, + + /// Label representing the negative class. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub negative_label: std::string::String, + } + + impl BinaryClassificationMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [aggregate_classification_metrics][crate::model::model::BinaryClassificationMetrics::aggregate_classification_metrics]. + pub fn set_aggregate_classification_metrics< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.aggregate_classification_metrics = v.into(); + self + } + + /// Sets the value of [positive_label][crate::model::model::BinaryClassificationMetrics::positive_label]. + pub fn set_positive_label>( + mut self, + v: T, + ) -> Self { + self.positive_label = v.into(); + self + } + + /// Sets the value of [negative_label][crate::model::model::BinaryClassificationMetrics::negative_label]. + pub fn set_negative_label>( + mut self, + v: T, + ) -> Self { + self.negative_label = v.into(); + self + } + + /// Sets the value of [binary_confusion_matrix_list][crate::model::model::BinaryClassificationMetrics::binary_confusion_matrix_list]. + pub fn set_binary_confusion_matrix_list(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::binary_classification_metrics::BinaryConfusionMatrix, + >, + { + use std::iter::Iterator; + self.binary_confusion_matrix_list = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for BinaryClassificationMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.BinaryClassificationMetrics" + } + } + + /// Defines additional types related to BinaryClassificationMetrics + pub mod binary_classification_metrics { + #[allow(unused_imports)] + use super::*; + + /// Confusion matrix for binary classification models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct BinaryConfusionMatrix { + /// Threshold value used when computing each of the following metric. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub positive_class_threshold: std::option::Option, + + /// Number of true samples predicted as true. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub true_positives: std::option::Option, + + /// Number of false samples predicted as true. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub false_positives: std::option::Option, + + /// Number of true samples predicted as false. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub true_negatives: std::option::Option, + + /// Number of false samples predicted as false. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub false_negatives: std::option::Option, + + /// The fraction of actual positive predictions that had positive actual + /// labels. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub precision: std::option::Option, + + /// The fraction of actual positive labels that were given a positive + /// prediction. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub recall: std::option::Option, + + /// The equally weighted average of recall and precision. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub f1_score: std::option::Option, + + /// The fraction of predictions given the correct label. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub accuracy: std::option::Option, + } + + impl BinaryConfusionMatrix { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [positive_class_threshold][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::positive_class_threshold]. + pub fn set_positive_class_threshold< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.positive_class_threshold = v.into(); + self + } + + /// Sets the value of [true_positives][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::true_positives]. + pub fn set_true_positives< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.true_positives = v.into(); + self + } + + /// Sets the value of [false_positives][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::false_positives]. + pub fn set_false_positives< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.false_positives = v.into(); + self + } + + /// Sets the value of [true_negatives][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::true_negatives]. + pub fn set_true_negatives< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.true_negatives = v.into(); + self + } + + /// Sets the value of [false_negatives][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::false_negatives]. + pub fn set_false_negatives< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.false_negatives = v.into(); + self + } + + /// Sets the value of [precision][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::precision]. + pub fn set_precision>>( + mut self, + v: T, + ) -> Self { + self.precision = v.into(); + self + } + + /// Sets the value of [recall][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::recall]. + pub fn set_recall>>( + mut self, + v: T, + ) -> Self { + self.recall = v.into(); + self + } + + /// Sets the value of [f1_score][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::f1_score]. + pub fn set_f1_score>>( + mut self, + v: T, + ) -> Self { + self.f1_score = v.into(); + self + } + + /// Sets the value of [accuracy][crate::model::model::binary_classification_metrics::BinaryConfusionMatrix::accuracy]. + pub fn set_accuracy>>( + mut self, + v: T, + ) -> Self { + self.accuracy = v.into(); + self + } + } + + impl wkt::message::Message for BinaryConfusionMatrix { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.BinaryClassificationMetrics.BinaryConfusionMatrix" + } + } + } + + /// Evaluation metrics for multi-class classification/classifier models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct MultiClassClassificationMetrics { + /// Aggregate classification metrics. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub aggregate_classification_metrics: + std::option::Option, + + /// Confusion matrix at different thresholds. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub confusion_matrix_list: + std::vec::Vec, + } + + impl MultiClassClassificationMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [aggregate_classification_metrics][crate::model::model::MultiClassClassificationMetrics::aggregate_classification_metrics]. + pub fn set_aggregate_classification_metrics< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.aggregate_classification_metrics = v.into(); + self + } + + /// Sets the value of [confusion_matrix_list][crate::model::model::MultiClassClassificationMetrics::confusion_matrix_list]. + pub fn set_confusion_matrix_list(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::multi_class_classification_metrics::ConfusionMatrix, + >, + { + use std::iter::Iterator; + self.confusion_matrix_list = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for MultiClassClassificationMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.MultiClassClassificationMetrics" + } + } + + /// Defines additional types related to MultiClassClassificationMetrics + pub mod multi_class_classification_metrics { + #[allow(unused_imports)] + use super::*; + + /// Confusion matrix for multi-class classification models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ConfusionMatrix { + /// Confidence threshold used when computing the entries of the + /// confusion matrix. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub confidence_threshold: std::option::Option, + + /// One row per actual label. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub rows: std::vec::Vec< + crate::model::model::multi_class_classification_metrics::confusion_matrix::Row, + >, + } + + impl ConfusionMatrix { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [confidence_threshold][crate::model::model::multi_class_classification_metrics::ConfusionMatrix::confidence_threshold]. + pub fn set_confidence_threshold< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.confidence_threshold = v.into(); + self + } + + /// Sets the value of [rows][crate::model::model::multi_class_classification_metrics::ConfusionMatrix::rows]. + pub fn set_rows(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::multi_class_classification_metrics::confusion_matrix::Row, + >, + { + use std::iter::Iterator; + self.rows = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for ConfusionMatrix { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.MultiClassClassificationMetrics.ConfusionMatrix" + } + } + + /// Defines additional types related to ConfusionMatrix + pub mod confusion_matrix { + #[allow(unused_imports)] + use super::*; + + /// A single entry in the confusion matrix. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct Entry { + /// The predicted label. For confidence_threshold > 0, we will + /// also add an entry indicating the number of items under the + /// confidence threshold. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub predicted_label: std::string::String, + + /// Number of items being predicted as this label. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub item_count: std::option::Option, + } + + impl Entry { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [predicted_label][crate::model::model::multi_class_classification_metrics::confusion_matrix::Entry::predicted_label]. + pub fn set_predicted_label>( + mut self, + v: T, + ) -> Self { + self.predicted_label = v.into(); + self + } + + /// Sets the value of [item_count][crate::model::model::multi_class_classification_metrics::confusion_matrix::Entry::item_count]. + pub fn set_item_count< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.item_count = v.into(); + self + } + } + + impl wkt::message::Message for Entry { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.MultiClassClassificationMetrics.ConfusionMatrix.Entry" + } + } + + /// A single row in the confusion matrix. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct Row { + + /// The original label of this row. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub actual_label: std::string::String, + + /// Info describing predicted label distribution. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub entries: std::vec::Vec, + } + + impl Row { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [actual_label][crate::model::model::multi_class_classification_metrics::confusion_matrix::Row::actual_label]. + pub fn set_actual_label>( + mut self, + v: T, + ) -> Self { + self.actual_label = v.into(); + self + } + + /// Sets the value of [entries][crate::model::model::multi_class_classification_metrics::confusion_matrix::Row::entries]. + pub fn set_entries(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into + { + use std::iter::Iterator; + self.entries = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for Row { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.MultiClassClassificationMetrics.ConfusionMatrix.Row" + } + } + } + } + + /// Evaluation metrics for clustering models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ClusteringMetrics { + /// Davies-Bouldin index. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub davies_bouldin_index: std::option::Option, + + /// Mean of squared distances between each sample to its cluster centroid. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub mean_squared_distance: std::option::Option, + + /// Information for all clusters. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub clusters: std::vec::Vec, + } + + impl ClusteringMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [davies_bouldin_index][crate::model::model::ClusteringMetrics::davies_bouldin_index]. + pub fn set_davies_bouldin_index< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.davies_bouldin_index = v.into(); + self + } + + /// Sets the value of [mean_squared_distance][crate::model::model::ClusteringMetrics::mean_squared_distance]. + pub fn set_mean_squared_distance< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.mean_squared_distance = v.into(); + self + } + + /// Sets the value of [clusters][crate::model::model::ClusteringMetrics::clusters]. + pub fn set_clusters(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.clusters = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for ClusteringMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ClusteringMetrics" + } + } + + /// Defines additional types related to ClusteringMetrics + pub mod clustering_metrics { + #[allow(unused_imports)] + use super::*; + + /// Message containing the information about one cluster. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct Cluster { + /// Centroid id. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub centroid_id: i64, + + /// Values of highly variant features for this cluster. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub feature_values: + std::vec::Vec, + + /// Count of training data rows that were assigned to this cluster. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub count: std::option::Option, + } + + impl Cluster { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [centroid_id][crate::model::model::clustering_metrics::Cluster::centroid_id]. + pub fn set_centroid_id>(mut self, v: T) -> Self { + self.centroid_id = v.into(); + self + } + + /// Sets the value of [count][crate::model::model::clustering_metrics::Cluster::count]. + pub fn set_count>>( + mut self, + v: T, + ) -> Self { + self.count = v.into(); + self + } + + /// Sets the value of [feature_values][crate::model::model::clustering_metrics::Cluster::feature_values]. + pub fn set_feature_values(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::clustering_metrics::cluster::FeatureValue, + >, + { + use std::iter::Iterator; + self.feature_values = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for Cluster { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ClusteringMetrics.Cluster" + } + } + + /// Defines additional types related to Cluster + pub mod cluster { + #[allow(unused_imports)] + use super::*; + + /// Representative value of a single feature within the cluster. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct FeatureValue { + /// The feature column name. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub feature_column: std::string::String, + + /// Value. + #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")] + pub value: std::option::Option< + crate::model::model::clustering_metrics::cluster::feature_value::Value, + >, + } + + impl FeatureValue { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [feature_column][crate::model::model::clustering_metrics::cluster::FeatureValue::feature_column]. + pub fn set_feature_column>( + mut self, + v: T, + ) -> Self { + self.feature_column = v.into(); + self + } + + /// Sets the value of `value`. + pub fn set_value< + T: std::convert::Into< + std::option::Option< + crate::model::model::clustering_metrics::cluster::feature_value::Value, + >, + >, + >( + mut self, + v: T, + ) -> Self { + self.value = v.into(); + self + } + + /// The value of [value][crate::model::model::clustering_metrics::cluster::FeatureValue::value] + /// if it holds a `NumericalValue`, `None` if the field is not set or + /// holds a different branch. + pub fn get_numerical_value( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.value.as_ref().and_then(|v| match v { + crate::model::model::clustering_metrics::cluster::feature_value::Value::NumericalValue(v) => std::option::Option::Some(v), + _ => std::option::Option::None, + }) + } + + /// The value of [value][crate::model::model::clustering_metrics::cluster::FeatureValue::value] + /// if it holds a `CategoricalValue`, `None` if the field is not set or + /// holds a different branch. + pub fn get_categorical_value(&self) -> std::option::Option<&std::boxed::Box>{ + #[allow(unreachable_patterns)] + self.value.as_ref().and_then(|v| match v { + crate::model::model::clustering_metrics::cluster::feature_value::Value::CategoricalValue(v) => std::option::Option::Some(v), + _ => std::option::Option::None, + }) + } + + /// Sets the value of [value][crate::model::model::clustering_metrics::cluster::FeatureValue::value] + /// to hold a `NumericalValue`. + /// + /// Note that all the setters affecting `value` are + /// mutually exclusive. + pub fn set_numerical_value< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.value = std::option::Option::Some( + crate::model::model::clustering_metrics::cluster::feature_value::Value::NumericalValue( + v.into() + ) + ); + self + } + + /// Sets the value of [value][crate::model::model::clustering_metrics::cluster::FeatureValue::value] + /// to hold a `CategoricalValue`. + /// + /// Note that all the setters affecting `value` are + /// mutually exclusive. + pub fn set_categorical_value>>(mut self, v: T) -> Self{ + self.value = std::option::Option::Some( + crate::model::model::clustering_metrics::cluster::feature_value::Value::CategoricalValue( + v.into() + ) + ); + self + } + } + + impl wkt::message::Message for FeatureValue { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ClusteringMetrics.Cluster.FeatureValue" + } + } + + /// Defines additional types related to FeatureValue + pub mod feature_value { + #[allow(unused_imports)] + use super::*; + + /// Representative value of a categorical feature. + #[serde_with::serde_as] + #[derive( + Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize, + )] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct CategoricalValue { + + /// Counts of all categories for the categorical feature. If there are + /// more than ten categories, we return top ten (by count) and return + /// one more CategoryCount with category "_OTHER_" and count as + /// aggregate counts of remaining categories. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub category_counts: std::vec::Vec, + } + + impl CategoricalValue { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [category_counts][crate::model::model::clustering_metrics::cluster::feature_value::CategoricalValue::category_counts]. + pub fn set_category_counts(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into + { + use std::iter::Iterator; + self.category_counts = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for CategoricalValue { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ClusteringMetrics.Cluster.FeatureValue.CategoricalValue" + } + } + + /// Defines additional types related to CategoricalValue + pub mod categorical_value { + #[allow(unused_imports)] + use super::*; + + /// Represents the count of a single category within the cluster. + #[serde_with::serde_as] + #[derive( + Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize, + )] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct CategoryCount { + /// The name of category. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub category: std::string::String, + + /// The count of training samples matching the category within the + /// cluster. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub count: std::option::Option, + } + + impl CategoryCount { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [category][crate::model::model::clustering_metrics::cluster::feature_value::categorical_value::CategoryCount::category]. + pub fn set_category>( + mut self, + v: T, + ) -> Self { + self.category = v.into(); + self + } + + /// Sets the value of [count][crate::model::model::clustering_metrics::cluster::feature_value::categorical_value::CategoryCount::count]. + pub fn set_count< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.count = v.into(); + self + } + } + + impl wkt::message::Message for CategoryCount { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ClusteringMetrics.Cluster.FeatureValue.CategoricalValue.CategoryCount" + } + } + } + + /// Value. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(rename_all = "camelCase")] + #[non_exhaustive] + pub enum Value { + /// The numerical feature value. This is the centroid value for this + /// feature. + NumericalValue(std::boxed::Box), + /// The categorical feature value. + CategoricalValue(std::boxed::Box), + } + } + } + } + + /// Evaluation metrics used by weighted-ALS models specified by + /// feedback_type=implicit. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct RankingMetrics { + /// Calculates a precision per user for all the items by ranking them and + /// then averages all the precisions across all the users. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub mean_average_precision: std::option::Option, + + /// Similar to the mean squared error computed in regression and explicit + /// recommendation models except instead of computing the rating directly, + /// the output from evaluate is computed against a preference which is 1 or 0 + /// depending on if the rating exists or not. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub mean_squared_error: std::option::Option, + + /// A metric to determine the goodness of a ranking calculated from the + /// predicted confidence by comparing it to an ideal rank measured by the + /// original ratings. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub normalized_discounted_cumulative_gain: std::option::Option, + + /// Determines the goodness of a ranking by computing the percentile rank + /// from the predicted confidence and dividing it by the original rank. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub average_rank: std::option::Option, + } + + impl RankingMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [mean_average_precision][crate::model::model::RankingMetrics::mean_average_precision]. + pub fn set_mean_average_precision< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.mean_average_precision = v.into(); + self + } + + /// Sets the value of [mean_squared_error][crate::model::model::RankingMetrics::mean_squared_error]. + pub fn set_mean_squared_error< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.mean_squared_error = v.into(); + self + } + + /// Sets the value of [normalized_discounted_cumulative_gain][crate::model::model::RankingMetrics::normalized_discounted_cumulative_gain]. + pub fn set_normalized_discounted_cumulative_gain< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.normalized_discounted_cumulative_gain = v.into(); + self + } + + /// Sets the value of [average_rank][crate::model::model::RankingMetrics::average_rank]. + pub fn set_average_rank>>( + mut self, + v: T, + ) -> Self { + self.average_rank = v.into(); + self + } + } + + impl wkt::message::Message for RankingMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.RankingMetrics" + } + } + + /// Model evaluation metrics for ARIMA forecasting models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ArimaForecastingMetrics { + /// Repeated as there can be many metric sets (one for each model) in + /// auto-arima and the large-scale case. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub arima_single_model_forecasting_metrics: std::vec::Vec< + crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics, + >, + } + + impl ArimaForecastingMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [arima_single_model_forecasting_metrics][crate::model::model::ArimaForecastingMetrics::arima_single_model_forecasting_metrics]. + pub fn set_arima_single_model_forecasting_metrics(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics, + >, + { + use std::iter::Iterator; + self.arima_single_model_forecasting_metrics = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for ArimaForecastingMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ArimaForecastingMetrics" + } + } + + /// Defines additional types related to ArimaForecastingMetrics + pub mod arima_forecasting_metrics { + #[allow(unused_imports)] + use super::*; + + /// Model evaluation metrics for a single ARIMA forecasting model. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ArimaSingleModelForecastingMetrics { + /// Non-seasonal order. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub non_seasonal_order: std::option::Option, + + /// Arima fitting metrics. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub arima_fitting_metrics: + std::option::Option, + + /// Is arima model fitted with drift or not. It is always false when d + /// is not 1. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub has_drift: std::option::Option, + + /// The time_series_id value for this time series. It will be one of + /// the unique values from the time_series_id_column specified during + /// ARIMA model training. Only present when time_series_id_column + /// training option was used. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub time_series_id: std::string::String, + + /// The tuple of time_series_ids identifying this time series. It will + /// be one of the unique tuples of values present in the + /// time_series_id_columns specified during ARIMA model training. Only + /// present when time_series_id_columns training option was used and + /// the order of values here are same as the order of + /// time_series_id_columns. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub time_series_ids: std::vec::Vec, + + /// Seasonal periods. Repeated because multiple periods are supported + /// for one time series. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub seasonal_periods: + std::vec::Vec, + + /// If true, holiday_effect is a part of time series decomposition result. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub has_holiday_effect: std::option::Option, + + /// If true, spikes_and_dips is a part of time series decomposition result. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub has_spikes_and_dips: std::option::Option, + + /// If true, step_changes is a part of time series decomposition result. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub has_step_changes: std::option::Option, + } + + impl ArimaSingleModelForecastingMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [non_seasonal_order][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::non_seasonal_order]. + pub fn set_non_seasonal_order< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.non_seasonal_order = v.into(); + self + } + + /// Sets the value of [arima_fitting_metrics][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::arima_fitting_metrics]. + pub fn set_arima_fitting_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.arima_fitting_metrics = v.into(); + self + } + + /// Sets the value of [has_drift][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::has_drift]. + pub fn set_has_drift>>( + mut self, + v: T, + ) -> Self { + self.has_drift = v.into(); + self + } + + /// Sets the value of [time_series_id][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::time_series_id]. + pub fn set_time_series_id>( + mut self, + v: T, + ) -> Self { + self.time_series_id = v.into(); + self + } + + /// Sets the value of [has_holiday_effect][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::has_holiday_effect]. + pub fn set_has_holiday_effect< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.has_holiday_effect = v.into(); + self + } + + /// Sets the value of [has_spikes_and_dips][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::has_spikes_and_dips]. + pub fn set_has_spikes_and_dips< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.has_spikes_and_dips = v.into(); + self + } + + /// Sets the value of [has_step_changes][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::has_step_changes]. + pub fn set_has_step_changes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.has_step_changes = v.into(); + self + } + + /// Sets the value of [time_series_ids][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::time_series_ids]. + pub fn set_time_series_ids(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.time_series_ids = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [seasonal_periods][crate::model::model::arima_forecasting_metrics::ArimaSingleModelForecastingMetrics::seasonal_periods]. + pub fn set_seasonal_periods(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.seasonal_periods = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for ArimaSingleModelForecastingMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ArimaForecastingMetrics.ArimaSingleModelForecastingMetrics" + } + } + } + + /// Model evaluation metrics for dimensionality reduction models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct DimensionalityReductionMetrics { + /// Total percentage of variance explained by the selected principal + /// components. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub total_explained_variance_ratio: std::option::Option, + } + + impl DimensionalityReductionMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [total_explained_variance_ratio][crate::model::model::DimensionalityReductionMetrics::total_explained_variance_ratio]. + pub fn set_total_explained_variance_ratio< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.total_explained_variance_ratio = v.into(); + self + } + } + + impl wkt::message::Message for DimensionalityReductionMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.DimensionalityReductionMetrics" + } + } + + /// Evaluation metrics of a model. These are either computed on all training + /// data or just the eval data based on whether eval data was used during + /// training. These are not present for imported models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct EvaluationMetrics { + /// Metrics. + #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")] + pub metrics: std::option::Option, + } + + impl EvaluationMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of `metrics`. + pub fn set_metrics< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.metrics = v.into(); + self + } + + /// The value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// if it holds a `RegressionMetrics`, `None` if the field is not set or + /// holds a different branch. + pub fn get_regression_metrics( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.metrics.as_ref().and_then(|v| match v { + crate::model::model::evaluation_metrics::Metrics::RegressionMetrics(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// if it holds a `BinaryClassificationMetrics`, `None` if the field is not set or + /// holds a different branch. + pub fn get_binary_classification_metrics( + &self, + ) -> std::option::Option<&std::boxed::Box> + { + #[allow(unreachable_patterns)] + self.metrics.as_ref().and_then(|v| match v { + crate::model::model::evaluation_metrics::Metrics::BinaryClassificationMetrics( + v, + ) => std::option::Option::Some(v), + _ => std::option::Option::None, + }) + } + + /// The value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// if it holds a `MultiClassClassificationMetrics`, `None` if the field is not set or + /// holds a different branch. + pub fn get_multi_class_classification_metrics( + &self, + ) -> std::option::Option< + &std::boxed::Box, + > { + #[allow(unreachable_patterns)] + self.metrics.as_ref().and_then(|v| match v { + crate::model::model::evaluation_metrics::Metrics::MultiClassClassificationMetrics(v) => std::option::Option::Some(v), + _ => std::option::Option::None, + }) + } + + /// The value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// if it holds a `ClusteringMetrics`, `None` if the field is not set or + /// holds a different branch. + pub fn get_clustering_metrics( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.metrics.as_ref().and_then(|v| match v { + crate::model::model::evaluation_metrics::Metrics::ClusteringMetrics(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// if it holds a `RankingMetrics`, `None` if the field is not set or + /// holds a different branch. + pub fn get_ranking_metrics( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.metrics.as_ref().and_then(|v| match v { + crate::model::model::evaluation_metrics::Metrics::RankingMetrics(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// if it holds a `ArimaForecastingMetrics`, `None` if the field is not set or + /// holds a different branch. + pub fn get_arima_forecasting_metrics( + &self, + ) -> std::option::Option<&std::boxed::Box> + { + #[allow(unreachable_patterns)] + self.metrics.as_ref().and_then(|v| match v { + crate::model::model::evaluation_metrics::Metrics::ArimaForecastingMetrics(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// if it holds a `DimensionalityReductionMetrics`, `None` if the field is not set or + /// holds a different branch. + pub fn get_dimensionality_reduction_metrics( + &self, + ) -> std::option::Option< + &std::boxed::Box, + > { + #[allow(unreachable_patterns)] + self.metrics.as_ref().and_then(|v| match v { + crate::model::model::evaluation_metrics::Metrics::DimensionalityReductionMetrics(v) => std::option::Option::Some(v), + _ => std::option::Option::None, + }) + } + + /// Sets the value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// to hold a `RegressionMetrics`. + /// + /// Note that all the setters affecting `metrics` are + /// mutually exclusive. + pub fn set_regression_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.metrics = std::option::Option::Some( + crate::model::model::evaluation_metrics::Metrics::RegressionMetrics(v.into()), + ); + self + } + + /// Sets the value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// to hold a `BinaryClassificationMetrics`. + /// + /// Note that all the setters affecting `metrics` are + /// mutually exclusive. + pub fn set_binary_classification_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.metrics = std::option::Option::Some( + crate::model::model::evaluation_metrics::Metrics::BinaryClassificationMetrics( + v.into(), + ), + ); + self + } + + /// Sets the value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// to hold a `MultiClassClassificationMetrics`. + /// + /// Note that all the setters affecting `metrics` are + /// mutually exclusive. + pub fn set_multi_class_classification_metrics< + T: std::convert::Into< + std::boxed::Box, + >, + >( + mut self, + v: T, + ) -> Self { + self.metrics = std::option::Option::Some( + crate::model::model::evaluation_metrics::Metrics::MultiClassClassificationMetrics( + v.into(), + ), + ); + self + } + + /// Sets the value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// to hold a `ClusteringMetrics`. + /// + /// Note that all the setters affecting `metrics` are + /// mutually exclusive. + pub fn set_clustering_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.metrics = std::option::Option::Some( + crate::model::model::evaluation_metrics::Metrics::ClusteringMetrics(v.into()), + ); + self + } + + /// Sets the value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// to hold a `RankingMetrics`. + /// + /// Note that all the setters affecting `metrics` are + /// mutually exclusive. + pub fn set_ranking_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.metrics = std::option::Option::Some( + crate::model::model::evaluation_metrics::Metrics::RankingMetrics(v.into()), + ); + self + } + + /// Sets the value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// to hold a `ArimaForecastingMetrics`. + /// + /// Note that all the setters affecting `metrics` are + /// mutually exclusive. + pub fn set_arima_forecasting_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.metrics = std::option::Option::Some( + crate::model::model::evaluation_metrics::Metrics::ArimaForecastingMetrics(v.into()), + ); + self + } + + /// Sets the value of [metrics][crate::model::model::EvaluationMetrics::metrics] + /// to hold a `DimensionalityReductionMetrics`. + /// + /// Note that all the setters affecting `metrics` are + /// mutually exclusive. + pub fn set_dimensionality_reduction_metrics< + T: std::convert::Into< + std::boxed::Box, + >, + >( + mut self, + v: T, + ) -> Self { + self.metrics = std::option::Option::Some( + crate::model::model::evaluation_metrics::Metrics::DimensionalityReductionMetrics( + v.into(), + ), + ); + self + } + } + + impl wkt::message::Message for EvaluationMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.EvaluationMetrics" + } + } + + /// Defines additional types related to EvaluationMetrics + pub mod evaluation_metrics { + #[allow(unused_imports)] + use super::*; + + /// Metrics. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(rename_all = "camelCase")] + #[non_exhaustive] + pub enum Metrics { + /// Populated for regression models and explicit feedback type matrix + /// factorization models. + RegressionMetrics(std::boxed::Box), + /// Populated for binary classification/classifier models. + BinaryClassificationMetrics( + std::boxed::Box, + ), + /// Populated for multi-class classification/classifier models. + MultiClassClassificationMetrics( + std::boxed::Box, + ), + /// Populated for clustering models. + ClusteringMetrics(std::boxed::Box), + /// Populated for implicit feedback type matrix factorization models. + RankingMetrics(std::boxed::Box), + /// Populated for ARIMA models. + ArimaForecastingMetrics(std::boxed::Box), + /// Evaluation metrics when the model is a dimensionality reduction model, + /// which currently includes PCA. + DimensionalityReductionMetrics( + std::boxed::Box, + ), + } + } + + /// Data split result. This contains references to the training and evaluation + /// data tables that were used to train the model. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct DataSplitResult { + /// Table reference of the training data after split. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub training_table: std::option::Option, + + /// Table reference of the evaluation data after split. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub evaluation_table: std::option::Option, + + /// Table reference of the test data after split. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub test_table: std::option::Option, + } + + impl DataSplitResult { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [training_table][crate::model::model::DataSplitResult::training_table]. + pub fn set_training_table< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.training_table = v.into(); + self + } + + /// Sets the value of [evaluation_table][crate::model::model::DataSplitResult::evaluation_table]. + pub fn set_evaluation_table< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.evaluation_table = v.into(); + self + } + + /// Sets the value of [test_table][crate::model::model::DataSplitResult::test_table]. + pub fn set_test_table< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.test_table = v.into(); + self + } + } + + impl wkt::message::Message for DataSplitResult { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.DataSplitResult" + } + } + + /// Arima order, can be used for both non-seasonal and seasonal parts. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ArimaOrder { + /// Order of the autoregressive part. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub p: std::option::Option, + + /// Order of the differencing part. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub d: std::option::Option, + + /// Order of the moving-average part. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub q: std::option::Option, + } + + impl ArimaOrder { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [p][crate::model::model::ArimaOrder::p]. + pub fn set_p>>( + mut self, + v: T, + ) -> Self { + self.p = v.into(); + self + } + + /// Sets the value of [d][crate::model::model::ArimaOrder::d]. + pub fn set_d>>( + mut self, + v: T, + ) -> Self { + self.d = v.into(); + self + } + + /// Sets the value of [q][crate::model::model::ArimaOrder::q]. + pub fn set_q>>( + mut self, + v: T, + ) -> Self { + self.q = v.into(); + self + } + } + + impl wkt::message::Message for ArimaOrder { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ArimaOrder" + } + } + + /// ARIMA model fitting metrics. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ArimaFittingMetrics { + /// Log-likelihood. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub log_likelihood: std::option::Option, + + /// AIC. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub aic: std::option::Option, + + /// Variance. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub variance: std::option::Option, + } + + impl ArimaFittingMetrics { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [log_likelihood][crate::model::model::ArimaFittingMetrics::log_likelihood]. + pub fn set_log_likelihood>>( + mut self, + v: T, + ) -> Self { + self.log_likelihood = v.into(); + self + } + + /// Sets the value of [aic][crate::model::model::ArimaFittingMetrics::aic]. + pub fn set_aic>>( + mut self, + v: T, + ) -> Self { + self.aic = v.into(); + self + } + + /// Sets the value of [variance][crate::model::model::ArimaFittingMetrics::variance]. + pub fn set_variance>>( + mut self, + v: T, + ) -> Self { + self.variance = v.into(); + self + } + } + + impl wkt::message::Message for ArimaFittingMetrics { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ArimaFittingMetrics" + } + } + + /// Global explanations containing the top most important features + /// after training. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct GlobalExplanation { + /// A list of the top global explanations. Sorted by absolute value of + /// attribution in descending order. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub explanations: std::vec::Vec, + + /// Class label for this set of global explanations. Will be empty/null for + /// binary logistic and linear regression models. Sorted alphabetically in + /// descending order. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub class_label: std::string::String, + } + + impl GlobalExplanation { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [class_label][crate::model::model::GlobalExplanation::class_label]. + pub fn set_class_label>(mut self, v: T) -> Self { + self.class_label = v.into(); + self + } + + /// Sets the value of [explanations][crate::model::model::GlobalExplanation::explanations]. + pub fn set_explanations(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.explanations = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for GlobalExplanation { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.GlobalExplanation" + } + } + + /// Defines additional types related to GlobalExplanation + pub mod global_explanation { + #[allow(unused_imports)] + use super::*; + + /// Explanation for a single feature. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct Explanation { + /// The full feature name. For non-numerical features, will be formatted + /// like `.`. Overall size of feature + /// name will always be truncated to first 120 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub feature_name: std::string::String, + + /// Attribution of feature. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub attribution: std::option::Option, + } + + impl Explanation { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [feature_name][crate::model::model::global_explanation::Explanation::feature_name]. + pub fn set_feature_name>( + mut self, + v: T, + ) -> Self { + self.feature_name = v.into(); + self + } + + /// Sets the value of [attribution][crate::model::model::global_explanation::Explanation::attribution]. + pub fn set_attribution>>( + mut self, + v: T, + ) -> Self { + self.attribution = v.into(); + self + } + } + + impl wkt::message::Message for Explanation { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.GlobalExplanation.Explanation" + } + } + } + + /// Encoding methods for categorical features. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct CategoryEncodingMethod {} + + impl CategoryEncodingMethod { + pub fn new() -> Self { + std::default::Default::default() + } + } + + impl wkt::message::Message for CategoryEncodingMethod { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.CategoryEncodingMethod" + } + } + + /// Defines additional types related to CategoryEncodingMethod + pub mod category_encoding_method { + #[allow(unused_imports)] + use super::*; + + /// Supported encoding methods for categorical features. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct EncodingMethod(i32); + + impl EncodingMethod { + /// Unspecified encoding method. + pub const ENCODING_METHOD_UNSPECIFIED: EncodingMethod = EncodingMethod::new(0); + + /// Applies one-hot encoding. + pub const ONE_HOT_ENCODING: EncodingMethod = EncodingMethod::new(1); + + /// Applies label encoding. + pub const LABEL_ENCODING: EncodingMethod = EncodingMethod::new(2); + + /// Applies dummy encoding. + pub const DUMMY_ENCODING: EncodingMethod = EncodingMethod::new(3); + + /// Creates a new EncodingMethod instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("ENCODING_METHOD_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("ONE_HOT_ENCODING"), + 2 => std::borrow::Cow::Borrowed("LABEL_ENCODING"), + 3 => std::borrow::Cow::Borrowed("DUMMY_ENCODING"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "ENCODING_METHOD_UNSPECIFIED" => { + std::option::Option::Some(Self::ENCODING_METHOD_UNSPECIFIED) + } + "ONE_HOT_ENCODING" => std::option::Option::Some(Self::ONE_HOT_ENCODING), + "LABEL_ENCODING" => std::option::Option::Some(Self::LABEL_ENCODING), + "DUMMY_ENCODING" => std::option::Option::Some(Self::DUMMY_ENCODING), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for EncodingMethod { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for EncodingMethod { + fn default() -> Self { + Self::new(0) + } + } + } + + /// PCA solver options. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct PcaSolverOptionEnums {} + + impl PcaSolverOptionEnums { + pub fn new() -> Self { + std::default::Default::default() + } + } + + impl wkt::message::Message for PcaSolverOptionEnums { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.PcaSolverOptionEnums" + } + } + + /// Defines additional types related to PcaSolverOptionEnums + pub mod pca_solver_option_enums { + #[allow(unused_imports)] + use super::*; + + /// Enums for supported PCA solvers. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct PcaSolver(i32); + + impl PcaSolver { + /// Default value. + pub const UNSPECIFIED: PcaSolver = PcaSolver::new(0); + + /// Full eigen-decoposition. + pub const FULL: PcaSolver = PcaSolver::new(1); + + /// Randomized SVD. + pub const RANDOMIZED: PcaSolver = PcaSolver::new(2); + + /// Auto. + pub const AUTO: PcaSolver = PcaSolver::new(3); + + /// Creates a new PcaSolver instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("FULL"), + 2 => std::borrow::Cow::Borrowed("RANDOMIZED"), + 3 => std::borrow::Cow::Borrowed("AUTO"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "UNSPECIFIED" => std::option::Option::Some(Self::UNSPECIFIED), + "FULL" => std::option::Option::Some(Self::FULL), + "RANDOMIZED" => std::option::Option::Some(Self::RANDOMIZED), + "AUTO" => std::option::Option::Some(Self::AUTO), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for PcaSolver { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for PcaSolver { + fn default() -> Self { + Self::new(0) + } + } + } + + /// Model registry options. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ModelRegistryOptionEnums {} + + impl ModelRegistryOptionEnums { + pub fn new() -> Self { + std::default::Default::default() + } + } + + impl wkt::message::Message for ModelRegistryOptionEnums { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.ModelRegistryOptionEnums" + } + } + + /// Defines additional types related to ModelRegistryOptionEnums + pub mod model_registry_option_enums { + #[allow(unused_imports)] + use super::*; + + /// Enums for supported model registries. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct ModelRegistry(i32); + + impl ModelRegistry { + /// Default value. + pub const MODEL_REGISTRY_UNSPECIFIED: ModelRegistry = ModelRegistry::new(0); + + /// Vertex AI. + pub const VERTEX_AI: ModelRegistry = ModelRegistry::new(1); + + /// Creates a new ModelRegistry instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("MODEL_REGISTRY_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("VERTEX_AI"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "MODEL_REGISTRY_UNSPECIFIED" => { + std::option::Option::Some(Self::MODEL_REGISTRY_UNSPECIFIED) + } + "VERTEX_AI" => std::option::Option::Some(Self::VERTEX_AI), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for ModelRegistry { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for ModelRegistry { + fn default() -> Self { + Self::new(0) + } + } + } + + /// Information about a single training query run for the model. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct TrainingRun { + /// Output only. Options that were used for this training run, includes + /// user specified and default options that were used. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub training_options: + std::option::Option, + + /// Output only. The start time of this training run. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub start_time: std::option::Option, + + /// Output only. Output of each iteration run, results.size() <= + /// max_iterations. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub results: std::vec::Vec, + + /// Output only. The evaluation metrics over training/eval data that were + /// computed at the end of training. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub evaluation_metrics: std::option::Option, + + /// Output only. Data split result of the training run. Only set when the + /// input data is actually split. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub data_split_result: std::option::Option, + + /// Output only. Global explanation contains the explanation of top features + /// on the model level. Applies to both regression and classification models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub model_level_global_explanation: + std::option::Option, + + /// Output only. Global explanation contains the explanation of top features + /// on the class level. Applies to classification models only. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub class_level_global_explanations: std::vec::Vec, + + /// The model id in the [Vertex AI Model + /// Registry](https://cloud.google.com/vertex-ai/docs/model-registry/introduction) + /// for this training run. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub vertex_ai_model_id: std::string::String, + + /// Output only. The model version in the [Vertex AI Model + /// Registry](https://cloud.google.com/vertex-ai/docs/model-registry/introduction) + /// for this training run. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub vertex_ai_model_version: std::string::String, + } + + impl TrainingRun { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [training_options][crate::model::model::TrainingRun::training_options]. + pub fn set_training_options< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.training_options = v.into(); + self + } + + /// Sets the value of [start_time][crate::model::model::TrainingRun::start_time]. + pub fn set_start_time>>( + mut self, + v: T, + ) -> Self { + self.start_time = v.into(); + self + } + + /// Sets the value of [evaluation_metrics][crate::model::model::TrainingRun::evaluation_metrics]. + pub fn set_evaluation_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.evaluation_metrics = v.into(); + self + } + + /// Sets the value of [data_split_result][crate::model::model::TrainingRun::data_split_result]. + pub fn set_data_split_result< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.data_split_result = v.into(); + self + } + + /// Sets the value of [model_level_global_explanation][crate::model::model::TrainingRun::model_level_global_explanation]. + pub fn set_model_level_global_explanation< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.model_level_global_explanation = v.into(); + self + } + + /// Sets the value of [vertex_ai_model_id][crate::model::model::TrainingRun::vertex_ai_model_id]. + pub fn set_vertex_ai_model_id>( + mut self, + v: T, + ) -> Self { + self.vertex_ai_model_id = v.into(); + self + } + + /// Sets the value of [vertex_ai_model_version][crate::model::model::TrainingRun::vertex_ai_model_version]. + pub fn set_vertex_ai_model_version>( + mut self, + v: T, + ) -> Self { + self.vertex_ai_model_version = v.into(); + self + } + + /// Sets the value of [results][crate::model::model::TrainingRun::results]. + pub fn set_results(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.results = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [class_level_global_explanations][crate::model::model::TrainingRun::class_level_global_explanations]. + pub fn set_class_level_global_explanations(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.class_level_global_explanations = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for TrainingRun { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.TrainingRun" + } + } + + /// Defines additional types related to TrainingRun + pub mod training_run { + #[allow(unused_imports)] + use super::*; + + /// Options used in model training. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct TrainingOptions { + /// The maximum number of iterations in training. Used only for iterative + /// training algorithms. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub max_iterations: i64, + + /// Type of loss function used during training run. + pub loss_type: crate::model::model::LossType, + + /// Learning rate in training. Used only for iterative training algorithms. + pub learn_rate: f64, + + /// L1 regularization coefficient. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub l1_regularization: std::option::Option, + + /// L2 regularization coefficient. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub l2_regularization: std::option::Option, + + /// When early_stop is true, stops training when accuracy improvement is + /// less than 'min_relative_progress'. Used only for iterative training + /// algorithms. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub min_relative_progress: std::option::Option, + + /// Whether to train a model from the last checkpoint. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub warm_start: std::option::Option, + + /// Whether to stop early when the loss doesn't improve significantly + /// any more (compared to min_relative_progress). Used only for iterative + /// training algorithms. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub early_stop: std::option::Option, + + /// Name of input label columns in training data. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub input_label_columns: std::vec::Vec, + + /// The data split type for training and evaluation, e.g. RANDOM. + pub data_split_method: crate::model::model::DataSplitMethod, + + /// The fraction of evaluation data over the whole input data. The rest + /// of data will be used as training data. The format should be double. + /// Accurate to two decimal places. + /// Default value is 0.2. + pub data_split_eval_fraction: f64, + + /// The column to split data with. This column won't be used as a + /// feature. + /// + /// . When data_split_method is CUSTOM, the corresponding column should + /// be boolean. The rows with true value tag are eval data, and the false + /// are training data. + /// . When data_split_method is SEQ, the first DATA_SPLIT_EVAL_FRACTION + /// rows (from smallest to largest) in the corresponding column are used + /// as training data, and the rest are eval data. It respects the order + /// in Orderable data types: + /// + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub data_split_column: std::string::String, + + /// The strategy to determine learn rate for the current iteration. + pub learn_rate_strategy: crate::model::model::LearnRateStrategy, + + /// Specifies the initial learning rate for the line search learn rate + /// strategy. + pub initial_learn_rate: f64, + + /// Weights associated with each label class, for rebalancing the + /// training data. Only applicable for classification models. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub label_class_weights: std::collections::HashMap, + + /// User column specified for matrix factorization models. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub user_column: std::string::String, + + /// Item column specified for matrix factorization models. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub item_column: std::string::String, + + /// Distance type for clustering models. + pub distance_type: crate::model::model::DistanceType, + + /// Number of clusters for clustering models. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub num_clusters: i64, + + /// Google Cloud Storage URI from which the model was imported. Only + /// applicable for imported models. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub model_uri: std::string::String, + + /// Optimization strategy for training linear regression models. + pub optimization_strategy: crate::model::model::OptimizationStrategy, + + /// Hidden units for dnn models. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + #[serde_as(as = "std::vec::Vec")] + pub hidden_units: std::vec::Vec, + + /// Batch size for dnn models. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub batch_size: i64, + + /// Dropout probability for dnn models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dropout: std::option::Option, + + /// Maximum depth of a tree for boosted tree models. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub max_tree_depth: i64, + + /// Subsample fraction of the training data to grow tree to prevent + /// overfitting for boosted tree models. + pub subsample: f64, + + /// Minimum split loss for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub min_split_loss: std::option::Option, + + /// Booster type for boosted tree models. + pub booster_type: crate::model::model::boosted_tree_option_enums::BoosterType, + + /// Number of parallel trees constructed during each iteration for boosted + /// tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_parallel_tree: std::option::Option, + + /// Type of normalization algorithm for boosted tree models using + /// dart booster. + pub dart_normalize_type: + crate::model::model::boosted_tree_option_enums::DartNormalizeType, + + /// Tree construction algorithm for boosted tree models. + pub tree_method: crate::model::model::boosted_tree_option_enums::TreeMethod, + + /// Minimum sum of instance weight needed in a child for boosted tree + /// models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub min_tree_child_weight: std::option::Option, + + /// Subsample ratio of columns when constructing each tree for boosted tree + /// models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub colsample_bytree: std::option::Option, + + /// Subsample ratio of columns for each level for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub colsample_bylevel: std::option::Option, + + /// Subsample ratio of columns for each node(split) for boosted tree + /// models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub colsample_bynode: std::option::Option, + + /// Num factors specified for matrix factorization models. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub num_factors: i64, + + /// Feedback type that specifies which algorithm to run for matrix + /// factorization. + pub feedback_type: crate::model::model::FeedbackType, + + /// Hyperparameter for matrix factoration when implicit feedback type is + /// specified. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub wals_alpha: std::option::Option, + + /// The method used to initialize the centroids for kmeans algorithm. + pub kmeans_initialization_method: + crate::model::model::kmeans_enums::KmeansInitializationMethod, + + /// The column used to provide the initial centroids for kmeans algorithm + /// when kmeans_initialization_method is CUSTOM. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub kmeans_initialization_column: std::string::String, + + /// Column to be designated as time series timestamp for ARIMA model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub time_series_timestamp_column: std::string::String, + + /// Column to be designated as time series data for ARIMA model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub time_series_data_column: std::string::String, + + /// Whether to enable auto ARIMA or not. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub auto_arima: std::option::Option, + + /// A specification of the non-seasonal part of the ARIMA model: the three + /// components (p, d, q) are the AR order, the degree of differencing, and + /// the MA order. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub non_seasonal_order: std::option::Option, + + /// The data frequency of a time series. + pub data_frequency: crate::model::model::DataFrequency, + + /// Whether or not p-value test should be computed for this model. Only + /// available for linear and logistic regression models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub calculate_p_values: std::option::Option, + + /// Include drift when fitting an ARIMA model. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub include_drift: std::option::Option, + + /// The geographical region based on which the holidays are considered in + /// time series modeling. If a valid value is specified, then holiday + /// effects modeling is enabled. + pub holiday_region: crate::model::model::HolidayRegion, + + /// A list of geographical regions that are used for time series modeling. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub holiday_regions: std::vec::Vec, + + /// The time series id column that was used during ARIMA model training. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub time_series_id_column: std::string::String, + + /// The time series id columns that were used during ARIMA model training. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub time_series_id_columns: std::vec::Vec, + + /// The forecast limit lower bound that was used during ARIMA model + /// training with limits. To see more details of the algorithm: + /// + pub forecast_limit_lower_bound: f64, + + /// The forecast limit upper bound that was used during ARIMA model + /// training with limits. + pub forecast_limit_upper_bound: f64, + + /// The number of periods ahead that need to be forecasted. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub horizon: i64, + + /// The max value of the sum of non-seasonal p and q. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub auto_arima_max_order: i64, + + /// The min value of the sum of non-seasonal p and q. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub auto_arima_min_order: i64, + + /// Number of trials to run this hyperparameter tuning job. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub num_trials: i64, + + /// Maximum number of trials to run in parallel. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub max_parallel_trials: i64, + + /// The target evaluation metrics to optimize the hyperparameters for. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub hparam_tuning_objectives: + std::vec::Vec, + + /// If true, perform decompose time series and save the results. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub decompose_time_series: std::option::Option, + + /// If true, clean spikes and dips in the input time series. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub clean_spikes_and_dips: std::option::Option, + + /// If true, detect step changes and make data adjustment in the input time + /// series. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub adjust_step_changes: std::option::Option, + + /// If true, enable global explanation during training. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub enable_global_explain: std::option::Option, + + /// Number of paths for the sampled Shapley explain method. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub sampled_shapley_num_paths: i64, + + /// Number of integral steps for the integrated gradients explain method. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub integrated_gradients_num_steps: i64, + + /// Categorical feature encoding method. + pub category_encoding_method: + crate::model::model::category_encoding_method::EncodingMethod, + + /// Based on the selected TF version, the corresponding docker image is + /// used to train external models. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub tf_version: std::string::String, + + /// Enums for color space, used for processing images in Object Table. + /// See more details at + /// . + pub color_space: crate::model::model::ColorSpace, + + /// Name of the instance weight column for training data. + /// This column isn't be used as a feature. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub instance_weight_column: std::string::String, + + /// Smoothing window size for the trend component. When a positive value is + /// specified, a center moving average smoothing is applied on the history + /// trend. When the smoothing window is out of the boundary at the + /// beginning or the end of the trend, the first element or the last + /// element is padded to fill the smoothing window before the average is + /// applied. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub trend_smoothing_window_size: i64, + + /// The fraction of the interpolated length of the time series that's used + /// to model the time series trend component. All of the time points of the + /// time series are used to model the non-trend component. This training + /// option accelerates modeling training without sacrificing much + /// forecasting accuracy. You can use this option with + /// `minTimeSeriesLength` but not with `maxTimeSeriesLength`. + pub time_series_length_fraction: f64, + + /// The minimum number of time points in a time series that are used in + /// modeling the trend component of the time series. If you use this option + /// you must also set the `timeSeriesLengthFraction` option. This training + /// option ensures that enough time points are available when you use + /// `timeSeriesLengthFraction` in trend modeling. This is particularly + /// important when forecasting multiple time series in a single query using + /// `timeSeriesIdColumn`. If the total number of time points is less than + /// the `minTimeSeriesLength` value, then the query uses all available time + /// points. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub min_time_series_length: i64, + + /// The maximum number of time points in a time series that can be used in + /// modeling the trend component of the time series. Don't use this option + /// with the `timeSeriesLengthFraction` or `minTimeSeriesLength` options. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub max_time_series_length: i64, + + /// User-selected XGBoost versions for training of XGBoost models. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub xgboost_version: std::string::String, + + /// Whether to use approximate feature contribution method in XGBoost model + /// explanation for global explain. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub approx_global_feature_contrib: std::option::Option, + + /// Whether the model should include intercept during model training. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub fit_intercept: std::option::Option, + + /// Number of principal components to keep in the PCA model. Must be <= the + /// number of features. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub num_principal_components: i64, + + /// The minimum ratio of cumulative explained variance that needs to be + /// given by the PCA model. + pub pca_explained_variance_ratio: f64, + + /// If true, scale the feature values by dividing the feature standard + /// deviation. Currently only apply to PCA. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub scale_features: std::option::Option, + + /// The solver for PCA. + pub pca_solver: crate::model::model::pca_solver_option_enums::PcaSolver, + + /// Whether to calculate class weights automatically based on the + /// popularity of each label. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub auto_class_weights: std::option::Option, + + /// Activation function of the neural nets. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub activation_fn: std::string::String, + + /// Optimizer used for training the neural nets. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub optimizer: std::string::String, + + /// Budget in hours for AutoML training. + pub budget_hours: f64, + + /// Whether to standardize numerical features. Default to true. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub standardize_features: std::option::Option, + + /// L1 regularization coefficient to activations. + pub l1_reg_activation: f64, + + /// The model registry. + pub model_registry: crate::model::model::model_registry_option_enums::ModelRegistry, + + /// The version aliases to apply in Vertex AI model registry. Always + /// overwrite if the version aliases exists in a existing model. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub vertex_ai_model_version_aliases: std::vec::Vec, + + /// Optional. Names of the columns to slice on. Applies to contribution + /// analysis models. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub dimension_id_columns: std::vec::Vec, + + /// The contribution metric. Applies to contribution analysis models. + /// Allowed formats supported are for summable and summable ratio + /// contribution metrics. These include expressions such as `SUM(x)` or + /// `SUM(x)/SUM(y)`, where x and y are column names from the base table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub contribution_metric: std::option::Option, + + /// Name of the column used to determine the rows corresponding to control + /// and test. Applies to contribution analysis models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub is_test_column: std::option::Option, + + /// The apriori support minimum. Applies to contribution analysis models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub min_apriori_support: std::option::Option, + } + + impl TrainingOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [max_iterations][crate::model::model::training_run::TrainingOptions::max_iterations]. + pub fn set_max_iterations>(mut self, v: T) -> Self { + self.max_iterations = v.into(); + self + } + + /// Sets the value of [loss_type][crate::model::model::training_run::TrainingOptions::loss_type]. + pub fn set_loss_type>( + mut self, + v: T, + ) -> Self { + self.loss_type = v.into(); + self + } + + /// Sets the value of [learn_rate][crate::model::model::training_run::TrainingOptions::learn_rate]. + pub fn set_learn_rate>(mut self, v: T) -> Self { + self.learn_rate = v.into(); + self + } + + /// Sets the value of [l1_regularization][crate::model::model::training_run::TrainingOptions::l1_regularization]. + pub fn set_l1_regularization< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.l1_regularization = v.into(); + self + } + + /// Sets the value of [l2_regularization][crate::model::model::training_run::TrainingOptions::l2_regularization]. + pub fn set_l2_regularization< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.l2_regularization = v.into(); + self + } + + /// Sets the value of [min_relative_progress][crate::model::model::training_run::TrainingOptions::min_relative_progress]. + pub fn set_min_relative_progress< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.min_relative_progress = v.into(); + self + } + + /// Sets the value of [warm_start][crate::model::model::training_run::TrainingOptions::warm_start]. + pub fn set_warm_start>>( + mut self, + v: T, + ) -> Self { + self.warm_start = v.into(); + self + } + + /// Sets the value of [early_stop][crate::model::model::training_run::TrainingOptions::early_stop]. + pub fn set_early_stop>>( + mut self, + v: T, + ) -> Self { + self.early_stop = v.into(); + self + } + + /// Sets the value of [data_split_method][crate::model::model::training_run::TrainingOptions::data_split_method]. + pub fn set_data_split_method< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.data_split_method = v.into(); + self + } + + /// Sets the value of [data_split_eval_fraction][crate::model::model::training_run::TrainingOptions::data_split_eval_fraction]. + pub fn set_data_split_eval_fraction>( + mut self, + v: T, + ) -> Self { + self.data_split_eval_fraction = v.into(); + self + } + + /// Sets the value of [data_split_column][crate::model::model::training_run::TrainingOptions::data_split_column]. + pub fn set_data_split_column>( + mut self, + v: T, + ) -> Self { + self.data_split_column = v.into(); + self + } + + /// Sets the value of [learn_rate_strategy][crate::model::model::training_run::TrainingOptions::learn_rate_strategy]. + pub fn set_learn_rate_strategy< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.learn_rate_strategy = v.into(); + self + } + + /// Sets the value of [initial_learn_rate][crate::model::model::training_run::TrainingOptions::initial_learn_rate]. + pub fn set_initial_learn_rate>(mut self, v: T) -> Self { + self.initial_learn_rate = v.into(); + self + } + + /// Sets the value of [user_column][crate::model::model::training_run::TrainingOptions::user_column]. + pub fn set_user_column>( + mut self, + v: T, + ) -> Self { + self.user_column = v.into(); + self + } + + /// Sets the value of [item_column][crate::model::model::training_run::TrainingOptions::item_column]. + pub fn set_item_column>( + mut self, + v: T, + ) -> Self { + self.item_column = v.into(); + self + } + + /// Sets the value of [distance_type][crate::model::model::training_run::TrainingOptions::distance_type]. + pub fn set_distance_type>( + mut self, + v: T, + ) -> Self { + self.distance_type = v.into(); + self + } + + /// Sets the value of [num_clusters][crate::model::model::training_run::TrainingOptions::num_clusters]. + pub fn set_num_clusters>(mut self, v: T) -> Self { + self.num_clusters = v.into(); + self + } + + /// Sets the value of [model_uri][crate::model::model::training_run::TrainingOptions::model_uri]. + pub fn set_model_uri>( + mut self, + v: T, + ) -> Self { + self.model_uri = v.into(); + self + } + + /// Sets the value of [optimization_strategy][crate::model::model::training_run::TrainingOptions::optimization_strategy]. + pub fn set_optimization_strategy< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.optimization_strategy = v.into(); + self + } + + /// Sets the value of [batch_size][crate::model::model::training_run::TrainingOptions::batch_size]. + pub fn set_batch_size>(mut self, v: T) -> Self { + self.batch_size = v.into(); + self + } + + /// Sets the value of [dropout][crate::model::model::training_run::TrainingOptions::dropout]. + pub fn set_dropout>>( + mut self, + v: T, + ) -> Self { + self.dropout = v.into(); + self + } + + /// Sets the value of [max_tree_depth][crate::model::model::training_run::TrainingOptions::max_tree_depth]. + pub fn set_max_tree_depth>(mut self, v: T) -> Self { + self.max_tree_depth = v.into(); + self + } + + /// Sets the value of [subsample][crate::model::model::training_run::TrainingOptions::subsample]. + pub fn set_subsample>(mut self, v: T) -> Self { + self.subsample = v.into(); + self + } + + /// Sets the value of [min_split_loss][crate::model::model::training_run::TrainingOptions::min_split_loss]. + pub fn set_min_split_loss< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.min_split_loss = v.into(); + self + } + + /// Sets the value of [booster_type][crate::model::model::training_run::TrainingOptions::booster_type]. + pub fn set_booster_type< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.booster_type = v.into(); + self + } + + /// Sets the value of [num_parallel_tree][crate::model::model::training_run::TrainingOptions::num_parallel_tree]. + pub fn set_num_parallel_tree< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_parallel_tree = v.into(); + self + } + + /// Sets the value of [dart_normalize_type][crate::model::model::training_run::TrainingOptions::dart_normalize_type]. + pub fn set_dart_normalize_type< + T: std::convert::Into< + crate::model::model::boosted_tree_option_enums::DartNormalizeType, + >, + >( + mut self, + v: T, + ) -> Self { + self.dart_normalize_type = v.into(); + self + } + + /// Sets the value of [tree_method][crate::model::model::training_run::TrainingOptions::tree_method]. + pub fn set_tree_method< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.tree_method = v.into(); + self + } + + /// Sets the value of [min_tree_child_weight][crate::model::model::training_run::TrainingOptions::min_tree_child_weight]. + pub fn set_min_tree_child_weight< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.min_tree_child_weight = v.into(); + self + } + + /// Sets the value of [colsample_bytree][crate::model::model::training_run::TrainingOptions::colsample_bytree]. + pub fn set_colsample_bytree< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.colsample_bytree = v.into(); + self + } + + /// Sets the value of [colsample_bylevel][crate::model::model::training_run::TrainingOptions::colsample_bylevel]. + pub fn set_colsample_bylevel< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.colsample_bylevel = v.into(); + self + } + + /// Sets the value of [colsample_bynode][crate::model::model::training_run::TrainingOptions::colsample_bynode]. + pub fn set_colsample_bynode< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.colsample_bynode = v.into(); + self + } + + /// Sets the value of [num_factors][crate::model::model::training_run::TrainingOptions::num_factors]. + pub fn set_num_factors>(mut self, v: T) -> Self { + self.num_factors = v.into(); + self + } + + /// Sets the value of [feedback_type][crate::model::model::training_run::TrainingOptions::feedback_type]. + pub fn set_feedback_type>( + mut self, + v: T, + ) -> Self { + self.feedback_type = v.into(); + self + } + + /// Sets the value of [wals_alpha][crate::model::model::training_run::TrainingOptions::wals_alpha]. + pub fn set_wals_alpha>>( + mut self, + v: T, + ) -> Self { + self.wals_alpha = v.into(); + self + } + + /// Sets the value of [kmeans_initialization_method][crate::model::model::training_run::TrainingOptions::kmeans_initialization_method]. + pub fn set_kmeans_initialization_method< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.kmeans_initialization_method = v.into(); + self + } + + /// Sets the value of [kmeans_initialization_column][crate::model::model::training_run::TrainingOptions::kmeans_initialization_column]. + pub fn set_kmeans_initialization_column>( + mut self, + v: T, + ) -> Self { + self.kmeans_initialization_column = v.into(); + self + } + + /// Sets the value of [time_series_timestamp_column][crate::model::model::training_run::TrainingOptions::time_series_timestamp_column]. + pub fn set_time_series_timestamp_column>( + mut self, + v: T, + ) -> Self { + self.time_series_timestamp_column = v.into(); + self + } + + /// Sets the value of [time_series_data_column][crate::model::model::training_run::TrainingOptions::time_series_data_column]. + pub fn set_time_series_data_column>( + mut self, + v: T, + ) -> Self { + self.time_series_data_column = v.into(); + self + } + + /// Sets the value of [auto_arima][crate::model::model::training_run::TrainingOptions::auto_arima]. + pub fn set_auto_arima>>( + mut self, + v: T, + ) -> Self { + self.auto_arima = v.into(); + self + } + + /// Sets the value of [non_seasonal_order][crate::model::model::training_run::TrainingOptions::non_seasonal_order]. + pub fn set_non_seasonal_order< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.non_seasonal_order = v.into(); + self + } + + /// Sets the value of [data_frequency][crate::model::model::training_run::TrainingOptions::data_frequency]. + pub fn set_data_frequency>( + mut self, + v: T, + ) -> Self { + self.data_frequency = v.into(); + self + } + + /// Sets the value of [calculate_p_values][crate::model::model::training_run::TrainingOptions::calculate_p_values]. + pub fn set_calculate_p_values< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.calculate_p_values = v.into(); + self + } + + /// Sets the value of [include_drift][crate::model::model::training_run::TrainingOptions::include_drift]. + pub fn set_include_drift>>( + mut self, + v: T, + ) -> Self { + self.include_drift = v.into(); + self + } + + /// Sets the value of [holiday_region][crate::model::model::training_run::TrainingOptions::holiday_region]. + pub fn set_holiday_region>( + mut self, + v: T, + ) -> Self { + self.holiday_region = v.into(); + self + } + + /// Sets the value of [time_series_id_column][crate::model::model::training_run::TrainingOptions::time_series_id_column]. + pub fn set_time_series_id_column>( + mut self, + v: T, + ) -> Self { + self.time_series_id_column = v.into(); + self + } + + /// Sets the value of [forecast_limit_lower_bound][crate::model::model::training_run::TrainingOptions::forecast_limit_lower_bound]. + pub fn set_forecast_limit_lower_bound>( + mut self, + v: T, + ) -> Self { + self.forecast_limit_lower_bound = v.into(); + self + } + + /// Sets the value of [forecast_limit_upper_bound][crate::model::model::training_run::TrainingOptions::forecast_limit_upper_bound]. + pub fn set_forecast_limit_upper_bound>( + mut self, + v: T, + ) -> Self { + self.forecast_limit_upper_bound = v.into(); + self + } + + /// Sets the value of [horizon][crate::model::model::training_run::TrainingOptions::horizon]. + pub fn set_horizon>(mut self, v: T) -> Self { + self.horizon = v.into(); + self + } + + /// Sets the value of [auto_arima_max_order][crate::model::model::training_run::TrainingOptions::auto_arima_max_order]. + pub fn set_auto_arima_max_order>(mut self, v: T) -> Self { + self.auto_arima_max_order = v.into(); + self + } + + /// Sets the value of [auto_arima_min_order][crate::model::model::training_run::TrainingOptions::auto_arima_min_order]. + pub fn set_auto_arima_min_order>(mut self, v: T) -> Self { + self.auto_arima_min_order = v.into(); + self + } + + /// Sets the value of [num_trials][crate::model::model::training_run::TrainingOptions::num_trials]. + pub fn set_num_trials>(mut self, v: T) -> Self { + self.num_trials = v.into(); + self + } + + /// Sets the value of [max_parallel_trials][crate::model::model::training_run::TrainingOptions::max_parallel_trials]. + pub fn set_max_parallel_trials>(mut self, v: T) -> Self { + self.max_parallel_trials = v.into(); + self + } + + /// Sets the value of [decompose_time_series][crate::model::model::training_run::TrainingOptions::decompose_time_series]. + pub fn set_decompose_time_series< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.decompose_time_series = v.into(); + self + } + + /// Sets the value of [clean_spikes_and_dips][crate::model::model::training_run::TrainingOptions::clean_spikes_and_dips]. + pub fn set_clean_spikes_and_dips< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.clean_spikes_and_dips = v.into(); + self + } + + /// Sets the value of [adjust_step_changes][crate::model::model::training_run::TrainingOptions::adjust_step_changes]. + pub fn set_adjust_step_changes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.adjust_step_changes = v.into(); + self + } + + /// Sets the value of [enable_global_explain][crate::model::model::training_run::TrainingOptions::enable_global_explain]. + pub fn set_enable_global_explain< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.enable_global_explain = v.into(); + self + } + + /// Sets the value of [sampled_shapley_num_paths][crate::model::model::training_run::TrainingOptions::sampled_shapley_num_paths]. + pub fn set_sampled_shapley_num_paths>( + mut self, + v: T, + ) -> Self { + self.sampled_shapley_num_paths = v.into(); + self + } + + /// Sets the value of [integrated_gradients_num_steps][crate::model::model::training_run::TrainingOptions::integrated_gradients_num_steps]. + pub fn set_integrated_gradients_num_steps>( + mut self, + v: T, + ) -> Self { + self.integrated_gradients_num_steps = v.into(); + self + } + + /// Sets the value of [category_encoding_method][crate::model::model::training_run::TrainingOptions::category_encoding_method]. + pub fn set_category_encoding_method< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.category_encoding_method = v.into(); + self + } + + /// Sets the value of [tf_version][crate::model::model::training_run::TrainingOptions::tf_version]. + pub fn set_tf_version>( + mut self, + v: T, + ) -> Self { + self.tf_version = v.into(); + self + } + + /// Sets the value of [color_space][crate::model::model::training_run::TrainingOptions::color_space]. + pub fn set_color_space>( + mut self, + v: T, + ) -> Self { + self.color_space = v.into(); + self + } + + /// Sets the value of [instance_weight_column][crate::model::model::training_run::TrainingOptions::instance_weight_column]. + pub fn set_instance_weight_column>( + mut self, + v: T, + ) -> Self { + self.instance_weight_column = v.into(); + self + } + + /// Sets the value of [trend_smoothing_window_size][crate::model::model::training_run::TrainingOptions::trend_smoothing_window_size]. + pub fn set_trend_smoothing_window_size>( + mut self, + v: T, + ) -> Self { + self.trend_smoothing_window_size = v.into(); + self + } + + /// Sets the value of [time_series_length_fraction][crate::model::model::training_run::TrainingOptions::time_series_length_fraction]. + pub fn set_time_series_length_fraction>( + mut self, + v: T, + ) -> Self { + self.time_series_length_fraction = v.into(); + self + } + + /// Sets the value of [min_time_series_length][crate::model::model::training_run::TrainingOptions::min_time_series_length]. + pub fn set_min_time_series_length>(mut self, v: T) -> Self { + self.min_time_series_length = v.into(); + self + } + + /// Sets the value of [max_time_series_length][crate::model::model::training_run::TrainingOptions::max_time_series_length]. + pub fn set_max_time_series_length>(mut self, v: T) -> Self { + self.max_time_series_length = v.into(); + self + } + + /// Sets the value of [xgboost_version][crate::model::model::training_run::TrainingOptions::xgboost_version]. + pub fn set_xgboost_version>( + mut self, + v: T, + ) -> Self { + self.xgboost_version = v.into(); + self + } + + /// Sets the value of [approx_global_feature_contrib][crate::model::model::training_run::TrainingOptions::approx_global_feature_contrib]. + pub fn set_approx_global_feature_contrib< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.approx_global_feature_contrib = v.into(); + self + } + + /// Sets the value of [fit_intercept][crate::model::model::training_run::TrainingOptions::fit_intercept]. + pub fn set_fit_intercept>>( + mut self, + v: T, + ) -> Self { + self.fit_intercept = v.into(); + self + } + + /// Sets the value of [num_principal_components][crate::model::model::training_run::TrainingOptions::num_principal_components]. + pub fn set_num_principal_components>( + mut self, + v: T, + ) -> Self { + self.num_principal_components = v.into(); + self + } + + /// Sets the value of [pca_explained_variance_ratio][crate::model::model::training_run::TrainingOptions::pca_explained_variance_ratio]. + pub fn set_pca_explained_variance_ratio>( + mut self, + v: T, + ) -> Self { + self.pca_explained_variance_ratio = v.into(); + self + } + + /// Sets the value of [scale_features][crate::model::model::training_run::TrainingOptions::scale_features]. + pub fn set_scale_features< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.scale_features = v.into(); + self + } + + /// Sets the value of [pca_solver][crate::model::model::training_run::TrainingOptions::pca_solver]. + pub fn set_pca_solver< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.pca_solver = v.into(); + self + } + + /// Sets the value of [auto_class_weights][crate::model::model::training_run::TrainingOptions::auto_class_weights]. + pub fn set_auto_class_weights< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.auto_class_weights = v.into(); + self + } + + /// Sets the value of [activation_fn][crate::model::model::training_run::TrainingOptions::activation_fn]. + pub fn set_activation_fn>( + mut self, + v: T, + ) -> Self { + self.activation_fn = v.into(); + self + } + + /// Sets the value of [optimizer][crate::model::model::training_run::TrainingOptions::optimizer]. + pub fn set_optimizer>( + mut self, + v: T, + ) -> Self { + self.optimizer = v.into(); + self + } + + /// Sets the value of [budget_hours][crate::model::model::training_run::TrainingOptions::budget_hours]. + pub fn set_budget_hours>(mut self, v: T) -> Self { + self.budget_hours = v.into(); + self + } + + /// Sets the value of [standardize_features][crate::model::model::training_run::TrainingOptions::standardize_features]. + pub fn set_standardize_features< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.standardize_features = v.into(); + self + } + + /// Sets the value of [l1_reg_activation][crate::model::model::training_run::TrainingOptions::l1_reg_activation]. + pub fn set_l1_reg_activation>(mut self, v: T) -> Self { + self.l1_reg_activation = v.into(); + self + } + + /// Sets the value of [model_registry][crate::model::model::training_run::TrainingOptions::model_registry]. + pub fn set_model_registry< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.model_registry = v.into(); + self + } + + /// Sets the value of [contribution_metric][crate::model::model::training_run::TrainingOptions::contribution_metric]. + pub fn set_contribution_metric< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.contribution_metric = v.into(); + self + } + + /// Sets the value of [is_test_column][crate::model::model::training_run::TrainingOptions::is_test_column]. + pub fn set_is_test_column< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.is_test_column = v.into(); + self + } + + /// Sets the value of [min_apriori_support][crate::model::model::training_run::TrainingOptions::min_apriori_support]. + pub fn set_min_apriori_support>>( + mut self, + v: T, + ) -> Self { + self.min_apriori_support = v.into(); + self + } + + /// Sets the value of [input_label_columns][crate::model::model::training_run::TrainingOptions::input_label_columns]. + pub fn set_input_label_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.input_label_columns = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [hidden_units][crate::model::model::training_run::TrainingOptions::hidden_units]. + pub fn set_hidden_units(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.hidden_units = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [holiday_regions][crate::model::model::training_run::TrainingOptions::holiday_regions]. + pub fn set_holiday_regions(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.holiday_regions = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [time_series_id_columns][crate::model::model::training_run::TrainingOptions::time_series_id_columns]. + pub fn set_time_series_id_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.time_series_id_columns = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [hparam_tuning_objectives][crate::model::model::training_run::TrainingOptions::hparam_tuning_objectives]. + pub fn set_hparam_tuning_objectives(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::hparam_tuning_enums::HparamTuningObjective, + >, + { + use std::iter::Iterator; + self.hparam_tuning_objectives = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [vertex_ai_model_version_aliases][crate::model::model::training_run::TrainingOptions::vertex_ai_model_version_aliases]. + pub fn set_vertex_ai_model_version_aliases(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.vertex_ai_model_version_aliases = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [dimension_id_columns][crate::model::model::training_run::TrainingOptions::dimension_id_columns]. + pub fn set_dimension_id_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.dimension_id_columns = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [label_class_weights][crate::model::model::training_run::TrainingOptions::label_class_weights]. + pub fn set_label_class_weights(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.label_class_weights = + v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } + } + + impl wkt::message::Message for TrainingOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.TrainingRun.TrainingOptions" + } + } + + /// Information about a single iteration of the training run. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct IterationResult { + /// Index of the iteration, 0 based. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub index: std::option::Option, + + /// Time taken to run the iteration in milliseconds. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub duration_ms: std::option::Option, + + /// Loss computed on the training data at the end of iteration. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub training_loss: std::option::Option, + + /// Loss computed on the eval data at the end of iteration. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub eval_loss: std::option::Option, + + /// Learn rate used for this iteration. + pub learn_rate: f64, + + /// Information about top clusters for clustering models. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub cluster_infos: + std::vec::Vec, + + /// Arima result. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub arima_result: std::option::Option< + crate::model::model::training_run::iteration_result::ArimaResult, + >, + + /// The information of the principal components. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub principal_component_infos: std::vec::Vec< + crate::model::model::training_run::iteration_result::PrincipalComponentInfo, + >, + } + + impl IterationResult { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [index][crate::model::model::training_run::IterationResult::index]. + pub fn set_index>>( + mut self, + v: T, + ) -> Self { + self.index = v.into(); + self + } + + /// Sets the value of [duration_ms][crate::model::model::training_run::IterationResult::duration_ms]. + pub fn set_duration_ms>>( + mut self, + v: T, + ) -> Self { + self.duration_ms = v.into(); + self + } + + /// Sets the value of [training_loss][crate::model::model::training_run::IterationResult::training_loss]. + pub fn set_training_loss< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.training_loss = v.into(); + self + } + + /// Sets the value of [eval_loss][crate::model::model::training_run::IterationResult::eval_loss]. + pub fn set_eval_loss>>( + mut self, + v: T, + ) -> Self { + self.eval_loss = v.into(); + self + } + + /// Sets the value of [learn_rate][crate::model::model::training_run::IterationResult::learn_rate]. + pub fn set_learn_rate>(mut self, v: T) -> Self { + self.learn_rate = v.into(); + self + } + + /// Sets the value of [arima_result][crate::model::model::training_run::IterationResult::arima_result]. + pub fn set_arima_result< + T: std::convert::Into< + std::option::Option< + crate::model::model::training_run::iteration_result::ArimaResult, + >, + >, + >( + mut self, + v: T, + ) -> Self { + self.arima_result = v.into(); + self + } + + /// Sets the value of [cluster_infos][crate::model::model::training_run::IterationResult::cluster_infos]. + pub fn set_cluster_infos(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::training_run::iteration_result::ClusterInfo, + >, + { + use std::iter::Iterator; + self.cluster_infos = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [principal_component_infos][crate::model::model::training_run::IterationResult::principal_component_infos]. + pub fn set_principal_component_infos(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::training_run::iteration_result::PrincipalComponentInfo, + >, + { + use std::iter::Iterator; + self.principal_component_infos = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for IterationResult { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.TrainingRun.IterationResult" + } + } + + /// Defines additional types related to IterationResult + pub mod iteration_result { + #[allow(unused_imports)] + use super::*; + + /// Information about a single cluster for clustering model. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ClusterInfo { + /// Centroid id. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub centroid_id: i64, + + /// Cluster radius, the average distance from centroid + /// to each point assigned to the cluster. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub cluster_radius: std::option::Option, + + /// Cluster size, the total number of points assigned to the cluster. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub cluster_size: std::option::Option, + } + + impl ClusterInfo { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [centroid_id][crate::model::model::training_run::iteration_result::ClusterInfo::centroid_id]. + pub fn set_centroid_id>(mut self, v: T) -> Self { + self.centroid_id = v.into(); + self + } + + /// Sets the value of [cluster_radius][crate::model::model::training_run::iteration_result::ClusterInfo::cluster_radius]. + pub fn set_cluster_radius< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.cluster_radius = v.into(); + self + } + + /// Sets the value of [cluster_size][crate::model::model::training_run::iteration_result::ClusterInfo::cluster_size]. + pub fn set_cluster_size< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.cluster_size = v.into(); + self + } + } + + impl wkt::message::Message for ClusterInfo { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.TrainingRun.IterationResult.ClusterInfo" + } + } + + /// (Auto-)arima fitting result. Wrap everything in ArimaResult for easier + /// refactoring if we want to use model-specific iteration results. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ArimaResult { + + /// This message is repeated because there are multiple arima models + /// fitted in auto-arima. For non-auto-arima model, its size is one. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub arima_model_info: std::vec::Vec, + + /// Seasonal periods. Repeated because multiple periods are supported for + /// one time series. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub seasonal_periods: std::vec::Vec, + } + + impl ArimaResult { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [arima_model_info][crate::model::model::training_run::iteration_result::ArimaResult::arima_model_info]. + pub fn set_arima_model_info(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into + { + use std::iter::Iterator; + self.arima_model_info = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [seasonal_periods][crate::model::model::training_run::iteration_result::ArimaResult::seasonal_periods]. + pub fn set_seasonal_periods(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.seasonal_periods = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for ArimaResult { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.TrainingRun.IterationResult.ArimaResult" + } + } + + /// Defines additional types related to ArimaResult + pub mod arima_result { + #[allow(unused_imports)] + use super::*; + + /// Arima coefficients. + #[serde_with::serde_as] + #[derive( + Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize, + )] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ArimaCoefficients { + /// Auto-regressive coefficients, an array of double. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub auto_regressive_coefficients: std::vec::Vec, + + /// Moving-average coefficients, an array of double. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub moving_average_coefficients: std::vec::Vec, + + /// Intercept coefficient, just a double not an array. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub intercept_coefficient: std::option::Option, + } + + impl ArimaCoefficients { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [intercept_coefficient][crate::model::model::training_run::iteration_result::arima_result::ArimaCoefficients::intercept_coefficient]. + pub fn set_intercept_coefficient< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.intercept_coefficient = v.into(); + self + } + + /// Sets the value of [auto_regressive_coefficients][crate::model::model::training_run::iteration_result::arima_result::ArimaCoefficients::auto_regressive_coefficients]. + pub fn set_auto_regressive_coefficients(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.auto_regressive_coefficients = + v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [moving_average_coefficients][crate::model::model::training_run::iteration_result::arima_result::ArimaCoefficients::moving_average_coefficients]. + pub fn set_moving_average_coefficients(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.moving_average_coefficients = + v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for ArimaCoefficients { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.TrainingRun.IterationResult.ArimaResult.ArimaCoefficients" + } + } + + /// Arima model information. + #[serde_with::serde_as] + #[derive( + Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize, + )] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct ArimaModelInfo { + + /// Non-seasonal order. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub non_seasonal_order: std::option::Option, + + /// Arima coefficients. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub arima_coefficients: std::option::Option, + + /// Arima fitting metrics. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub arima_fitting_metrics: std::option::Option, + + /// Whether Arima model fitted with drift or not. It is always false + /// when d is not 1. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub has_drift: std::option::Option, + + /// The time_series_id value for this time series. It will be one of + /// the unique values from the time_series_id_column specified during + /// ARIMA model training. Only present when time_series_id_column + /// training option was used. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub time_series_id: std::string::String, + + /// The tuple of time_series_ids identifying this time series. It will + /// be one of the unique tuples of values present in the + /// time_series_id_columns specified during ARIMA model training. Only + /// present when time_series_id_columns training option was used and + /// the order of values here are same as the order of + /// time_series_id_columns. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub time_series_ids: std::vec::Vec, + + /// Seasonal periods. Repeated because multiple periods are supported + /// for one time series. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub seasonal_periods: std::vec::Vec, + + /// If true, holiday_effect is a part of time series decomposition + /// result. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub has_holiday_effect: std::option::Option, + + /// If true, spikes_and_dips is a part of time series decomposition + /// result. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub has_spikes_and_dips: std::option::Option, + + /// If true, step_changes is a part of time series decomposition + /// result. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub has_step_changes: std::option::Option, + } + + impl ArimaModelInfo { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [non_seasonal_order][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::non_seasonal_order]. + pub fn set_non_seasonal_order< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.non_seasonal_order = v.into(); + self + } + + /// Sets the value of [arima_coefficients][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::arima_coefficients]. + pub fn set_arima_coefficients>>(mut self, v: T) -> Self{ + self.arima_coefficients = v.into(); + self + } + + /// Sets the value of [arima_fitting_metrics][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::arima_fitting_metrics]. + pub fn set_arima_fitting_metrics< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.arima_fitting_metrics = v.into(); + self + } + + /// Sets the value of [has_drift][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::has_drift]. + pub fn set_has_drift< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.has_drift = v.into(); + self + } + + /// Sets the value of [time_series_id][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::time_series_id]. + pub fn set_time_series_id>( + mut self, + v: T, + ) -> Self { + self.time_series_id = v.into(); + self + } + + /// Sets the value of [has_holiday_effect][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::has_holiday_effect]. + pub fn set_has_holiday_effect< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.has_holiday_effect = v.into(); + self + } + + /// Sets the value of [has_spikes_and_dips][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::has_spikes_and_dips]. + pub fn set_has_spikes_and_dips< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.has_spikes_and_dips = v.into(); + self + } + + /// Sets the value of [has_step_changes][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::has_step_changes]. + pub fn set_has_step_changes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.has_step_changes = v.into(); + self + } + + /// Sets the value of [time_series_ids][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::time_series_ids]. + pub fn set_time_series_ids(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.time_series_ids = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [seasonal_periods][crate::model::model::training_run::iteration_result::arima_result::ArimaModelInfo::seasonal_periods]. + pub fn set_seasonal_periods(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into< + crate::model::model::seasonal_period::SeasonalPeriodType, + >, + { + use std::iter::Iterator; + self.seasonal_periods = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for ArimaModelInfo { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.TrainingRun.IterationResult.ArimaResult.ArimaModelInfo" + } + } + } + + /// Principal component infos, used only for eigen decomposition based + /// models, e.g., PCA. Ordered by explained_variance in the descending + /// order. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct PrincipalComponentInfo { + /// Id of the principal component. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub principal_component_id: std::option::Option, + + /// Explained variance by this principal component, which is simply the + /// eigenvalue. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub explained_variance: std::option::Option, + + /// Explained_variance over the total explained variance. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub explained_variance_ratio: std::option::Option, + + /// The explained_variance is pre-ordered in the descending order to + /// compute the cumulative explained variance ratio. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub cumulative_explained_variance_ratio: std::option::Option, + } + + impl PrincipalComponentInfo { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [principal_component_id][crate::model::model::training_run::iteration_result::PrincipalComponentInfo::principal_component_id]. + pub fn set_principal_component_id< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.principal_component_id = v.into(); + self + } + + /// Sets the value of [explained_variance][crate::model::model::training_run::iteration_result::PrincipalComponentInfo::explained_variance]. + pub fn set_explained_variance< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.explained_variance = v.into(); + self + } + + /// Sets the value of [explained_variance_ratio][crate::model::model::training_run::iteration_result::PrincipalComponentInfo::explained_variance_ratio]. + pub fn set_explained_variance_ratio< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.explained_variance_ratio = v.into(); + self + } + + /// Sets the value of [cumulative_explained_variance_ratio][crate::model::model::training_run::iteration_result::PrincipalComponentInfo::cumulative_explained_variance_ratio]. + pub fn set_cumulative_explained_variance_ratio< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.cumulative_explained_variance_ratio = v.into(); + self + } + } + + impl wkt::message::Message for PrincipalComponentInfo { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.TrainingRun.IterationResult.PrincipalComponentInfo" + } + } + } + } + + /// Search space for a double hyperparameter. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct DoubleHparamSearchSpace { + /// Search space. + #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")] + pub search_space: + std::option::Option, + } + + impl DoubleHparamSearchSpace { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of `search_space`. + pub fn set_search_space< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.search_space = v.into(); + self + } + + /// The value of [search_space][crate::model::model::DoubleHparamSearchSpace::search_space] + /// if it holds a `Range`, `None` if the field is not set or + /// holds a different branch. + pub fn get_range( + &self, + ) -> std::option::Option< + &std::boxed::Box, + > { + #[allow(unreachable_patterns)] + self.search_space.as_ref().and_then(|v| match v { + crate::model::model::double_hparam_search_space::SearchSpace::Range(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [search_space][crate::model::model::DoubleHparamSearchSpace::search_space] + /// if it holds a `Candidates`, `None` if the field is not set or + /// holds a different branch. + pub fn get_candidates( + &self, + ) -> std::option::Option< + &std::boxed::Box, + > { + #[allow(unreachable_patterns)] + self.search_space.as_ref().and_then(|v| match v { + crate::model::model::double_hparam_search_space::SearchSpace::Candidates(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// Sets the value of [search_space][crate::model::model::DoubleHparamSearchSpace::search_space] + /// to hold a `Range`. + /// + /// Note that all the setters affecting `search_space` are + /// mutually exclusive. + pub fn set_range< + T: std::convert::Into< + std::boxed::Box, + >, + >( + mut self, + v: T, + ) -> Self { + self.search_space = std::option::Option::Some( + crate::model::model::double_hparam_search_space::SearchSpace::Range(v.into()), + ); + self + } + + /// Sets the value of [search_space][crate::model::model::DoubleHparamSearchSpace::search_space] + /// to hold a `Candidates`. + /// + /// Note that all the setters affecting `search_space` are + /// mutually exclusive. + pub fn set_candidates< + T: std::convert::Into< + std::boxed::Box, + >, + >( + mut self, + v: T, + ) -> Self { + self.search_space = std::option::Option::Some( + crate::model::model::double_hparam_search_space::SearchSpace::Candidates(v.into()), + ); + self + } + } + + impl wkt::message::Message for DoubleHparamSearchSpace { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.DoubleHparamSearchSpace" + } + } + + /// Defines additional types related to DoubleHparamSearchSpace + pub mod double_hparam_search_space { + #[allow(unused_imports)] + use super::*; + + /// Range of a double hyperparameter. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct DoubleRange { + /// Min value of the double parameter. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub min: std::option::Option, + + /// Max value of the double parameter. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub max: std::option::Option, + } + + impl DoubleRange { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [min][crate::model::model::double_hparam_search_space::DoubleRange::min]. + pub fn set_min>>( + mut self, + v: T, + ) -> Self { + self.min = v.into(); + self + } + + /// Sets the value of [max][crate::model::model::double_hparam_search_space::DoubleRange::max]. + pub fn set_max>>( + mut self, + v: T, + ) -> Self { + self.max = v.into(); + self + } + } + + impl wkt::message::Message for DoubleRange { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.DoubleHparamSearchSpace.DoubleRange" + } + } + + /// Discrete candidates of a double hyperparameter. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct DoubleCandidates { + /// Candidates for the double parameter in increasing order. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub candidates: std::vec::Vec, + } + + impl DoubleCandidates { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [candidates][crate::model::model::double_hparam_search_space::DoubleCandidates::candidates]. + pub fn set_candidates(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.candidates = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for DoubleCandidates { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.DoubleHparamSearchSpace.DoubleCandidates" + } + } + + /// Search space. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(rename_all = "camelCase")] + #[non_exhaustive] + pub enum SearchSpace { + /// Range of the double hyperparameter. + Range(std::boxed::Box), + /// Candidates of the double hyperparameter. + Candidates( + std::boxed::Box, + ), + } + } + + /// Search space for an int hyperparameter. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct IntHparamSearchSpace { + /// Search space. + #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")] + pub search_space: + std::option::Option, + } + + impl IntHparamSearchSpace { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of `search_space`. + pub fn set_search_space< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.search_space = v.into(); + self + } + + /// The value of [search_space][crate::model::model::IntHparamSearchSpace::search_space] + /// if it holds a `Range`, `None` if the field is not set or + /// holds a different branch. + pub fn get_range( + &self, + ) -> std::option::Option< + &std::boxed::Box, + > { + #[allow(unreachable_patterns)] + self.search_space.as_ref().and_then(|v| match v { + crate::model::model::int_hparam_search_space::SearchSpace::Range(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [search_space][crate::model::model::IntHparamSearchSpace::search_space] + /// if it holds a `Candidates`, `None` if the field is not set or + /// holds a different branch. + pub fn get_candidates( + &self, + ) -> std::option::Option< + &std::boxed::Box, + > { + #[allow(unreachable_patterns)] + self.search_space.as_ref().and_then(|v| match v { + crate::model::model::int_hparam_search_space::SearchSpace::Candidates(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// Sets the value of [search_space][crate::model::model::IntHparamSearchSpace::search_space] + /// to hold a `Range`. + /// + /// Note that all the setters affecting `search_space` are + /// mutually exclusive. + pub fn set_range< + T: std::convert::Into< + std::boxed::Box, + >, + >( + mut self, + v: T, + ) -> Self { + self.search_space = std::option::Option::Some( + crate::model::model::int_hparam_search_space::SearchSpace::Range(v.into()), + ); + self + } + + /// Sets the value of [search_space][crate::model::model::IntHparamSearchSpace::search_space] + /// to hold a `Candidates`. + /// + /// Note that all the setters affecting `search_space` are + /// mutually exclusive. + pub fn set_candidates< + T: std::convert::Into< + std::boxed::Box, + >, + >( + mut self, + v: T, + ) -> Self { + self.search_space = std::option::Option::Some( + crate::model::model::int_hparam_search_space::SearchSpace::Candidates(v.into()), + ); + self + } + } + + impl wkt::message::Message for IntHparamSearchSpace { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.IntHparamSearchSpace" + } + } + + /// Defines additional types related to IntHparamSearchSpace + pub mod int_hparam_search_space { + #[allow(unused_imports)] + use super::*; + + /// Range of an int hyperparameter. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct IntRange { + /// Min value of the int parameter. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub min: std::option::Option, + + /// Max value of the int parameter. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub max: std::option::Option, + } + + impl IntRange { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [min][crate::model::model::int_hparam_search_space::IntRange::min]. + pub fn set_min>>( + mut self, + v: T, + ) -> Self { + self.min = v.into(); + self + } + + /// Sets the value of [max][crate::model::model::int_hparam_search_space::IntRange::max]. + pub fn set_max>>( + mut self, + v: T, + ) -> Self { + self.max = v.into(); + self + } + } + + impl wkt::message::Message for IntRange { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.IntHparamSearchSpace.IntRange" + } + } + + /// Discrete candidates of an int hyperparameter. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct IntCandidates { + /// Candidates for the int parameter in increasing order. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + #[serde_as(as = "std::vec::Vec")] + pub candidates: std::vec::Vec, + } + + impl IntCandidates { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [candidates][crate::model::model::int_hparam_search_space::IntCandidates::candidates]. + pub fn set_candidates(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.candidates = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for IntCandidates { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.IntHparamSearchSpace.IntCandidates" + } + } + + /// Search space. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(rename_all = "camelCase")] + #[non_exhaustive] + pub enum SearchSpace { + /// Range of the int hyperparameter. + Range(std::boxed::Box), + /// Candidates of the int hyperparameter. + Candidates( + std::boxed::Box, + ), + } + } + + /// Search space for string and enum. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct StringHparamSearchSpace { + /// Canididates for the string or enum parameter in lower case. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub candidates: std::vec::Vec, + } + + impl StringHparamSearchSpace { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [candidates][crate::model::model::StringHparamSearchSpace::candidates]. + pub fn set_candidates(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.candidates = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for StringHparamSearchSpace { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.StringHparamSearchSpace" + } + } + + /// Search space for int array. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct IntArrayHparamSearchSpace { + /// Candidates for the int array parameter. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub candidates: std::vec::Vec, + } + + impl IntArrayHparamSearchSpace { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [candidates][crate::model::model::IntArrayHparamSearchSpace::candidates]. + pub fn set_candidates(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.candidates = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for IntArrayHparamSearchSpace { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.IntArrayHparamSearchSpace" + } + } + + /// Defines additional types related to IntArrayHparamSearchSpace + pub mod int_array_hparam_search_space { + #[allow(unused_imports)] + use super::*; + + /// An array of int. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct IntArray { + /// Elements in the int array. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + #[serde_as(as = "std::vec::Vec")] + pub elements: std::vec::Vec, + } + + impl IntArray { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [elements][crate::model::model::int_array_hparam_search_space::IntArray::elements]. + pub fn set_elements(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.elements = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for IntArray { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.IntArrayHparamSearchSpace.IntArray" + } + } + } + + /// Hyperparameter search spaces. + /// These should be a subset of training_options. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct HparamSearchSpaces { + /// Learning rate of training jobs. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub learn_rate: std::option::Option, + + /// L1 regularization coefficient. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub l1_reg: std::option::Option, + + /// L2 regularization coefficient. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub l2_reg: std::option::Option, + + /// Number of clusters for k-means. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub num_clusters: std::option::Option, + + /// Number of latent factors to train on. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub num_factors: std::option::Option, + + /// Hidden units for neural network models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub hidden_units: std::option::Option, + + /// Mini batch sample size. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub batch_size: std::option::Option, + + /// Dropout probability for dnn model training and boosted tree models + /// using dart booster. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dropout: std::option::Option, + + /// Maximum depth of a tree for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub max_tree_depth: std::option::Option, + + /// Subsample the training data to grow tree to prevent overfitting for + /// boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub subsample: std::option::Option, + + /// Minimum split loss for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub min_split_loss: std::option::Option, + + /// Hyperparameter for matrix factoration when implicit feedback type is + /// specified. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub wals_alpha: std::option::Option, + + /// Booster type for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub booster_type: std::option::Option, + + /// Number of parallel trees for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub num_parallel_tree: std::option::Option, + + /// Dart normalization type for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub dart_normalize_type: std::option::Option, + + /// Tree construction algorithm for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub tree_method: std::option::Option, + + /// Minimum sum of instance weight needed in a child for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub min_tree_child_weight: std::option::Option, + + /// Subsample ratio of columns when constructing each tree for boosted tree + /// models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub colsample_bytree: std::option::Option, + + /// Subsample ratio of columns for each level for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub colsample_bylevel: std::option::Option, + + /// Subsample ratio of columns for each node(split) for boosted tree models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub colsample_bynode: std::option::Option, + + /// Activation functions of neural network models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub activation_fn: std::option::Option, + + /// Optimizer of TF models. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub optimizer: std::option::Option, + } + + impl HparamSearchSpaces { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [learn_rate][crate::model::model::HparamSearchSpaces::learn_rate]. + pub fn set_learn_rate< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.learn_rate = v.into(); + self + } + + /// Sets the value of [l1_reg][crate::model::model::HparamSearchSpaces::l1_reg]. + pub fn set_l1_reg< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.l1_reg = v.into(); + self + } + + /// Sets the value of [l2_reg][crate::model::model::HparamSearchSpaces::l2_reg]. + pub fn set_l2_reg< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.l2_reg = v.into(); + self + } + + /// Sets the value of [num_clusters][crate::model::model::HparamSearchSpaces::num_clusters]. + pub fn set_num_clusters< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_clusters = v.into(); + self + } + + /// Sets the value of [num_factors][crate::model::model::HparamSearchSpaces::num_factors]. + pub fn set_num_factors< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_factors = v.into(); + self + } + + /// Sets the value of [hidden_units][crate::model::model::HparamSearchSpaces::hidden_units]. + pub fn set_hidden_units< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.hidden_units = v.into(); + self + } + + /// Sets the value of [batch_size][crate::model::model::HparamSearchSpaces::batch_size]. + pub fn set_batch_size< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.batch_size = v.into(); + self + } + + /// Sets the value of [dropout][crate::model::model::HparamSearchSpaces::dropout]. + pub fn set_dropout< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.dropout = v.into(); + self + } + + /// Sets the value of [max_tree_depth][crate::model::model::HparamSearchSpaces::max_tree_depth]. + pub fn set_max_tree_depth< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.max_tree_depth = v.into(); + self + } + + /// Sets the value of [subsample][crate::model::model::HparamSearchSpaces::subsample]. + pub fn set_subsample< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.subsample = v.into(); + self + } + + /// Sets the value of [min_split_loss][crate::model::model::HparamSearchSpaces::min_split_loss]. + pub fn set_min_split_loss< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.min_split_loss = v.into(); + self + } + + /// Sets the value of [wals_alpha][crate::model::model::HparamSearchSpaces::wals_alpha]. + pub fn set_wals_alpha< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.wals_alpha = v.into(); + self + } + + /// Sets the value of [booster_type][crate::model::model::HparamSearchSpaces::booster_type]. + pub fn set_booster_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.booster_type = v.into(); + self + } + + /// Sets the value of [num_parallel_tree][crate::model::model::HparamSearchSpaces::num_parallel_tree]. + pub fn set_num_parallel_tree< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_parallel_tree = v.into(); + self + } + + /// Sets the value of [dart_normalize_type][crate::model::model::HparamSearchSpaces::dart_normalize_type]. + pub fn set_dart_normalize_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.dart_normalize_type = v.into(); + self + } + + /// Sets the value of [tree_method][crate::model::model::HparamSearchSpaces::tree_method]. + pub fn set_tree_method< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.tree_method = v.into(); + self + } + + /// Sets the value of [min_tree_child_weight][crate::model::model::HparamSearchSpaces::min_tree_child_weight]. + pub fn set_min_tree_child_weight< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.min_tree_child_weight = v.into(); + self + } + + /// Sets the value of [colsample_bytree][crate::model::model::HparamSearchSpaces::colsample_bytree]. + pub fn set_colsample_bytree< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.colsample_bytree = v.into(); + self + } + + /// Sets the value of [colsample_bylevel][crate::model::model::HparamSearchSpaces::colsample_bylevel]. + pub fn set_colsample_bylevel< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.colsample_bylevel = v.into(); + self + } + + /// Sets the value of [colsample_bynode][crate::model::model::HparamSearchSpaces::colsample_bynode]. + pub fn set_colsample_bynode< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.colsample_bynode = v.into(); + self + } + + /// Sets the value of [activation_fn][crate::model::model::HparamSearchSpaces::activation_fn]. + pub fn set_activation_fn< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.activation_fn = v.into(); + self + } + + /// Sets the value of [optimizer][crate::model::model::HparamSearchSpaces::optimizer]. + pub fn set_optimizer< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.optimizer = v.into(); + self + } + } + + impl wkt::message::Message for HparamSearchSpaces { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.HparamSearchSpaces" + } + } + + /// Training info of a trial in [hyperparameter + /// tuning](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-hp-tuning-overview) + /// models. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct HparamTuningTrial { + /// 1-based index of the trial. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub trial_id: i64, + + /// Starting time of the trial. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub start_time_ms: i64, + + /// Ending time of the trial. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub end_time_ms: i64, + + /// The hyperprameters selected for this trial. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub hparams: std::option::Option, + + /// Evaluation metrics of this trial calculated on the test data. + /// Empty in Job API. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub evaluation_metrics: std::option::Option, + + /// The status of the trial. + pub status: crate::model::model::hparam_tuning_trial::TrialStatus, + + /// Error message for FAILED and INFEASIBLE trial. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub error_message: std::string::String, + + /// Loss computed on the training data at the end of trial. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub training_loss: std::option::Option, + + /// Loss computed on the eval data at the end of trial. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub eval_loss: std::option::Option, + + /// Hyperparameter tuning evaluation metrics of this trial calculated on the + /// eval data. Unlike evaluation_metrics, only the fields corresponding to + /// the hparam_tuning_objectives are set. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub hparam_tuning_evaluation_metrics: + std::option::Option, + } + + impl HparamTuningTrial { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [trial_id][crate::model::model::HparamTuningTrial::trial_id]. + pub fn set_trial_id>(mut self, v: T) -> Self { + self.trial_id = v.into(); + self + } + + /// Sets the value of [start_time_ms][crate::model::model::HparamTuningTrial::start_time_ms]. + pub fn set_start_time_ms>(mut self, v: T) -> Self { + self.start_time_ms = v.into(); + self + } + + /// Sets the value of [end_time_ms][crate::model::model::HparamTuningTrial::end_time_ms]. + pub fn set_end_time_ms>(mut self, v: T) -> Self { + self.end_time_ms = v.into(); + self + } + + /// Sets the value of [hparams][crate::model::model::HparamTuningTrial::hparams]. + pub fn set_hparams< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.hparams = v.into(); + self + } + + /// Sets the value of [evaluation_metrics][crate::model::model::HparamTuningTrial::evaluation_metrics]. + pub fn set_evaluation_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.evaluation_metrics = v.into(); + self + } + + /// Sets the value of [status][crate::model::model::HparamTuningTrial::status]. + pub fn set_status< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.status = v.into(); + self + } + + /// Sets the value of [error_message][crate::model::model::HparamTuningTrial::error_message]. + pub fn set_error_message>( + mut self, + v: T, + ) -> Self { + self.error_message = v.into(); + self + } + + /// Sets the value of [training_loss][crate::model::model::HparamTuningTrial::training_loss]. + pub fn set_training_loss>>( + mut self, + v: T, + ) -> Self { + self.training_loss = v.into(); + self + } + + /// Sets the value of [eval_loss][crate::model::model::HparamTuningTrial::eval_loss]. + pub fn set_eval_loss>>( + mut self, + v: T, + ) -> Self { + self.eval_loss = v.into(); + self + } + + /// Sets the value of [hparam_tuning_evaluation_metrics][crate::model::model::HparamTuningTrial::hparam_tuning_evaluation_metrics]. + pub fn set_hparam_tuning_evaluation_metrics< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.hparam_tuning_evaluation_metrics = v.into(); + self + } + } + + impl wkt::message::Message for HparamTuningTrial { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Model.HparamTuningTrial" + } + } + + /// Defines additional types related to HparamTuningTrial + pub mod hparam_tuning_trial { + #[allow(unused_imports)] + use super::*; + + /// Current status of the trial. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct TrialStatus(i32); + + impl TrialStatus { + /// Default value. + pub const TRIAL_STATUS_UNSPECIFIED: TrialStatus = TrialStatus::new(0); + + /// Scheduled but not started. + pub const NOT_STARTED: TrialStatus = TrialStatus::new(1); + + /// Running state. + pub const RUNNING: TrialStatus = TrialStatus::new(2); + + /// The trial succeeded. + pub const SUCCEEDED: TrialStatus = TrialStatus::new(3); + + /// The trial failed. + pub const FAILED: TrialStatus = TrialStatus::new(4); + + /// The trial is infeasible due to the invalid params. + pub const INFEASIBLE: TrialStatus = TrialStatus::new(5); + + /// Trial stopped early because it's not promising. + pub const STOPPED_EARLY: TrialStatus = TrialStatus::new(6); + + /// Creates a new TrialStatus instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("TRIAL_STATUS_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("NOT_STARTED"), + 2 => std::borrow::Cow::Borrowed("RUNNING"), + 3 => std::borrow::Cow::Borrowed("SUCCEEDED"), + 4 => std::borrow::Cow::Borrowed("FAILED"), + 5 => std::borrow::Cow::Borrowed("INFEASIBLE"), + 6 => std::borrow::Cow::Borrowed("STOPPED_EARLY"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "TRIAL_STATUS_UNSPECIFIED" => { + std::option::Option::Some(Self::TRIAL_STATUS_UNSPECIFIED) + } + "NOT_STARTED" => std::option::Option::Some(Self::NOT_STARTED), + "RUNNING" => std::option::Option::Some(Self::RUNNING), + "SUCCEEDED" => std::option::Option::Some(Self::SUCCEEDED), + "FAILED" => std::option::Option::Some(Self::FAILED), + "INFEASIBLE" => std::option::Option::Some(Self::INFEASIBLE), + "STOPPED_EARLY" => std::option::Option::Some(Self::STOPPED_EARLY), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for TrialStatus { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for TrialStatus { + fn default() -> Self { + Self::new(0) + } + } + } + + /// Indicates the type of the Model. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct ModelType(i32); + + impl ModelType { + /// Default value. + pub const MODEL_TYPE_UNSPECIFIED: ModelType = ModelType::new(0); + + /// Linear regression model. + pub const LINEAR_REGRESSION: ModelType = ModelType::new(1); + + /// Logistic regression based classification model. + pub const LOGISTIC_REGRESSION: ModelType = ModelType::new(2); + + /// K-means clustering model. + pub const KMEANS: ModelType = ModelType::new(3); + + /// Matrix factorization model. + pub const MATRIX_FACTORIZATION: ModelType = ModelType::new(4); + + /// DNN classifier model. + pub const DNN_CLASSIFIER: ModelType = ModelType::new(5); + + /// An imported TensorFlow model. + pub const TENSORFLOW: ModelType = ModelType::new(6); + + /// DNN regressor model. + pub const DNN_REGRESSOR: ModelType = ModelType::new(7); + + /// An imported XGBoost model. + pub const XGBOOST: ModelType = ModelType::new(8); + + /// Boosted tree regressor model. + pub const BOOSTED_TREE_REGRESSOR: ModelType = ModelType::new(9); + + /// Boosted tree classifier model. + pub const BOOSTED_TREE_CLASSIFIER: ModelType = ModelType::new(10); + + /// ARIMA model. + pub const ARIMA: ModelType = ModelType::new(11); + + /// AutoML Tables regression model. + pub const AUTOML_REGRESSOR: ModelType = ModelType::new(12); + + /// AutoML Tables classification model. + pub const AUTOML_CLASSIFIER: ModelType = ModelType::new(13); + + /// Prinpical Component Analysis model. + pub const PCA: ModelType = ModelType::new(14); + + /// Wide-and-deep classifier model. + pub const DNN_LINEAR_COMBINED_CLASSIFIER: ModelType = ModelType::new(16); + + /// Wide-and-deep regressor model. + pub const DNN_LINEAR_COMBINED_REGRESSOR: ModelType = ModelType::new(17); + + /// Autoencoder model. + pub const AUTOENCODER: ModelType = ModelType::new(18); + + /// New name for the ARIMA model. + pub const ARIMA_PLUS: ModelType = ModelType::new(19); + + /// ARIMA with external regressors. + pub const ARIMA_PLUS_XREG: ModelType = ModelType::new(23); + + /// Random forest regressor model. + pub const RANDOM_FOREST_REGRESSOR: ModelType = ModelType::new(24); + + /// Random forest classifier model. + pub const RANDOM_FOREST_CLASSIFIER: ModelType = ModelType::new(25); + + /// An imported TensorFlow Lite model. + pub const TENSORFLOW_LITE: ModelType = ModelType::new(26); + + /// An imported ONNX model. + pub const ONNX: ModelType = ModelType::new(28); + + /// Model to capture the columns and logic in the TRANSFORM clause along with + /// statistics useful for ML analytic functions. + pub const TRANSFORM_ONLY: ModelType = ModelType::new(29); + + /// The contribution analysis model. + pub const CONTRIBUTION_ANALYSIS: ModelType = ModelType::new(37); + + /// Creates a new ModelType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("MODEL_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("LINEAR_REGRESSION"), + 2 => std::borrow::Cow::Borrowed("LOGISTIC_REGRESSION"), + 3 => std::borrow::Cow::Borrowed("KMEANS"), + 4 => std::borrow::Cow::Borrowed("MATRIX_FACTORIZATION"), + 5 => std::borrow::Cow::Borrowed("DNN_CLASSIFIER"), + 6 => std::borrow::Cow::Borrowed("TENSORFLOW"), + 7 => std::borrow::Cow::Borrowed("DNN_REGRESSOR"), + 8 => std::borrow::Cow::Borrowed("XGBOOST"), + 9 => std::borrow::Cow::Borrowed("BOOSTED_TREE_REGRESSOR"), + 10 => std::borrow::Cow::Borrowed("BOOSTED_TREE_CLASSIFIER"), + 11 => std::borrow::Cow::Borrowed("ARIMA"), + 12 => std::borrow::Cow::Borrowed("AUTOML_REGRESSOR"), + 13 => std::borrow::Cow::Borrowed("AUTOML_CLASSIFIER"), + 14 => std::borrow::Cow::Borrowed("PCA"), + 16 => std::borrow::Cow::Borrowed("DNN_LINEAR_COMBINED_CLASSIFIER"), + 17 => std::borrow::Cow::Borrowed("DNN_LINEAR_COMBINED_REGRESSOR"), + 18 => std::borrow::Cow::Borrowed("AUTOENCODER"), + 19 => std::borrow::Cow::Borrowed("ARIMA_PLUS"), + 23 => std::borrow::Cow::Borrowed("ARIMA_PLUS_XREG"), + 24 => std::borrow::Cow::Borrowed("RANDOM_FOREST_REGRESSOR"), + 25 => std::borrow::Cow::Borrowed("RANDOM_FOREST_CLASSIFIER"), + 26 => std::borrow::Cow::Borrowed("TENSORFLOW_LITE"), + 28 => std::borrow::Cow::Borrowed("ONNX"), + 29 => std::borrow::Cow::Borrowed("TRANSFORM_ONLY"), + 37 => std::borrow::Cow::Borrowed("CONTRIBUTION_ANALYSIS"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "MODEL_TYPE_UNSPECIFIED" => std::option::Option::Some(Self::MODEL_TYPE_UNSPECIFIED), + "LINEAR_REGRESSION" => std::option::Option::Some(Self::LINEAR_REGRESSION), + "LOGISTIC_REGRESSION" => std::option::Option::Some(Self::LOGISTIC_REGRESSION), + "KMEANS" => std::option::Option::Some(Self::KMEANS), + "MATRIX_FACTORIZATION" => std::option::Option::Some(Self::MATRIX_FACTORIZATION), + "DNN_CLASSIFIER" => std::option::Option::Some(Self::DNN_CLASSIFIER), + "TENSORFLOW" => std::option::Option::Some(Self::TENSORFLOW), + "DNN_REGRESSOR" => std::option::Option::Some(Self::DNN_REGRESSOR), + "XGBOOST" => std::option::Option::Some(Self::XGBOOST), + "BOOSTED_TREE_REGRESSOR" => std::option::Option::Some(Self::BOOSTED_TREE_REGRESSOR), + "BOOSTED_TREE_CLASSIFIER" => { + std::option::Option::Some(Self::BOOSTED_TREE_CLASSIFIER) + } + "ARIMA" => std::option::Option::Some(Self::ARIMA), + "AUTOML_REGRESSOR" => std::option::Option::Some(Self::AUTOML_REGRESSOR), + "AUTOML_CLASSIFIER" => std::option::Option::Some(Self::AUTOML_CLASSIFIER), + "PCA" => std::option::Option::Some(Self::PCA), + "DNN_LINEAR_COMBINED_CLASSIFIER" => { + std::option::Option::Some(Self::DNN_LINEAR_COMBINED_CLASSIFIER) + } + "DNN_LINEAR_COMBINED_REGRESSOR" => { + std::option::Option::Some(Self::DNN_LINEAR_COMBINED_REGRESSOR) + } + "AUTOENCODER" => std::option::Option::Some(Self::AUTOENCODER), + "ARIMA_PLUS" => std::option::Option::Some(Self::ARIMA_PLUS), + "ARIMA_PLUS_XREG" => std::option::Option::Some(Self::ARIMA_PLUS_XREG), + "RANDOM_FOREST_REGRESSOR" => { + std::option::Option::Some(Self::RANDOM_FOREST_REGRESSOR) + } + "RANDOM_FOREST_CLASSIFIER" => { + std::option::Option::Some(Self::RANDOM_FOREST_CLASSIFIER) + } + "TENSORFLOW_LITE" => std::option::Option::Some(Self::TENSORFLOW_LITE), + "ONNX" => std::option::Option::Some(Self::ONNX), + "TRANSFORM_ONLY" => std::option::Option::Some(Self::TRANSFORM_ONLY), + "CONTRIBUTION_ANALYSIS" => std::option::Option::Some(Self::CONTRIBUTION_ANALYSIS), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for ModelType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for ModelType { + fn default() -> Self { + Self::new(0) + } + } + + /// Loss metric to evaluate model training performance. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct LossType(i32); + + impl LossType { + /// Default value. + pub const LOSS_TYPE_UNSPECIFIED: LossType = LossType::new(0); + + /// Mean squared loss, used for linear regression. + pub const MEAN_SQUARED_LOSS: LossType = LossType::new(1); + + /// Mean log loss, used for logistic regression. + pub const MEAN_LOG_LOSS: LossType = LossType::new(2); + + /// Creates a new LossType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("LOSS_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("MEAN_SQUARED_LOSS"), + 2 => std::borrow::Cow::Borrowed("MEAN_LOG_LOSS"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "LOSS_TYPE_UNSPECIFIED" => std::option::Option::Some(Self::LOSS_TYPE_UNSPECIFIED), + "MEAN_SQUARED_LOSS" => std::option::Option::Some(Self::MEAN_SQUARED_LOSS), + "MEAN_LOG_LOSS" => std::option::Option::Some(Self::MEAN_LOG_LOSS), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for LossType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for LossType { + fn default() -> Self { + Self::new(0) + } + } + + /// Distance metric used to compute the distance between two points. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct DistanceType(i32); + + impl DistanceType { + /// Default value. + pub const DISTANCE_TYPE_UNSPECIFIED: DistanceType = DistanceType::new(0); + + /// Eculidean distance. + pub const EUCLIDEAN: DistanceType = DistanceType::new(1); + + /// Cosine distance. + pub const COSINE: DistanceType = DistanceType::new(2); + + /// Creates a new DistanceType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("DISTANCE_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("EUCLIDEAN"), + 2 => std::borrow::Cow::Borrowed("COSINE"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "DISTANCE_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::DISTANCE_TYPE_UNSPECIFIED) + } + "EUCLIDEAN" => std::option::Option::Some(Self::EUCLIDEAN), + "COSINE" => std::option::Option::Some(Self::COSINE), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for DistanceType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for DistanceType { + fn default() -> Self { + Self::new(0) + } + } + + /// Indicates the method to split input data into multiple tables. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct DataSplitMethod(i32); + + impl DataSplitMethod { + /// Default value. + pub const DATA_SPLIT_METHOD_UNSPECIFIED: DataSplitMethod = DataSplitMethod::new(0); + + /// Splits data randomly. + pub const RANDOM: DataSplitMethod = DataSplitMethod::new(1); + + /// Splits data with the user provided tags. + pub const CUSTOM: DataSplitMethod = DataSplitMethod::new(2); + + /// Splits data sequentially. + pub const SEQUENTIAL: DataSplitMethod = DataSplitMethod::new(3); + + /// Data split will be skipped. + pub const NO_SPLIT: DataSplitMethod = DataSplitMethod::new(4); + + /// Splits data automatically: Uses NO_SPLIT if the data size is small. + /// Otherwise uses RANDOM. + pub const AUTO_SPLIT: DataSplitMethod = DataSplitMethod::new(5); + + /// Creates a new DataSplitMethod instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("DATA_SPLIT_METHOD_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("RANDOM"), + 2 => std::borrow::Cow::Borrowed("CUSTOM"), + 3 => std::borrow::Cow::Borrowed("SEQUENTIAL"), + 4 => std::borrow::Cow::Borrowed("NO_SPLIT"), + 5 => std::borrow::Cow::Borrowed("AUTO_SPLIT"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "DATA_SPLIT_METHOD_UNSPECIFIED" => { + std::option::Option::Some(Self::DATA_SPLIT_METHOD_UNSPECIFIED) + } + "RANDOM" => std::option::Option::Some(Self::RANDOM), + "CUSTOM" => std::option::Option::Some(Self::CUSTOM), + "SEQUENTIAL" => std::option::Option::Some(Self::SEQUENTIAL), + "NO_SPLIT" => std::option::Option::Some(Self::NO_SPLIT), + "AUTO_SPLIT" => std::option::Option::Some(Self::AUTO_SPLIT), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for DataSplitMethod { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for DataSplitMethod { + fn default() -> Self { + Self::new(0) + } + } + + /// Type of supported data frequency for time series forecasting models. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct DataFrequency(i32); + + impl DataFrequency { + /// Default value. + pub const DATA_FREQUENCY_UNSPECIFIED: DataFrequency = DataFrequency::new(0); + + /// Automatically inferred from timestamps. + pub const AUTO_FREQUENCY: DataFrequency = DataFrequency::new(1); + + /// Yearly data. + pub const YEARLY: DataFrequency = DataFrequency::new(2); + + /// Quarterly data. + pub const QUARTERLY: DataFrequency = DataFrequency::new(3); + + /// Monthly data. + pub const MONTHLY: DataFrequency = DataFrequency::new(4); + + /// Weekly data. + pub const WEEKLY: DataFrequency = DataFrequency::new(5); + + /// Daily data. + pub const DAILY: DataFrequency = DataFrequency::new(6); + + /// Hourly data. + pub const HOURLY: DataFrequency = DataFrequency::new(7); + + /// Per-minute data. + pub const PER_MINUTE: DataFrequency = DataFrequency::new(8); + + /// Creates a new DataFrequency instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("DATA_FREQUENCY_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("AUTO_FREQUENCY"), + 2 => std::borrow::Cow::Borrowed("YEARLY"), + 3 => std::borrow::Cow::Borrowed("QUARTERLY"), + 4 => std::borrow::Cow::Borrowed("MONTHLY"), + 5 => std::borrow::Cow::Borrowed("WEEKLY"), + 6 => std::borrow::Cow::Borrowed("DAILY"), + 7 => std::borrow::Cow::Borrowed("HOURLY"), + 8 => std::borrow::Cow::Borrowed("PER_MINUTE"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "DATA_FREQUENCY_UNSPECIFIED" => { + std::option::Option::Some(Self::DATA_FREQUENCY_UNSPECIFIED) + } + "AUTO_FREQUENCY" => std::option::Option::Some(Self::AUTO_FREQUENCY), + "YEARLY" => std::option::Option::Some(Self::YEARLY), + "QUARTERLY" => std::option::Option::Some(Self::QUARTERLY), + "MONTHLY" => std::option::Option::Some(Self::MONTHLY), + "WEEKLY" => std::option::Option::Some(Self::WEEKLY), + "DAILY" => std::option::Option::Some(Self::DAILY), + "HOURLY" => std::option::Option::Some(Self::HOURLY), + "PER_MINUTE" => std::option::Option::Some(Self::PER_MINUTE), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for DataFrequency { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for DataFrequency { + fn default() -> Self { + Self::new(0) + } + } + + /// Type of supported holiday regions for time series forecasting models. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct HolidayRegion(i32); + + impl HolidayRegion { + /// Holiday region unspecified. + pub const HOLIDAY_REGION_UNSPECIFIED: HolidayRegion = HolidayRegion::new(0); + + /// Global. + pub const GLOBAL: HolidayRegion = HolidayRegion::new(1); + + /// North America. + pub const NA: HolidayRegion = HolidayRegion::new(2); + + /// Japan and Asia Pacific: Korea, Greater China, India, Australia, and New + /// Zealand. + pub const JAPAC: HolidayRegion = HolidayRegion::new(3); + + /// Europe, the Middle East and Africa. + pub const EMEA: HolidayRegion = HolidayRegion::new(4); + + /// Latin America and the Caribbean. + pub const LAC: HolidayRegion = HolidayRegion::new(5); + + /// United Arab Emirates + pub const AE: HolidayRegion = HolidayRegion::new(6); + + /// Argentina + pub const AR: HolidayRegion = HolidayRegion::new(7); + + /// Austria + pub const AT: HolidayRegion = HolidayRegion::new(8); + + /// Australia + pub const AU: HolidayRegion = HolidayRegion::new(9); + + /// Belgium + pub const BE: HolidayRegion = HolidayRegion::new(10); + + /// Brazil + pub const BR: HolidayRegion = HolidayRegion::new(11); + + /// Canada + pub const CA: HolidayRegion = HolidayRegion::new(12); + + /// Switzerland + pub const CH: HolidayRegion = HolidayRegion::new(13); + + /// Chile + pub const CL: HolidayRegion = HolidayRegion::new(14); + + /// China + pub const CN: HolidayRegion = HolidayRegion::new(15); + + /// Colombia + pub const CO: HolidayRegion = HolidayRegion::new(16); + + /// Czechoslovakia + pub const CS: HolidayRegion = HolidayRegion::new(17); + + /// Czech Republic + pub const CZ: HolidayRegion = HolidayRegion::new(18); + + /// Germany + pub const DE: HolidayRegion = HolidayRegion::new(19); + + /// Denmark + pub const DK: HolidayRegion = HolidayRegion::new(20); + + /// Algeria + pub const DZ: HolidayRegion = HolidayRegion::new(21); + + /// Ecuador + pub const EC: HolidayRegion = HolidayRegion::new(22); + + /// Estonia + pub const EE: HolidayRegion = HolidayRegion::new(23); + + /// Egypt + pub const EG: HolidayRegion = HolidayRegion::new(24); + + /// Spain + pub const ES: HolidayRegion = HolidayRegion::new(25); + + /// Finland + pub const FI: HolidayRegion = HolidayRegion::new(26); + + /// France + pub const FR: HolidayRegion = HolidayRegion::new(27); + + /// Great Britain (United Kingdom) + pub const GB: HolidayRegion = HolidayRegion::new(28); + + /// Greece + pub const GR: HolidayRegion = HolidayRegion::new(29); + + /// Hong Kong + pub const HK: HolidayRegion = HolidayRegion::new(30); + + /// Hungary + pub const HU: HolidayRegion = HolidayRegion::new(31); + + /// Indonesia + pub const ID: HolidayRegion = HolidayRegion::new(32); + + /// Ireland + pub const IE: HolidayRegion = HolidayRegion::new(33); + + /// Israel + pub const IL: HolidayRegion = HolidayRegion::new(34); + + /// India + pub const IN: HolidayRegion = HolidayRegion::new(35); + + /// Iran + pub const IR: HolidayRegion = HolidayRegion::new(36); + + /// Italy + pub const IT: HolidayRegion = HolidayRegion::new(37); + + /// Japan + pub const JP: HolidayRegion = HolidayRegion::new(38); + + /// Korea (South) + pub const KR: HolidayRegion = HolidayRegion::new(39); + + /// Latvia + pub const LV: HolidayRegion = HolidayRegion::new(40); + + /// Morocco + pub const MA: HolidayRegion = HolidayRegion::new(41); + + /// Mexico + pub const MX: HolidayRegion = HolidayRegion::new(42); + + /// Malaysia + pub const MY: HolidayRegion = HolidayRegion::new(43); + + /// Nigeria + pub const NG: HolidayRegion = HolidayRegion::new(44); + + /// Netherlands + pub const NL: HolidayRegion = HolidayRegion::new(45); + + /// Norway + pub const NO: HolidayRegion = HolidayRegion::new(46); + + /// New Zealand + pub const NZ: HolidayRegion = HolidayRegion::new(47); + + /// Peru + pub const PE: HolidayRegion = HolidayRegion::new(48); + + /// Philippines + pub const PH: HolidayRegion = HolidayRegion::new(49); + + /// Pakistan + pub const PK: HolidayRegion = HolidayRegion::new(50); + + /// Poland + pub const PL: HolidayRegion = HolidayRegion::new(51); + + /// Portugal + pub const PT: HolidayRegion = HolidayRegion::new(52); + + /// Romania + pub const RO: HolidayRegion = HolidayRegion::new(53); + + /// Serbia + pub const RS: HolidayRegion = HolidayRegion::new(54); + + /// Russian Federation + pub const RU: HolidayRegion = HolidayRegion::new(55); + + /// Saudi Arabia + pub const SA: HolidayRegion = HolidayRegion::new(56); + + /// Sweden + pub const SE: HolidayRegion = HolidayRegion::new(57); + + /// Singapore + pub const SG: HolidayRegion = HolidayRegion::new(58); + + /// Slovenia + pub const SI: HolidayRegion = HolidayRegion::new(59); + + /// Slovakia + pub const SK: HolidayRegion = HolidayRegion::new(60); + + /// Thailand + pub const TH: HolidayRegion = HolidayRegion::new(61); + + /// Turkey + pub const TR: HolidayRegion = HolidayRegion::new(62); + + /// Taiwan + pub const TW: HolidayRegion = HolidayRegion::new(63); + + /// Ukraine + pub const UA: HolidayRegion = HolidayRegion::new(64); + + /// United States + pub const US: HolidayRegion = HolidayRegion::new(65); + + /// Venezuela + pub const VE: HolidayRegion = HolidayRegion::new(66); + + /// Vietnam + pub const VN: HolidayRegion = HolidayRegion::new(67); + + /// South Africa + pub const ZA: HolidayRegion = HolidayRegion::new(68); + + /// Creates a new HolidayRegion instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("HOLIDAY_REGION_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("GLOBAL"), + 2 => std::borrow::Cow::Borrowed("NA"), + 3 => std::borrow::Cow::Borrowed("JAPAC"), + 4 => std::borrow::Cow::Borrowed("EMEA"), + 5 => std::borrow::Cow::Borrowed("LAC"), + 6 => std::borrow::Cow::Borrowed("AE"), + 7 => std::borrow::Cow::Borrowed("AR"), + 8 => std::borrow::Cow::Borrowed("AT"), + 9 => std::borrow::Cow::Borrowed("AU"), + 10 => std::borrow::Cow::Borrowed("BE"), + 11 => std::borrow::Cow::Borrowed("BR"), + 12 => std::borrow::Cow::Borrowed("CA"), + 13 => std::borrow::Cow::Borrowed("CH"), + 14 => std::borrow::Cow::Borrowed("CL"), + 15 => std::borrow::Cow::Borrowed("CN"), + 16 => std::borrow::Cow::Borrowed("CO"), + 17 => std::borrow::Cow::Borrowed("CS"), + 18 => std::borrow::Cow::Borrowed("CZ"), + 19 => std::borrow::Cow::Borrowed("DE"), + 20 => std::borrow::Cow::Borrowed("DK"), + 21 => std::borrow::Cow::Borrowed("DZ"), + 22 => std::borrow::Cow::Borrowed("EC"), + 23 => std::borrow::Cow::Borrowed("EE"), + 24 => std::borrow::Cow::Borrowed("EG"), + 25 => std::borrow::Cow::Borrowed("ES"), + 26 => std::borrow::Cow::Borrowed("FI"), + 27 => std::borrow::Cow::Borrowed("FR"), + 28 => std::borrow::Cow::Borrowed("GB"), + 29 => std::borrow::Cow::Borrowed("GR"), + 30 => std::borrow::Cow::Borrowed("HK"), + 31 => std::borrow::Cow::Borrowed("HU"), + 32 => std::borrow::Cow::Borrowed("ID"), + 33 => std::borrow::Cow::Borrowed("IE"), + 34 => std::borrow::Cow::Borrowed("IL"), + 35 => std::borrow::Cow::Borrowed("IN"), + 36 => std::borrow::Cow::Borrowed("IR"), + 37 => std::borrow::Cow::Borrowed("IT"), + 38 => std::borrow::Cow::Borrowed("JP"), + 39 => std::borrow::Cow::Borrowed("KR"), + 40 => std::borrow::Cow::Borrowed("LV"), + 41 => std::borrow::Cow::Borrowed("MA"), + 42 => std::borrow::Cow::Borrowed("MX"), + 43 => std::borrow::Cow::Borrowed("MY"), + 44 => std::borrow::Cow::Borrowed("NG"), + 45 => std::borrow::Cow::Borrowed("NL"), + 46 => std::borrow::Cow::Borrowed("NO"), + 47 => std::borrow::Cow::Borrowed("NZ"), + 48 => std::borrow::Cow::Borrowed("PE"), + 49 => std::borrow::Cow::Borrowed("PH"), + 50 => std::borrow::Cow::Borrowed("PK"), + 51 => std::borrow::Cow::Borrowed("PL"), + 52 => std::borrow::Cow::Borrowed("PT"), + 53 => std::borrow::Cow::Borrowed("RO"), + 54 => std::borrow::Cow::Borrowed("RS"), + 55 => std::borrow::Cow::Borrowed("RU"), + 56 => std::borrow::Cow::Borrowed("SA"), + 57 => std::borrow::Cow::Borrowed("SE"), + 58 => std::borrow::Cow::Borrowed("SG"), + 59 => std::borrow::Cow::Borrowed("SI"), + 60 => std::borrow::Cow::Borrowed("SK"), + 61 => std::borrow::Cow::Borrowed("TH"), + 62 => std::borrow::Cow::Borrowed("TR"), + 63 => std::borrow::Cow::Borrowed("TW"), + 64 => std::borrow::Cow::Borrowed("UA"), + 65 => std::borrow::Cow::Borrowed("US"), + 66 => std::borrow::Cow::Borrowed("VE"), + 67 => std::borrow::Cow::Borrowed("VN"), + 68 => std::borrow::Cow::Borrowed("ZA"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "HOLIDAY_REGION_UNSPECIFIED" => { + std::option::Option::Some(Self::HOLIDAY_REGION_UNSPECIFIED) + } + "GLOBAL" => std::option::Option::Some(Self::GLOBAL), + "NA" => std::option::Option::Some(Self::NA), + "JAPAC" => std::option::Option::Some(Self::JAPAC), + "EMEA" => std::option::Option::Some(Self::EMEA), + "LAC" => std::option::Option::Some(Self::LAC), + "AE" => std::option::Option::Some(Self::AE), + "AR" => std::option::Option::Some(Self::AR), + "AT" => std::option::Option::Some(Self::AT), + "AU" => std::option::Option::Some(Self::AU), + "BE" => std::option::Option::Some(Self::BE), + "BR" => std::option::Option::Some(Self::BR), + "CA" => std::option::Option::Some(Self::CA), + "CH" => std::option::Option::Some(Self::CH), + "CL" => std::option::Option::Some(Self::CL), + "CN" => std::option::Option::Some(Self::CN), + "CO" => std::option::Option::Some(Self::CO), + "CS" => std::option::Option::Some(Self::CS), + "CZ" => std::option::Option::Some(Self::CZ), + "DE" => std::option::Option::Some(Self::DE), + "DK" => std::option::Option::Some(Self::DK), + "DZ" => std::option::Option::Some(Self::DZ), + "EC" => std::option::Option::Some(Self::EC), + "EE" => std::option::Option::Some(Self::EE), + "EG" => std::option::Option::Some(Self::EG), + "ES" => std::option::Option::Some(Self::ES), + "FI" => std::option::Option::Some(Self::FI), + "FR" => std::option::Option::Some(Self::FR), + "GB" => std::option::Option::Some(Self::GB), + "GR" => std::option::Option::Some(Self::GR), + "HK" => std::option::Option::Some(Self::HK), + "HU" => std::option::Option::Some(Self::HU), + "ID" => std::option::Option::Some(Self::ID), + "IE" => std::option::Option::Some(Self::IE), + "IL" => std::option::Option::Some(Self::IL), + "IN" => std::option::Option::Some(Self::IN), + "IR" => std::option::Option::Some(Self::IR), + "IT" => std::option::Option::Some(Self::IT), + "JP" => std::option::Option::Some(Self::JP), + "KR" => std::option::Option::Some(Self::KR), + "LV" => std::option::Option::Some(Self::LV), + "MA" => std::option::Option::Some(Self::MA), + "MX" => std::option::Option::Some(Self::MX), + "MY" => std::option::Option::Some(Self::MY), + "NG" => std::option::Option::Some(Self::NG), + "NL" => std::option::Option::Some(Self::NL), + "NO" => std::option::Option::Some(Self::NO), + "NZ" => std::option::Option::Some(Self::NZ), + "PE" => std::option::Option::Some(Self::PE), + "PH" => std::option::Option::Some(Self::PH), + "PK" => std::option::Option::Some(Self::PK), + "PL" => std::option::Option::Some(Self::PL), + "PT" => std::option::Option::Some(Self::PT), + "RO" => std::option::Option::Some(Self::RO), + "RS" => std::option::Option::Some(Self::RS), + "RU" => std::option::Option::Some(Self::RU), + "SA" => std::option::Option::Some(Self::SA), + "SE" => std::option::Option::Some(Self::SE), + "SG" => std::option::Option::Some(Self::SG), + "SI" => std::option::Option::Some(Self::SI), + "SK" => std::option::Option::Some(Self::SK), + "TH" => std::option::Option::Some(Self::TH), + "TR" => std::option::Option::Some(Self::TR), + "TW" => std::option::Option::Some(Self::TW), + "UA" => std::option::Option::Some(Self::UA), + "US" => std::option::Option::Some(Self::US), + "VE" => std::option::Option::Some(Self::VE), + "VN" => std::option::Option::Some(Self::VN), + "ZA" => std::option::Option::Some(Self::ZA), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for HolidayRegion { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for HolidayRegion { + fn default() -> Self { + Self::new(0) + } + } + + /// Enums for color space, used for processing images in Object Table. + /// See more details at + /// . + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct ColorSpace(i32); + + impl ColorSpace { + /// Unspecified color space + pub const COLOR_SPACE_UNSPECIFIED: ColorSpace = ColorSpace::new(0); + + /// RGB + pub const RGB: ColorSpace = ColorSpace::new(1); + + /// HSV + pub const HSV: ColorSpace = ColorSpace::new(2); + + /// YIQ + pub const YIQ: ColorSpace = ColorSpace::new(3); + + /// YUV + pub const YUV: ColorSpace = ColorSpace::new(4); + + /// GRAYSCALE + pub const GRAYSCALE: ColorSpace = ColorSpace::new(5); + + /// Creates a new ColorSpace instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("COLOR_SPACE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("RGB"), + 2 => std::borrow::Cow::Borrowed("HSV"), + 3 => std::borrow::Cow::Borrowed("YIQ"), + 4 => std::borrow::Cow::Borrowed("YUV"), + 5 => std::borrow::Cow::Borrowed("GRAYSCALE"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "COLOR_SPACE_UNSPECIFIED" => { + std::option::Option::Some(Self::COLOR_SPACE_UNSPECIFIED) + } + "RGB" => std::option::Option::Some(Self::RGB), + "HSV" => std::option::Option::Some(Self::HSV), + "YIQ" => std::option::Option::Some(Self::YIQ), + "YUV" => std::option::Option::Some(Self::YUV), + "GRAYSCALE" => std::option::Option::Some(Self::GRAYSCALE), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for ColorSpace { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for ColorSpace { + fn default() -> Self { + Self::new(0) + } + } + + /// Indicates the learning rate optimization strategy to use. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct LearnRateStrategy(i32); + + impl LearnRateStrategy { + /// Default value. + pub const LEARN_RATE_STRATEGY_UNSPECIFIED: LearnRateStrategy = LearnRateStrategy::new(0); + + /// Use line search to determine learning rate. + pub const LINE_SEARCH: LearnRateStrategy = LearnRateStrategy::new(1); + + /// Use a constant learning rate. + pub const CONSTANT: LearnRateStrategy = LearnRateStrategy::new(2); + + /// Creates a new LearnRateStrategy instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("LEARN_RATE_STRATEGY_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("LINE_SEARCH"), + 2 => std::borrow::Cow::Borrowed("CONSTANT"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "LEARN_RATE_STRATEGY_UNSPECIFIED" => { + std::option::Option::Some(Self::LEARN_RATE_STRATEGY_UNSPECIFIED) + } + "LINE_SEARCH" => std::option::Option::Some(Self::LINE_SEARCH), + "CONSTANT" => std::option::Option::Some(Self::CONSTANT), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for LearnRateStrategy { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for LearnRateStrategy { + fn default() -> Self { + Self::new(0) + } + } + + /// Indicates the optimization strategy used for training. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct OptimizationStrategy(i32); + + impl OptimizationStrategy { + /// Default value. + pub const OPTIMIZATION_STRATEGY_UNSPECIFIED: OptimizationStrategy = + OptimizationStrategy::new(0); + + /// Uses an iterative batch gradient descent algorithm. + pub const BATCH_GRADIENT_DESCENT: OptimizationStrategy = OptimizationStrategy::new(1); + + /// Uses a normal equation to solve linear regression problem. + pub const NORMAL_EQUATION: OptimizationStrategy = OptimizationStrategy::new(2); + + /// Creates a new OptimizationStrategy instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("OPTIMIZATION_STRATEGY_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("BATCH_GRADIENT_DESCENT"), + 2 => std::borrow::Cow::Borrowed("NORMAL_EQUATION"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "OPTIMIZATION_STRATEGY_UNSPECIFIED" => { + std::option::Option::Some(Self::OPTIMIZATION_STRATEGY_UNSPECIFIED) + } + "BATCH_GRADIENT_DESCENT" => std::option::Option::Some(Self::BATCH_GRADIENT_DESCENT), + "NORMAL_EQUATION" => std::option::Option::Some(Self::NORMAL_EQUATION), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for OptimizationStrategy { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for OptimizationStrategy { + fn default() -> Self { + Self::new(0) + } + } + + /// Indicates the training algorithm to use for matrix factorization models. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct FeedbackType(i32); + + impl FeedbackType { + /// Default value. + pub const FEEDBACK_TYPE_UNSPECIFIED: FeedbackType = FeedbackType::new(0); + + /// Use weighted-als for implicit feedback problems. + pub const IMPLICIT: FeedbackType = FeedbackType::new(1); + + /// Use nonweighted-als for explicit feedback problems. + pub const EXPLICIT: FeedbackType = FeedbackType::new(2); + + /// Creates a new FeedbackType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("FEEDBACK_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("IMPLICIT"), + 2 => std::borrow::Cow::Borrowed("EXPLICIT"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "FEEDBACK_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::FEEDBACK_TYPE_UNSPECIFIED) + } + "IMPLICIT" => std::option::Option::Some(Self::IMPLICIT), + "EXPLICIT" => std::option::Option::Some(Self::EXPLICIT), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for FeedbackType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for FeedbackType { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Request format for getting information about a BigQuery ML model. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GetModelRequest { + /// Required. Project ID of the requested model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the requested model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Model ID of the requested model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub model_id: std::string::String, +} + +impl GetModelRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::GetModelRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetModelRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [model_id][crate::model::GetModelRequest::model_id]. + pub fn set_model_id>(mut self, v: T) -> Self { + self.model_id = v.into(); + self + } +} + +impl wkt::message::Message for GetModelRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GetModelRequest" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct PatchModelRequest { + /// Required. Project ID of the model to patch. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the model to patch. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Model ID of the model to patch. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub model_id: std::string::String, + + /// Required. Patched model. + /// Follows RFC5789 patch semantics. Missing fields are not updated. + /// To clear a field, explicitly set to default value. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub model: std::option::Option, +} + +impl PatchModelRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::PatchModelRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::PatchModelRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [model_id][crate::model::PatchModelRequest::model_id]. + pub fn set_model_id>(mut self, v: T) -> Self { + self.model_id = v.into(); + self + } + + /// Sets the value of [model][crate::model::PatchModelRequest::model]. + pub fn set_model>>( + mut self, + v: T, + ) -> Self { + self.model = v.into(); + self + } +} + +impl wkt::message::Message for PatchModelRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.PatchModelRequest" + } +} + +/// Request format for deleting BigQuery ML models. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DeleteModelRequest { + /// Required. Project ID of the model to delete. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the model to delete. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Model ID of the model to delete. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub model_id: std::string::String, +} + +impl DeleteModelRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::DeleteModelRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteModelRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [model_id][crate::model::DeleteModelRequest::model_id]. + pub fn set_model_id>(mut self, v: T) -> Self { + self.model_id = v.into(); + self + } +} + +impl wkt::message::Message for DeleteModelRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DeleteModelRequest" + } +} + +/// Request format for listing BigQuery ML models. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListModelsRequest { + /// Required. Project ID of the models to list. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the models to list. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// The maximum number of results to return in a single response page. + /// Leverage the page tokens to iterate through the entire collection. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub max_results: std::option::Option, + + /// Page token, returned by a previous call to request the next page of + /// results + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub page_token: std::string::String, +} + +impl ListModelsRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::ListModelsRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ListModelsRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [max_results][crate::model::ListModelsRequest::max_results]. + pub fn set_max_results>>( + mut self, + v: T, + ) -> Self { + self.max_results = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListModelsRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.page_token = v.into(); + self + } +} + +impl wkt::message::Message for ListModelsRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListModelsRequest" + } +} + +/// Response format for a single page when listing BigQuery ML models. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListModelsResponse { + /// Models in the requested dataset. Only the following fields are populated: + /// model_reference, model_type, creation_time, last_modified_time and + /// labels. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub models: std::vec::Vec, + + /// A token to request the next page of results. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub next_page_token: std::string::String, +} + +impl ListModelsResponse { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [next_page_token][crate::model::ListModelsResponse::next_page_token]. + pub fn set_next_page_token>(mut self, v: T) -> Self { + self.next_page_token = v.into(); + self + } + + /// Sets the value of [models][crate::model::ListModelsResponse::models]. + pub fn set_models(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.models = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for ListModelsResponse { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListModelsResponse" + } +} + +/// Id path of a model. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ModelReference { + /// Required. The ID of the project containing this model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. The ID of the dataset containing this model. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. The ID of the model. The ID must contain only + /// letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum + /// length is 1,024 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub model_id: std::string::String, +} + +impl ModelReference { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::ModelReference::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ModelReference::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [model_id][crate::model::ModelReference::model_id]. + pub fn set_model_id>(mut self, v: T) -> Self { + self.model_id = v.into(); + self + } +} + +impl wkt::message::Message for ModelReference { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ModelReference" + } +} + +/// The partitioning information, which includes managed table, external table +/// and metastore partitioned table partition information. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct PartitioningDefinition { + /// Optional. Details about each partitioning column. This field is output only + /// for all partitioning types other than metastore partitioned tables. + /// BigQuery native tables only support 1 partitioning column. Other table + /// types may support 0, 1 or more partitioning columns. + /// For metastore partitioned tables, the order must match the definition order + /// in the Hive Metastore, where it must match the physical layout of the + /// table. For example, + /// + /// CREATE TABLE a_table(id BIGINT, name STRING) + /// PARTITIONED BY (city STRING, state STRING). + /// + /// In this case the values must be ['city', 'state'] in that order. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub partitioned_column: std::vec::Vec, +} + +impl PartitioningDefinition { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [partitioned_column][crate::model::PartitioningDefinition::partitioned_column]. + pub fn set_partitioned_column(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.partitioned_column = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for PartitioningDefinition { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.PartitioningDefinition" + } +} + +/// The partitioning column information. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct PartitionedColumn { + /// Required. The name of the partition column. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub field: std::option::Option, +} + +impl PartitionedColumn { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [field][crate::model::PartitionedColumn::field]. + pub fn set_field>>( + mut self, + v: T, + ) -> Self { + self.field = v.into(); + self + } +} + +impl wkt::message::Message for PartitionedColumn { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.PartitionedColumn" + } +} + +/// Represents privacy policy associated with "aggregation threshold" method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct AggregationThresholdPolicy { + /// Optional. The threshold for the "aggregation threshold" policy. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub threshold: std::option::Option, + + /// Optional. The privacy unit column(s) associated with this policy. + /// For now, only one column per data source object (table, view) is allowed as + /// a privacy unit column. + /// Representing as a repeated field in metadata for extensibility to + /// multiple columns in future. + /// Duplicates and Repeated struct fields are not allowed. + /// For nested fields, use dot notation ("outer.inner") + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub privacy_unit_columns: std::vec::Vec, +} + +impl AggregationThresholdPolicy { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [threshold][crate::model::AggregationThresholdPolicy::threshold]. + pub fn set_threshold>>(mut self, v: T) -> Self { + self.threshold = v.into(); + self + } + + /// Sets the value of [privacy_unit_columns][crate::model::AggregationThresholdPolicy::privacy_unit_columns]. + pub fn set_privacy_unit_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.privacy_unit_columns = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for AggregationThresholdPolicy { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.AggregationThresholdPolicy" + } +} + +/// Represents privacy policy associated with "differential privacy" method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DifferentialPrivacyPolicy { + /// Optional. The maximum epsilon value that a query can consume. If the + /// subscriber specifies epsilon as a parameter in a SELECT query, it must be + /// less than or equal to this value. The epsilon parameter controls the amount + /// of noise that is added to the groups — a higher epsilon means less noise. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub max_epsilon_per_query: std::option::Option, + + /// Optional. The delta value that is used per query. Delta represents the + /// probability that any row will fail to be epsilon differentially private. + /// Indicates the risk associated with exposing aggregate rows in the result of + /// a query. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub delta_per_query: std::option::Option, + + /// Optional. The maximum groups contributed value that is used per query. + /// Represents the maximum number of groups to which each protected entity can + /// contribute. Changing this value does not improve or worsen privacy. The + /// best value for accuracy and utility depends on the query and data. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub max_groups_contributed: std::option::Option, + + /// Optional. The privacy unit column associated with this policy. Differential + /// privacy policies can only have one privacy unit column per data source + /// object (table, view). + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub privacy_unit_column: std::option::Option, + + /// Optional. The total epsilon budget for all queries against the + /// privacy-protected view. Each subscriber query against this view charges the + /// amount of epsilon they request in their query. If there is sufficient + /// budget, then the subscriber query attempts to complete. It might still fail + /// due to other reasons, in which case the charge is refunded. If there is + /// insufficient budget the query is rejected. There might be multiple charge + /// attempts if a single query references multiple views. In this case there + /// must be sufficient budget for all charges or the query is rejected and + /// charges are refunded in best effort. The budget does not have a refresh + /// policy and can only be updated via ALTER VIEW or circumvented by creating a + /// new view that can be queried with a fresh budget. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub epsilon_budget: std::option::Option, + + /// Optional. The total delta budget for all queries against the + /// privacy-protected view. Each subscriber query against this view charges the + /// amount of delta that is pre-defined by the contributor through the privacy + /// policy delta_per_query field. If there is sufficient budget, then the + /// subscriber query attempts to complete. It might still fail due to other + /// reasons, in which case the charge is refunded. If there is insufficient + /// budget the query is rejected. There might be multiple charge attempts if a + /// single query references multiple views. In this case there must be + /// sufficient budget for all charges or the query is rejected and charges are + /// refunded in best effort. The budget does not have a refresh policy and can + /// only be updated via ALTER VIEW or circumvented by creating a new view that + /// can be queried with a fresh budget. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub delta_budget: std::option::Option, + + /// Output only. The epsilon budget remaining. If budget is exhausted, no more + /// queries are allowed. Note that the budget for queries that are in progress + /// is deducted before the query executes. If the query fails or is cancelled + /// then the budget is refunded. In this case the amount of budget remaining + /// can increase. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub epsilon_budget_remaining: std::option::Option, + + /// Output only. The delta budget remaining. If budget is exhausted, no more + /// queries are allowed. Note that the budget for queries that are in progress + /// is deducted before the query executes. If the query fails or is cancelled + /// then the budget is refunded. In this case the amount of budget remaining + /// can increase. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub delta_budget_remaining: std::option::Option, +} + +impl DifferentialPrivacyPolicy { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [max_epsilon_per_query][crate::model::DifferentialPrivacyPolicy::max_epsilon_per_query]. + pub fn set_max_epsilon_per_query>>( + mut self, + v: T, + ) -> Self { + self.max_epsilon_per_query = v.into(); + self + } + + /// Sets the value of [delta_per_query][crate::model::DifferentialPrivacyPolicy::delta_per_query]. + pub fn set_delta_per_query>>( + mut self, + v: T, + ) -> Self { + self.delta_per_query = v.into(); + self + } + + /// Sets the value of [max_groups_contributed][crate::model::DifferentialPrivacyPolicy::max_groups_contributed]. + pub fn set_max_groups_contributed>>( + mut self, + v: T, + ) -> Self { + self.max_groups_contributed = v.into(); + self + } + + /// Sets the value of [privacy_unit_column][crate::model::DifferentialPrivacyPolicy::privacy_unit_column]. + pub fn set_privacy_unit_column< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.privacy_unit_column = v.into(); + self + } + + /// Sets the value of [epsilon_budget][crate::model::DifferentialPrivacyPolicy::epsilon_budget]. + pub fn set_epsilon_budget>>( + mut self, + v: T, + ) -> Self { + self.epsilon_budget = v.into(); + self + } + + /// Sets the value of [delta_budget][crate::model::DifferentialPrivacyPolicy::delta_budget]. + pub fn set_delta_budget>>( + mut self, + v: T, + ) -> Self { + self.delta_budget = v.into(); + self + } + + /// Sets the value of [epsilon_budget_remaining][crate::model::DifferentialPrivacyPolicy::epsilon_budget_remaining]. + pub fn set_epsilon_budget_remaining>>( + mut self, + v: T, + ) -> Self { + self.epsilon_budget_remaining = v.into(); + self + } + + /// Sets the value of [delta_budget_remaining][crate::model::DifferentialPrivacyPolicy::delta_budget_remaining]. + pub fn set_delta_budget_remaining>>( + mut self, + v: T, + ) -> Self { + self.delta_budget_remaining = v.into(); + self + } +} + +impl wkt::message::Message for DifferentialPrivacyPolicy { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DifferentialPrivacyPolicy" + } +} + +/// Represents privacy policy associated with "join restrictions". Join +/// restriction gives data providers the ability to enforce joins on the +/// 'join_allowed_columns' when data is queried from a privacy protected view. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct JoinRestrictionPolicy { + /// Optional. Specifies if a join is required or not on queries for the view. + /// Default is JOIN_CONDITION_UNSPECIFIED. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub join_condition: std::option::Option, + + /// Optional. The only columns that joins are allowed on. + /// This field is must be specified for join_conditions JOIN_ANY and JOIN_ALL + /// and it cannot be set for JOIN_BLOCKED. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub join_allowed_columns: std::vec::Vec, +} + +impl JoinRestrictionPolicy { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [join_condition][crate::model::JoinRestrictionPolicy::join_condition]. + pub fn set_join_condition< + T: std::convert::Into< + std::option::Option, + >, + >( + mut self, + v: T, + ) -> Self { + self.join_condition = v.into(); + self + } + + /// Sets the value of [join_allowed_columns][crate::model::JoinRestrictionPolicy::join_allowed_columns]. + pub fn set_join_allowed_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.join_allowed_columns = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for JoinRestrictionPolicy { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.JoinRestrictionPolicy" + } +} + +/// Defines additional types related to JoinRestrictionPolicy +pub mod join_restriction_policy { + #[allow(unused_imports)] + use super::*; + + /// Enum for Join Restrictions policy. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct JoinCondition(i32); + + impl JoinCondition { + /// A join is neither required nor restricted on any column. Default value. + pub const JOIN_CONDITION_UNSPECIFIED: JoinCondition = JoinCondition::new(0); + + /// A join is required on at least one of the specified columns. + pub const JOIN_ANY: JoinCondition = JoinCondition::new(1); + + /// A join is required on all specified columns. + pub const JOIN_ALL: JoinCondition = JoinCondition::new(2); + + /// A join is not required, but if present it is only permitted on + /// 'join_allowed_columns' + pub const JOIN_NOT_REQUIRED: JoinCondition = JoinCondition::new(3); + + /// Joins are blocked for all queries. + pub const JOIN_BLOCKED: JoinCondition = JoinCondition::new(4); + + /// Creates a new JoinCondition instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("JOIN_CONDITION_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("JOIN_ANY"), + 2 => std::borrow::Cow::Borrowed("JOIN_ALL"), + 3 => std::borrow::Cow::Borrowed("JOIN_NOT_REQUIRED"), + 4 => std::borrow::Cow::Borrowed("JOIN_BLOCKED"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "JOIN_CONDITION_UNSPECIFIED" => { + std::option::Option::Some(Self::JOIN_CONDITION_UNSPECIFIED) + } + "JOIN_ANY" => std::option::Option::Some(Self::JOIN_ANY), + "JOIN_ALL" => std::option::Option::Some(Self::JOIN_ALL), + "JOIN_NOT_REQUIRED" => std::option::Option::Some(Self::JOIN_NOT_REQUIRED), + "JOIN_BLOCKED" => std::option::Option::Some(Self::JOIN_BLOCKED), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for JoinCondition { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for JoinCondition { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Represents privacy policy that contains the privacy requirements specified by +/// the data owner. Currently, this is only supported on views. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct PrivacyPolicy { + /// Optional. Join restriction policy is outside of the one of policies, since + /// this policy can be set along with other policies. This policy gives data + /// providers the ability to enforce joins on the 'join_allowed_columns' when + /// data is queried from a privacy protected view. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub join_restriction_policy: std::option::Option, + + /// Privacy policy associated with this requirement specification. Only one of + /// the privacy methods is allowed per data source object. + #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")] + pub privacy_policy: std::option::Option, +} + +impl PrivacyPolicy { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [join_restriction_policy][crate::model::PrivacyPolicy::join_restriction_policy]. + pub fn set_join_restriction_policy< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.join_restriction_policy = v.into(); + self + } + + /// Sets the value of `privacy_policy`. + pub fn set_privacy_policy< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.privacy_policy = v.into(); + self + } + + /// The value of [privacy_policy][crate::model::PrivacyPolicy::privacy_policy] + /// if it holds a `AggregationThresholdPolicy`, `None` if the field is not set or + /// holds a different branch. + pub fn get_aggregation_threshold_policy( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.privacy_policy.as_ref().and_then(|v| match v { + crate::model::privacy_policy::PrivacyPolicy::AggregationThresholdPolicy(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [privacy_policy][crate::model::PrivacyPolicy::privacy_policy] + /// if it holds a `DifferentialPrivacyPolicy`, `None` if the field is not set or + /// holds a different branch. + pub fn get_differential_privacy_policy( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.privacy_policy.as_ref().and_then(|v| match v { + crate::model::privacy_policy::PrivacyPolicy::DifferentialPrivacyPolicy(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// Sets the value of [privacy_policy][crate::model::PrivacyPolicy::privacy_policy] + /// to hold a `AggregationThresholdPolicy`. + /// + /// Note that all the setters affecting `privacy_policy` are + /// mutually exclusive. + pub fn set_aggregation_threshold_policy< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.privacy_policy = std::option::Option::Some( + crate::model::privacy_policy::PrivacyPolicy::AggregationThresholdPolicy(v.into()), + ); + self + } + + /// Sets the value of [privacy_policy][crate::model::PrivacyPolicy::privacy_policy] + /// to hold a `DifferentialPrivacyPolicy`. + /// + /// Note that all the setters affecting `privacy_policy` are + /// mutually exclusive. + pub fn set_differential_privacy_policy< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.privacy_policy = std::option::Option::Some( + crate::model::privacy_policy::PrivacyPolicy::DifferentialPrivacyPolicy(v.into()), + ); + self + } +} + +impl wkt::message::Message for PrivacyPolicy { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.PrivacyPolicy" + } +} + +/// Defines additional types related to PrivacyPolicy +pub mod privacy_policy { + #[allow(unused_imports)] + use super::*; + + /// Privacy policy associated with this requirement specification. Only one of + /// the privacy methods is allowed per data source object. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(rename_all = "camelCase")] + #[non_exhaustive] + pub enum PrivacyPolicy { + /// Optional. Policy used for aggregation thresholds. + AggregationThresholdPolicy(std::boxed::Box), + /// Optional. Policy used for differential privacy. + DifferentialPrivacyPolicy(std::boxed::Box), + } +} + +/// Request object of GetServiceAccount +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GetServiceAccountRequest { + /// Required. ID of the project. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, +} + +impl GetServiceAccountRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::GetServiceAccountRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } +} + +impl wkt::message::Message for GetServiceAccountRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GetServiceAccountRequest" + } +} + +/// Response object of GetServiceAccount +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GetServiceAccountResponse { + /// The resource type of the response. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub kind: std::string::String, + + /// The service account email address. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub email: std::string::String, +} + +impl GetServiceAccountResponse { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [kind][crate::model::GetServiceAccountResponse::kind]. + pub fn set_kind>(mut self, v: T) -> Self { + self.kind = v.into(); + self + } + + /// Sets the value of [email][crate::model::GetServiceAccountResponse::email]. + pub fn set_email>(mut self, v: T) -> Self { + self.email = v.into(); + self + } +} + +impl wkt::message::Message for GetServiceAccountResponse { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GetServiceAccountResponse" + } +} + +/// The type of a struct parameter. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct QueryParameterStructType { + /// Optional. The name of this field. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub name: std::string::String, + + /// Required. The type of this field. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub r#type: std::option::Option>, + + /// Optional. Human-oriented description of the field. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub description: std::string::String, +} + +impl QueryParameterStructType { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::QueryParameterStructType::name]. + pub fn set_name>(mut self, v: T) -> Self { + self.name = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::QueryParameterStructType::type]. + pub fn set_type< + T: std::convert::Into>>, + >( + mut self, + v: T, + ) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [description][crate::model::QueryParameterStructType::description]. + pub fn set_description>(mut self, v: T) -> Self { + self.description = v.into(); + self + } +} + +impl wkt::message::Message for QueryParameterStructType { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.QueryParameterStructType" + } +} + +/// The type of a query parameter. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct QueryParameterType { + /// Required. The top level type of this field. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + + /// Optional. The type of the array's elements, if this is an array. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub array_type: std::option::Option>, + + /// Optional. The types of the fields of this struct, in order, if this is a + /// struct. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub struct_types: std::vec::Vec, + + /// Optional. The element type of the range, if this is a range. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub range_element_type: std::option::Option>, +} + +impl QueryParameterType { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [r#type][crate::model::QueryParameterType::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [array_type][crate::model::QueryParameterType::array_type]. + pub fn set_array_type< + T: std::convert::Into>>, + >( + mut self, + v: T, + ) -> Self { + self.array_type = v.into(); + self + } + + /// Sets the value of [range_element_type][crate::model::QueryParameterType::range_element_type]. + pub fn set_range_element_type< + T: std::convert::Into>>, + >( + mut self, + v: T, + ) -> Self { + self.range_element_type = v.into(); + self + } + + /// Sets the value of [struct_types][crate::model::QueryParameterType::struct_types]. + pub fn set_struct_types(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.struct_types = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for QueryParameterType { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.QueryParameterType" + } +} + +/// Represents the value of a range. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct RangeValue { + /// Optional. The start value of the range. A missing value represents an + /// unbounded start. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub start: std::option::Option>, + + /// Optional. The end value of the range. A missing value represents an + /// unbounded end. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub end: std::option::Option>, +} + +impl RangeValue { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [start][crate::model::RangeValue::start]. + pub fn set_start< + T: std::convert::Into>>, + >( + mut self, + v: T, + ) -> Self { + self.start = v.into(); + self + } + + /// Sets the value of [end][crate::model::RangeValue::end]. + pub fn set_end< + T: std::convert::Into>>, + >( + mut self, + v: T, + ) -> Self { + self.end = v.into(); + self + } +} + +impl wkt::message::Message for RangeValue { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.RangeValue" + } +} + +/// The value of a query parameter. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct QueryParameterValue { + /// Optional. The value of this value, if a simple scalar type. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub value: std::option::Option, + + /// Optional. The array values, if this is an array type. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub array_values: std::vec::Vec, + + /// The struct field values. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub struct_values: + std::collections::HashMap, + + /// Optional. The range value, if this is a range type. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub range_value: std::option::Option>, + + /// This field should not be used. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub alt_struct_values: std::vec::Vec, +} + +impl QueryParameterValue { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [value][crate::model::QueryParameterValue::value]. + pub fn set_value>>( + mut self, + v: T, + ) -> Self { + self.value = v.into(); + self + } + + /// Sets the value of [range_value][crate::model::QueryParameterValue::range_value]. + pub fn set_range_value< + T: std::convert::Into>>, + >( + mut self, + v: T, + ) -> Self { + self.range_value = v.into(); + self + } + + /// Sets the value of [array_values][crate::model::QueryParameterValue::array_values]. + pub fn set_array_values(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.array_values = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [alt_struct_values][crate::model::QueryParameterValue::alt_struct_values]. + pub fn set_alt_struct_values(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.alt_struct_values = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [struct_values][crate::model::QueryParameterValue::struct_values]. + pub fn set_struct_values(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.struct_values = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for QueryParameterValue { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.QueryParameterValue" + } +} + +/// A parameter given to a query. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct QueryParameter { + /// Optional. If unset, this is a positional parameter. Otherwise, should be + /// unique within a query. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub name: std::string::String, + + /// Required. The type of this parameter. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub parameter_type: std::option::Option, + + /// Required. The value of this parameter. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub parameter_value: std::option::Option, +} + +impl QueryParameter { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::QueryParameter::name]. + pub fn set_name>(mut self, v: T) -> Self { + self.name = v.into(); + self + } + + /// Sets the value of [parameter_type][crate::model::QueryParameter::parameter_type]. + pub fn set_parameter_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.parameter_type = v.into(); + self + } + + /// Sets the value of [parameter_value][crate::model::QueryParameter::parameter_value]. + pub fn set_parameter_value< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.parameter_value = v.into(); + self + } +} + +impl wkt::message::Message for QueryParameter { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.QueryParameter" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct RangePartitioning { + /// Required. The name of the column to partition the table on. It must be a + /// top-level, INT64 column whose mode is NULLABLE or REQUIRED. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub field: std::string::String, + + /// Defines the ranges for range partitioning. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub range: std::option::Option, +} + +impl RangePartitioning { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [field][crate::model::RangePartitioning::field]. + pub fn set_field>(mut self, v: T) -> Self { + self.field = v.into(); + self + } + + /// Sets the value of [range][crate::model::RangePartitioning::range]. + pub fn set_range< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.range = v.into(); + self + } +} + +impl wkt::message::Message for RangePartitioning { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.RangePartitioning" + } +} + +/// Defines additional types related to RangePartitioning +pub mod range_partitioning { + #[allow(unused_imports)] + use super::*; + + /// Defines the ranges for range partitioning. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct Range { + /// Required. The start of range partitioning, inclusive. This field is an + /// INT64 value represented as a string. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub start: std::string::String, + + /// Required. The end of range partitioning, exclusive. This field is an + /// INT64 value represented as a string. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub end: std::string::String, + + /// Required. The width of each interval. This field is an INT64 value + /// represented as a string. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub interval: std::string::String, + } + + impl Range { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [start][crate::model::range_partitioning::Range::start]. + pub fn set_start>(mut self, v: T) -> Self { + self.start = v.into(); + self + } + + /// Sets the value of [end][crate::model::range_partitioning::Range::end]. + pub fn set_end>(mut self, v: T) -> Self { + self.end = v.into(); + self + } + + /// Sets the value of [interval][crate::model::range_partitioning::Range::interval]. + pub fn set_interval>(mut self, v: T) -> Self { + self.interval = v.into(); + self + } + } + + impl wkt::message::Message for Range { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.RangePartitioning.Range" + } + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct RestrictionConfig { + /// Output only. Specifies the type of dataset/table restriction. + #[serde(rename = "type")] + pub r#type: crate::model::restriction_config::RestrictionType, +} + +impl RestrictionConfig { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [r#type][crate::model::RestrictionConfig::type]. + pub fn set_type>( + mut self, + v: T, + ) -> Self { + self.r#type = v.into(); + self + } +} + +impl wkt::message::Message for RestrictionConfig { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.RestrictionConfig" + } +} + +/// Defines additional types related to RestrictionConfig +pub mod restriction_config { + #[allow(unused_imports)] + use super::*; + + /// RestrictionType specifies the type of dataset/table restriction. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct RestrictionType(i32); + + impl RestrictionType { + /// Should never be used. + pub const RESTRICTION_TYPE_UNSPECIFIED: RestrictionType = RestrictionType::new(0); + + /// Restrict data egress. See [Data + /// egress](https://cloud.google.com/bigquery/docs/analytics-hub-introduction#data_egress) + /// for more details. + pub const RESTRICTED_DATA_EGRESS: RestrictionType = RestrictionType::new(1); + + /// Creates a new RestrictionType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("RESTRICTION_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("RESTRICTED_DATA_EGRESS"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "RESTRICTION_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::RESTRICTION_TYPE_UNSPECIFIED) + } + "RESTRICTED_DATA_EGRESS" => std::option::Option::Some(Self::RESTRICTED_DATA_EGRESS), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for RestrictionType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for RestrictionType { + fn default() -> Self { + Self::new(0) + } + } +} + +/// A user-defined function or a stored procedure. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Routine { + /// Output only. A hash of this resource. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub etag: std::string::String, + + /// Required. Reference describing the ID of this routine. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub routine_reference: std::option::Option, + + /// Required. The type of routine. + pub routine_type: crate::model::routine::RoutineType, + + /// Output only. The time when this routine was created, in milliseconds since + /// the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub creation_time: i64, + + /// Output only. The time when this routine was last modified, in milliseconds + /// since the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub last_modified_time: i64, + + /// Optional. Defaults to "SQL" if remote_function_options field is absent, not + /// set otherwise. + pub language: crate::model::routine::Language, + + /// Optional. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub arguments: std::vec::Vec, + + /// Optional if language = "SQL"; required otherwise. + /// Cannot be set if routine_type = "TABLE_VALUED_FUNCTION". + /// + /// If absent, the return type is inferred from definition_body at query time + /// in each query that references this routine. If present, then the evaluated + /// result will be cast to the specified returned type at query time. + /// + /// For example, for the functions created with the following statements: + /// + /// * `CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);` + /// + /// * `CREATE FUNCTION Increment(x FLOAT64) AS (Add(x, 1));` + /// + /// * `CREATE FUNCTION Decrement(x FLOAT64) RETURNS FLOAT64 AS (Add(x, -1));` + /// + /// + /// The return_type is `{type_kind: "FLOAT64"}` for `Add` and `Decrement`, and + /// is absent for `Increment` (inferred as FLOAT64 at query time). + /// + /// Suppose the function `Add` is replaced by + /// `CREATE OR REPLACE FUNCTION Add(x INT64, y INT64) AS (x + y);` + /// + /// Then the inferred return type of `Increment` is automatically changed to + /// INT64 at query time, while the return type of `Decrement` remains FLOAT64. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub return_type: std::option::Option, + + /// Optional. Can be set only if routine_type = "TABLE_VALUED_FUNCTION". + /// + /// If absent, the return table type is inferred from definition_body at query + /// time in each query that references this routine. If present, then the + /// columns in the evaluated table result will be cast to match the column + /// types specified in return table type, at query time. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub return_table_type: std::option::Option, + + /// Optional. If language = "JAVASCRIPT", this field stores the path of the + /// imported JAVASCRIPT libraries. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub imported_libraries: std::vec::Vec, + + /// Required. The body of the routine. + /// + /// For functions, this is the expression in the AS clause. + /// + /// If language=SQL, it is the substring inside (but excluding) the + /// parentheses. For example, for the function created with the following + /// statement: + /// + /// `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` + /// + /// The definition_body is `concat(x, "\n", y)` (\n is not replaced with + /// linebreak). + /// + /// If language=JAVASCRIPT, it is the evaluated string in the AS clause. + /// For example, for the function created with the following statement: + /// + /// `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` + /// + /// The definition_body is + /// + /// `return "\n";\n` + /// + /// Note that both \n are replaced with linebreaks. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub definition_body: std::string::String, + + /// Optional. The description of the routine, if defined. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub description: std::string::String, + + /// Optional. The determinism level of the JavaScript UDF, if defined. + pub determinism_level: crate::model::routine::DeterminismLevel, + + /// Optional. The security mode of the routine, if defined. If not defined, the + /// security mode is automatically determined from the routine's configuration. + pub security_mode: crate::model::routine::SecurityMode, + + /// Optional. Use this option to catch many common errors. Error checking is + /// not exhaustive, and successfully creating a procedure doesn't guarantee + /// that the procedure will successfully execute at runtime. If `strictMode` is + /// set to `TRUE`, the procedure body is further checked for errors such as + /// non-existent tables or columns. The `CREATE PROCEDURE` statement fails if + /// the body fails any of these checks. + /// + /// If `strictMode` is set to `FALSE`, the procedure body is checked only for + /// syntax. For procedures that invoke themselves recursively, specify + /// `strictMode=FALSE` to avoid non-existent procedure errors during + /// validation. + /// + /// Default value is `TRUE`. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub strict_mode: std::option::Option, + + /// Optional. Remote function specific options. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub remote_function_options: std::option::Option, + + /// Optional. Spark specific options. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub spark_options: std::option::Option, + + /// Optional. If set to `DATA_MASKING`, the function is validated and made + /// available as a masking function. For more information, see [Create custom + /// masking + /// routines](https://cloud.google.com/bigquery/docs/user-defined-functions#custom-mask). + pub data_governance_type: crate::model::routine::DataGovernanceType, +} + +impl Routine { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [etag][crate::model::Routine::etag]. + pub fn set_etag>(mut self, v: T) -> Self { + self.etag = v.into(); + self + } + + /// Sets the value of [routine_reference][crate::model::Routine::routine_reference]. + pub fn set_routine_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.routine_reference = v.into(); + self + } + + /// Sets the value of [routine_type][crate::model::Routine::routine_type]. + pub fn set_routine_type>( + mut self, + v: T, + ) -> Self { + self.routine_type = v.into(); + self + } + + /// Sets the value of [creation_time][crate::model::Routine::creation_time]. + pub fn set_creation_time>(mut self, v: T) -> Self { + self.creation_time = v.into(); + self + } + + /// Sets the value of [last_modified_time][crate::model::Routine::last_modified_time]. + pub fn set_last_modified_time>(mut self, v: T) -> Self { + self.last_modified_time = v.into(); + self + } + + /// Sets the value of [language][crate::model::Routine::language]. + pub fn set_language>( + mut self, + v: T, + ) -> Self { + self.language = v.into(); + self + } + + /// Sets the value of [return_type][crate::model::Routine::return_type]. + pub fn set_return_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.return_type = v.into(); + self + } + + /// Sets the value of [return_table_type][crate::model::Routine::return_table_type]. + pub fn set_return_table_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.return_table_type = v.into(); + self + } + + /// Sets the value of [definition_body][crate::model::Routine::definition_body]. + pub fn set_definition_body>(mut self, v: T) -> Self { + self.definition_body = v.into(); + self + } + + /// Sets the value of [description][crate::model::Routine::description]. + pub fn set_description>(mut self, v: T) -> Self { + self.description = v.into(); + self + } + + /// Sets the value of [determinism_level][crate::model::Routine::determinism_level]. + pub fn set_determinism_level>( + mut self, + v: T, + ) -> Self { + self.determinism_level = v.into(); + self + } + + /// Sets the value of [security_mode][crate::model::Routine::security_mode]. + pub fn set_security_mode>( + mut self, + v: T, + ) -> Self { + self.security_mode = v.into(); + self + } + + /// Sets the value of [strict_mode][crate::model::Routine::strict_mode]. + pub fn set_strict_mode>>( + mut self, + v: T, + ) -> Self { + self.strict_mode = v.into(); + self + } + + /// Sets the value of [remote_function_options][crate::model::Routine::remote_function_options]. + pub fn set_remote_function_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.remote_function_options = v.into(); + self + } + + /// Sets the value of [spark_options][crate::model::Routine::spark_options]. + pub fn set_spark_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.spark_options = v.into(); + self + } + + /// Sets the value of [data_governance_type][crate::model::Routine::data_governance_type]. + pub fn set_data_governance_type< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.data_governance_type = v.into(); + self + } + + /// Sets the value of [arguments][crate::model::Routine::arguments]. + pub fn set_arguments(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.arguments = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [imported_libraries][crate::model::Routine::imported_libraries]. + pub fn set_imported_libraries(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.imported_libraries = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for Routine { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Routine" + } +} + +/// Defines additional types related to Routine +pub mod routine { + #[allow(unused_imports)] + use super::*; + + /// Input/output argument of a function or a stored procedure. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct Argument { + /// Optional. The name of this argument. Can be absent for function return + /// argument. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub name: std::string::String, + + /// Optional. Defaults to FIXED_TYPE. + pub argument_kind: crate::model::routine::argument::ArgumentKind, + + /// Optional. Specifies whether the argument is input or output. + /// Can be set for procedures only. + pub mode: crate::model::routine::argument::Mode, + + /// Set if argument_kind == FIXED_TYPE. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub data_type: std::option::Option, + + /// Optional. Whether the argument is an aggregate function parameter. + /// Must be Unset for routine types other than AGGREGATE_FUNCTION. + /// For AGGREGATE_FUNCTION, if set to false, it is equivalent to adding "NOT + /// AGGREGATE" clause in DDL; Otherwise, it is equivalent to omitting "NOT + /// AGGREGATE" clause in DDL. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub is_aggregate: std::option::Option, + } + + impl Argument { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::routine::Argument::name]. + pub fn set_name>(mut self, v: T) -> Self { + self.name = v.into(); + self + } + + /// Sets the value of [argument_kind][crate::model::routine::Argument::argument_kind]. + pub fn set_argument_kind< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.argument_kind = v.into(); + self + } + + /// Sets the value of [mode][crate::model::routine::Argument::mode]. + pub fn set_mode>( + mut self, + v: T, + ) -> Self { + self.mode = v.into(); + self + } + + /// Sets the value of [data_type][crate::model::routine::Argument::data_type]. + pub fn set_data_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.data_type = v.into(); + self + } + + /// Sets the value of [is_aggregate][crate::model::routine::Argument::is_aggregate]. + pub fn set_is_aggregate>>( + mut self, + v: T, + ) -> Self { + self.is_aggregate = v.into(); + self + } + } + + impl wkt::message::Message for Argument { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Routine.Argument" + } + } + + /// Defines additional types related to Argument + pub mod argument { + #[allow(unused_imports)] + use super::*; + + /// Represents the kind of a given argument. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct ArgumentKind(i32); + + impl ArgumentKind { + /// Default value. + pub const ARGUMENT_KIND_UNSPECIFIED: ArgumentKind = ArgumentKind::new(0); + + /// The argument is a variable with fully specified type, which can be a + /// struct or an array, but not a table. + pub const FIXED_TYPE: ArgumentKind = ArgumentKind::new(1); + + /// The argument is any type, including struct or array, but not a table. + pub const ANY_TYPE: ArgumentKind = ArgumentKind::new(2); + + /// Creates a new ArgumentKind instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("ARGUMENT_KIND_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("FIXED_TYPE"), + 2 => std::borrow::Cow::Borrowed("ANY_TYPE"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "ARGUMENT_KIND_UNSPECIFIED" => { + std::option::Option::Some(Self::ARGUMENT_KIND_UNSPECIFIED) + } + "FIXED_TYPE" => std::option::Option::Some(Self::FIXED_TYPE), + "ANY_TYPE" => std::option::Option::Some(Self::ANY_TYPE), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for ArgumentKind { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for ArgumentKind { + fn default() -> Self { + Self::new(0) + } + } + + /// The input/output mode of the argument. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct Mode(i32); + + impl Mode { + /// Default value. + pub const MODE_UNSPECIFIED: Mode = Mode::new(0); + + /// The argument is input-only. + pub const IN: Mode = Mode::new(1); + + /// The argument is output-only. + pub const OUT: Mode = Mode::new(2); + + /// The argument is both an input and an output. + pub const INOUT: Mode = Mode::new(3); + + /// Creates a new Mode instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("MODE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("IN"), + 2 => std::borrow::Cow::Borrowed("OUT"), + 3 => std::borrow::Cow::Borrowed("INOUT"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "MODE_UNSPECIFIED" => std::option::Option::Some(Self::MODE_UNSPECIFIED), + "IN" => std::option::Option::Some(Self::IN), + "OUT" => std::option::Option::Some(Self::OUT), + "INOUT" => std::option::Option::Some(Self::INOUT), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for Mode { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for Mode { + fn default() -> Self { + Self::new(0) + } + } + } + + /// Options for a remote user-defined function. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct RemoteFunctionOptions { + /// Endpoint of the user-provided remote service, e.g. + /// `````` + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub endpoint: std::string::String, + + /// Fully qualified name of the user-provided connection object which holds + /// the authentication information to send requests to the remote service. + /// Format: + /// ```"projects/{projectId}/locations/{locationId}/connections/{connectionId}"``` + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub connection: std::string::String, + + /// User-defined context as a set of key/value pairs, which will be sent as + /// function invocation context together with batched arguments in the + /// requests to the remote service. The total number of bytes of keys and + /// values must be less than 8KB. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub user_defined_context: + std::collections::HashMap, + + /// Max number of rows in each batch sent to the remote service. + /// If absent or if 0, BigQuery dynamically decides the number of rows in a + /// batch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub max_batching_rows: i64, + } + + impl RemoteFunctionOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [endpoint][crate::model::routine::RemoteFunctionOptions::endpoint]. + pub fn set_endpoint>(mut self, v: T) -> Self { + self.endpoint = v.into(); + self + } + + /// Sets the value of [connection][crate::model::routine::RemoteFunctionOptions::connection]. + pub fn set_connection>(mut self, v: T) -> Self { + self.connection = v.into(); + self + } + + /// Sets the value of [max_batching_rows][crate::model::routine::RemoteFunctionOptions::max_batching_rows]. + pub fn set_max_batching_rows>(mut self, v: T) -> Self { + self.max_batching_rows = v.into(); + self + } + + /// Sets the value of [user_defined_context][crate::model::routine::RemoteFunctionOptions::user_defined_context]. + pub fn set_user_defined_context(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.user_defined_context = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } + } + + impl wkt::message::Message for RemoteFunctionOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Routine.RemoteFunctionOptions" + } + } + + /// The fine-grained type of the routine. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct RoutineType(i32); + + impl RoutineType { + /// Default value. + pub const ROUTINE_TYPE_UNSPECIFIED: RoutineType = RoutineType::new(0); + + /// Non-built-in persistent scalar function. + pub const SCALAR_FUNCTION: RoutineType = RoutineType::new(1); + + /// Stored procedure. + pub const PROCEDURE: RoutineType = RoutineType::new(2); + + /// Non-built-in persistent TVF. + pub const TABLE_VALUED_FUNCTION: RoutineType = RoutineType::new(3); + + /// Non-built-in persistent aggregate function. + pub const AGGREGATE_FUNCTION: RoutineType = RoutineType::new(4); + + /// Creates a new RoutineType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("ROUTINE_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("SCALAR_FUNCTION"), + 2 => std::borrow::Cow::Borrowed("PROCEDURE"), + 3 => std::borrow::Cow::Borrowed("TABLE_VALUED_FUNCTION"), + 4 => std::borrow::Cow::Borrowed("AGGREGATE_FUNCTION"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "ROUTINE_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::ROUTINE_TYPE_UNSPECIFIED) + } + "SCALAR_FUNCTION" => std::option::Option::Some(Self::SCALAR_FUNCTION), + "PROCEDURE" => std::option::Option::Some(Self::PROCEDURE), + "TABLE_VALUED_FUNCTION" => std::option::Option::Some(Self::TABLE_VALUED_FUNCTION), + "AGGREGATE_FUNCTION" => std::option::Option::Some(Self::AGGREGATE_FUNCTION), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for RoutineType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for RoutineType { + fn default() -> Self { + Self::new(0) + } + } + + /// The language of the routine. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct Language(i32); + + impl Language { + /// Default value. + pub const LANGUAGE_UNSPECIFIED: Language = Language::new(0); + + /// SQL language. + pub const SQL: Language = Language::new(1); + + /// JavaScript language. + pub const JAVASCRIPT: Language = Language::new(2); + + /// Python language. + pub const PYTHON: Language = Language::new(3); + + /// Java language. + pub const JAVA: Language = Language::new(4); + + /// Scala language. + pub const SCALA: Language = Language::new(5); + + /// Creates a new Language instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("LANGUAGE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("SQL"), + 2 => std::borrow::Cow::Borrowed("JAVASCRIPT"), + 3 => std::borrow::Cow::Borrowed("PYTHON"), + 4 => std::borrow::Cow::Borrowed("JAVA"), + 5 => std::borrow::Cow::Borrowed("SCALA"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "LANGUAGE_UNSPECIFIED" => std::option::Option::Some(Self::LANGUAGE_UNSPECIFIED), + "SQL" => std::option::Option::Some(Self::SQL), + "JAVASCRIPT" => std::option::Option::Some(Self::JAVASCRIPT), + "PYTHON" => std::option::Option::Some(Self::PYTHON), + "JAVA" => std::option::Option::Some(Self::JAVA), + "SCALA" => std::option::Option::Some(Self::SCALA), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for Language { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for Language { + fn default() -> Self { + Self::new(0) + } + } + + /// JavaScript UDF determinism levels. + /// + /// If all JavaScript UDFs are DETERMINISTIC, the query result is + /// potentially cacheable (see below). If any JavaScript UDF is + /// NOT_DETERMINISTIC, the query result is not cacheable. + /// + /// Even if a JavaScript UDF is deterministic, many other factors can prevent + /// usage of cached query results. Example factors include but not limited to: + /// DDL/DML, non-deterministic SQL function calls, update of referenced + /// tables/views/UDFs or imported JavaScript libraries. + /// + /// SQL UDFs cannot have determinism specified. Their determinism is + /// automatically determined. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct DeterminismLevel(i32); + + impl DeterminismLevel { + /// The determinism of the UDF is unspecified. + pub const DETERMINISM_LEVEL_UNSPECIFIED: DeterminismLevel = DeterminismLevel::new(0); + + /// The UDF is deterministic, meaning that 2 function calls with the same + /// inputs always produce the same result, even across 2 query runs. + pub const DETERMINISTIC: DeterminismLevel = DeterminismLevel::new(1); + + /// The UDF is not deterministic. + pub const NOT_DETERMINISTIC: DeterminismLevel = DeterminismLevel::new(2); + + /// Creates a new DeterminismLevel instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("DETERMINISM_LEVEL_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("DETERMINISTIC"), + 2 => std::borrow::Cow::Borrowed("NOT_DETERMINISTIC"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "DETERMINISM_LEVEL_UNSPECIFIED" => { + std::option::Option::Some(Self::DETERMINISM_LEVEL_UNSPECIFIED) + } + "DETERMINISTIC" => std::option::Option::Some(Self::DETERMINISTIC), + "NOT_DETERMINISTIC" => std::option::Option::Some(Self::NOT_DETERMINISTIC), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for DeterminismLevel { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for DeterminismLevel { + fn default() -> Self { + Self::new(0) + } + } + + /// Security mode. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct SecurityMode(i32); + + impl SecurityMode { + /// The security mode of the routine is unspecified. + pub const SECURITY_MODE_UNSPECIFIED: SecurityMode = SecurityMode::new(0); + + /// The routine is to be executed with the privileges of the user who + /// defines it. + pub const DEFINER: SecurityMode = SecurityMode::new(1); + + /// The routine is to be executed with the privileges of the user who + /// invokes it. + pub const INVOKER: SecurityMode = SecurityMode::new(2); + + /// Creates a new SecurityMode instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("SECURITY_MODE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("DEFINER"), + 2 => std::borrow::Cow::Borrowed("INVOKER"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "SECURITY_MODE_UNSPECIFIED" => { + std::option::Option::Some(Self::SECURITY_MODE_UNSPECIFIED) + } + "DEFINER" => std::option::Option::Some(Self::DEFINER), + "INVOKER" => std::option::Option::Some(Self::INVOKER), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for SecurityMode { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for SecurityMode { + fn default() -> Self { + Self::new(0) + } + } + + /// Data governance type values. Only supports `DATA_MASKING`. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct DataGovernanceType(i32); + + impl DataGovernanceType { + /// The data governance type is unspecified. + pub const DATA_GOVERNANCE_TYPE_UNSPECIFIED: DataGovernanceType = DataGovernanceType::new(0); + + /// The data governance type is data masking. + pub const DATA_MASKING: DataGovernanceType = DataGovernanceType::new(1); + + /// Creates a new DataGovernanceType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("DATA_GOVERNANCE_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("DATA_MASKING"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "DATA_GOVERNANCE_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::DATA_GOVERNANCE_TYPE_UNSPECIFIED) + } + "DATA_MASKING" => std::option::Option::Some(Self::DATA_MASKING), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for DataGovernanceType { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for DataGovernanceType { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Options for a user-defined Spark routine. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct SparkOptions { + /// Fully qualified name of the user-provided Spark connection object. Format: + /// ```"projects/{project_id}/locations/{location_id}/connections/{connection_id}"``` + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub connection: std::string::String, + + /// Runtime version. If not specified, the default runtime version is used. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub runtime_version: std::string::String, + + /// Custom container image for the runtime environment. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub container_image: std::string::String, + + /// Configuration properties as a set of key/value pairs, which will be passed + /// on to the Spark application. For more information, see + /// [Apache Spark](https://spark.apache.org/docs/latest/index.html) and the + /// [procedure option + /// list](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#procedure_option_list). + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub properties: std::collections::HashMap, + + /// The main file/jar URI of the Spark application. Exactly one of the + /// definition_body field and the main_file_uri field must be set for Python. + /// Exactly one of main_class and main_file_uri field + /// should be set for Java/Scala language type. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub main_file_uri: std::string::String, + + /// Python files to be placed on the PYTHONPATH for PySpark application. + /// Supported file types: `.py`, `.egg`, and `.zip`. For more information + /// about Apache Spark, see + /// [Apache Spark](https://spark.apache.org/docs/latest/index.html). + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub py_file_uris: std::vec::Vec, + + /// JARs to include on the driver and executor CLASSPATH. + /// For more information about Apache Spark, see + /// [Apache Spark](https://spark.apache.org/docs/latest/index.html). + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub jar_uris: std::vec::Vec, + + /// Files to be placed in the working directory of each executor. + /// For more information about Apache Spark, see + /// [Apache Spark](https://spark.apache.org/docs/latest/index.html). + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub file_uris: std::vec::Vec, + + /// Archive files to be extracted into the working directory of each executor. + /// For more information about Apache Spark, see + /// [Apache Spark](https://spark.apache.org/docs/latest/index.html). + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub archive_uris: std::vec::Vec, + + /// The fully qualified name of a class in jar_uris, for example, + /// com.example.wordcount. Exactly one of main_class and main_jar_uri field + /// should be set for Java/Scala language type. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub main_class: std::string::String, +} + +impl SparkOptions { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [connection][crate::model::SparkOptions::connection]. + pub fn set_connection>(mut self, v: T) -> Self { + self.connection = v.into(); + self + } + + /// Sets the value of [runtime_version][crate::model::SparkOptions::runtime_version]. + pub fn set_runtime_version>(mut self, v: T) -> Self { + self.runtime_version = v.into(); + self + } + + /// Sets the value of [container_image][crate::model::SparkOptions::container_image]. + pub fn set_container_image>(mut self, v: T) -> Self { + self.container_image = v.into(); + self + } + + /// Sets the value of [main_file_uri][crate::model::SparkOptions::main_file_uri]. + pub fn set_main_file_uri>(mut self, v: T) -> Self { + self.main_file_uri = v.into(); + self + } + + /// Sets the value of [main_class][crate::model::SparkOptions::main_class]. + pub fn set_main_class>(mut self, v: T) -> Self { + self.main_class = v.into(); + self + } + + /// Sets the value of [py_file_uris][crate::model::SparkOptions::py_file_uris]. + pub fn set_py_file_uris(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.py_file_uris = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [jar_uris][crate::model::SparkOptions::jar_uris]. + pub fn set_jar_uris(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.jar_uris = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [file_uris][crate::model::SparkOptions::file_uris]. + pub fn set_file_uris(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.file_uris = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [archive_uris][crate::model::SparkOptions::archive_uris]. + pub fn set_archive_uris(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.archive_uris = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [properties][crate::model::SparkOptions::properties]. + pub fn set_properties(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.properties = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for SparkOptions { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.SparkOptions" + } +} + +/// Describes the format for getting information about a routine. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GetRoutineRequest { + /// Required. Project ID of the requested routine + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the requested routine + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Routine ID of the requested routine + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub routine_id: std::string::String, +} + +impl GetRoutineRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::GetRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [routine_id][crate::model::GetRoutineRequest::routine_id]. + pub fn set_routine_id>(mut self, v: T) -> Self { + self.routine_id = v.into(); + self + } +} + +impl wkt::message::Message for GetRoutineRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GetRoutineRequest" + } +} + +/// Describes the format for inserting a routine. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct InsertRoutineRequest { + /// Required. Project ID of the new routine + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the new routine + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. A routine resource to insert + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub routine: std::option::Option, +} + +impl InsertRoutineRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::InsertRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::InsertRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [routine][crate::model::InsertRoutineRequest::routine]. + pub fn set_routine>>( + mut self, + v: T, + ) -> Self { + self.routine = v.into(); + self + } +} + +impl wkt::message::Message for InsertRoutineRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.InsertRoutineRequest" + } +} + +/// Describes the format for updating a routine. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct UpdateRoutineRequest { + /// Required. Project ID of the routine to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the routine to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Routine ID of the routine to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub routine_id: std::string::String, + + /// Required. A routine resource which will replace the specified routine + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub routine: std::option::Option, +} + +impl UpdateRoutineRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::UpdateRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [routine_id][crate::model::UpdateRoutineRequest::routine_id]. + pub fn set_routine_id>(mut self, v: T) -> Self { + self.routine_id = v.into(); + self + } + + /// Sets the value of [routine][crate::model::UpdateRoutineRequest::routine]. + pub fn set_routine>>( + mut self, + v: T, + ) -> Self { + self.routine = v.into(); + self + } +} + +impl wkt::message::Message for UpdateRoutineRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.UpdateRoutineRequest" + } +} + +/// Describes the format for the partial update (patch) of a routine. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct PatchRoutineRequest { + /// Required. Project ID of the routine to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the routine to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Routine ID of the routine to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub routine_id: std::string::String, + + /// Required. A routine resource which will be used to partially + /// update the specified routine + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub routine: std::option::Option, + + /// Only the Routine fields in the field mask are updated + /// by the given routine. Repeated routine fields will be fully replaced + /// if contained in the field mask. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub field_mask: std::option::Option, +} + +impl PatchRoutineRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::PatchRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::PatchRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [routine_id][crate::model::PatchRoutineRequest::routine_id]. + pub fn set_routine_id>(mut self, v: T) -> Self { + self.routine_id = v.into(); + self + } + + /// Sets the value of [routine][crate::model::PatchRoutineRequest::routine]. + pub fn set_routine>>( + mut self, + v: T, + ) -> Self { + self.routine = v.into(); + self + } + + /// Sets the value of [field_mask][crate::model::PatchRoutineRequest::field_mask]. + pub fn set_field_mask>>( + mut self, + v: T, + ) -> Self { + self.field_mask = v.into(); + self + } +} + +impl wkt::message::Message for PatchRoutineRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.PatchRoutineRequest" + } +} + +/// Describes the format for deleting a routine. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DeleteRoutineRequest { + /// Required. Project ID of the routine to delete + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the routine to delete + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Routine ID of the routine to delete + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub routine_id: std::string::String, +} + +impl DeleteRoutineRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::DeleteRoutineRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteRoutineRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [routine_id][crate::model::DeleteRoutineRequest::routine_id]. + pub fn set_routine_id>(mut self, v: T) -> Self { + self.routine_id = v.into(); + self + } +} + +impl wkt::message::Message for DeleteRoutineRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DeleteRoutineRequest" + } +} + +/// Describes the format for listing routines. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListRoutinesRequest { + /// Required. Project ID of the routines to list + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the routines to list + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// The maximum number of results to return in a single response page. + /// Leverage the page tokens to iterate through the entire collection. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub max_results: std::option::Option, + + /// Page token, returned by a previous call, to request the next page of + /// results + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub page_token: std::string::String, + + /// If set, then only the Routines matching this filter are returned. + /// The supported format is `routineType:{RoutineType}`, where `{RoutineType}` + /// is a RoutineType enum. For example: `routineType:SCALAR_FUNCTION`. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub filter: std::string::String, +} + +impl ListRoutinesRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::ListRoutinesRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ListRoutinesRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [max_results][crate::model::ListRoutinesRequest::max_results]. + pub fn set_max_results>>( + mut self, + v: T, + ) -> Self { + self.max_results = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListRoutinesRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.page_token = v.into(); + self + } + + /// Sets the value of [filter][crate::model::ListRoutinesRequest::filter]. + pub fn set_filter>(mut self, v: T) -> Self { + self.filter = v.into(); + self + } +} + +impl wkt::message::Message for ListRoutinesRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListRoutinesRequest" + } +} + +/// Describes the format of a single result page when listing routines. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListRoutinesResponse { + /// Routines in the requested dataset. Unless read_mask is set in the request, + /// only the following fields are populated: + /// etag, project_id, dataset_id, routine_id, routine_type, creation_time, + /// last_modified_time, language, and remote_function_options. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub routines: std::vec::Vec, + + /// A token to request the next page of results. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub next_page_token: std::string::String, +} + +impl ListRoutinesResponse { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [next_page_token][crate::model::ListRoutinesResponse::next_page_token]. + pub fn set_next_page_token>(mut self, v: T) -> Self { + self.next_page_token = v.into(); + self + } + + /// Sets the value of [routines][crate::model::ListRoutinesResponse::routines]. + pub fn set_routines(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.routines = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for ListRoutinesResponse { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListRoutinesResponse" + } +} + +/// Id path of a routine. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct RoutineReference { + /// Required. The ID of the project containing this routine. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. The ID of the dataset containing this routine. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. The ID of the routine. The ID must contain only + /// letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum + /// length is 256 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub routine_id: std::string::String, +} + +impl RoutineReference { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::RoutineReference::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::RoutineReference::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [routine_id][crate::model::RoutineReference::routine_id]. + pub fn set_routine_id>(mut self, v: T) -> Self { + self.routine_id = v.into(); + self + } +} + +impl wkt::message::Message for RoutineReference { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.RoutineReference" + } +} + +/// Request message for the ListRowAccessPolicies method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListRowAccessPoliciesRequest { + /// Required. Project ID of the row access policies to list. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of row access policies to list. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the table to list row access policies. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// Page token, returned by a previous call, to request the next page of + /// results. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub page_token: std::string::String, + + /// The maximum number of results to return in a single response page. Leverage + /// the page tokens to iterate through the entire collection. + pub page_size: i32, +} + +impl ListRowAccessPoliciesRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::ListRowAccessPoliciesRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ListRowAccessPoliciesRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::ListRowAccessPoliciesRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListRowAccessPoliciesRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.page_token = v.into(); + self + } + + /// Sets the value of [page_size][crate::model::ListRowAccessPoliciesRequest::page_size]. + pub fn set_page_size>(mut self, v: T) -> Self { + self.page_size = v.into(); + self + } +} + +impl wkt::message::Message for ListRowAccessPoliciesRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListRowAccessPoliciesRequest" + } +} + +/// Response message for the ListRowAccessPolicies method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListRowAccessPoliciesResponse { + /// Row access policies on the requested table. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub row_access_policies: std::vec::Vec, + + /// A token to request the next page of results. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub next_page_token: std::string::String, +} + +impl ListRowAccessPoliciesResponse { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [next_page_token][crate::model::ListRowAccessPoliciesResponse::next_page_token]. + pub fn set_next_page_token>(mut self, v: T) -> Self { + self.next_page_token = v.into(); + self + } + + /// Sets the value of [row_access_policies][crate::model::ListRowAccessPoliciesResponse::row_access_policies]. + pub fn set_row_access_policies(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.row_access_policies = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for ListRowAccessPoliciesResponse { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListRowAccessPoliciesResponse" + } +} + +impl gax::paginator::PageableResponse for ListRowAccessPoliciesResponse { + type PageItem = crate::model::RowAccessPolicy; + + fn items(self) -> std::vec::Vec { + self.row_access_policies + } + + fn next_page_token(&self) -> std::string::String { + use std::clone::Clone; + self.next_page_token.clone() + } +} + +/// Request message for the GetRowAccessPolicy method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GetRowAccessPolicyRequest { + /// Required. Project ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// Required. Policy ID of the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub policy_id: std::string::String, +} + +impl GetRowAccessPolicyRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::GetRowAccessPolicyRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetRowAccessPolicyRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::GetRowAccessPolicyRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [policy_id][crate::model::GetRowAccessPolicyRequest::policy_id]. + pub fn set_policy_id>(mut self, v: T) -> Self { + self.policy_id = v.into(); + self + } +} + +impl wkt::message::Message for GetRowAccessPolicyRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GetRowAccessPolicyRequest" + } +} + +/// Request message for the CreateRowAccessPolicy method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct CreateRowAccessPolicyRequest { + /// Required. Project ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// Required. The row access policy to create. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub row_access_policy: std::option::Option, +} + +impl CreateRowAccessPolicyRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::CreateRowAccessPolicyRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::CreateRowAccessPolicyRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::CreateRowAccessPolicyRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [row_access_policy][crate::model::CreateRowAccessPolicyRequest::row_access_policy]. + pub fn set_row_access_policy< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.row_access_policy = v.into(); + self + } +} + +impl wkt::message::Message for CreateRowAccessPolicyRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.CreateRowAccessPolicyRequest" + } +} + +/// Request message for the UpdateRowAccessPolicy method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct UpdateRowAccessPolicyRequest { + /// Required. Project ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the table to get the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// Required. Policy ID of the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub policy_id: std::string::String, + + /// Required. The row access policy to update. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub row_access_policy: std::option::Option, +} + +impl UpdateRowAccessPolicyRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::UpdateRowAccessPolicyRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateRowAccessPolicyRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::UpdateRowAccessPolicyRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [policy_id][crate::model::UpdateRowAccessPolicyRequest::policy_id]. + pub fn set_policy_id>(mut self, v: T) -> Self { + self.policy_id = v.into(); + self + } + + /// Sets the value of [row_access_policy][crate::model::UpdateRowAccessPolicyRequest::row_access_policy]. + pub fn set_row_access_policy< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.row_access_policy = v.into(); + self + } +} + +impl wkt::message::Message for UpdateRowAccessPolicyRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.UpdateRowAccessPolicyRequest" + } +} + +/// Request message for the DeleteRowAccessPolicy method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DeleteRowAccessPolicyRequest { + /// Required. Project ID of the table to delete the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the table to delete the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the table to delete the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// Required. Policy ID of the row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub policy_id: std::string::String, + + /// If set to true, it deletes the row access policy even if it's the last row + /// access policy on the table and the deletion will widen the access rather + /// narrowing it. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub force: std::option::Option, +} + +impl DeleteRowAccessPolicyRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::DeleteRowAccessPolicyRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteRowAccessPolicyRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::DeleteRowAccessPolicyRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [policy_id][crate::model::DeleteRowAccessPolicyRequest::policy_id]. + pub fn set_policy_id>(mut self, v: T) -> Self { + self.policy_id = v.into(); + self + } + + /// Sets the value of [force][crate::model::DeleteRowAccessPolicyRequest::force]. + pub fn set_force>>(mut self, v: T) -> Self { + self.force = v.into(); + self + } +} + +impl wkt::message::Message for DeleteRowAccessPolicyRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DeleteRowAccessPolicyRequest" + } +} + +/// Request message for the BatchDeleteRowAccessPoliciesRequest method. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct BatchDeleteRowAccessPoliciesRequest { + /// Required. Project ID of the table to delete the row access policies. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the table to delete the row access policies. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the table to delete the row access policies. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// Required. Policy IDs of the row access policies. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub policy_ids: std::vec::Vec, + + /// If set to true, it deletes the row access policy even if it's the last row + /// access policy on the table and the deletion will widen the access rather + /// narrowing it. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub force: std::option::Option, +} + +impl BatchDeleteRowAccessPoliciesRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::BatchDeleteRowAccessPoliciesRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::BatchDeleteRowAccessPoliciesRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::BatchDeleteRowAccessPoliciesRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [force][crate::model::BatchDeleteRowAccessPoliciesRequest::force]. + pub fn set_force>>(mut self, v: T) -> Self { + self.force = v.into(); + self + } + + /// Sets the value of [policy_ids][crate::model::BatchDeleteRowAccessPoliciesRequest::policy_ids]. + pub fn set_policy_ids(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.policy_ids = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for BatchDeleteRowAccessPoliciesRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.BatchDeleteRowAccessPoliciesRequest" + } +} + +/// Represents access on a subset of rows on the specified table, defined by its +/// filter predicate. Access to the subset of rows is controlled by its IAM +/// policy. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct RowAccessPolicy { + /// Output only. A hash of this resource. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub etag: std::string::String, + + /// Required. Reference describing the ID of this row access policy. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub row_access_policy_reference: std::option::Option, + + /// Required. A SQL boolean expression that represents the rows defined by this + /// row access policy, similar to the boolean expression in a WHERE clause of a + /// SELECT query on a table. + /// References to other tables, routines, and temporary functions are not + /// supported. + /// + /// Examples: region="EU" + /// date_field = CAST('2019-9-27' as DATE) + /// nullable_field is not NULL + /// numeric_field BETWEEN 1.0 AND 5.0 + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub filter_predicate: std::string::String, + + /// Output only. The time when this row access policy was created, in + /// milliseconds since the epoch. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub creation_time: std::option::Option, + + /// Output only. The time when this row access policy was last modified, in + /// milliseconds since the epoch. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub last_modified_time: std::option::Option, + + /// Optional. Input only. The optional list of iam_member users or groups that + /// specifies the initial members that the row-level access policy should be + /// created with. + /// + /// grantees types: + /// + /// - "user:alice@example.com": An email address that represents a specific + /// Google account. + /// - "serviceAccount:my-other-app@appspot.gserviceaccount.com": An email + /// address that represents a service account. + /// - "group:admins@example.com": An email address that represents a Google + /// group. + /// - "domain:example.com":The Google Workspace domain (primary) that + /// represents all the users of that domain. + /// - "allAuthenticatedUsers": A special identifier that represents all service + /// accounts and all users on the internet who have authenticated with a Google + /// Account. This identifier includes accounts that aren't connected to a + /// Google Workspace or Cloud Identity domain, such as personal Gmail accounts. + /// Users who aren't authenticated, such as anonymous visitors, aren't + /// included. + /// - "allUsers":A special identifier that represents anyone who is on + /// the internet, including authenticated and unauthenticated users. Because + /// BigQuery requires authentication before a user can access the service, + /// allUsers includes only authenticated users. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub grantees: std::vec::Vec, +} + +impl RowAccessPolicy { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [etag][crate::model::RowAccessPolicy::etag]. + pub fn set_etag>(mut self, v: T) -> Self { + self.etag = v.into(); + self + } + + /// Sets the value of [row_access_policy_reference][crate::model::RowAccessPolicy::row_access_policy_reference]. + pub fn set_row_access_policy_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.row_access_policy_reference = v.into(); + self + } + + /// Sets the value of [filter_predicate][crate::model::RowAccessPolicy::filter_predicate]. + pub fn set_filter_predicate>( + mut self, + v: T, + ) -> Self { + self.filter_predicate = v.into(); + self + } + + /// Sets the value of [creation_time][crate::model::RowAccessPolicy::creation_time]. + pub fn set_creation_time>>( + mut self, + v: T, + ) -> Self { + self.creation_time = v.into(); + self + } + + /// Sets the value of [last_modified_time][crate::model::RowAccessPolicy::last_modified_time]. + pub fn set_last_modified_time>>( + mut self, + v: T, + ) -> Self { + self.last_modified_time = v.into(); + self + } + + /// Sets the value of [grantees][crate::model::RowAccessPolicy::grantees]. + pub fn set_grantees(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.grantees = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for RowAccessPolicy { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.RowAccessPolicy" + } +} + +/// Id path of a row access policy. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct RowAccessPolicyReference { + /// Required. The ID of the project containing this row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. The ID of the dataset containing this row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. The ID of the table containing this row access policy. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// Required. The ID of the row access policy. The ID must contain only + /// letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum + /// length is 256 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub policy_id: std::string::String, +} + +impl RowAccessPolicyReference { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::RowAccessPolicyReference::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::RowAccessPolicyReference::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::RowAccessPolicyReference::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [policy_id][crate::model::RowAccessPolicyReference::policy_id]. + pub fn set_policy_id>(mut self, v: T) -> Self { + self.policy_id = v.into(); + self + } +} + +impl wkt::message::Message for RowAccessPolicyReference { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.RowAccessPolicyReference" + } +} + +/// The data type of a variable such as a function argument. +/// Examples include: +/// +/// * INT64: `{"typeKind": "INT64"}` +/// +/// * ARRAY\: +/// +/// * { +/// "typeKind": "ARRAY", +/// "arrayElementType": {"typeKind": "STRING"} +/// } +/// +/// * STRUCT>: +/// +/// * { +/// "typeKind": "STRUCT", +/// "structType": +/// { +/// "fields": +/// [ +/// { +/// "name": "x", +/// "type": {"typeKind": "STRING"} +/// }, +/// { +/// "name": "y", +/// "type": +/// { +/// "typeKind": "ARRAY", +/// "arrayElementType": {"typeKind": "DATE"} +/// } +/// } +/// ] +/// } +/// } +/// +/// * RANGE\: +/// +/// * { +/// "typeKind": "RANGE", +/// "rangeElementType": {"typeKind": "DATE"} +/// } +/// +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct StandardSqlDataType { + /// Required. The top level type of this field. + /// Can be any GoogleSQL data type (e.g., "INT64", "DATE", "ARRAY"). + pub type_kind: crate::model::standard_sql_data_type::TypeKind, + + /// For complex types, the sub type information. + #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")] + pub sub_type: std::option::Option, +} + +impl StandardSqlDataType { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [type_kind][crate::model::StandardSqlDataType::type_kind]. + pub fn set_type_kind>( + mut self, + v: T, + ) -> Self { + self.type_kind = v.into(); + self + } + + /// Sets the value of `sub_type`. + pub fn set_sub_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.sub_type = v.into(); + self + } + + /// The value of [sub_type][crate::model::StandardSqlDataType::sub_type] + /// if it holds a `ArrayElementType`, `None` if the field is not set or + /// holds a different branch. + pub fn get_array_element_type( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.sub_type.as_ref().and_then(|v| match v { + crate::model::standard_sql_data_type::SubType::ArrayElementType(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [sub_type][crate::model::StandardSqlDataType::sub_type] + /// if it holds a `StructType`, `None` if the field is not set or + /// holds a different branch. + pub fn get_struct_type( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.sub_type.as_ref().and_then(|v| match v { + crate::model::standard_sql_data_type::SubType::StructType(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// The value of [sub_type][crate::model::StandardSqlDataType::sub_type] + /// if it holds a `RangeElementType`, `None` if the field is not set or + /// holds a different branch. + pub fn get_range_element_type( + &self, + ) -> std::option::Option<&std::boxed::Box> { + #[allow(unreachable_patterns)] + self.sub_type.as_ref().and_then(|v| match v { + crate::model::standard_sql_data_type::SubType::RangeElementType(v) => { + std::option::Option::Some(v) + } + _ => std::option::Option::None, + }) + } + + /// Sets the value of [sub_type][crate::model::StandardSqlDataType::sub_type] + /// to hold a `ArrayElementType`. + /// + /// Note that all the setters affecting `sub_type` are + /// mutually exclusive. + pub fn set_array_element_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.sub_type = std::option::Option::Some( + crate::model::standard_sql_data_type::SubType::ArrayElementType(v.into()), + ); + self + } + + /// Sets the value of [sub_type][crate::model::StandardSqlDataType::sub_type] + /// to hold a `StructType`. + /// + /// Note that all the setters affecting `sub_type` are + /// mutually exclusive. + pub fn set_struct_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.sub_type = std::option::Option::Some( + crate::model::standard_sql_data_type::SubType::StructType(v.into()), + ); + self + } + + /// Sets the value of [sub_type][crate::model::StandardSqlDataType::sub_type] + /// to hold a `RangeElementType`. + /// + /// Note that all the setters affecting `sub_type` are + /// mutually exclusive. + pub fn set_range_element_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.sub_type = std::option::Option::Some( + crate::model::standard_sql_data_type::SubType::RangeElementType(v.into()), + ); + self + } +} + +impl wkt::message::Message for StandardSqlDataType { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.StandardSqlDataType" + } +} + +/// Defines additional types related to StandardSqlDataType +pub mod standard_sql_data_type { + #[allow(unused_imports)] + use super::*; + + /// The kind of the datatype. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct TypeKind(i32); + + impl TypeKind { + /// Invalid type. + pub const TYPE_KIND_UNSPECIFIED: TypeKind = TypeKind::new(0); + + /// Encoded as a string in decimal format. + pub const INT64: TypeKind = TypeKind::new(2); + + /// Encoded as a boolean "false" or "true". + pub const BOOL: TypeKind = TypeKind::new(5); + + /// Encoded as a number, or string "NaN", "Infinity" or "-Infinity". + pub const FLOAT64: TypeKind = TypeKind::new(7); + + /// Encoded as a string value. + pub const STRING: TypeKind = TypeKind::new(8); + + /// Encoded as a base64 string per RFC 4648, section 4. + pub const BYTES: TypeKind = TypeKind::new(9); + + /// Encoded as an RFC 3339 timestamp with mandatory "Z" time zone string: + /// 1985-04-12T23:20:50.52Z + pub const TIMESTAMP: TypeKind = TypeKind::new(19); + + /// Encoded as RFC 3339 full-date format string: 1985-04-12 + pub const DATE: TypeKind = TypeKind::new(10); + + /// Encoded as RFC 3339 partial-time format string: 23:20:50.52 + pub const TIME: TypeKind = TypeKind::new(20); + + /// Encoded as RFC 3339 full-date "T" partial-time: 1985-04-12T23:20:50.52 + pub const DATETIME: TypeKind = TypeKind::new(21); + + /// Encoded as fully qualified 3 part: 0-5 15 2:30:45.6 + pub const INTERVAL: TypeKind = TypeKind::new(26); + + /// Encoded as WKT + pub const GEOGRAPHY: TypeKind = TypeKind::new(22); + + /// Encoded as a decimal string. + pub const NUMERIC: TypeKind = TypeKind::new(23); + + /// Encoded as a decimal string. + pub const BIGNUMERIC: TypeKind = TypeKind::new(24); + + /// Encoded as a string. + pub const JSON: TypeKind = TypeKind::new(25); + + /// Encoded as a list with types matching Type.array_type. + pub const ARRAY: TypeKind = TypeKind::new(16); + + /// Encoded as a list with fields of type Type.struct_type[i]. List is used + /// because a JSON object cannot have duplicate field names. + pub const STRUCT: TypeKind = TypeKind::new(17); + + /// Encoded as a pair with types matching range_element_type. Pairs must + /// begin with "[", end with ")", and be separated by ", ". + pub const RANGE: TypeKind = TypeKind::new(29); + + /// Creates a new TypeKind instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("TYPE_KIND_UNSPECIFIED"), + 2 => std::borrow::Cow::Borrowed("INT64"), + 5 => std::borrow::Cow::Borrowed("BOOL"), + 7 => std::borrow::Cow::Borrowed("FLOAT64"), + 8 => std::borrow::Cow::Borrowed("STRING"), + 9 => std::borrow::Cow::Borrowed("BYTES"), + 10 => std::borrow::Cow::Borrowed("DATE"), + 16 => std::borrow::Cow::Borrowed("ARRAY"), + 17 => std::borrow::Cow::Borrowed("STRUCT"), + 19 => std::borrow::Cow::Borrowed("TIMESTAMP"), + 20 => std::borrow::Cow::Borrowed("TIME"), + 21 => std::borrow::Cow::Borrowed("DATETIME"), + 22 => std::borrow::Cow::Borrowed("GEOGRAPHY"), + 23 => std::borrow::Cow::Borrowed("NUMERIC"), + 24 => std::borrow::Cow::Borrowed("BIGNUMERIC"), + 25 => std::borrow::Cow::Borrowed("JSON"), + 26 => std::borrow::Cow::Borrowed("INTERVAL"), + 29 => std::borrow::Cow::Borrowed("RANGE"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "TYPE_KIND_UNSPECIFIED" => std::option::Option::Some(Self::TYPE_KIND_UNSPECIFIED), + "INT64" => std::option::Option::Some(Self::INT64), + "BOOL" => std::option::Option::Some(Self::BOOL), + "FLOAT64" => std::option::Option::Some(Self::FLOAT64), + "STRING" => std::option::Option::Some(Self::STRING), + "BYTES" => std::option::Option::Some(Self::BYTES), + "TIMESTAMP" => std::option::Option::Some(Self::TIMESTAMP), + "DATE" => std::option::Option::Some(Self::DATE), + "TIME" => std::option::Option::Some(Self::TIME), + "DATETIME" => std::option::Option::Some(Self::DATETIME), + "INTERVAL" => std::option::Option::Some(Self::INTERVAL), + "GEOGRAPHY" => std::option::Option::Some(Self::GEOGRAPHY), + "NUMERIC" => std::option::Option::Some(Self::NUMERIC), + "BIGNUMERIC" => std::option::Option::Some(Self::BIGNUMERIC), + "JSON" => std::option::Option::Some(Self::JSON), + "ARRAY" => std::option::Option::Some(Self::ARRAY), + "STRUCT" => std::option::Option::Some(Self::STRUCT), + "RANGE" => std::option::Option::Some(Self::RANGE), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for TypeKind { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for TypeKind { + fn default() -> Self { + Self::new(0) + } + } + + /// For complex types, the sub type information. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(rename_all = "camelCase")] + #[non_exhaustive] + pub enum SubType { + /// The type of the array's elements, if type_kind = "ARRAY". + ArrayElementType(std::boxed::Box), + /// The fields of this struct, in order, if type_kind = "STRUCT". + StructType(std::boxed::Box), + /// The type of the range's elements, if type_kind = "RANGE". + RangeElementType(std::boxed::Box), + } +} + +/// A field or a column. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct StandardSqlField { + /// Optional. The name of this field. Can be absent for struct fields. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub name: std::string::String, + + /// Optional. The type of this parameter. Absent if not explicitly + /// specified (e.g., CREATE FUNCTION statement can omit the return type; + /// in this case the output parameter does not have this "type" field). + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub r#type: std::option::Option>, +} + +impl StandardSqlField { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::StandardSqlField::name]. + pub fn set_name>(mut self, v: T) -> Self { + self.name = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::StandardSqlField::type]. + pub fn set_type< + T: std::convert::Into>>, + >( + mut self, + v: T, + ) -> Self { + self.r#type = v.into(); + self + } +} + +impl wkt::message::Message for StandardSqlField { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.StandardSqlField" + } +} + +/// The representation of a SQL STRUCT type. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct StandardSqlStructType { + /// Fields within the struct. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub fields: std::vec::Vec, +} + +impl StandardSqlStructType { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [fields][crate::model::StandardSqlStructType::fields]. + pub fn set_fields(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.fields = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for StandardSqlStructType { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.StandardSqlStructType" + } +} + +/// A table type +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct StandardSqlTableType { + /// The columns in this table type + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub columns: std::vec::Vec, +} + +impl StandardSqlTableType { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [columns][crate::model::StandardSqlTableType::columns]. + pub fn set_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.columns = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for StandardSqlTableType { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.StandardSqlTableType" + } +} + +/// System variables given to a query. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct SystemVariables { + /// Output only. Data type for each system variable. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub types: std::collections::HashMap, + + /// Output only. Value for each system variable. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub values: std::option::Option, +} + +impl SystemVariables { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [values][crate::model::SystemVariables::values]. + pub fn set_values>>( + mut self, + v: T, + ) -> Self { + self.values = v.into(); + self + } + + /// Sets the value of [types][crate::model::SystemVariables::types]. + pub fn set_types(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for SystemVariables { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.SystemVariables" + } +} + +/// Replication info of a table created using `AS REPLICA` DDL like: +/// `CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv` +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct TableReplicationInfo { + /// Required. Source table reference that is replicated. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub source_table: std::option::Option, + + /// Optional. Specifies the interval at which the source table is polled for + /// updates. + /// It's Optional. If not specified, default replication interval would be + /// applied. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub replication_interval_ms: i64, + + /// Optional. Output only. If source is a materialized view, this field + /// signifies the last refresh time of the source. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub replicated_source_last_refresh_time: i64, + + /// Optional. Output only. Replication status of configured replication. + pub replication_status: crate::model::table_replication_info::ReplicationStatus, + + /// Optional. Output only. Replication error that will permanently stopped + /// table replication. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub replication_error: std::option::Option, +} + +impl TableReplicationInfo { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [source_table][crate::model::TableReplicationInfo::source_table]. + pub fn set_source_table< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.source_table = v.into(); + self + } + + /// Sets the value of [replication_interval_ms][crate::model::TableReplicationInfo::replication_interval_ms]. + pub fn set_replication_interval_ms>(mut self, v: T) -> Self { + self.replication_interval_ms = v.into(); + self + } + + /// Sets the value of [replicated_source_last_refresh_time][crate::model::TableReplicationInfo::replicated_source_last_refresh_time]. + pub fn set_replicated_source_last_refresh_time>( + mut self, + v: T, + ) -> Self { + self.replicated_source_last_refresh_time = v.into(); + self + } + + /// Sets the value of [replication_status][crate::model::TableReplicationInfo::replication_status]. + pub fn set_replication_status< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.replication_status = v.into(); + self + } + + /// Sets the value of [replication_error][crate::model::TableReplicationInfo::replication_error]. + pub fn set_replication_error< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.replication_error = v.into(); + self + } +} + +impl wkt::message::Message for TableReplicationInfo { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TableReplicationInfo" + } +} + +/// Defines additional types related to TableReplicationInfo +pub mod table_replication_info { + #[allow(unused_imports)] + use super::*; + + /// Replication status of the table created using `AS REPLICA` like: + /// `CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv` + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct ReplicationStatus(i32); + + impl ReplicationStatus { + /// Default value. + pub const REPLICATION_STATUS_UNSPECIFIED: ReplicationStatus = ReplicationStatus::new(0); + + /// Replication is Active with no errors. + pub const ACTIVE: ReplicationStatus = ReplicationStatus::new(1); + + /// Source object is deleted. + pub const SOURCE_DELETED: ReplicationStatus = ReplicationStatus::new(2); + + /// Source revoked replication permissions. + pub const PERMISSION_DENIED: ReplicationStatus = ReplicationStatus::new(3); + + /// Source configuration doesn’t allow replication. + pub const UNSUPPORTED_CONFIGURATION: ReplicationStatus = ReplicationStatus::new(4); + + /// Creates a new ReplicationStatus instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("REPLICATION_STATUS_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("ACTIVE"), + 2 => std::borrow::Cow::Borrowed("SOURCE_DELETED"), + 3 => std::borrow::Cow::Borrowed("PERMISSION_DENIED"), + 4 => std::borrow::Cow::Borrowed("UNSUPPORTED_CONFIGURATION"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "REPLICATION_STATUS_UNSPECIFIED" => { + std::option::Option::Some(Self::REPLICATION_STATUS_UNSPECIFIED) + } + "ACTIVE" => std::option::Option::Some(Self::ACTIVE), + "SOURCE_DELETED" => std::option::Option::Some(Self::SOURCE_DELETED), + "PERMISSION_DENIED" => std::option::Option::Some(Self::PERMISSION_DENIED), + "UNSUPPORTED_CONFIGURATION" => { + std::option::Option::Some(Self::UNSUPPORTED_CONFIGURATION) + } + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for ReplicationStatus { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for ReplicationStatus { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Describes the definition of a logical view. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ViewDefinition { + /// Required. A query that BigQuery executes when the view is referenced. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub query: std::string::String, + + /// Describes user-defined function resources used in the query. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub user_defined_function_resources: std::vec::Vec, + + /// Specifies whether to use BigQuery's legacy SQL for this view. + /// The default value is true. If set to false, the view will use + /// BigQuery's GoogleSQL: + /// + /// + /// Queries and views that reference this view must use the same flag value. + /// A wrapper is used here because the default value is True. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub use_legacy_sql: std::option::Option, + + /// True if the column names are explicitly specified. For example by using the + /// 'CREATE VIEW v(c1, c2) AS ...' syntax. + /// Can only be set for GoogleSQL views. + pub use_explicit_column_names: bool, + + /// Optional. Specifies the privacy policy for the view. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub privacy_policy: std::option::Option, + + /// Optional. Foreign view representations. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub foreign_definitions: std::vec::Vec, +} + +impl ViewDefinition { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [query][crate::model::ViewDefinition::query]. + pub fn set_query>(mut self, v: T) -> Self { + self.query = v.into(); + self + } + + /// Sets the value of [use_legacy_sql][crate::model::ViewDefinition::use_legacy_sql]. + pub fn set_use_legacy_sql>>( + mut self, + v: T, + ) -> Self { + self.use_legacy_sql = v.into(); + self + } + + /// Sets the value of [use_explicit_column_names][crate::model::ViewDefinition::use_explicit_column_names]. + pub fn set_use_explicit_column_names>(mut self, v: T) -> Self { + self.use_explicit_column_names = v.into(); + self + } + + /// Sets the value of [privacy_policy][crate::model::ViewDefinition::privacy_policy]. + pub fn set_privacy_policy< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.privacy_policy = v.into(); + self + } + + /// Sets the value of [user_defined_function_resources][crate::model::ViewDefinition::user_defined_function_resources]. + pub fn set_user_defined_function_resources(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.user_defined_function_resources = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [foreign_definitions][crate::model::ViewDefinition::foreign_definitions]. + pub fn set_foreign_definitions(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.foreign_definitions = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for ViewDefinition { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ViewDefinition" + } +} + +/// A view can be represented in multiple ways. Each representation has its own +/// dialect. This message stores the metadata required for these representations. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ForeignViewDefinition { + /// Required. The query that defines the view. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub query: std::string::String, + + /// Optional. Represents the dialect of the query. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dialect: std::string::String, +} + +impl ForeignViewDefinition { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [query][crate::model::ForeignViewDefinition::query]. + pub fn set_query>(mut self, v: T) -> Self { + self.query = v.into(); + self + } + + /// Sets the value of [dialect][crate::model::ForeignViewDefinition::dialect]. + pub fn set_dialect>(mut self, v: T) -> Self { + self.dialect = v.into(); + self + } +} + +impl wkt::message::Message for ForeignViewDefinition { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ForeignViewDefinition" + } +} + +/// Definition and configuration of a materialized view. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct MaterializedViewDefinition { + /// Required. A query whose results are persisted. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub query: std::string::String, + + /// Output only. The time when this materialized view was last refreshed, in + /// milliseconds since the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub last_refresh_time: i64, + + /// Optional. Enable automatic refresh of the materialized view when the base + /// table is updated. The default value is "true". + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub enable_refresh: std::option::Option, + + /// Optional. The maximum frequency at which this materialized view will be + /// refreshed. The default value is "1800000" (30 minutes). + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub refresh_interval_ms: std::option::Option, + + /// Optional. This option declares the intention to construct a materialized + /// view that isn't refreshed incrementally. Non-incremental materialized views + /// support an expanded range of SQL queries. The + /// `allow_non_incremental_definition` option can't be changed after the + /// materialized view is created. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub allow_non_incremental_definition: std::option::Option, +} + +impl MaterializedViewDefinition { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [query][crate::model::MaterializedViewDefinition::query]. + pub fn set_query>(mut self, v: T) -> Self { + self.query = v.into(); + self + } + + /// Sets the value of [last_refresh_time][crate::model::MaterializedViewDefinition::last_refresh_time]. + pub fn set_last_refresh_time>(mut self, v: T) -> Self { + self.last_refresh_time = v.into(); + self + } + + /// Sets the value of [enable_refresh][crate::model::MaterializedViewDefinition::enable_refresh]. + pub fn set_enable_refresh>>( + mut self, + v: T, + ) -> Self { + self.enable_refresh = v.into(); + self + } + + /// Sets the value of [refresh_interval_ms][crate::model::MaterializedViewDefinition::refresh_interval_ms]. + pub fn set_refresh_interval_ms>>( + mut self, + v: T, + ) -> Self { + self.refresh_interval_ms = v.into(); + self + } + + /// Sets the value of [allow_non_incremental_definition][crate::model::MaterializedViewDefinition::allow_non_incremental_definition]. + pub fn set_allow_non_incremental_definition< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.allow_non_incremental_definition = v.into(); + self + } +} + +impl wkt::message::Message for MaterializedViewDefinition { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.MaterializedViewDefinition" + } +} + +/// Status of a materialized view. +/// The last refresh timestamp status is omitted here, but is present in the +/// MaterializedViewDefinition message. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct MaterializedViewStatus { + /// Output only. Refresh watermark of materialized view. The base tables' data + /// were collected into the materialized view cache until this time. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub refresh_watermark: std::option::Option, + + /// Output only. Error result of the last automatic refresh. If present, + /// indicates that the last automatic refresh was unsuccessful. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub last_refresh_status: std::option::Option, +} + +impl MaterializedViewStatus { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [refresh_watermark][crate::model::MaterializedViewStatus::refresh_watermark]. + pub fn set_refresh_watermark>>( + mut self, + v: T, + ) -> Self { + self.refresh_watermark = v.into(); + self + } + + /// Sets the value of [last_refresh_status][crate::model::MaterializedViewStatus::last_refresh_status]. + pub fn set_last_refresh_status< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.last_refresh_status = v.into(); + self + } +} + +impl wkt::message::Message for MaterializedViewStatus { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.MaterializedViewStatus" + } +} + +/// Information about base table and snapshot time of the snapshot. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct SnapshotDefinition { + /// Required. Reference describing the ID of the table that was snapshot. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub base_table_reference: std::option::Option, + + /// Required. The time at which the base table was snapshot. This value is + /// reported in the JSON response using RFC3339 format. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub snapshot_time: std::option::Option, +} + +impl SnapshotDefinition { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [base_table_reference][crate::model::SnapshotDefinition::base_table_reference]. + pub fn set_base_table_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.base_table_reference = v.into(); + self + } + + /// Sets the value of [snapshot_time][crate::model::SnapshotDefinition::snapshot_time]. + pub fn set_snapshot_time>>( + mut self, + v: T, + ) -> Self { + self.snapshot_time = v.into(); + self + } +} + +impl wkt::message::Message for SnapshotDefinition { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.SnapshotDefinition" + } +} + +/// Information about base table and clone time of a table clone. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct CloneDefinition { + /// Required. Reference describing the ID of the table that was cloned. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub base_table_reference: std::option::Option, + + /// Required. The time at which the base table was cloned. This value is + /// reported in the JSON response using RFC3339 format. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub clone_time: std::option::Option, +} + +impl CloneDefinition { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [base_table_reference][crate::model::CloneDefinition::base_table_reference]. + pub fn set_base_table_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.base_table_reference = v.into(); + self + } + + /// Sets the value of [clone_time][crate::model::CloneDefinition::clone_time]. + pub fn set_clone_time>>( + mut self, + v: T, + ) -> Self { + self.clone_time = v.into(); + self + } +} + +impl wkt::message::Message for CloneDefinition { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.CloneDefinition" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Streamingbuffer { + /// Output only. A lower-bound estimate of the number of bytes currently in + /// the streaming buffer. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub estimated_bytes: u64, + + /// Output only. A lower-bound estimate of the number of rows currently in the + /// streaming buffer. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub estimated_rows: u64, + + /// Output only. Contains the timestamp of the oldest entry in the streaming + /// buffer, in milliseconds since the epoch, if the streaming buffer is + /// available. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub oldest_entry_time: u64, +} + +impl Streamingbuffer { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [estimated_bytes][crate::model::Streamingbuffer::estimated_bytes]. + pub fn set_estimated_bytes>(mut self, v: T) -> Self { + self.estimated_bytes = v.into(); + self + } + + /// Sets the value of [estimated_rows][crate::model::Streamingbuffer::estimated_rows]. + pub fn set_estimated_rows>(mut self, v: T) -> Self { + self.estimated_rows = v.into(); + self + } + + /// Sets the value of [oldest_entry_time][crate::model::Streamingbuffer::oldest_entry_time]. + pub fn set_oldest_entry_time>(mut self, v: T) -> Self { + self.oldest_entry_time = v.into(); + self + } +} + +impl wkt::message::Message for Streamingbuffer { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Streamingbuffer" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct Table { + /// The type of resource ID. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub kind: std::string::String, + + /// Output only. A hash of this resource. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub etag: std::string::String, + + /// Output only. An opaque ID uniquely identifying the table. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub id: std::string::String, + + /// Output only. A URL that can be used to access this resource again. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub self_link: std::string::String, + + /// Required. Reference describing the ID of this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub table_reference: std::option::Option, + + /// Optional. A descriptive name for this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub friendly_name: std::option::Option, + + /// Optional. A user-friendly description of this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub description: std::option::Option, + + /// The labels associated with this table. You can use these to organize and + /// group your tables. Label keys and values can be no longer than 63 + /// characters, can only contain lowercase letters, numeric characters, + /// underscores and dashes. International characters are allowed. Label values + /// are optional. Label keys must start with a letter and each label in the + /// list must have a different key. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub labels: std::collections::HashMap, + + /// Optional. Describes the schema of this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub schema: std::option::Option, + + /// If specified, configures time-based partitioning for this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub time_partitioning: std::option::Option, + + /// If specified, configures range partitioning for this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub range_partitioning: std::option::Option, + + /// Clustering specification for the table. Must be specified with time-based + /// partitioning, data in the table will be first partitioned and subsequently + /// clustered. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub clustering: std::option::Option, + + /// Optional. If set to true, queries over this table require + /// a partition filter that can be used for partition elimination to be + /// specified. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub require_partition_filter: std::option::Option, + + /// Optional. The partition information for all table formats, including + /// managed partitioned tables, hive partitioned tables, iceberg partitioned, + /// and metastore partitioned tables. This field is only populated for + /// metastore partitioned tables. For other table formats, this is an output + /// only field. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub partition_definition: std::option::Option, + + /// Output only. The size of this table in logical bytes, excluding any data in + /// the streaming buffer. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_bytes: std::option::Option, + + /// Output only. The physical size of this table in bytes. This includes + /// storage used for time travel. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_physical_bytes: std::option::Option, + + /// Output only. The number of logical bytes in the table that are considered + /// "long-term storage". + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_long_term_bytes: std::option::Option, + + /// Output only. The number of rows of data in this table, excluding any data + /// in the streaming buffer. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_rows: std::option::Option, + + /// Output only. The time when this table was created, in milliseconds since + /// the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub creation_time: i64, + + /// Optional. The time when this table expires, in milliseconds since the + /// epoch. If not present, the table will persist indefinitely. Expired tables + /// will be deleted and their storage reclaimed. The defaultTableExpirationMs + /// property of the encapsulating dataset can be used to set a default + /// expirationTime on newly created tables. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub expiration_time: std::option::Option, + + /// Output only. The time when this table was last modified, in milliseconds + /// since the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub last_modified_time: u64, + + /// Output only. Describes the table type. The following values are supported: + /// + /// * `TABLE`: A normal BigQuery table. + /// * `VIEW`: A virtual table defined by a SQL query. + /// * `EXTERNAL`: A table that references data stored in an external storage + /// system, such as Google Cloud Storage. + /// * `MATERIALIZED_VIEW`: A precomputed view defined by a SQL query. + /// * `SNAPSHOT`: An immutable BigQuery table that preserves the contents of a + /// base table at a particular time. See additional information on + /// [table + /// snapshots](https://cloud.google.com/bigquery/docs/table-snapshots-intro). + /// + /// The default value is `TABLE`. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + + /// Optional. The view definition. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub view: std::option::Option, + + /// Optional. The materialized view definition. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub materialized_view: std::option::Option, + + /// Output only. The materialized view status. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub materialized_view_status: std::option::Option, + + /// Optional. Describes the data format, location, and other properties of + /// a table stored outside of BigQuery. By defining these properties, the data + /// source can then be queried as if it were a standard BigQuery table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub external_data_configuration: std::option::Option, + + /// Optional. Specifies the configuration of a BigLake managed table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub biglake_configuration: std::option::Option, + + /// Optional. If set, overrides the default managed table type configured in + /// the dataset. + pub managed_table_type: crate::model::ManagedTableType, + + /// Output only. The geographic location where the table resides. This value + /// is inherited from the dataset. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub location: std::string::String, + + /// Output only. Contains information regarding this table's streaming buffer, + /// if one is present. This field will be absent if the table is not being + /// streamed to or if there is no data in the streaming buffer. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub streaming_buffer: std::option::Option, + + /// Custom encryption configuration (e.g., Cloud KMS keys). + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub encryption_configuration: std::option::Option, + + /// Output only. Contains information about the snapshot. This value is set via + /// snapshot creation. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub snapshot_definition: std::option::Option, + + /// Optional. Defines the default collation specification of new STRING fields + /// in the table. During table creation or update, if a STRING field is added + /// to this table without explicit collation specified, then the table inherits + /// the table default collation. A change to this field affects only fields + /// added afterwards, and does not alter the existing fields. + /// The following values are supported: + /// + /// * 'und:ci': undetermined locale, case insensitive. + /// * '': empty string. Default to case-sensitive behavior. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub default_collation: std::option::Option, + + /// Optional. Defines the default rounding mode specification of new decimal + /// fields (NUMERIC OR BIGNUMERIC) in the table. During table creation or + /// update, if a decimal field is added to this table without an explicit + /// rounding mode specified, then the field inherits the table default + /// rounding mode. Changing this field doesn't affect existing fields. + pub default_rounding_mode: crate::model::table_field_schema::RoundingMode, + + /// Output only. Contains information about the clone. This value is set via + /// the clone operation. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub clone_definition: std::option::Option, + + /// Output only. Number of physical bytes used by time travel storage (deleted + /// or changed data). This data is not kept in real time, and might be delayed + /// by a few seconds to a few minutes. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_time_travel_physical_bytes: std::option::Option, + + /// Output only. Total number of logical bytes in the table or materialized + /// view. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_total_logical_bytes: std::option::Option, + + /// Output only. Number of logical bytes that are less than 90 days old. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_active_logical_bytes: std::option::Option, + + /// Output only. Number of logical bytes that are more than 90 days old. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_long_term_logical_bytes: std::option::Option, + + /// Output only. Number of physical bytes used by current live data storage. + /// This data is not kept in real time, and might be delayed by a few seconds + /// to a few minutes. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_current_physical_bytes: std::option::Option, + + /// Output only. The physical size of this table in bytes. This also includes + /// storage used for time travel. This data is not kept in real time, and might + /// be delayed by a few seconds to a few minutes. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_total_physical_bytes: std::option::Option, + + /// Output only. Number of physical bytes less than 90 days old. This data is + /// not kept in real time, and might be delayed by a few seconds to a few + /// minutes. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_active_physical_bytes: std::option::Option, + + /// Output only. Number of physical bytes more than 90 days old. + /// This data is not kept in real time, and might be delayed by a few seconds + /// to a few minutes. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_long_term_physical_bytes: std::option::Option, + + /// Output only. The number of partitions present in the table or materialized + /// view. This data is not kept in real time, and might be delayed by a few + /// seconds to a few minutes. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub num_partitions: std::option::Option, + + /// Optional. The maximum staleness of data that could be returned when the + /// table (or stale MV) is queried. Staleness encoded as a string encoding + /// of sql IntervalValue type. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub max_staleness: std::string::String, + + /// Optional. Output only. Restriction config for table. If set, restrict + /// certain accesses on the table based on the config. See [Data + /// egress](https://cloud.google.com/bigquery/docs/analytics-hub-introduction#data_egress) + /// for more details. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub restrictions: std::option::Option, + + /// Optional. Tables Primary Key and Foreign Key information + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub table_constraints: std::option::Option, + + /// Optional. The [tags](https://cloud.google.com/bigquery/docs/tags) attached + /// to this table. Tag keys are globally unique. Tag key is expected to be in + /// the namespaced format, for example "123456789012/environment" where + /// 123456789012 is the ID of the parent organization or project resource for + /// this tag key. Tag value is expected to be the short name, for example + /// "Production". See [Tag + /// definitions](https://cloud.google.com/iam/docs/tags-access-control#definitions) + /// for more details. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub resource_tags: std::collections::HashMap, + + /// Optional. Table replication info for table created `AS REPLICA` DDL like: + /// `CREATE MATERIALIZED VIEW mv1 AS REPLICA OF src_mv` + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub table_replication_info: std::option::Option, + + /// Optional. Output only. Table references of all replicas currently active on + /// the table. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub replicas: std::vec::Vec, + + /// Optional. Options defining open source compatible table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub external_catalog_table_options: + std::option::Option, +} + +impl Table { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [kind][crate::model::Table::kind]. + pub fn set_kind>(mut self, v: T) -> Self { + self.kind = v.into(); + self + } + + /// Sets the value of [etag][crate::model::Table::etag]. + pub fn set_etag>(mut self, v: T) -> Self { + self.etag = v.into(); + self + } + + /// Sets the value of [id][crate::model::Table::id]. + pub fn set_id>(mut self, v: T) -> Self { + self.id = v.into(); + self + } + + /// Sets the value of [self_link][crate::model::Table::self_link]. + pub fn set_self_link>(mut self, v: T) -> Self { + self.self_link = v.into(); + self + } + + /// Sets the value of [table_reference][crate::model::Table::table_reference]. + pub fn set_table_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.table_reference = v.into(); + self + } + + /// Sets the value of [friendly_name][crate::model::Table::friendly_name]. + pub fn set_friendly_name>>( + mut self, + v: T, + ) -> Self { + self.friendly_name = v.into(); + self + } + + /// Sets the value of [description][crate::model::Table::description]. + pub fn set_description>>( + mut self, + v: T, + ) -> Self { + self.description = v.into(); + self + } + + /// Sets the value of [schema][crate::model::Table::schema]. + pub fn set_schema>>( + mut self, + v: T, + ) -> Self { + self.schema = v.into(); + self + } + + /// Sets the value of [time_partitioning][crate::model::Table::time_partitioning]. + pub fn set_time_partitioning< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.time_partitioning = v.into(); + self + } + + /// Sets the value of [range_partitioning][crate::model::Table::range_partitioning]. + pub fn set_range_partitioning< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.range_partitioning = v.into(); + self + } + + /// Sets the value of [clustering][crate::model::Table::clustering]. + pub fn set_clustering>>( + mut self, + v: T, + ) -> Self { + self.clustering = v.into(); + self + } + + /// Sets the value of [require_partition_filter][crate::model::Table::require_partition_filter]. + pub fn set_require_partition_filter< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.require_partition_filter = v.into(); + self + } + + /// Sets the value of [partition_definition][crate::model::Table::partition_definition]. + pub fn set_partition_definition< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.partition_definition = v.into(); + self + } + + /// Sets the value of [num_bytes][crate::model::Table::num_bytes]. + pub fn set_num_bytes>>( + mut self, + v: T, + ) -> Self { + self.num_bytes = v.into(); + self + } + + /// Sets the value of [num_physical_bytes][crate::model::Table::num_physical_bytes]. + pub fn set_num_physical_bytes>>( + mut self, + v: T, + ) -> Self { + self.num_physical_bytes = v.into(); + self + } + + /// Sets the value of [num_long_term_bytes][crate::model::Table::num_long_term_bytes]. + pub fn set_num_long_term_bytes>>( + mut self, + v: T, + ) -> Self { + self.num_long_term_bytes = v.into(); + self + } + + /// Sets the value of [num_rows][crate::model::Table::num_rows]. + pub fn set_num_rows>>( + mut self, + v: T, + ) -> Self { + self.num_rows = v.into(); + self + } + + /// Sets the value of [creation_time][crate::model::Table::creation_time]. + pub fn set_creation_time>(mut self, v: T) -> Self { + self.creation_time = v.into(); + self + } + + /// Sets the value of [expiration_time][crate::model::Table::expiration_time]. + pub fn set_expiration_time>>( + mut self, + v: T, + ) -> Self { + self.expiration_time = v.into(); + self + } + + /// Sets the value of [last_modified_time][crate::model::Table::last_modified_time]. + pub fn set_last_modified_time>(mut self, v: T) -> Self { + self.last_modified_time = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::Table::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [view][crate::model::Table::view]. + pub fn set_view>>( + mut self, + v: T, + ) -> Self { + self.view = v.into(); + self + } + + /// Sets the value of [materialized_view][crate::model::Table::materialized_view]. + pub fn set_materialized_view< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.materialized_view = v.into(); + self + } + + /// Sets the value of [materialized_view_status][crate::model::Table::materialized_view_status]. + pub fn set_materialized_view_status< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.materialized_view_status = v.into(); + self + } + + /// Sets the value of [external_data_configuration][crate::model::Table::external_data_configuration]. + pub fn set_external_data_configuration< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.external_data_configuration = v.into(); + self + } + + /// Sets the value of [biglake_configuration][crate::model::Table::biglake_configuration]. + pub fn set_biglake_configuration< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.biglake_configuration = v.into(); + self + } + + /// Sets the value of [managed_table_type][crate::model::Table::managed_table_type]. + pub fn set_managed_table_type>( + mut self, + v: T, + ) -> Self { + self.managed_table_type = v.into(); + self + } + + /// Sets the value of [location][crate::model::Table::location]. + pub fn set_location>(mut self, v: T) -> Self { + self.location = v.into(); + self + } + + /// Sets the value of [streaming_buffer][crate::model::Table::streaming_buffer]. + pub fn set_streaming_buffer< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.streaming_buffer = v.into(); + self + } + + /// Sets the value of [encryption_configuration][crate::model::Table::encryption_configuration]. + pub fn set_encryption_configuration< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.encryption_configuration = v.into(); + self + } + + /// Sets the value of [snapshot_definition][crate::model::Table::snapshot_definition]. + pub fn set_snapshot_definition< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.snapshot_definition = v.into(); + self + } + + /// Sets the value of [default_collation][crate::model::Table::default_collation]. + pub fn set_default_collation>>( + mut self, + v: T, + ) -> Self { + self.default_collation = v.into(); + self + } + + /// Sets the value of [default_rounding_mode][crate::model::Table::default_rounding_mode]. + pub fn set_default_rounding_mode< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.default_rounding_mode = v.into(); + self + } + + /// Sets the value of [clone_definition][crate::model::Table::clone_definition]. + pub fn set_clone_definition< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.clone_definition = v.into(); + self + } + + /// Sets the value of [num_time_travel_physical_bytes][crate::model::Table::num_time_travel_physical_bytes]. + pub fn set_num_time_travel_physical_bytes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_time_travel_physical_bytes = v.into(); + self + } + + /// Sets the value of [num_total_logical_bytes][crate::model::Table::num_total_logical_bytes]. + pub fn set_num_total_logical_bytes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_total_logical_bytes = v.into(); + self + } + + /// Sets the value of [num_active_logical_bytes][crate::model::Table::num_active_logical_bytes]. + pub fn set_num_active_logical_bytes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_active_logical_bytes = v.into(); + self + } + + /// Sets the value of [num_long_term_logical_bytes][crate::model::Table::num_long_term_logical_bytes]. + pub fn set_num_long_term_logical_bytes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_long_term_logical_bytes = v.into(); + self + } + + /// Sets the value of [num_current_physical_bytes][crate::model::Table::num_current_physical_bytes]. + pub fn set_num_current_physical_bytes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_current_physical_bytes = v.into(); + self + } + + /// Sets the value of [num_total_physical_bytes][crate::model::Table::num_total_physical_bytes]. + pub fn set_num_total_physical_bytes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_total_physical_bytes = v.into(); + self + } + + /// Sets the value of [num_active_physical_bytes][crate::model::Table::num_active_physical_bytes]. + pub fn set_num_active_physical_bytes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_active_physical_bytes = v.into(); + self + } + + /// Sets the value of [num_long_term_physical_bytes][crate::model::Table::num_long_term_physical_bytes]. + pub fn set_num_long_term_physical_bytes< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.num_long_term_physical_bytes = v.into(); + self + } + + /// Sets the value of [num_partitions][crate::model::Table::num_partitions]. + pub fn set_num_partitions>>( + mut self, + v: T, + ) -> Self { + self.num_partitions = v.into(); + self + } + + /// Sets the value of [max_staleness][crate::model::Table::max_staleness]. + pub fn set_max_staleness>(mut self, v: T) -> Self { + self.max_staleness = v.into(); + self + } + + /// Sets the value of [restrictions][crate::model::Table::restrictions]. + pub fn set_restrictions< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.restrictions = v.into(); + self + } + + /// Sets the value of [table_constraints][crate::model::Table::table_constraints]. + pub fn set_table_constraints< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.table_constraints = v.into(); + self + } + + /// Sets the value of [table_replication_info][crate::model::Table::table_replication_info]. + pub fn set_table_replication_info< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.table_replication_info = v.into(); + self + } + + /// Sets the value of [external_catalog_table_options][crate::model::Table::external_catalog_table_options]. + pub fn set_external_catalog_table_options< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.external_catalog_table_options = v.into(); + self + } + + /// Sets the value of [replicas][crate::model::Table::replicas]. + pub fn set_replicas(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.replicas = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [labels][crate::model::Table::labels]. + pub fn set_labels(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } + + /// Sets the value of [resource_tags][crate::model::Table::resource_tags]. + pub fn set_resource_tags(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.resource_tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for Table { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.Table" + } +} + +/// Request format for getting table metadata. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct GetTableRequest { + /// Required. Project ID of the requested table + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the requested table + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the requested table + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// List of table schema fields to return (comma-separated). + /// If unspecified, all fields are returned. + /// A fieldMask cannot be used here because the fields will automatically be + /// converted from camelCase to snake_case and the conversion will fail if + /// there are underscores. Since these are fields in BigQuery table schemas, + /// underscores are allowed. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub selected_fields: std::string::String, + + /// Optional. Specifies the view that determines which table information is + /// returned. By default, basic table information and storage statistics + /// (STORAGE_STATS) are returned. + pub view: crate::model::get_table_request::TableMetadataView, +} + +impl GetTableRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::GetTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::GetTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::GetTableRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [selected_fields][crate::model::GetTableRequest::selected_fields]. + pub fn set_selected_fields>(mut self, v: T) -> Self { + self.selected_fields = v.into(); + self + } + + /// Sets the value of [view][crate::model::GetTableRequest::view]. + pub fn set_view>( + mut self, + v: T, + ) -> Self { + self.view = v.into(); + self + } +} + +impl wkt::message::Message for GetTableRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.GetTableRequest" + } +} + +/// Defines additional types related to GetTableRequest +pub mod get_table_request { + #[allow(unused_imports)] + use super::*; + + /// TableMetadataView specifies which table information is returned. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct TableMetadataView(i32); + + impl TableMetadataView { + /// The default value. + /// Default to the STORAGE_STATS view. + pub const TABLE_METADATA_VIEW_UNSPECIFIED: TableMetadataView = TableMetadataView::new(0); + + /// Includes basic table information including schema and + /// partitioning specification. This view does not include storage statistics + /// such as numRows or numBytes. This view is significantly more efficient + /// and should be used to support high query rates. + pub const BASIC: TableMetadataView = TableMetadataView::new(1); + + /// Includes all information in the BASIC view as well as storage statistics + /// (numBytes, numLongTermBytes, numRows and lastModifiedTime). + pub const STORAGE_STATS: TableMetadataView = TableMetadataView::new(2); + + /// Includes all table information, including storage statistics. + /// It returns same information as STORAGE_STATS view, but may contain + /// additional information in the future. + pub const FULL: TableMetadataView = TableMetadataView::new(3); + + /// Creates a new TableMetadataView instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("TABLE_METADATA_VIEW_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("BASIC"), + 2 => std::borrow::Cow::Borrowed("STORAGE_STATS"), + 3 => std::borrow::Cow::Borrowed("FULL"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "TABLE_METADATA_VIEW_UNSPECIFIED" => { + std::option::Option::Some(Self::TABLE_METADATA_VIEW_UNSPECIFIED) + } + "BASIC" => std::option::Option::Some(Self::BASIC), + "STORAGE_STATS" => std::option::Option::Some(Self::STORAGE_STATS), + "FULL" => std::option::Option::Some(Self::FULL), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for TableMetadataView { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for TableMetadataView { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Request format for inserting table metadata. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct InsertTableRequest { + /// Required. Project ID of the new table + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the new table + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. A tables resource to insert + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub table: std::option::Option, +} + +impl InsertTableRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::InsertTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::InsertTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table][crate::model::InsertTableRequest::table]. + pub fn set_table>>( + mut self, + v: T, + ) -> Self { + self.table = v.into(); + self + } +} + +impl wkt::message::Message for InsertTableRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.InsertTableRequest" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct UpdateOrPatchTableRequest { + /// Required. Project ID of the table to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the table to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the table to update + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, + + /// Required. A tables resource which will replace or patch the specified table + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub table: std::option::Option, + + /// Optional. When true will autodetect schema, else will keep original schema. + pub autodetect_schema: bool, +} + +impl UpdateOrPatchTableRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::UpdateOrPatchTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::UpdateOrPatchTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::UpdateOrPatchTableRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } + + /// Sets the value of [table][crate::model::UpdateOrPatchTableRequest::table]. + pub fn set_table>>( + mut self, + v: T, + ) -> Self { + self.table = v.into(); + self + } + + /// Sets the value of [autodetect_schema][crate::model::UpdateOrPatchTableRequest::autodetect_schema]. + pub fn set_autodetect_schema>(mut self, v: T) -> Self { + self.autodetect_schema = v.into(); + self + } +} + +impl wkt::message::Message for UpdateOrPatchTableRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.UpdateOrPatchTableRequest" + } +} + +/// Request format for deleting a table. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DeleteTableRequest { + /// Required. Project ID of the table to delete + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the table to delete + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. Table ID of the table to delete + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, +} + +impl DeleteTableRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::DeleteTableRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::DeleteTableRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::DeleteTableRequest::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } +} + +impl wkt::message::Message for DeleteTableRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DeleteTableRequest" + } +} + +/// Request format for enumerating tables. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListTablesRequest { + /// Required. Project ID of the tables to list + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. Dataset ID of the tables to list + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// The maximum number of results to return in a single response page. + /// Leverage the page tokens to iterate through the entire collection. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub max_results: std::option::Option, + + /// Page token, returned by a previous call, to request the next page of + /// results + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub page_token: std::string::String, +} + +impl ListTablesRequest { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::ListTablesRequest::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::ListTablesRequest::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [max_results][crate::model::ListTablesRequest::max_results]. + pub fn set_max_results>>( + mut self, + v: T, + ) -> Self { + self.max_results = v.into(); + self + } + + /// Sets the value of [page_token][crate::model::ListTablesRequest::page_token]. + pub fn set_page_token>(mut self, v: T) -> Self { + self.page_token = v.into(); + self + } +} + +impl wkt::message::Message for ListTablesRequest { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListTablesRequest" + } +} + +/// Information about a logical view. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListFormatView { + /// True if view is defined in legacy SQL dialect, + /// false if in GoogleSQL. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub use_legacy_sql: std::option::Option, + + /// Specifies the privacy policy for the view. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub privacy_policy: std::option::Option, +} + +impl ListFormatView { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [use_legacy_sql][crate::model::ListFormatView::use_legacy_sql]. + pub fn set_use_legacy_sql>>( + mut self, + v: T, + ) -> Self { + self.use_legacy_sql = v.into(); + self + } + + /// Sets the value of [privacy_policy][crate::model::ListFormatView::privacy_policy]. + pub fn set_privacy_policy< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.privacy_policy = v.into(); + self + } +} + +impl wkt::message::Message for ListFormatView { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListFormatView" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ListFormatTable { + /// The resource type. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub kind: std::string::String, + + /// An opaque ID of the table. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub id: std::string::String, + + /// A reference uniquely identifying table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub table_reference: std::option::Option, + + /// The user-friendly name for this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub friendly_name: std::option::Option, + + /// The type of table. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + + /// The time-based partitioning for this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub time_partitioning: std::option::Option, + + /// The range partitioning for this table. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub range_partitioning: std::option::Option, + + /// Clustering specification for this table, if configured. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub clustering: std::option::Option, + + /// The labels associated with this table. You can use these to organize + /// and group your tables. + #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")] + pub labels: std::collections::HashMap, + + /// Additional details for a view. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub view: std::option::Option, + + /// Output only. The time when this table was created, in milliseconds since + /// the epoch. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub creation_time: i64, + + /// The time when this table expires, in milliseconds since the + /// epoch. If not present, the table will persist indefinitely. Expired tables + /// will be deleted and their storage reclaimed. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub expiration_time: i64, + + /// Optional. If set to true, queries including this table must specify a + /// partition filter. This filter is used for partition elimination. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub require_partition_filter: std::option::Option, +} + +impl ListFormatTable { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [kind][crate::model::ListFormatTable::kind]. + pub fn set_kind>(mut self, v: T) -> Self { + self.kind = v.into(); + self + } + + /// Sets the value of [id][crate::model::ListFormatTable::id]. + pub fn set_id>(mut self, v: T) -> Self { + self.id = v.into(); + self + } + + /// Sets the value of [table_reference][crate::model::ListFormatTable::table_reference]. + pub fn set_table_reference< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.table_reference = v.into(); + self + } + + /// Sets the value of [friendly_name][crate::model::ListFormatTable::friendly_name]. + pub fn set_friendly_name>>( + mut self, + v: T, + ) -> Self { + self.friendly_name = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::ListFormatTable::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [time_partitioning][crate::model::ListFormatTable::time_partitioning]. + pub fn set_time_partitioning< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.time_partitioning = v.into(); + self + } + + /// Sets the value of [range_partitioning][crate::model::ListFormatTable::range_partitioning]. + pub fn set_range_partitioning< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.range_partitioning = v.into(); + self + } + + /// Sets the value of [clustering][crate::model::ListFormatTable::clustering]. + pub fn set_clustering>>( + mut self, + v: T, + ) -> Self { + self.clustering = v.into(); + self + } + + /// Sets the value of [view][crate::model::ListFormatTable::view]. + pub fn set_view>>( + mut self, + v: T, + ) -> Self { + self.view = v.into(); + self + } + + /// Sets the value of [creation_time][crate::model::ListFormatTable::creation_time]. + pub fn set_creation_time>(mut self, v: T) -> Self { + self.creation_time = v.into(); + self + } + + /// Sets the value of [expiration_time][crate::model::ListFormatTable::expiration_time]. + pub fn set_expiration_time>(mut self, v: T) -> Self { + self.expiration_time = v.into(); + self + } + + /// Sets the value of [require_partition_filter][crate::model::ListFormatTable::require_partition_filter]. + pub fn set_require_partition_filter< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.require_partition_filter = v.into(); + self + } + + /// Sets the value of [labels][crate::model::ListFormatTable::labels]. + pub fn set_labels(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } +} + +impl wkt::message::Message for ListFormatTable { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ListFormatTable" + } +} + +/// Partial projection of the metadata for a given table in a list response. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct TableList { + /// The type of list. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub kind: std::string::String, + + /// A hash of this page of results. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub etag: std::string::String, + + /// A token to request the next page of results. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub next_page_token: std::string::String, + + /// Tables in the requested dataset. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub tables: std::vec::Vec, + + /// The total number of tables in the dataset. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub total_items: std::option::Option, +} + +impl TableList { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [kind][crate::model::TableList::kind]. + pub fn set_kind>(mut self, v: T) -> Self { + self.kind = v.into(); + self + } + + /// Sets the value of [etag][crate::model::TableList::etag]. + pub fn set_etag>(mut self, v: T) -> Self { + self.etag = v.into(); + self + } + + /// Sets the value of [next_page_token][crate::model::TableList::next_page_token]. + pub fn set_next_page_token>(mut self, v: T) -> Self { + self.next_page_token = v.into(); + self + } + + /// Sets the value of [total_items][crate::model::TableList::total_items]. + pub fn set_total_items>>( + mut self, + v: T, + ) -> Self { + self.total_items = v.into(); + self + } + + /// Sets the value of [tables][crate::model::TableList::tables]. + pub fn set_tables(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.tables = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for TableList { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TableList" + } +} + +/// Represents the primary key constraint on a table's columns. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct PrimaryKey { + /// Required. The columns that are composed of the primary key constraint. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub columns: std::vec::Vec, +} + +impl PrimaryKey { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [columns][crate::model::PrimaryKey::columns]. + pub fn set_columns(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.columns = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for PrimaryKey { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.PrimaryKey" + } +} + +/// The pair of the foreign key column and primary key column. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ColumnReference { + /// Required. The column that composes the foreign key. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub referencing_column: std::string::String, + + /// Required. The column in the primary key that are referenced by the + /// referencing_column. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub referenced_column: std::string::String, +} + +impl ColumnReference { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [referencing_column][crate::model::ColumnReference::referencing_column]. + pub fn set_referencing_column>( + mut self, + v: T, + ) -> Self { + self.referencing_column = v.into(); + self + } + + /// Sets the value of [referenced_column][crate::model::ColumnReference::referenced_column]. + pub fn set_referenced_column>( + mut self, + v: T, + ) -> Self { + self.referenced_column = v.into(); + self + } +} + +impl wkt::message::Message for ColumnReference { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ColumnReference" + } +} + +/// Represents a foreign key constraint on a table's columns. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ForeignKey { + /// Optional. Set only if the foreign key constraint is named. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub name: std::string::String, + + /// Required. The table that holds the primary key and is referenced by this + /// foreign key. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub referenced_table: std::option::Option, + + /// Required. The columns that compose the foreign key. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub column_references: std::vec::Vec, +} + +impl ForeignKey { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::ForeignKey::name]. + pub fn set_name>(mut self, v: T) -> Self { + self.name = v.into(); + self + } + + /// Sets the value of [referenced_table][crate::model::ForeignKey::referenced_table]. + pub fn set_referenced_table< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.referenced_table = v.into(); + self + } + + /// Sets the value of [column_references][crate::model::ForeignKey::column_references]. + pub fn set_column_references(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.column_references = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for ForeignKey { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ForeignKey" + } +} + +/// The TableConstraints defines the primary key and foreign key. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct TableConstraints { + /// Optional. Represents a primary key constraint on a table's columns. + /// Present only if the table has a primary key. + /// The primary key is not enforced. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub primary_key: std::option::Option, + + /// Optional. Present only if the table has a foreign key. + /// The foreign key is not enforced. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub foreign_keys: std::vec::Vec, +} + +impl TableConstraints { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [primary_key][crate::model::TableConstraints::primary_key]. + pub fn set_primary_key>>( + mut self, + v: T, + ) -> Self { + self.primary_key = v.into(); + self + } + + /// Sets the value of [foreign_keys][crate::model::TableConstraints::foreign_keys]. + pub fn set_foreign_keys(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.foreign_keys = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for TableConstraints { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TableConstraints" + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct TableReference { + /// Required. The ID of the project containing this table. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub project_id: std::string::String, + + /// Required. The ID of the dataset containing this table. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub dataset_id: std::string::String, + + /// Required. The ID of the table. The ID can contain Unicode characters in + /// category L (letter), M (mark), N (number), Pc (connector, including + /// underscore), Pd (dash), and Zs (space). For more information, see [General + /// Category](https://wikipedia.org/wiki/Unicode_character_property#General_Category). + /// The maximum length is 1,024 characters. Certain operations allow suffixing + /// of the table ID with a partition decorator, such as + /// `sample_table$20190123`. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub table_id: std::string::String, +} + +impl TableReference { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [project_id][crate::model::TableReference::project_id]. + pub fn set_project_id>(mut self, v: T) -> Self { + self.project_id = v.into(); + self + } + + /// Sets the value of [dataset_id][crate::model::TableReference::dataset_id]. + pub fn set_dataset_id>(mut self, v: T) -> Self { + self.dataset_id = v.into(); + self + } + + /// Sets the value of [table_id][crate::model::TableReference::table_id]. + pub fn set_table_id>(mut self, v: T) -> Self { + self.table_id = v.into(); + self + } +} + +impl wkt::message::Message for TableReference { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TableReference" + } +} + +/// Schema of a table +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct TableSchema { + /// Describes the fields in a table. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub fields: std::vec::Vec, + + /// Optional. Specifies metadata of the foreign data type definition in field + /// schema + /// ([TableFieldSchema.foreign_type_definition][google.cloud.bigquery.v2.TableFieldSchema.foreign_type_definition]). + /// + /// [google.cloud.bigquery.v2.TableFieldSchema.foreign_type_definition]: crate::model::TableFieldSchema::foreign_type_definition + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub foreign_type_info: std::option::Option, +} + +impl TableSchema { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [foreign_type_info][crate::model::TableSchema::foreign_type_info]. + pub fn set_foreign_type_info< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.foreign_type_info = v.into(); + self + } + + /// Sets the value of [fields][crate::model::TableSchema::fields]. + pub fn set_fields(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.fields = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for TableSchema { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TableSchema" + } +} + +/// Metadata about the foreign data type definition such as the system +/// in which the type is defined. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct ForeignTypeInfo { + /// Required. Specifies the system which defines the foreign data type. + pub type_system: crate::model::foreign_type_info::TypeSystem, +} + +impl ForeignTypeInfo { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [type_system][crate::model::ForeignTypeInfo::type_system]. + pub fn set_type_system>( + mut self, + v: T, + ) -> Self { + self.type_system = v.into(); + self + } +} + +impl wkt::message::Message for ForeignTypeInfo { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.ForeignTypeInfo" + } +} + +/// Defines additional types related to ForeignTypeInfo +pub mod foreign_type_info { + #[allow(unused_imports)] + use super::*; + + /// External systems, such as query engines or table formats, that have their + /// own data types. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct TypeSystem(i32); + + impl TypeSystem { + /// TypeSystem not specified. + pub const TYPE_SYSTEM_UNSPECIFIED: TypeSystem = TypeSystem::new(0); + + /// Represents Hive data types. + pub const HIVE: TypeSystem = TypeSystem::new(1); + + /// Creates a new TypeSystem instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("TYPE_SYSTEM_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("HIVE"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "TYPE_SYSTEM_UNSPECIFIED" => { + std::option::Option::Some(Self::TYPE_SYSTEM_UNSPECIFIED) + } + "HIVE" => std::option::Option::Some(Self::HIVE), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for TypeSystem { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for TypeSystem { + fn default() -> Self { + Self::new(0) + } + } +} + +/// Data policy option proto, it currently supports name only, will support +/// precedence later. +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct DataPolicyOption { + /// Data policy resource name in the form of + /// projects/project_id/locations/location_id/dataPolicies/data_policy_id. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub name: std::option::Option, +} + +impl DataPolicyOption { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::DataPolicyOption::name]. + pub fn set_name>>( + mut self, + v: T, + ) -> Self { + self.name = v.into(); + self + } +} + +impl wkt::message::Message for DataPolicyOption { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.DataPolicyOption" + } +} + +/// A field in TableSchema +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct TableFieldSchema { + /// Required. The field name. The name must contain only letters (a-z, A-Z), + /// numbers (0-9), or underscores (_), and must start with a letter or + /// underscore. The maximum length is 300 characters. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub name: std::string::String, + + /// Required. The field data type. Possible values include: + /// + /// * STRING + /// * BYTES + /// * INTEGER (or INT64) + /// * FLOAT (or FLOAT64) + /// * BOOLEAN (or BOOL) + /// * TIMESTAMP + /// * DATE + /// * TIME + /// * DATETIME + /// * GEOGRAPHY + /// * NUMERIC + /// * BIGNUMERIC + /// * JSON + /// * RECORD (or STRUCT) + /// * RANGE + /// + /// Use of RECORD/STRUCT indicates that the field contains a nested schema. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + + /// Optional. The field mode. Possible values include NULLABLE, REQUIRED and + /// REPEATED. The default value is NULLABLE. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub mode: std::string::String, + + /// Optional. Describes the nested schema fields if the type property is set + /// to RECORD. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub fields: std::vec::Vec, + + /// Optional. The field description. The maximum length is 1,024 characters. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub description: std::option::Option, + + /// Optional. The policy tags attached to this field, used for field-level + /// access control. If not set, defaults to empty policy_tags. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub policy_tags: std::option::Option, + + /// Optional. Data policy options, will replace the data_policies. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub data_policies: std::vec::Vec, + + /// Optional. Maximum length of values of this field for STRINGS or BYTES. + /// + /// If max_length is not specified, no maximum length constraint is imposed + /// on this field. + /// + /// If type = "STRING", then max_length represents the maximum UTF-8 + /// length of strings in this field. + /// + /// If type = "BYTES", then max_length represents the maximum number of + /// bytes in this field. + /// + /// It is invalid to set this field if type ≠ "STRING" and ≠ "BYTES". + #[serde_as(as = "serde_with::DisplayFromStr")] + pub max_length: i64, + + /// Optional. Precision (maximum number of total digits in base 10) and scale + /// (maximum number of digits in the fractional part in base 10) constraints + /// for values of this field for NUMERIC or BIGNUMERIC. + /// + /// It is invalid to set precision or scale if type ≠ "NUMERIC" and ≠ + /// "BIGNUMERIC". + /// + /// If precision and scale are not specified, no value range constraint is + /// imposed on this field insofar as values are permitted by the type. + /// + /// Values of this NUMERIC or BIGNUMERIC field must be in this range when: + /// + /// * Precision (\P\) and scale (\S\) are specified: + /// [-10\\P\-\S\\ + 10\-\S\\, + /// 10\\P\-\S\\ - 10\-\S\\] + /// * Precision (\P\) is specified but not scale (and thus scale is + /// interpreted to be equal to zero): + /// [-10\\P\\ + 1, 10\\P\\ - 1]. + /// + /// Acceptable values for precision and scale if both are specified: + /// + /// * If type = "NUMERIC": + /// 1 ≤ precision - scale ≤ 29 and 0 ≤ scale ≤ 9. + /// * If type = "BIGNUMERIC": + /// 1 ≤ precision - scale ≤ 38 and 0 ≤ scale ≤ 38. + /// + /// Acceptable values for precision if only precision is specified but not + /// scale (and thus scale is interpreted to be equal to zero): + /// + /// * If type = "NUMERIC": 1 ≤ precision ≤ 29. + /// * If type = "BIGNUMERIC": 1 ≤ precision ≤ 38. + /// + /// If scale is specified but not precision, then it is invalid. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub precision: i64, + + /// Optional. See documentation for precision. + #[serde_as(as = "serde_with::DisplayFromStr")] + pub scale: i64, + + /// Optional. Specifies the rounding mode to be used when storing values of + /// NUMERIC and BIGNUMERIC type. + pub rounding_mode: crate::model::table_field_schema::RoundingMode, + + /// Optional. Field collation can be set only when the type of field is STRING. + /// The following values are supported: + /// + /// * 'und:ci': undetermined locale, case insensitive. + /// * '': empty string. Default to case-sensitive behavior. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub collation: std::option::Option, + + /// Optional. A SQL expression to specify the [default value] + /// () for this field. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub default_value_expression: std::option::Option, + + /// Optional. The subtype of the RANGE, if the type of this field is RANGE. If + /// the type is RANGE, this field is required. Values for the field element + /// type can be the following: + /// + /// * DATE + /// * DATETIME + /// * TIMESTAMP + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub range_element_type: std::option::Option, + + /// Optional. Definition of the foreign data type. + /// Only valid for top-level schema fields (not nested fields). + /// If the type is FOREIGN, this field is required. + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub foreign_type_definition: std::string::String, +} + +impl TableFieldSchema { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [name][crate::model::TableFieldSchema::name]. + pub fn set_name>(mut self, v: T) -> Self { + self.name = v.into(); + self + } + + /// Sets the value of [r#type][crate::model::TableFieldSchema::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [mode][crate::model::TableFieldSchema::mode]. + pub fn set_mode>(mut self, v: T) -> Self { + self.mode = v.into(); + self + } + + /// Sets the value of [description][crate::model::TableFieldSchema::description]. + pub fn set_description>>( + mut self, + v: T, + ) -> Self { + self.description = v.into(); + self + } + + /// Sets the value of [policy_tags][crate::model::TableFieldSchema::policy_tags]. + pub fn set_policy_tags< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.policy_tags = v.into(); + self + } + + /// Sets the value of [max_length][crate::model::TableFieldSchema::max_length]. + pub fn set_max_length>(mut self, v: T) -> Self { + self.max_length = v.into(); + self + } + + /// Sets the value of [precision][crate::model::TableFieldSchema::precision]. + pub fn set_precision>(mut self, v: T) -> Self { + self.precision = v.into(); + self + } + + /// Sets the value of [scale][crate::model::TableFieldSchema::scale]. + pub fn set_scale>(mut self, v: T) -> Self { + self.scale = v.into(); + self + } + + /// Sets the value of [rounding_mode][crate::model::TableFieldSchema::rounding_mode]. + pub fn set_rounding_mode< + T: std::convert::Into, + >( + mut self, + v: T, + ) -> Self { + self.rounding_mode = v.into(); + self + } + + /// Sets the value of [collation][crate::model::TableFieldSchema::collation]. + pub fn set_collation>>( + mut self, + v: T, + ) -> Self { + self.collation = v.into(); + self + } + + /// Sets the value of [default_value_expression][crate::model::TableFieldSchema::default_value_expression]. + pub fn set_default_value_expression< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.default_value_expression = v.into(); + self + } + + /// Sets the value of [range_element_type][crate::model::TableFieldSchema::range_element_type]. + pub fn set_range_element_type< + T: std::convert::Into>, + >( + mut self, + v: T, + ) -> Self { + self.range_element_type = v.into(); + self + } + + /// Sets the value of [foreign_type_definition][crate::model::TableFieldSchema::foreign_type_definition]. + pub fn set_foreign_type_definition>( + mut self, + v: T, + ) -> Self { + self.foreign_type_definition = v.into(); + self + } + + /// Sets the value of [fields][crate::model::TableFieldSchema::fields]. + pub fn set_fields(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.fields = v.into_iter().map(|i| i.into()).collect(); + self + } + + /// Sets the value of [data_policies][crate::model::TableFieldSchema::data_policies]. + pub fn set_data_policies(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.data_policies = v.into_iter().map(|i| i.into()).collect(); + self + } +} + +impl wkt::message::Message for TableFieldSchema { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TableFieldSchema" + } +} + +/// Defines additional types related to TableFieldSchema +pub mod table_field_schema { + #[allow(unused_imports)] + use super::*; + + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct PolicyTagList { + /// A list of policy tag resource names. For example, + /// "projects/1/locations/eu/taxonomies/2/policyTags/3". At most 1 policy tag + /// is currently allowed. + #[serde(skip_serializing_if = "std::vec::Vec::is_empty")] + pub names: std::vec::Vec, + } + + impl PolicyTagList { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [names][crate::model::table_field_schema::PolicyTagList::names]. + pub fn set_names(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + V: std::convert::Into, + { + use std::iter::Iterator; + self.names = v.into_iter().map(|i| i.into()).collect(); + self + } + } + + impl wkt::message::Message for PolicyTagList { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TableFieldSchema.PolicyTagList" + } + } + + /// Represents the type of a field element. + #[serde_with::serde_as] + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[serde(default, rename_all = "camelCase")] + #[non_exhaustive] + pub struct FieldElementType { + /// Required. The type of a field element. For more information, see + /// [TableFieldSchema.type][google.cloud.bigquery.v2.TableFieldSchema.type]. + /// + /// [google.cloud.bigquery.v2.TableFieldSchema.type]: crate::model::TableFieldSchema::type + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + } + + impl FieldElementType { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [r#type][crate::model::table_field_schema::FieldElementType::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + } + + impl wkt::message::Message for FieldElementType { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TableFieldSchema.FieldElementType" + } + } + + /// Rounding mode options that can be used when storing NUMERIC + /// or BIGNUMERIC values. + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct RoundingMode(i32); + + impl RoundingMode { + /// Unspecified will default to using ROUND_HALF_AWAY_FROM_ZERO. + pub const ROUNDING_MODE_UNSPECIFIED: RoundingMode = RoundingMode::new(0); + + /// ROUND_HALF_AWAY_FROM_ZERO rounds half values away from zero + /// when applying precision and scale upon writing of NUMERIC and BIGNUMERIC + /// values. + /// For Scale: 0 + /// 1.1, 1.2, 1.3, 1.4 => 1 + /// 1.5, 1.6, 1.7, 1.8, 1.9 => 2 + pub const ROUND_HALF_AWAY_FROM_ZERO: RoundingMode = RoundingMode::new(1); + + /// ROUND_HALF_EVEN rounds half values to the nearest even value + /// when applying precision and scale upon writing of NUMERIC and BIGNUMERIC + /// values. + /// For Scale: 0 + /// 1.1, 1.2, 1.3, 1.4 => 1 + /// 1.5 => 2 + /// 1.6, 1.7, 1.8, 1.9 => 2 + /// 2.5 => 2 + pub const ROUND_HALF_EVEN: RoundingMode = RoundingMode::new(2); + + /// Creates a new RoundingMode instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("ROUNDING_MODE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("ROUND_HALF_AWAY_FROM_ZERO"), + 2 => std::borrow::Cow::Borrowed("ROUND_HALF_EVEN"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "ROUNDING_MODE_UNSPECIFIED" => { + std::option::Option::Some(Self::ROUNDING_MODE_UNSPECIFIED) + } + "ROUND_HALF_AWAY_FROM_ZERO" => { + std::option::Option::Some(Self::ROUND_HALF_AWAY_FROM_ZERO) + } + "ROUND_HALF_EVEN" => std::option::Option::Some(Self::ROUND_HALF_EVEN), + _ => std::option::Option::None, + } + } + } + + impl std::convert::From for RoundingMode { + fn from(value: i32) -> Self { + Self::new(value) + } + } + + impl std::default::Default for RoundingMode { + fn default() -> Self { + Self::new(0) + } + } +} + +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct TimePartitioning { + /// Required. The supported types are DAY, HOUR, MONTH, and YEAR, which will + /// generate one partition per day, hour, month, and year, respectively. + #[serde(rename = "type")] + #[serde(skip_serializing_if = "std::string::String::is_empty")] + pub r#type: std::string::String, + + /// Optional. Number of milliseconds for which to keep the storage for a + /// partition. + /// A wrapper is used here because 0 is an invalid value. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + #[serde_as(as = "std::option::Option")] + pub expiration_ms: std::option::Option, + + /// Optional. If not set, the table is partitioned by pseudo + /// column '_PARTITIONTIME'; if set, the table is partitioned by this field. + /// The field must be a top-level TIMESTAMP or DATE field. Its mode must be + /// NULLABLE or REQUIRED. + /// A wrapper is used here because an empty string is an invalid value. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub field: std::option::Option, +} + +impl TimePartitioning { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [r#type][crate::model::TimePartitioning::type]. + pub fn set_type>(mut self, v: T) -> Self { + self.r#type = v.into(); + self + } + + /// Sets the value of [expiration_ms][crate::model::TimePartitioning::expiration_ms]. + pub fn set_expiration_ms>>( + mut self, + v: T, + ) -> Self { + self.expiration_ms = v.into(); + self + } + + /// Sets the value of [field][crate::model::TimePartitioning::field]. + pub fn set_field>>( + mut self, + v: T, + ) -> Self { + self.field = v.into(); + self + } +} + +impl wkt::message::Message for TimePartitioning { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.TimePartitioning" + } +} + +/// This is used for defining User Defined Function (UDF) resources only when +/// using legacy SQL. Users of GoogleSQL should leverage either DDL (e.g. +/// CREATE [TEMPORARY] FUNCTION ... ) or the Routines API to define UDF +/// resources. +/// +/// For additional information on migrating, see: +/// +#[serde_with::serde_as] +#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(default, rename_all = "camelCase")] +#[non_exhaustive] +pub struct UserDefinedFunctionResource { + /// [Pick one] A code resource to load from a Google Cloud Storage URI + /// (gs://bucket/path). + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub resource_uri: std::option::Option, + + /// [Pick one] An inline resource that contains code for a user-defined + /// function (UDF). Providing a inline code resource is equivalent to providing + /// a URI for a file containing the same code. + #[serde(skip_serializing_if = "std::option::Option::is_none")] + pub inline_code: std::option::Option, +} + +impl UserDefinedFunctionResource { + pub fn new() -> Self { + std::default::Default::default() + } + + /// Sets the value of [resource_uri][crate::model::UserDefinedFunctionResource::resource_uri]. + pub fn set_resource_uri>>( + mut self, + v: T, + ) -> Self { + self.resource_uri = v.into(); + self + } + + /// Sets the value of [inline_code][crate::model::UserDefinedFunctionResource::inline_code]. + pub fn set_inline_code>>( + mut self, + v: T, + ) -> Self { + self.inline_code = v.into(); + self + } +} + +impl wkt::message::Message for UserDefinedFunctionResource { + fn typename() -> &'static str { + "type.googleapis.com/google.cloud.bigquery.v2.UserDefinedFunctionResource" + } +} + +/// The data types that could be used as a target type when converting decimal +/// values. +#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct DecimalTargetType(i32); + +impl DecimalTargetType { + /// Invalid type. + pub const DECIMAL_TARGET_TYPE_UNSPECIFIED: DecimalTargetType = DecimalTargetType::new(0); + + /// Decimal values could be converted to NUMERIC + /// type. + pub const NUMERIC: DecimalTargetType = DecimalTargetType::new(1); + + /// Decimal values could be converted to BIGNUMERIC + /// type. + pub const BIGNUMERIC: DecimalTargetType = DecimalTargetType::new(2); + + /// Decimal values could be converted to STRING type. + pub const STRING: DecimalTargetType = DecimalTargetType::new(3); + + /// Creates a new DecimalTargetType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("DECIMAL_TARGET_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("NUMERIC"), + 2 => std::borrow::Cow::Borrowed("BIGNUMERIC"), + 3 => std::borrow::Cow::Borrowed("STRING"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "DECIMAL_TARGET_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::DECIMAL_TARGET_TYPE_UNSPECIFIED) + } + "NUMERIC" => std::option::Option::Some(Self::NUMERIC), + "BIGNUMERIC" => std::option::Option::Some(Self::BIGNUMERIC), + "STRING" => std::option::Option::Some(Self::STRING), + _ => std::option::Option::None, + } + } +} + +impl std::convert::From for DecimalTargetType { + fn from(value: i32) -> Self { + Self::new(value) + } +} + +impl std::default::Default for DecimalTargetType { + fn default() -> Self { + Self::new(0) + } +} + +/// This enum defines how to interpret source URIs for load jobs and external +/// tables. +#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct FileSetSpecType(i32); + +impl FileSetSpecType { + /// This option expands source URIs by listing files from the object store. It + /// is the default behavior if FileSetSpecType is not set. + pub const FILE_SET_SPEC_TYPE_FILE_SYSTEM_MATCH: FileSetSpecType = FileSetSpecType::new(0); + + /// This option indicates that the provided URIs are newline-delimited manifest + /// files, with one URI per line. Wildcard URIs are not supported. + pub const FILE_SET_SPEC_TYPE_NEW_LINE_DELIMITED_MANIFEST: FileSetSpecType = + FileSetSpecType::new(1); + + /// Creates a new FileSetSpecType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("FILE_SET_SPEC_TYPE_FILE_SYSTEM_MATCH"), + 1 => std::borrow::Cow::Borrowed("FILE_SET_SPEC_TYPE_NEW_LINE_DELIMITED_MANIFEST"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "FILE_SET_SPEC_TYPE_FILE_SYSTEM_MATCH" => { + std::option::Option::Some(Self::FILE_SET_SPEC_TYPE_FILE_SYSTEM_MATCH) + } + "FILE_SET_SPEC_TYPE_NEW_LINE_DELIMITED_MANIFEST" => { + std::option::Option::Some(Self::FILE_SET_SPEC_TYPE_NEW_LINE_DELIMITED_MANIFEST) + } + _ => std::option::Option::None, + } + } +} + +impl std::convert::From for FileSetSpecType { + fn from(value: i32) -> Self { + Self::new(value) + } +} + +impl std::default::Default for FileSetSpecType { + fn default() -> Self { + Self::new(0) + } +} + +/// Used to indicate that a JSON variant, rather than normal JSON, is being used +/// as the source_format. This should only be used in combination with the +/// JSON source format. +#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct JsonExtension(i32); + +impl JsonExtension { + /// The default if provided value is not one included in the enum, or the value + /// is not specified. The source format is parsed without any modification. + pub const JSON_EXTENSION_UNSPECIFIED: JsonExtension = JsonExtension::new(0); + + /// Use GeoJSON variant of JSON. See . + pub const GEOJSON: JsonExtension = JsonExtension::new(1); + + /// Creates a new JsonExtension instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("JSON_EXTENSION_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("GEOJSON"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "JSON_EXTENSION_UNSPECIFIED" => { + std::option::Option::Some(Self::JSON_EXTENSION_UNSPECIFIED) + } + "GEOJSON" => std::option::Option::Some(Self::GEOJSON), + _ => std::option::Option::None, + } + } +} + +impl std::convert::From for JsonExtension { + fn from(value: i32) -> Self { + Self::new(value) + } +} + +impl std::default::Default for JsonExtension { + fn default() -> Self { + Self::new(0) + } +} + +/// The classification of managed table types that can be created. +#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct ManagedTableType(i32); + +impl ManagedTableType { + /// No managed table type specified. + pub const MANAGED_TABLE_TYPE_UNSPECIFIED: ManagedTableType = ManagedTableType::new(0); + + /// The managed table is a native BigQuery table. + pub const NATIVE: ManagedTableType = ManagedTableType::new(1); + + /// The managed table is a BigQuery table for Apache Iceberg. + pub const ICEBERG: ManagedTableType = ManagedTableType::new(2); + + /// Creates a new ManagedTableType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("MANAGED_TABLE_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("NATIVE"), + 2 => std::borrow::Cow::Borrowed("ICEBERG"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "MANAGED_TABLE_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::MANAGED_TABLE_TYPE_UNSPECIFIED) + } + "NATIVE" => std::option::Option::Some(Self::NATIVE), + "ICEBERG" => std::option::Option::Some(Self::ICEBERG), + _ => std::option::Option::None, + } + } +} + +impl std::convert::From for ManagedTableType { + fn from(value: i32) -> Self { + Self::new(value) + } +} + +impl std::default::Default for ManagedTableType { + fn default() -> Self { + Self::new(0) + } +} + +/// Indicates the map target type. Only applies to parquet maps. +#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct MapTargetType(i32); + +impl MapTargetType { + /// In this mode, the map will have the following schema: + /// struct map_field_name { repeated struct key_value { key value } }. + pub const MAP_TARGET_TYPE_UNSPECIFIED: MapTargetType = MapTargetType::new(0); + + /// In this mode, the map will have the following schema: + /// repeated struct map_field_name { key value }. + pub const ARRAY_OF_STRUCT: MapTargetType = MapTargetType::new(1); + + /// Creates a new MapTargetType instance. + pub(crate) const fn new(value: i32) -> Self { + Self(value) + } + + /// Gets the enum value. + pub fn value(&self) -> i32 { + self.0 + } + + /// Gets the enum value as a string. + pub fn as_str_name(&self) -> std::borrow::Cow<'static, str> { + match self.0 { + 0 => std::borrow::Cow::Borrowed("MAP_TARGET_TYPE_UNSPECIFIED"), + 1 => std::borrow::Cow::Borrowed("ARRAY_OF_STRUCT"), + _ => std::borrow::Cow::Owned(std::format!("UNKNOWN-VALUE:{}", self.0)), + } + } + + /// Creates an enum value from the value name. + pub fn from_str_name(name: &str) -> std::option::Option { + match name { + "MAP_TARGET_TYPE_UNSPECIFIED" => { + std::option::Option::Some(Self::MAP_TARGET_TYPE_UNSPECIFIED) + } + "ARRAY_OF_STRUCT" => std::option::Option::Some(Self::ARRAY_OF_STRUCT), + _ => std::option::Option::None, + } + } +} + +impl std::convert::From for MapTargetType { + fn from(value: i32) -> Self { + Self::new(value) + } +} + +impl std::default::Default for MapTargetType { + fn default() -> Self { + Self::new(0) + } +} diff --git a/src/generated/cloud/bigquery/v2/src/stubs.rs b/src/generated/cloud/bigquery/v2/src/stubs.rs new file mode 100755 index 000000000..5874d16cc --- /dev/null +++ b/src/generated/cloud/bigquery/v2/src/stubs.rs @@ -0,0 +1,409 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by sidekick. DO NOT EDIT. + +//! Traits to mock the clients in this library. +//! +//! Application developers may need to mock the clients in this library to test +//! how their application works with different (and sometimes hard to trigger) +//! client and service behavior. Such test can define mocks implementing the +//! trait(s) defined in this module, initialize the client with an instance of +//! this mock in their tests, and verify their application responds as expected. + +#![allow(rustdoc::broken_intra_doc_links)] + +use gax::error::Error; + +pub(crate) mod dynamic; + +/// Defines the trait used to implement [super::client::DatasetService]. +/// +/// Application developers may need to implement this trait to mock +/// `client::DatasetService`. In other use-cases, application developers only +/// use `client::DatasetService` and need not be concerned with this trait or +/// its implementations. +/// +/// Services gain new RPCs routinely. Consequently, this trait gains new methods +/// too. To avoid breaking applications the trait provides a default +/// implementation of each method. Most of these implementations just return an +/// error. +pub trait DatasetService: std::fmt::Debug + Send + Sync { + /// Implements [super::client::DatasetService::get_dataset]. + fn get_dataset( + &self, + _req: crate::model::GetDatasetRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::DatasetService::insert_dataset]. + fn insert_dataset( + &self, + _req: crate::model::InsertDatasetRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::DatasetService::patch_dataset]. + fn patch_dataset( + &self, + _req: crate::model::UpdateOrPatchDatasetRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::DatasetService::update_dataset]. + fn update_dataset( + &self, + _req: crate::model::UpdateOrPatchDatasetRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::DatasetService::delete_dataset]. + fn delete_dataset( + &self, + _req: crate::model::DeleteDatasetRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::DatasetService::list_datasets]. + fn list_datasets( + &self, + _req: crate::model::ListDatasetsRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::DatasetService::undelete_dataset]. + fn undelete_dataset( + &self, + _req: crate::model::UndeleteDatasetRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } +} + +/// Defines the trait used to implement [super::client::ModelService]. +/// +/// Application developers may need to implement this trait to mock +/// `client::ModelService`. In other use-cases, application developers only +/// use `client::ModelService` and need not be concerned with this trait or +/// its implementations. +/// +/// Services gain new RPCs routinely. Consequently, this trait gains new methods +/// too. To avoid breaking applications the trait provides a default +/// implementation of each method. Most of these implementations just return an +/// error. +pub trait ModelService: std::fmt::Debug + Send + Sync { + /// Implements [super::client::ModelService::get_model]. + fn get_model( + &self, + _req: crate::model::GetModelRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::ModelService::list_models]. + fn list_models( + &self, + _req: crate::model::ListModelsRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send + { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::ModelService::patch_model]. + fn patch_model( + &self, + _req: crate::model::PatchModelRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::ModelService::delete_model]. + fn delete_model( + &self, + _req: crate::model::DeleteModelRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } +} + +/// Defines the trait used to implement [super::client::ProjectService]. +/// +/// Application developers may need to implement this trait to mock +/// `client::ProjectService`. In other use-cases, application developers only +/// use `client::ProjectService` and need not be concerned with this trait or +/// its implementations. +/// +/// Services gain new RPCs routinely. Consequently, this trait gains new methods +/// too. To avoid breaking applications the trait provides a default +/// implementation of each method. Most of these implementations just return an +/// error. +pub trait ProjectService: std::fmt::Debug + Send + Sync { + /// Implements [super::client::ProjectService::get_service_account]. + fn get_service_account( + &self, + _req: crate::model::GetServiceAccountRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send + { + std::future::ready::>(Err( + Error::other("unimplemented"), + )) + } +} + +/// Defines the trait used to implement [super::client::RoutineService]. +/// +/// Application developers may need to implement this trait to mock +/// `client::RoutineService`. In other use-cases, application developers only +/// use `client::RoutineService` and need not be concerned with this trait or +/// its implementations. +/// +/// Services gain new RPCs routinely. Consequently, this trait gains new methods +/// too. To avoid breaking applications the trait provides a default +/// implementation of each method. Most of these implementations just return an +/// error. +pub trait RoutineService: std::fmt::Debug + Send + Sync { + /// Implements [super::client::RoutineService::get_routine]. + fn get_routine( + &self, + _req: crate::model::GetRoutineRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::RoutineService::insert_routine]. + fn insert_routine( + &self, + _req: crate::model::InsertRoutineRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::RoutineService::update_routine]. + fn update_routine( + &self, + _req: crate::model::UpdateRoutineRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::RoutineService::delete_routine]. + fn delete_routine( + &self, + _req: crate::model::DeleteRoutineRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::RoutineService::list_routines]. + fn list_routines( + &self, + _req: crate::model::ListRoutinesRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send + { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } +} + +/// Defines the trait used to implement [super::client::RowAccessPolicyService]. +/// +/// Application developers may need to implement this trait to mock +/// `client::RowAccessPolicyService`. In other use-cases, application developers only +/// use `client::RowAccessPolicyService` and need not be concerned with this trait or +/// its implementations. +/// +/// Services gain new RPCs routinely. Consequently, this trait gains new methods +/// too. To avoid breaking applications the trait provides a default +/// implementation of each method. Most of these implementations just return an +/// error. +pub trait RowAccessPolicyService: std::fmt::Debug + Send + Sync { + /// Implements [super::client::RowAccessPolicyService::list_row_access_policies]. + fn list_row_access_policies( + &self, + _req: crate::model::ListRowAccessPoliciesRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + + Send { + std::future::ready::>(Err( + Error::other("unimplemented"), + )) + } + + /// Implements [super::client::RowAccessPolicyService::get_row_access_policy]. + fn get_row_access_policy( + &self, + _req: crate::model::GetRowAccessPolicyRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send + { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::RowAccessPolicyService::create_row_access_policy]. + fn create_row_access_policy( + &self, + _req: crate::model::CreateRowAccessPolicyRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send + { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::RowAccessPolicyService::update_row_access_policy]. + fn update_row_access_policy( + &self, + _req: crate::model::UpdateRowAccessPolicyRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send + { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } + + /// Implements [super::client::RowAccessPolicyService::delete_row_access_policy]. + fn delete_row_access_policy( + &self, + _req: crate::model::DeleteRowAccessPolicyRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::RowAccessPolicyService::batch_delete_row_access_policies]. + fn batch_delete_row_access_policies( + &self, + _req: crate::model::BatchDeleteRowAccessPoliciesRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } +} + +/// Defines the trait used to implement [super::client::TableService]. +/// +/// Application developers may need to implement this trait to mock +/// `client::TableService`. In other use-cases, application developers only +/// use `client::TableService` and need not be concerned with this trait or +/// its implementations. +/// +/// Services gain new RPCs routinely. Consequently, this trait gains new methods +/// too. To avoid breaking applications the trait provides a default +/// implementation of each method. Most of these implementations just return an +/// error. +pub trait TableService: std::fmt::Debug + Send + Sync { + /// Implements [super::client::TableService::get_table]. + fn get_table( + &self, + _req: crate::model::GetTableRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::TableService::insert_table]. + fn insert_table( + &self, + _req: crate::model::InsertTableRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::TableService::patch_table]. + fn patch_table( + &self, + _req: crate::model::UpdateOrPatchTableRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::TableService::update_table]. + fn update_table( + &self, + _req: crate::model::UpdateOrPatchTableRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::TableService::delete_table]. + fn delete_table( + &self, + _req: crate::model::DeleteTableRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other("unimplemented"))) + } + + /// Implements [super::client::TableService::list_tables]. + fn list_tables( + &self, + _req: crate::model::ListTablesRequest, + _options: gax::options::RequestOptions, + ) -> impl std::future::Future> + Send { + std::future::ready::>(Err(Error::other( + "unimplemented", + ))) + } +} diff --git a/src/generated/cloud/bigquery/v2/src/stubs/dynamic.rs b/src/generated/cloud/bigquery/v2/src/stubs/dynamic.rs new file mode 100755 index 000000000..3dff9eeda --- /dev/null +++ b/src/generated/cloud/bigquery/v2/src/stubs/dynamic.rs @@ -0,0 +1,498 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by sidekick. DO NOT EDIT. + +/// A dyn-compatible, crate-private version of [super::DatasetService]. +#[async_trait::async_trait] +pub trait DatasetService: std::fmt::Debug + Send + Sync { + async fn get_dataset( + &self, + req: crate::model::GetDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn insert_dataset( + &self, + req: crate::model::InsertDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn patch_dataset( + &self, + req: crate::model::UpdateOrPatchDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn update_dataset( + &self, + req: crate::model::UpdateOrPatchDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn delete_dataset( + &self, + req: crate::model::DeleteDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn list_datasets( + &self, + req: crate::model::ListDatasetsRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn undelete_dataset( + &self, + req: crate::model::UndeleteDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; +} + +/// All implementations of [super::DatasetService] also implement [DatasetService]. +#[async_trait::async_trait] +impl DatasetService for T { + /// Forwards the call to the implementation provided by `T`. + async fn get_dataset( + &self, + req: crate::model::GetDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::get_dataset(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn insert_dataset( + &self, + req: crate::model::InsertDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::insert_dataset(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn patch_dataset( + &self, + req: crate::model::UpdateOrPatchDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::patch_dataset(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn update_dataset( + &self, + req: crate::model::UpdateOrPatchDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::update_dataset(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn delete_dataset( + &self, + req: crate::model::DeleteDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::delete_dataset(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn list_datasets( + &self, + req: crate::model::ListDatasetsRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::list_datasets(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn undelete_dataset( + &self, + req: crate::model::UndeleteDatasetRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::undelete_dataset(self, req, options).await + } +} + +/// A dyn-compatible, crate-private version of [super::ModelService]. +#[async_trait::async_trait] +pub trait ModelService: std::fmt::Debug + Send + Sync { + async fn get_model( + &self, + req: crate::model::GetModelRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn list_models( + &self, + req: crate::model::ListModelsRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn patch_model( + &self, + req: crate::model::PatchModelRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn delete_model( + &self, + req: crate::model::DeleteModelRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; +} + +/// All implementations of [super::ModelService] also implement [ModelService]. +#[async_trait::async_trait] +impl ModelService for T { + /// Forwards the call to the implementation provided by `T`. + async fn get_model( + &self, + req: crate::model::GetModelRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::get_model(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn list_models( + &self, + req: crate::model::ListModelsRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::list_models(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn patch_model( + &self, + req: crate::model::PatchModelRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::patch_model(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn delete_model( + &self, + req: crate::model::DeleteModelRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::delete_model(self, req, options).await + } +} + +/// A dyn-compatible, crate-private version of [super::ProjectService]. +#[async_trait::async_trait] +pub trait ProjectService: std::fmt::Debug + Send + Sync { + async fn get_service_account( + &self, + req: crate::model::GetServiceAccountRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; +} + +/// All implementations of [super::ProjectService] also implement [ProjectService]. +#[async_trait::async_trait] +impl ProjectService for T { + /// Forwards the call to the implementation provided by `T`. + async fn get_service_account( + &self, + req: crate::model::GetServiceAccountRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::get_service_account(self, req, options).await + } +} + +/// A dyn-compatible, crate-private version of [super::RoutineService]. +#[async_trait::async_trait] +pub trait RoutineService: std::fmt::Debug + Send + Sync { + async fn get_routine( + &self, + req: crate::model::GetRoutineRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn insert_routine( + &self, + req: crate::model::InsertRoutineRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn update_routine( + &self, + req: crate::model::UpdateRoutineRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn delete_routine( + &self, + req: crate::model::DeleteRoutineRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn list_routines( + &self, + req: crate::model::ListRoutinesRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; +} + +/// All implementations of [super::RoutineService] also implement [RoutineService]. +#[async_trait::async_trait] +impl RoutineService for T { + /// Forwards the call to the implementation provided by `T`. + async fn get_routine( + &self, + req: crate::model::GetRoutineRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::get_routine(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn insert_routine( + &self, + req: crate::model::InsertRoutineRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::insert_routine(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn update_routine( + &self, + req: crate::model::UpdateRoutineRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::update_routine(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn delete_routine( + &self, + req: crate::model::DeleteRoutineRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::delete_routine(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn list_routines( + &self, + req: crate::model::ListRoutinesRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::list_routines(self, req, options).await + } +} + +/// A dyn-compatible, crate-private version of [super::RowAccessPolicyService]. +#[async_trait::async_trait] +pub trait RowAccessPolicyService: std::fmt::Debug + Send + Sync { + async fn list_row_access_policies( + &self, + req: crate::model::ListRowAccessPoliciesRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn get_row_access_policy( + &self, + req: crate::model::GetRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn create_row_access_policy( + &self, + req: crate::model::CreateRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn update_row_access_policy( + &self, + req: crate::model::UpdateRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn delete_row_access_policy( + &self, + req: crate::model::DeleteRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn batch_delete_row_access_policies( + &self, + req: crate::model::BatchDeleteRowAccessPoliciesRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; +} + +/// All implementations of [super::RowAccessPolicyService] also implement [RowAccessPolicyService]. +#[async_trait::async_trait] +impl RowAccessPolicyService for T { + /// Forwards the call to the implementation provided by `T`. + async fn list_row_access_policies( + &self, + req: crate::model::ListRowAccessPoliciesRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::list_row_access_policies(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn get_row_access_policy( + &self, + req: crate::model::GetRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::get_row_access_policy(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn create_row_access_policy( + &self, + req: crate::model::CreateRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::create_row_access_policy(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn update_row_access_policy( + &self, + req: crate::model::UpdateRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::update_row_access_policy(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn delete_row_access_policy( + &self, + req: crate::model::DeleteRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::delete_row_access_policy(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn batch_delete_row_access_policies( + &self, + req: crate::model::BatchDeleteRowAccessPoliciesRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::batch_delete_row_access_policies(self, req, options).await + } +} + +/// A dyn-compatible, crate-private version of [super::TableService]. +#[async_trait::async_trait] +pub trait TableService: std::fmt::Debug + Send + Sync { + async fn get_table( + &self, + req: crate::model::GetTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn insert_table( + &self, + req: crate::model::InsertTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn patch_table( + &self, + req: crate::model::UpdateOrPatchTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn update_table( + &self, + req: crate::model::UpdateOrPatchTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn delete_table( + &self, + req: crate::model::DeleteTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; + + async fn list_tables( + &self, + req: crate::model::ListTablesRequest, + options: gax::options::RequestOptions, + ) -> crate::Result; +} + +/// All implementations of [super::TableService] also implement [TableService]. +#[async_trait::async_trait] +impl TableService for T { + /// Forwards the call to the implementation provided by `T`. + async fn get_table( + &self, + req: crate::model::GetTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::get_table(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn insert_table( + &self, + req: crate::model::InsertTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::insert_table(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn patch_table( + &self, + req: crate::model::UpdateOrPatchTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::patch_table(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn update_table( + &self, + req: crate::model::UpdateOrPatchTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::update_table(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn delete_table( + &self, + req: crate::model::DeleteTableRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::delete_table(self, req, options).await + } + + /// Forwards the call to the implementation provided by `T`. + async fn list_tables( + &self, + req: crate::model::ListTablesRequest, + options: gax::options::RequestOptions, + ) -> crate::Result { + T::list_tables(self, req, options).await + } +} diff --git a/src/generated/cloud/bigquery/v2/src/tracing.rs b/src/generated/cloud/bigquery/v2/src/tracing.rs new file mode 100755 index 000000000..9434c587b --- /dev/null +++ b/src/generated/cloud/bigquery/v2/src/tracing.rs @@ -0,0 +1,417 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by sidekick. DO NOT EDIT. +use crate::Result; + +/// Implements a [DatasetService](super::stubs::DatasetService) decorator for logging and tracing. +#[derive(Clone, Debug)] +pub struct DatasetService +where + T: super::stubs::DatasetService + std::fmt::Debug + Send + Sync, +{ + inner: T, +} + +impl DatasetService +where + T: super::stubs::DatasetService + std::fmt::Debug + Send + Sync, +{ + pub fn new(inner: T) -> Self { + Self { inner } + } +} + +impl super::stubs::DatasetService for DatasetService +where + T: super::stubs::DatasetService + std::fmt::Debug + Send + Sync, +{ + #[tracing::instrument(ret)] + async fn get_dataset( + &self, + req: crate::model::GetDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.get_dataset(req, options).await + } + + #[tracing::instrument(ret)] + async fn insert_dataset( + &self, + req: crate::model::InsertDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.insert_dataset(req, options).await + } + + #[tracing::instrument(ret)] + async fn patch_dataset( + &self, + req: crate::model::UpdateOrPatchDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.patch_dataset(req, options).await + } + + #[tracing::instrument(ret)] + async fn update_dataset( + &self, + req: crate::model::UpdateOrPatchDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.update_dataset(req, options).await + } + + #[tracing::instrument(ret)] + async fn delete_dataset( + &self, + req: crate::model::DeleteDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.delete_dataset(req, options).await + } + + #[tracing::instrument(ret)] + async fn list_datasets( + &self, + req: crate::model::ListDatasetsRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.list_datasets(req, options).await + } + + #[tracing::instrument(ret)] + async fn undelete_dataset( + &self, + req: crate::model::UndeleteDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.undelete_dataset(req, options).await + } +} + +/// Implements a [ModelService](super::stubs::ModelService) decorator for logging and tracing. +#[derive(Clone, Debug)] +pub struct ModelService +where + T: super::stubs::ModelService + std::fmt::Debug + Send + Sync, +{ + inner: T, +} + +impl ModelService +where + T: super::stubs::ModelService + std::fmt::Debug + Send + Sync, +{ + pub fn new(inner: T) -> Self { + Self { inner } + } +} + +impl super::stubs::ModelService for ModelService +where + T: super::stubs::ModelService + std::fmt::Debug + Send + Sync, +{ + #[tracing::instrument(ret)] + async fn get_model( + &self, + req: crate::model::GetModelRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.get_model(req, options).await + } + + #[tracing::instrument(ret)] + async fn list_models( + &self, + req: crate::model::ListModelsRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.list_models(req, options).await + } + + #[tracing::instrument(ret)] + async fn patch_model( + &self, + req: crate::model::PatchModelRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.patch_model(req, options).await + } + + #[tracing::instrument(ret)] + async fn delete_model( + &self, + req: crate::model::DeleteModelRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.delete_model(req, options).await + } +} + +/// Implements a [ProjectService](super::stubs::ProjectService) decorator for logging and tracing. +#[derive(Clone, Debug)] +pub struct ProjectService +where + T: super::stubs::ProjectService + std::fmt::Debug + Send + Sync, +{ + inner: T, +} + +impl ProjectService +where + T: super::stubs::ProjectService + std::fmt::Debug + Send + Sync, +{ + pub fn new(inner: T) -> Self { + Self { inner } + } +} + +impl super::stubs::ProjectService for ProjectService +where + T: super::stubs::ProjectService + std::fmt::Debug + Send + Sync, +{ + #[tracing::instrument(ret)] + async fn get_service_account( + &self, + req: crate::model::GetServiceAccountRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.get_service_account(req, options).await + } +} + +/// Implements a [RoutineService](super::stubs::RoutineService) decorator for logging and tracing. +#[derive(Clone, Debug)] +pub struct RoutineService +where + T: super::stubs::RoutineService + std::fmt::Debug + Send + Sync, +{ + inner: T, +} + +impl RoutineService +where + T: super::stubs::RoutineService + std::fmt::Debug + Send + Sync, +{ + pub fn new(inner: T) -> Self { + Self { inner } + } +} + +impl super::stubs::RoutineService for RoutineService +where + T: super::stubs::RoutineService + std::fmt::Debug + Send + Sync, +{ + #[tracing::instrument(ret)] + async fn get_routine( + &self, + req: crate::model::GetRoutineRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.get_routine(req, options).await + } + + #[tracing::instrument(ret)] + async fn insert_routine( + &self, + req: crate::model::InsertRoutineRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.insert_routine(req, options).await + } + + #[tracing::instrument(ret)] + async fn update_routine( + &self, + req: crate::model::UpdateRoutineRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.update_routine(req, options).await + } + + #[tracing::instrument(ret)] + async fn delete_routine( + &self, + req: crate::model::DeleteRoutineRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.delete_routine(req, options).await + } + + #[tracing::instrument(ret)] + async fn list_routines( + &self, + req: crate::model::ListRoutinesRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.list_routines(req, options).await + } +} + +/// Implements a [RowAccessPolicyService](super::stubs::RowAccessPolicyService) decorator for logging and tracing. +#[derive(Clone, Debug)] +pub struct RowAccessPolicyService +where + T: super::stubs::RowAccessPolicyService + std::fmt::Debug + Send + Sync, +{ + inner: T, +} + +impl RowAccessPolicyService +where + T: super::stubs::RowAccessPolicyService + std::fmt::Debug + Send + Sync, +{ + pub fn new(inner: T) -> Self { + Self { inner } + } +} + +impl super::stubs::RowAccessPolicyService for RowAccessPolicyService +where + T: super::stubs::RowAccessPolicyService + std::fmt::Debug + Send + Sync, +{ + #[tracing::instrument(ret)] + async fn list_row_access_policies( + &self, + req: crate::model::ListRowAccessPoliciesRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.list_row_access_policies(req, options).await + } + + #[tracing::instrument(ret)] + async fn get_row_access_policy( + &self, + req: crate::model::GetRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.get_row_access_policy(req, options).await + } + + #[tracing::instrument(ret)] + async fn create_row_access_policy( + &self, + req: crate::model::CreateRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.create_row_access_policy(req, options).await + } + + #[tracing::instrument(ret)] + async fn update_row_access_policy( + &self, + req: crate::model::UpdateRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.update_row_access_policy(req, options).await + } + + #[tracing::instrument(ret)] + async fn delete_row_access_policy( + &self, + req: crate::model::DeleteRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.delete_row_access_policy(req, options).await + } + + #[tracing::instrument(ret)] + async fn batch_delete_row_access_policies( + &self, + req: crate::model::BatchDeleteRowAccessPoliciesRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner + .batch_delete_row_access_policies(req, options) + .await + } +} + +/// Implements a [TableService](super::stubs::TableService) decorator for logging and tracing. +#[derive(Clone, Debug)] +pub struct TableService +where + T: super::stubs::TableService + std::fmt::Debug + Send + Sync, +{ + inner: T, +} + +impl TableService +where + T: super::stubs::TableService + std::fmt::Debug + Send + Sync, +{ + pub fn new(inner: T) -> Self { + Self { inner } + } +} + +impl super::stubs::TableService for TableService +where + T: super::stubs::TableService + std::fmt::Debug + Send + Sync, +{ + #[tracing::instrument(ret)] + async fn get_table( + &self, + req: crate::model::GetTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.get_table(req, options).await + } + + #[tracing::instrument(ret)] + async fn insert_table( + &self, + req: crate::model::InsertTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.insert_table(req, options).await + } + + #[tracing::instrument(ret)] + async fn patch_table( + &self, + req: crate::model::UpdateOrPatchTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.patch_table(req, options).await + } + + #[tracing::instrument(ret)] + async fn update_table( + &self, + req: crate::model::UpdateOrPatchTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.update_table(req, options).await + } + + #[tracing::instrument(ret)] + async fn delete_table( + &self, + req: crate::model::DeleteTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.delete_table(req, options).await + } + + #[tracing::instrument(ret)] + async fn list_tables( + &self, + req: crate::model::ListTablesRequest, + options: gax::options::RequestOptions, + ) -> Result { + self.inner.list_tables(req, options).await + } +} diff --git a/src/generated/cloud/bigquery/v2/src/transport.rs b/src/generated/cloud/bigquery/v2/src/transport.rs new file mode 100755 index 000000000..4442d8e5c --- /dev/null +++ b/src/generated/cloud/bigquery/v2/src/transport.rs @@ -0,0 +1,924 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by sidekick. DO NOT EDIT. + +use crate::Result; +#[allow(unused_imports)] +use gax::error::Error; + +/// Implements [DatasetService](super::stubs::DatasetService) using a [gaxi::http::ReqwestClient]. +#[derive(Clone)] +pub struct DatasetService { + inner: gaxi::http::ReqwestClient, +} + +impl std::fmt::Debug for DatasetService { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { + f.debug_struct("DatasetService") + .field("inner", &self.inner) + .finish() + } +} + +impl DatasetService { + pub async fn new(config: gax::options::ClientConfig) -> Result { + let inner = gaxi::http::ReqwestClient::new(config, crate::DEFAULT_HOST).await?; + Ok(Self { inner }) + } +} + +impl super::stubs::DatasetService for DatasetService { + async fn get_dataset( + &self, + req: crate::model::GetDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("datasetView", &req.dataset_view.value())]); + let builder = builder.query(&[("accessPolicyVersion", &req.access_policy_version)]); + self.inner + .execute(builder, None::, options) + .await + } + + async fn insert_dataset( + &self, + req: crate::model::InsertDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::POST.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::POST, + format!("/bigquery/v2/projects/{}/datasets", req.project_id), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("accessPolicyVersion", &req.access_policy_version)]); + self.inner + .execute(builder, Some(req.dataset), options) + .await + } + + async fn patch_dataset( + &self, + req: crate::model::UpdateOrPatchDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::PATCH.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::PATCH, + format!( + "/bigquery/v2/projects/{}/datasets/{}", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("accessPolicyVersion", &req.access_policy_version)]); + self.inner + .execute(builder, Some(req.dataset), options) + .await + } + + async fn update_dataset( + &self, + req: crate::model::UpdateOrPatchDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::PUT.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::PUT, + format!( + "/bigquery/v2/projects/{}/datasets/{}", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("accessPolicyVersion", &req.access_policy_version)]); + self.inner + .execute(builder, Some(req.dataset), options) + .await + } + + async fn delete_dataset( + &self, + req: crate::model::DeleteDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::DELETE.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::DELETE, + format!( + "/bigquery/v2/projects/{}/datasets/{}", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("deleteContents", &req.delete_contents)]); + self.inner + .execute(builder, None::, options) + .await + } + + async fn list_datasets( + &self, + req: crate::model::ListDatasetsRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!("/bigquery/v2/projects/{}/datasets", req.project_id), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = req + .max_results + .as_ref() + .map(|p| serde_json::to_value(p).map_err(Error::serde)) + .transpose()? + .into_iter() + .fold(builder, |builder, v| { + use gaxi::query_parameter::QueryParameter; + v.add(builder, "maxResults") + }); + let builder = builder.query(&[("pageToken", &req.page_token)]); + let builder = builder.query(&[("all", &req.all)]); + let builder = builder.query(&[("filter", &req.filter)]); + self.inner + .execute(builder, None::, options) + .await + } + + async fn undelete_dataset( + &self, + req: crate::model::UndeleteDatasetRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::POST.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::POST, + format!( + "/bigquery/v2/projects/{}/datasets/{}:undelete", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner.execute(builder, Some(req), options).await + } +} + +/// Implements [ModelService](super::stubs::ModelService) using a [gaxi::http::ReqwestClient]. +#[derive(Clone)] +pub struct ModelService { + inner: gaxi::http::ReqwestClient, +} + +impl std::fmt::Debug for ModelService { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { + f.debug_struct("ModelService") + .field("inner", &self.inner) + .finish() + } +} + +impl ModelService { + pub async fn new(config: gax::options::ClientConfig) -> Result { + let inner = gaxi::http::ReqwestClient::new(config, crate::DEFAULT_HOST).await?; + Ok(Self { inner }) + } +} + +impl super::stubs::ModelService for ModelService { + async fn get_model( + &self, + req: crate::model::GetModelRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}/models/{}", + req.project_id, req.dataset_id, req.model_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, None::, options) + .await + } + + async fn list_models( + &self, + req: crate::model::ListModelsRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}/models", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = req + .max_results + .as_ref() + .map(|p| serde_json::to_value(p).map_err(Error::serde)) + .transpose()? + .into_iter() + .fold(builder, |builder, v| { + use gaxi::query_parameter::QueryParameter; + v.add(builder, "maxResults") + }); + let builder = builder.query(&[("pageToken", &req.page_token)]); + self.inner + .execute(builder, None::, options) + .await + } + + async fn patch_model( + &self, + req: crate::model::PatchModelRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::PATCH.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::PATCH, + format!( + "/bigquery/v2/projects/{}/datasets/{}/models/{}", + req.project_id, req.dataset_id, req.model_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner.execute(builder, Some(req.model), options).await + } + + async fn delete_model( + &self, + req: crate::model::DeleteModelRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::DELETE.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::DELETE, + format!( + "/bigquery/v2/projects/{}/datasets/{}/models/{}", + req.project_id, req.dataset_id, req.model_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, None::, options) + .await + } +} + +/// Implements [ProjectService](super::stubs::ProjectService) using a [gaxi::http::ReqwestClient]. +#[derive(Clone)] +pub struct ProjectService { + inner: gaxi::http::ReqwestClient, +} + +impl std::fmt::Debug for ProjectService { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { + f.debug_struct("ProjectService") + .field("inner", &self.inner) + .finish() + } +} + +impl ProjectService { + pub async fn new(config: gax::options::ClientConfig) -> Result { + let inner = gaxi::http::ReqwestClient::new(config, crate::DEFAULT_HOST).await?; + Ok(Self { inner }) + } +} + +impl super::stubs::ProjectService for ProjectService { + async fn get_service_account( + &self, + req: crate::model::GetServiceAccountRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!("/bigquery/v2/projects/{}/serviceAccount", req.project_id), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, None::, options) + .await + } +} + +/// Implements [RoutineService](super::stubs::RoutineService) using a [gaxi::http::ReqwestClient]. +#[derive(Clone)] +pub struct RoutineService { + inner: gaxi::http::ReqwestClient, +} + +impl std::fmt::Debug for RoutineService { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { + f.debug_struct("RoutineService") + .field("inner", &self.inner) + .finish() + } +} + +impl RoutineService { + pub async fn new(config: gax::options::ClientConfig) -> Result { + let inner = gaxi::http::ReqwestClient::new(config, crate::DEFAULT_HOST).await?; + Ok(Self { inner }) + } +} + +impl super::stubs::RoutineService for RoutineService { + async fn get_routine( + &self, + req: crate::model::GetRoutineRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}/routines/{}", + req.project_id, req.dataset_id, req.routine_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, None::, options) + .await + } + + async fn insert_routine( + &self, + req: crate::model::InsertRoutineRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::POST.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::POST, + format!( + "/bigquery/v2/projects/{}/datasets/{}/routines", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, Some(req.routine), options) + .await + } + + async fn update_routine( + &self, + req: crate::model::UpdateRoutineRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::PUT.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::PUT, + format!( + "/bigquery/v2/projects/{}/datasets/{}/routines/{}", + req.project_id, req.dataset_id, req.routine_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, Some(req.routine), options) + .await + } + + async fn delete_routine( + &self, + req: crate::model::DeleteRoutineRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::DELETE.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::DELETE, + format!( + "/bigquery/v2/projects/{}/datasets/{}/routines/{}", + req.project_id, req.dataset_id, req.routine_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, None::, options) + .await + } + + async fn list_routines( + &self, + req: crate::model::ListRoutinesRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}/routines", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = req + .max_results + .as_ref() + .map(|p| serde_json::to_value(p).map_err(Error::serde)) + .transpose()? + .into_iter() + .fold(builder, |builder, v| { + use gaxi::query_parameter::QueryParameter; + v.add(builder, "maxResults") + }); + let builder = builder.query(&[("pageToken", &req.page_token)]); + let builder = builder.query(&[("filter", &req.filter)]); + self.inner + .execute(builder, None::, options) + .await + } +} + +/// Implements [RowAccessPolicyService](super::stubs::RowAccessPolicyService) using a [gaxi::http::ReqwestClient]. +#[derive(Clone)] +pub struct RowAccessPolicyService { + inner: gaxi::http::ReqwestClient, +} + +impl std::fmt::Debug for RowAccessPolicyService { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { + f.debug_struct("RowAccessPolicyService") + .field("inner", &self.inner) + .finish() + } +} + +impl RowAccessPolicyService { + pub async fn new(config: gax::options::ClientConfig) -> Result { + let inner = gaxi::http::ReqwestClient::new(config, crate::DEFAULT_HOST).await?; + Ok(Self { inner }) + } +} + +impl super::stubs::RowAccessPolicyService for RowAccessPolicyService { + async fn list_row_access_policies( + &self, + req: crate::model::ListRowAccessPoliciesRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}/rowAccessPolicies", + req.project_id, req.dataset_id, req.table_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("pageToken", &req.page_token)]); + let builder = builder.query(&[("pageSize", &req.page_size)]); + self.inner + .execute(builder, None::, options) + .await + } + + async fn get_row_access_policy( + &self, + req: crate::model::GetRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}/rowAccessPolicies/{}", + req.project_id, req.dataset_id, req.table_id, req.policy_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, None::, options) + .await + } + + async fn create_row_access_policy( + &self, + req: crate::model::CreateRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::POST.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::POST, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}/rowAccessPolicies", + req.project_id, req.dataset_id, req.table_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, Some(req.row_access_policy), options) + .await + } + + async fn update_row_access_policy( + &self, + req: crate::model::UpdateRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::PUT.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::PUT, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}/rowAccessPolicies/{}", + req.project_id, req.dataset_id, req.table_id, req.policy_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, Some(req.row_access_policy), options) + .await + } + + async fn delete_row_access_policy( + &self, + req: crate::model::DeleteRowAccessPolicyRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::DELETE.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::DELETE, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}/rowAccessPolicies/{}", + req.project_id, req.dataset_id, req.table_id, req.policy_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = req + .force + .iter() + .fold(builder, |builder, p| builder.query(&[("force", p)])); + self.inner + .execute(builder, None::, options) + .await + } + + async fn batch_delete_row_access_policies( + &self, + req: crate::model::BatchDeleteRowAccessPoliciesRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::POST.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::POST, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}/rowAccessPolicies:batchDelete", + req.project_id, req.dataset_id, req.table_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner.execute(builder, Some(req), options).await + } +} + +/// Implements [TableService](super::stubs::TableService) using a [gaxi::http::ReqwestClient]. +#[derive(Clone)] +pub struct TableService { + inner: gaxi::http::ReqwestClient, +} + +impl std::fmt::Debug for TableService { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { + f.debug_struct("TableService") + .field("inner", &self.inner) + .finish() + } +} + +impl TableService { + pub async fn new(config: gax::options::ClientConfig) -> Result { + let inner = gaxi::http::ReqwestClient::new(config, crate::DEFAULT_HOST).await?; + Ok(Self { inner }) + } +} + +impl super::stubs::TableService for TableService { + async fn get_table( + &self, + req: crate::model::GetTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}", + req.project_id, req.dataset_id, req.table_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("selectedFields", &req.selected_fields)]); + let builder = builder.query(&[("view", &req.view.value())]); + self.inner + .execute(builder, None::, options) + .await + } + + async fn insert_table( + &self, + req: crate::model::InsertTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::POST.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::POST, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner.execute(builder, Some(req.table), options).await + } + + async fn patch_table( + &self, + req: crate::model::UpdateOrPatchTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::PATCH.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::PATCH, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}", + req.project_id, req.dataset_id, req.table_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("autodetectSchema", &req.autodetect_schema)]); + self.inner.execute(builder, Some(req.table), options).await + } + + async fn update_table( + &self, + req: crate::model::UpdateOrPatchTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::PUT.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::PUT, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}", + req.project_id, req.dataset_id, req.table_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = builder.query(&[("autodetectSchema", &req.autodetect_schema)]); + self.inner.execute(builder, Some(req.table), options).await + } + + async fn delete_table( + &self, + req: crate::model::DeleteTableRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::DELETE.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::DELETE, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables/{}", + req.project_id, req.dataset_id, req.table_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + self.inner + .execute(builder, None::, options) + .await + } + + async fn list_tables( + &self, + req: crate::model::ListTablesRequest, + options: gax::options::RequestOptions, + ) -> Result { + let options = options.set_default_idempotency(reqwest::Method::GET.is_idempotent()); + let builder = self + .inner + .builder( + reqwest::Method::GET, + format!( + "/bigquery/v2/projects/{}/datasets/{}/tables", + req.project_id, req.dataset_id + ), + ) + .query(&[("$alt", "json;enum-encoding=int")]) + .header( + "x-goog-api-client", + reqwest::header::HeaderValue::from_static(&crate::info::X_GOOG_API_CLIENT_HEADER), + ); + let builder = req + .max_results + .as_ref() + .map(|p| serde_json::to_value(p).map_err(Error::serde)) + .transpose()? + .into_iter() + .fold(builder, |builder, v| { + use gaxi::query_parameter::QueryParameter; + v.add(builder, "maxResults") + }); + let builder = builder.query(&[("pageToken", &req.page_token)]); + self.inner + .execute(builder, None::, options) + .await + } +}