Skip to main content

google_cloud_bigquery/write/generated/gapic_storage/
model.rs

1// Copyright 2026 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21
22mod debug;
23mod deserialize;
24mod serialize;
25
26/// Arrow schema as specified in
27/// <https://arrow.apache.org/docs/python/api/datatypes.html>
28/// and serialized to bytes using IPC:
29/// <https://arrow.apache.org/docs/format/Columnar.html#serialization-and-interprocess-communication-ipc>
30///
31/// See code samples on how this message can be deserialized.
32#[derive(Clone, Default, PartialEq)]
33#[non_exhaustive]
34pub struct ArrowSchema {
35    /// IPC serialized Arrow schema.
36    pub serialized_schema: ::bytes::Bytes,
37
38    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
39}
40
41impl ArrowSchema {
42    /// Creates a new default instance.
43    pub fn new() -> Self {
44        std::default::Default::default()
45    }
46
47    /// Sets the value of [serialized_schema][crate::write::generated::gapic_storage::model::ArrowSchema::serialized_schema].
48    ///
49    /// # Example
50    /// ```ignore,no_run
51    /// # use google_cloud_bigquery::model::ArrowSchema;
52    /// let x = ArrowSchema::new().set_serialized_schema(bytes::Bytes::from_static(b"example"));
53    /// ```
54    pub fn set_serialized_schema<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
55        self.serialized_schema = v.into();
56        self
57    }
58}
59
60impl wkt::message::Message for ArrowSchema {
61    fn typename() -> &'static str {
62        "type.googleapis.com/google.cloud.bigquery.storage.v1.ArrowSchema"
63    }
64}
65
66/// Arrow RecordBatch.
67#[derive(Clone, Default, PartialEq)]
68#[non_exhaustive]
69pub struct ArrowRecordBatch {
70    /// IPC-serialized Arrow RecordBatch.
71    pub serialized_record_batch: ::bytes::Bytes,
72
73    /// [Deprecated] The count of rows in `serialized_record_batch`.
74    /// Please use the format-independent ReadRowsResponse.row_count instead.
75    #[deprecated]
76    pub row_count: i64,
77
78    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
79}
80
81impl ArrowRecordBatch {
82    /// Creates a new default instance.
83    pub fn new() -> Self {
84        std::default::Default::default()
85    }
86
87    /// Sets the value of [serialized_record_batch][crate::write::generated::gapic_storage::model::ArrowRecordBatch::serialized_record_batch].
88    ///
89    /// # Example
90    /// ```ignore,no_run
91    /// # use google_cloud_bigquery::model::ArrowRecordBatch;
92    /// let x = ArrowRecordBatch::new().set_serialized_record_batch(bytes::Bytes::from_static(b"example"));
93    /// ```
94    pub fn set_serialized_record_batch<T: std::convert::Into<::bytes::Bytes>>(
95        mut self,
96        v: T,
97    ) -> Self {
98        self.serialized_record_batch = v.into();
99        self
100    }
101
102    /// Sets the value of [row_count][crate::write::generated::gapic_storage::model::ArrowRecordBatch::row_count].
103    ///
104    /// # Example
105    /// ```ignore,no_run
106    /// # use google_cloud_bigquery::model::ArrowRecordBatch;
107    /// let x = ArrowRecordBatch::new().set_row_count(42);
108    /// ```
109    #[deprecated]
110    pub fn set_row_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
111        self.row_count = v.into();
112        self
113    }
114}
115
116impl wkt::message::Message for ArrowRecordBatch {
117    fn typename() -> &'static str {
118        "type.googleapis.com/google.cloud.bigquery.storage.v1.ArrowRecordBatch"
119    }
120}
121
122/// Contains options specific to Arrow Serialization.
123#[derive(Clone, Default, PartialEq)]
124#[non_exhaustive]
125pub struct ArrowSerializationOptions {
126
127    /// The compression codec to use for Arrow buffers in serialized record
128    /// batches.
129    pub buffer_compression: crate::write::generated::gapic_storage::model::arrow_serialization_options::CompressionCodec,
130
131    /// Optional. Set timestamp precision option. If not set, the default precision
132    /// is microseconds.
133    pub picos_timestamp_precision: crate::write::generated::gapic_storage::model::arrow_serialization_options::PicosTimestampPrecision,
134
135    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
136}
137
138impl ArrowSerializationOptions {
139    /// Creates a new default instance.
140    pub fn new() -> Self {
141        std::default::Default::default()
142    }
143
144    /// Sets the value of [buffer_compression][crate::write::generated::gapic_storage::model::ArrowSerializationOptions::buffer_compression].
145    ///
146    /// # Example
147    /// ```ignore,no_run
148    /// # use google_cloud_bigquery::model::ArrowSerializationOptions;
149    /// use google_cloud_bigquery::model::arrow_serialization_options::CompressionCodec;
150    /// let x0 = ArrowSerializationOptions::new().set_buffer_compression(CompressionCodec::Lz4Frame);
151    /// let x1 = ArrowSerializationOptions::new().set_buffer_compression(CompressionCodec::Zstd);
152    /// ```
153    pub fn set_buffer_compression<T: std::convert::Into<crate::write::generated::gapic_storage::model::arrow_serialization_options::CompressionCodec>>(mut self, v: T) -> Self{
154        self.buffer_compression = v.into();
155        self
156    }
157
158    /// Sets the value of [picos_timestamp_precision][crate::write::generated::gapic_storage::model::ArrowSerializationOptions::picos_timestamp_precision].
159    ///
160    /// # Example
161    /// ```ignore,no_run
162    /// # use google_cloud_bigquery::model::ArrowSerializationOptions;
163    /// use google_cloud_bigquery::model::arrow_serialization_options::PicosTimestampPrecision;
164    /// let x0 = ArrowSerializationOptions::new().set_picos_timestamp_precision(PicosTimestampPrecision::TimestampPrecisionMicros);
165    /// let x1 = ArrowSerializationOptions::new().set_picos_timestamp_precision(PicosTimestampPrecision::TimestampPrecisionNanos);
166    /// let x2 = ArrowSerializationOptions::new().set_picos_timestamp_precision(PicosTimestampPrecision::TimestampPrecisionPicos);
167    /// ```
168    pub fn set_picos_timestamp_precision<T: std::convert::Into<crate::write::generated::gapic_storage::model::arrow_serialization_options::PicosTimestampPrecision>>(mut self, v: T) -> Self{
169        self.picos_timestamp_precision = v.into();
170        self
171    }
172}
173
174impl wkt::message::Message for ArrowSerializationOptions {
175    fn typename() -> &'static str {
176        "type.googleapis.com/google.cloud.bigquery.storage.v1.ArrowSerializationOptions"
177    }
178}
179
180/// Defines additional types related to [ArrowSerializationOptions].
181pub mod arrow_serialization_options {
182    #[allow(unused_imports)]
183    use super::*;
184
185    /// Compression codec's supported by Arrow.
186    ///
187    /// # Working with unknown values
188    ///
189    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
190    /// additional enum variants at any time. Adding new variants is not considered
191    /// a breaking change. Applications should write their code in anticipation of:
192    ///
193    /// - New values appearing in future releases of the client library, **and**
194    /// - New values received dynamically, without application changes.
195    ///
196    /// Please consult the [Working with enums] section in the user guide for some
197    /// guidelines.
198    ///
199    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
200    #[derive(Clone, Debug, PartialEq)]
201    #[non_exhaustive]
202    pub enum CompressionCodec {
203        /// If unspecified no compression will be used.
204        CompressionUnspecified,
205        /// LZ4 Frame (<https://github.com/lz4/lz4/blob/dev/doc/lz4_Frame_format.md>)
206        Lz4Frame,
207        /// Zstandard compression.
208        Zstd,
209        /// If set, the enum was initialized with an unknown value.
210        ///
211        /// Applications can examine the value using [CompressionCodec::value] or
212        /// [CompressionCodec::name].
213        UnknownValue(compression_codec::UnknownValue),
214    }
215
216    #[doc(hidden)]
217    pub mod compression_codec {
218        #[allow(unused_imports)]
219        use super::*;
220        #[derive(Clone, Debug, PartialEq)]
221        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
222    }
223
224    impl CompressionCodec {
225        /// Gets the enum value.
226        ///
227        /// Returns `None` if the enum contains an unknown value deserialized from
228        /// the string representation of enums.
229        pub fn value(&self) -> std::option::Option<i32> {
230            match self {
231                Self::CompressionUnspecified => std::option::Option::Some(0),
232                Self::Lz4Frame => std::option::Option::Some(1),
233                Self::Zstd => std::option::Option::Some(2),
234                Self::UnknownValue(u) => u.0.value(),
235            }
236        }
237
238        /// Gets the enum value as a string.
239        ///
240        /// Returns `None` if the enum contains an unknown value deserialized from
241        /// the integer representation of enums.
242        pub fn name(&self) -> std::option::Option<&str> {
243            match self {
244                Self::CompressionUnspecified => {
245                    std::option::Option::Some("COMPRESSION_UNSPECIFIED")
246                }
247                Self::Lz4Frame => std::option::Option::Some("LZ4_FRAME"),
248                Self::Zstd => std::option::Option::Some("ZSTD"),
249                Self::UnknownValue(u) => u.0.name(),
250            }
251        }
252    }
253
254    impl std::default::Default for CompressionCodec {
255        fn default() -> Self {
256            use std::convert::From;
257            Self::from(0)
258        }
259    }
260
261    impl std::fmt::Display for CompressionCodec {
262        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
263            wkt::internal::display_enum(f, self.name(), self.value())
264        }
265    }
266
267    impl std::convert::From<i32> for CompressionCodec {
268        fn from(value: i32) -> Self {
269            match value {
270                0 => Self::CompressionUnspecified,
271                1 => Self::Lz4Frame,
272                2 => Self::Zstd,
273                _ => Self::UnknownValue(compression_codec::UnknownValue(
274                    wkt::internal::UnknownEnumValue::Integer(value),
275                )),
276            }
277        }
278    }
279
280    impl std::convert::From<&str> for CompressionCodec {
281        fn from(value: &str) -> Self {
282            use std::string::ToString;
283            match value {
284                "COMPRESSION_UNSPECIFIED" => Self::CompressionUnspecified,
285                "LZ4_FRAME" => Self::Lz4Frame,
286                "ZSTD" => Self::Zstd,
287                _ => Self::UnknownValue(compression_codec::UnknownValue(
288                    wkt::internal::UnknownEnumValue::String(value.to_string()),
289                )),
290            }
291        }
292    }
293
294    impl serde::ser::Serialize for CompressionCodec {
295        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
296        where
297            S: serde::Serializer,
298        {
299            match self {
300                Self::CompressionUnspecified => serializer.serialize_i32(0),
301                Self::Lz4Frame => serializer.serialize_i32(1),
302                Self::Zstd => serializer.serialize_i32(2),
303                Self::UnknownValue(u) => u.0.serialize(serializer),
304            }
305        }
306    }
307
308    impl<'de> serde::de::Deserialize<'de> for CompressionCodec {
309        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
310        where
311            D: serde::Deserializer<'de>,
312        {
313            deserializer.deserialize_any(wkt::internal::EnumVisitor::<CompressionCodec>::new(
314                ".google.cloud.bigquery.storage.v1.ArrowSerializationOptions.CompressionCodec",
315            ))
316        }
317    }
318
319    /// The precision of the timestamp value in the Avro message. This precision
320    /// will **only** be applied to the column(s) with the `TIMESTAMP_PICOS` type.
321    ///
322    /// # Working with unknown values
323    ///
324    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
325    /// additional enum variants at any time. Adding new variants is not considered
326    /// a breaking change. Applications should write their code in anticipation of:
327    ///
328    /// - New values appearing in future releases of the client library, **and**
329    /// - New values received dynamically, without application changes.
330    ///
331    /// Please consult the [Working with enums] section in the user guide for some
332    /// guidelines.
333    ///
334    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
335    #[derive(Clone, Debug, PartialEq)]
336    #[non_exhaustive]
337    pub enum PicosTimestampPrecision {
338        /// Unspecified timestamp precision. The default precision is microseconds.
339        Unspecified,
340        /// Timestamp values returned by Read API will be truncated to microsecond
341        /// level precision. The value will be encoded as Arrow TIMESTAMP type in a
342        /// 64 bit integer.
343        TimestampPrecisionMicros,
344        /// Timestamp values returned by Read API will be truncated to nanosecond
345        /// level precision. The value will be encoded as Arrow TIMESTAMP type in a
346        /// 64 bit integer.
347        TimestampPrecisionNanos,
348        /// Read API will return full precision picosecond value. The value will be
349        /// encoded as a string which conforms to ISO 8601 format.
350        TimestampPrecisionPicos,
351        /// If set, the enum was initialized with an unknown value.
352        ///
353        /// Applications can examine the value using [PicosTimestampPrecision::value] or
354        /// [PicosTimestampPrecision::name].
355        UnknownValue(picos_timestamp_precision::UnknownValue),
356    }
357
358    #[doc(hidden)]
359    pub mod picos_timestamp_precision {
360        #[allow(unused_imports)]
361        use super::*;
362        #[derive(Clone, Debug, PartialEq)]
363        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
364    }
365
366    impl PicosTimestampPrecision {
367        /// Gets the enum value.
368        ///
369        /// Returns `None` if the enum contains an unknown value deserialized from
370        /// the string representation of enums.
371        pub fn value(&self) -> std::option::Option<i32> {
372            match self {
373                Self::Unspecified => std::option::Option::Some(0),
374                Self::TimestampPrecisionMicros => std::option::Option::Some(1),
375                Self::TimestampPrecisionNanos => std::option::Option::Some(2),
376                Self::TimestampPrecisionPicos => std::option::Option::Some(3),
377                Self::UnknownValue(u) => u.0.value(),
378            }
379        }
380
381        /// Gets the enum value as a string.
382        ///
383        /// Returns `None` if the enum contains an unknown value deserialized from
384        /// the integer representation of enums.
385        pub fn name(&self) -> std::option::Option<&str> {
386            match self {
387                Self::Unspecified => {
388                    std::option::Option::Some("PICOS_TIMESTAMP_PRECISION_UNSPECIFIED")
389                }
390                Self::TimestampPrecisionMicros => {
391                    std::option::Option::Some("TIMESTAMP_PRECISION_MICROS")
392                }
393                Self::TimestampPrecisionNanos => {
394                    std::option::Option::Some("TIMESTAMP_PRECISION_NANOS")
395                }
396                Self::TimestampPrecisionPicos => {
397                    std::option::Option::Some("TIMESTAMP_PRECISION_PICOS")
398                }
399                Self::UnknownValue(u) => u.0.name(),
400            }
401        }
402    }
403
404    impl std::default::Default for PicosTimestampPrecision {
405        fn default() -> Self {
406            use std::convert::From;
407            Self::from(0)
408        }
409    }
410
411    impl std::fmt::Display for PicosTimestampPrecision {
412        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
413            wkt::internal::display_enum(f, self.name(), self.value())
414        }
415    }
416
417    impl std::convert::From<i32> for PicosTimestampPrecision {
418        fn from(value: i32) -> Self {
419            match value {
420                0 => Self::Unspecified,
421                1 => Self::TimestampPrecisionMicros,
422                2 => Self::TimestampPrecisionNanos,
423                3 => Self::TimestampPrecisionPicos,
424                _ => Self::UnknownValue(picos_timestamp_precision::UnknownValue(
425                    wkt::internal::UnknownEnumValue::Integer(value),
426                )),
427            }
428        }
429    }
430
431    impl std::convert::From<&str> for PicosTimestampPrecision {
432        fn from(value: &str) -> Self {
433            use std::string::ToString;
434            match value {
435                "PICOS_TIMESTAMP_PRECISION_UNSPECIFIED" => Self::Unspecified,
436                "TIMESTAMP_PRECISION_MICROS" => Self::TimestampPrecisionMicros,
437                "TIMESTAMP_PRECISION_NANOS" => Self::TimestampPrecisionNanos,
438                "TIMESTAMP_PRECISION_PICOS" => Self::TimestampPrecisionPicos,
439                _ => Self::UnknownValue(picos_timestamp_precision::UnknownValue(
440                    wkt::internal::UnknownEnumValue::String(value.to_string()),
441                )),
442            }
443        }
444    }
445
446    impl serde::ser::Serialize for PicosTimestampPrecision {
447        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
448        where
449            S: serde::Serializer,
450        {
451            match self {
452                Self::Unspecified => serializer.serialize_i32(0),
453                Self::TimestampPrecisionMicros => serializer.serialize_i32(1),
454                Self::TimestampPrecisionNanos => serializer.serialize_i32(2),
455                Self::TimestampPrecisionPicos => serializer.serialize_i32(3),
456                Self::UnknownValue(u) => u.0.serialize(serializer),
457            }
458        }
459    }
460
461    impl<'de> serde::de::Deserialize<'de> for PicosTimestampPrecision {
462        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
463        where
464            D: serde::Deserializer<'de>,
465        {
466            deserializer.deserialize_any(wkt::internal::EnumVisitor::<PicosTimestampPrecision>::new(
467                ".google.cloud.bigquery.storage.v1.ArrowSerializationOptions.PicosTimestampPrecision"))
468        }
469    }
470}
471
472/// Avro schema.
473#[derive(Clone, Default, PartialEq)]
474#[non_exhaustive]
475pub struct AvroSchema {
476    /// Json serialized schema, as described at
477    /// <https://avro.apache.org/docs/1.8.1/spec.html>.
478    pub schema: std::string::String,
479
480    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
481}
482
483impl AvroSchema {
484    /// Creates a new default instance.
485    pub fn new() -> Self {
486        std::default::Default::default()
487    }
488
489    /// Sets the value of [schema][crate::write::generated::gapic_storage::model::AvroSchema::schema].
490    ///
491    /// # Example
492    /// ```ignore,no_run
493    /// # use google_cloud_bigquery::model::AvroSchema;
494    /// let x = AvroSchema::new().set_schema("example");
495    /// ```
496    pub fn set_schema<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
497        self.schema = v.into();
498        self
499    }
500}
501
502impl wkt::message::Message for AvroSchema {
503    fn typename() -> &'static str {
504        "type.googleapis.com/google.cloud.bigquery.storage.v1.AvroSchema"
505    }
506}
507
508/// Avro rows.
509#[derive(Clone, Default, PartialEq)]
510#[non_exhaustive]
511pub struct AvroRows {
512    /// Binary serialized rows in a block.
513    pub serialized_binary_rows: ::bytes::Bytes,
514
515    /// [Deprecated] The count of rows in the returning block.
516    /// Please use the format-independent ReadRowsResponse.row_count instead.
517    #[deprecated]
518    pub row_count: i64,
519
520    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
521}
522
523impl AvroRows {
524    /// Creates a new default instance.
525    pub fn new() -> Self {
526        std::default::Default::default()
527    }
528
529    /// Sets the value of [serialized_binary_rows][crate::write::generated::gapic_storage::model::AvroRows::serialized_binary_rows].
530    ///
531    /// # Example
532    /// ```ignore,no_run
533    /// # use google_cloud_bigquery::model::AvroRows;
534    /// let x = AvroRows::new().set_serialized_binary_rows(bytes::Bytes::from_static(b"example"));
535    /// ```
536    pub fn set_serialized_binary_rows<T: std::convert::Into<::bytes::Bytes>>(
537        mut self,
538        v: T,
539    ) -> Self {
540        self.serialized_binary_rows = v.into();
541        self
542    }
543
544    /// Sets the value of [row_count][crate::write::generated::gapic_storage::model::AvroRows::row_count].
545    ///
546    /// # Example
547    /// ```ignore,no_run
548    /// # use google_cloud_bigquery::model::AvroRows;
549    /// let x = AvroRows::new().set_row_count(42);
550    /// ```
551    #[deprecated]
552    pub fn set_row_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
553        self.row_count = v.into();
554        self
555    }
556}
557
558impl wkt::message::Message for AvroRows {
559    fn typename() -> &'static str {
560        "type.googleapis.com/google.cloud.bigquery.storage.v1.AvroRows"
561    }
562}
563
564/// Contains options specific to Avro Serialization.
565#[derive(Clone, Default, PartialEq)]
566#[non_exhaustive]
567pub struct AvroSerializationOptions {
568
569    /// Enable displayName attribute in Avro schema.
570    ///
571    /// The Avro specification requires field names to be alphanumeric.  By
572    /// default, in cases when column names do not conform to these requirements
573    /// (e.g. non-ascii unicode codepoints) and Avro is requested as an output
574    /// format, the CreateReadSession call will fail.
575    ///
576    /// Setting this field to true, populates avro field names with a placeholder
577    /// value and populates a "displayName" attribute for every avro field with the
578    /// original column name.
579    pub enable_display_name_attribute: bool,
580
581    /// Optional. Set timestamp precision option. If not set, the default precision
582    /// is microseconds.
583    pub picos_timestamp_precision: crate::write::generated::gapic_storage::model::avro_serialization_options::PicosTimestampPrecision,
584
585    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
586}
587
588impl AvroSerializationOptions {
589    /// Creates a new default instance.
590    pub fn new() -> Self {
591        std::default::Default::default()
592    }
593
594    /// Sets the value of [enable_display_name_attribute][crate::write::generated::gapic_storage::model::AvroSerializationOptions::enable_display_name_attribute].
595    ///
596    /// # Example
597    /// ```ignore,no_run
598    /// # use google_cloud_bigquery::model::AvroSerializationOptions;
599    /// let x = AvroSerializationOptions::new().set_enable_display_name_attribute(true);
600    /// ```
601    pub fn set_enable_display_name_attribute<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
602        self.enable_display_name_attribute = v.into();
603        self
604    }
605
606    /// Sets the value of [picos_timestamp_precision][crate::write::generated::gapic_storage::model::AvroSerializationOptions::picos_timestamp_precision].
607    ///
608    /// # Example
609    /// ```ignore,no_run
610    /// # use google_cloud_bigquery::model::AvroSerializationOptions;
611    /// use google_cloud_bigquery::model::avro_serialization_options::PicosTimestampPrecision;
612    /// let x0 = AvroSerializationOptions::new().set_picos_timestamp_precision(PicosTimestampPrecision::TimestampPrecisionMicros);
613    /// let x1 = AvroSerializationOptions::new().set_picos_timestamp_precision(PicosTimestampPrecision::TimestampPrecisionNanos);
614    /// let x2 = AvroSerializationOptions::new().set_picos_timestamp_precision(PicosTimestampPrecision::TimestampPrecisionPicos);
615    /// ```
616    pub fn set_picos_timestamp_precision<T: std::convert::Into<crate::write::generated::gapic_storage::model::avro_serialization_options::PicosTimestampPrecision>>(mut self, v: T) -> Self{
617        self.picos_timestamp_precision = v.into();
618        self
619    }
620}
621
622impl wkt::message::Message for AvroSerializationOptions {
623    fn typename() -> &'static str {
624        "type.googleapis.com/google.cloud.bigquery.storage.v1.AvroSerializationOptions"
625    }
626}
627
628/// Defines additional types related to [AvroSerializationOptions].
629pub mod avro_serialization_options {
630    #[allow(unused_imports)]
631    use super::*;
632
633    /// The precision of the timestamp value in the Avro message. This precision
634    /// will **only** be applied to the column(s) with the `TIMESTAMP_PICOS` type.
635    ///
636    /// # Working with unknown values
637    ///
638    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
639    /// additional enum variants at any time. Adding new variants is not considered
640    /// a breaking change. Applications should write their code in anticipation of:
641    ///
642    /// - New values appearing in future releases of the client library, **and**
643    /// - New values received dynamically, without application changes.
644    ///
645    /// Please consult the [Working with enums] section in the user guide for some
646    /// guidelines.
647    ///
648    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
649    #[derive(Clone, Debug, PartialEq)]
650    #[non_exhaustive]
651    pub enum PicosTimestampPrecision {
652        /// Unspecified timestamp precision. The default precision is microseconds.
653        Unspecified,
654        /// Timestamp values returned by Read API will be truncated to microsecond
655        /// level precision. The value will be encoded as Avro TIMESTAMP type in a
656        /// 64 bit integer.
657        TimestampPrecisionMicros,
658        /// Timestamp values returned by Read API will be truncated to nanosecond
659        /// level precision. The value will be encoded as Avro TIMESTAMP type in a
660        /// 64 bit integer.
661        TimestampPrecisionNanos,
662        /// Read API will return full precision picosecond value. The value will be
663        /// encoded as a string which conforms to ISO 8601 format.
664        TimestampPrecisionPicos,
665        /// If set, the enum was initialized with an unknown value.
666        ///
667        /// Applications can examine the value using [PicosTimestampPrecision::value] or
668        /// [PicosTimestampPrecision::name].
669        UnknownValue(picos_timestamp_precision::UnknownValue),
670    }
671
672    #[doc(hidden)]
673    pub mod picos_timestamp_precision {
674        #[allow(unused_imports)]
675        use super::*;
676        #[derive(Clone, Debug, PartialEq)]
677        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
678    }
679
680    impl PicosTimestampPrecision {
681        /// Gets the enum value.
682        ///
683        /// Returns `None` if the enum contains an unknown value deserialized from
684        /// the string representation of enums.
685        pub fn value(&self) -> std::option::Option<i32> {
686            match self {
687                Self::Unspecified => std::option::Option::Some(0),
688                Self::TimestampPrecisionMicros => std::option::Option::Some(1),
689                Self::TimestampPrecisionNanos => std::option::Option::Some(2),
690                Self::TimestampPrecisionPicos => std::option::Option::Some(3),
691                Self::UnknownValue(u) => u.0.value(),
692            }
693        }
694
695        /// Gets the enum value as a string.
696        ///
697        /// Returns `None` if the enum contains an unknown value deserialized from
698        /// the integer representation of enums.
699        pub fn name(&self) -> std::option::Option<&str> {
700            match self {
701                Self::Unspecified => {
702                    std::option::Option::Some("PICOS_TIMESTAMP_PRECISION_UNSPECIFIED")
703                }
704                Self::TimestampPrecisionMicros => {
705                    std::option::Option::Some("TIMESTAMP_PRECISION_MICROS")
706                }
707                Self::TimestampPrecisionNanos => {
708                    std::option::Option::Some("TIMESTAMP_PRECISION_NANOS")
709                }
710                Self::TimestampPrecisionPicos => {
711                    std::option::Option::Some("TIMESTAMP_PRECISION_PICOS")
712                }
713                Self::UnknownValue(u) => u.0.name(),
714            }
715        }
716    }
717
718    impl std::default::Default for PicosTimestampPrecision {
719        fn default() -> Self {
720            use std::convert::From;
721            Self::from(0)
722        }
723    }
724
725    impl std::fmt::Display for PicosTimestampPrecision {
726        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
727            wkt::internal::display_enum(f, self.name(), self.value())
728        }
729    }
730
731    impl std::convert::From<i32> for PicosTimestampPrecision {
732        fn from(value: i32) -> Self {
733            match value {
734                0 => Self::Unspecified,
735                1 => Self::TimestampPrecisionMicros,
736                2 => Self::TimestampPrecisionNanos,
737                3 => Self::TimestampPrecisionPicos,
738                _ => Self::UnknownValue(picos_timestamp_precision::UnknownValue(
739                    wkt::internal::UnknownEnumValue::Integer(value),
740                )),
741            }
742        }
743    }
744
745    impl std::convert::From<&str> for PicosTimestampPrecision {
746        fn from(value: &str) -> Self {
747            use std::string::ToString;
748            match value {
749                "PICOS_TIMESTAMP_PRECISION_UNSPECIFIED" => Self::Unspecified,
750                "TIMESTAMP_PRECISION_MICROS" => Self::TimestampPrecisionMicros,
751                "TIMESTAMP_PRECISION_NANOS" => Self::TimestampPrecisionNanos,
752                "TIMESTAMP_PRECISION_PICOS" => Self::TimestampPrecisionPicos,
753                _ => Self::UnknownValue(picos_timestamp_precision::UnknownValue(
754                    wkt::internal::UnknownEnumValue::String(value.to_string()),
755                )),
756            }
757        }
758    }
759
760    impl serde::ser::Serialize for PicosTimestampPrecision {
761        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
762        where
763            S: serde::Serializer,
764        {
765            match self {
766                Self::Unspecified => serializer.serialize_i32(0),
767                Self::TimestampPrecisionMicros => serializer.serialize_i32(1),
768                Self::TimestampPrecisionNanos => serializer.serialize_i32(2),
769                Self::TimestampPrecisionPicos => serializer.serialize_i32(3),
770                Self::UnknownValue(u) => u.0.serialize(serializer),
771            }
772        }
773    }
774
775    impl<'de> serde::de::Deserialize<'de> for PicosTimestampPrecision {
776        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
777        where
778            D: serde::Deserializer<'de>,
779        {
780            deserializer.deserialize_any(wkt::internal::EnumVisitor::<PicosTimestampPrecision>::new(
781                ".google.cloud.bigquery.storage.v1.AvroSerializationOptions.PicosTimestampPrecision"))
782        }
783    }
784}
785
786/// ProtoSchema describes the schema of the serialized protocol buffer data rows.
787#[derive(Clone, Default, PartialEq)]
788#[non_exhaustive]
789pub struct ProtoSchema {
790    /// Descriptor for input message.  The provided descriptor must be self
791    /// contained, such that data rows sent can be fully decoded using only the
792    /// single descriptor.  For data rows that are compositions of multiple
793    /// independent messages, this means the descriptor may need to be transformed
794    /// to only use nested types:
795    /// <https://developers.google.com/protocol-buffers/docs/proto#nested>
796    ///
797    /// For additional information for how proto types and values map onto BigQuery
798    /// see: <https://cloud.google.com/bigquery/docs/write-api#data_type_conversions>
799    pub proto_descriptor: std::option::Option<wkt::DescriptorProto>,
800
801    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
802}
803
804impl ProtoSchema {
805    /// Creates a new default instance.
806    pub fn new() -> Self {
807        std::default::Default::default()
808    }
809
810    /// Sets the value of [proto_descriptor][crate::write::generated::gapic_storage::model::ProtoSchema::proto_descriptor].
811    ///
812    /// # Example
813    /// ```ignore,no_run
814    /// # use google_cloud_bigquery::model::ProtoSchema;
815    /// use wkt::DescriptorProto;
816    /// let x = ProtoSchema::new().set_proto_descriptor(DescriptorProto::default()/* use setters */);
817    /// ```
818    pub fn set_proto_descriptor<T>(mut self, v: T) -> Self
819    where
820        T: std::convert::Into<wkt::DescriptorProto>,
821    {
822        self.proto_descriptor = std::option::Option::Some(v.into());
823        self
824    }
825
826    /// Sets or clears the value of [proto_descriptor][crate::write::generated::gapic_storage::model::ProtoSchema::proto_descriptor].
827    ///
828    /// # Example
829    /// ```ignore,no_run
830    /// # use google_cloud_bigquery::model::ProtoSchema;
831    /// use wkt::DescriptorProto;
832    /// let x = ProtoSchema::new().set_or_clear_proto_descriptor(Some(DescriptorProto::default()/* use setters */));
833    /// let x = ProtoSchema::new().set_or_clear_proto_descriptor(None::<DescriptorProto>);
834    /// ```
835    pub fn set_or_clear_proto_descriptor<T>(mut self, v: std::option::Option<T>) -> Self
836    where
837        T: std::convert::Into<wkt::DescriptorProto>,
838    {
839        self.proto_descriptor = v.map(|x| x.into());
840        self
841    }
842}
843
844impl wkt::message::Message for ProtoSchema {
845    fn typename() -> &'static str {
846        "type.googleapis.com/google.cloud.bigquery.storage.v1.ProtoSchema"
847    }
848}
849
850#[allow(missing_docs)]
851#[derive(Clone, Default, PartialEq)]
852#[non_exhaustive]
853pub struct ProtoRows {
854    /// A sequence of rows serialized as a Protocol Buffer.
855    ///
856    /// See <https://developers.google.com/protocol-buffers/docs/overview> for more
857    /// information on deserializing this field.
858    pub serialized_rows: std::vec::Vec<::bytes::Bytes>,
859
860    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
861}
862
863impl ProtoRows {
864    /// Creates a new default instance.
865    pub fn new() -> Self {
866        std::default::Default::default()
867    }
868
869    /// Sets the value of [serialized_rows][crate::write::generated::gapic_storage::model::ProtoRows::serialized_rows].
870    ///
871    /// # Example
872    /// ```ignore,no_run
873    /// # use google_cloud_bigquery::model::ProtoRows;
874    /// let b1 = bytes::Bytes::from_static(b"abc");
875    /// let b2 = bytes::Bytes::from_static(b"xyz");
876    /// let x = ProtoRows::new().set_serialized_rows([b1, b2]);
877    /// ```
878    pub fn set_serialized_rows<T, V>(mut self, v: T) -> Self
879    where
880        T: std::iter::IntoIterator<Item = V>,
881        V: std::convert::Into<::bytes::Bytes>,
882    {
883        use std::iter::Iterator;
884        self.serialized_rows = v.into_iter().map(|i| i.into()).collect();
885        self
886    }
887}
888
889impl wkt::message::Message for ProtoRows {
890    fn typename() -> &'static str {
891        "type.googleapis.com/google.cloud.bigquery.storage.v1.ProtoRows"
892    }
893}
894
895/// Request message for `CreateReadSession`.
896#[derive(Clone, Default, PartialEq)]
897#[non_exhaustive]
898pub struct CreateReadSessionRequest {
899    /// Required. The request project that owns the session, in the form of
900    /// `projects/{project_id}`.
901    pub parent: std::string::String,
902
903    /// Required. Session to be created.
904    pub read_session:
905        std::option::Option<crate::write::generated::gapic_storage::model::ReadSession>,
906
907    /// Max initial number of streams. If unset or zero, the server will
908    /// provide a value of streams so as to produce reasonable throughput. Must be
909    /// non-negative. The number of streams may be lower than the requested number,
910    /// depending on the amount parallelism that is reasonable for the table.
911    /// There is a default system max limit of 1,000.
912    ///
913    /// This must be greater than or equal to preferred_min_stream_count.
914    /// Typically, clients should either leave this unset to let the system to
915    /// determine an upper bound OR set this a size for the maximum "units of work"
916    /// it can gracefully handle.
917    pub max_stream_count: i32,
918
919    /// The minimum preferred stream count. This parameter can be used to inform
920    /// the service that there is a desired lower bound on the number of streams.
921    /// This is typically a target parallelism of the client (e.g. a Spark
922    /// cluster with N-workers would set this to a low multiple of N to ensure
923    /// good cluster utilization).
924    ///
925    /// The system will make a best effort to provide at least this number of
926    /// streams, but in some cases might provide less.
927    pub preferred_min_stream_count: i32,
928
929    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
930}
931
932impl CreateReadSessionRequest {
933    /// Creates a new default instance.
934    pub fn new() -> Self {
935        std::default::Default::default()
936    }
937
938    /// Sets the value of [parent][crate::write::generated::gapic_storage::model::CreateReadSessionRequest::parent].
939    ///
940    /// # Example
941    /// ```ignore,no_run
942    /// # use google_cloud_bigquery::model::CreateReadSessionRequest;
943    /// let x = CreateReadSessionRequest::new().set_parent("example");
944    /// ```
945    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
946        self.parent = v.into();
947        self
948    }
949
950    /// Sets the value of [read_session][crate::write::generated::gapic_storage::model::CreateReadSessionRequest::read_session].
951    ///
952    /// # Example
953    /// ```ignore,no_run
954    /// # use google_cloud_bigquery::model::CreateReadSessionRequest;
955    /// use google_cloud_bigquery::model::ReadSession;
956    /// let x = CreateReadSessionRequest::new().set_read_session(ReadSession::default()/* use setters */);
957    /// ```
958    pub fn set_read_session<T>(mut self, v: T) -> Self
959    where
960        T: std::convert::Into<crate::write::generated::gapic_storage::model::ReadSession>,
961    {
962        self.read_session = std::option::Option::Some(v.into());
963        self
964    }
965
966    /// Sets or clears the value of [read_session][crate::write::generated::gapic_storage::model::CreateReadSessionRequest::read_session].
967    ///
968    /// # Example
969    /// ```ignore,no_run
970    /// # use google_cloud_bigquery::model::CreateReadSessionRequest;
971    /// use google_cloud_bigquery::model::ReadSession;
972    /// let x = CreateReadSessionRequest::new().set_or_clear_read_session(Some(ReadSession::default()/* use setters */));
973    /// let x = CreateReadSessionRequest::new().set_or_clear_read_session(None::<ReadSession>);
974    /// ```
975    pub fn set_or_clear_read_session<T>(mut self, v: std::option::Option<T>) -> Self
976    where
977        T: std::convert::Into<crate::write::generated::gapic_storage::model::ReadSession>,
978    {
979        self.read_session = v.map(|x| x.into());
980        self
981    }
982
983    /// Sets the value of [max_stream_count][crate::write::generated::gapic_storage::model::CreateReadSessionRequest::max_stream_count].
984    ///
985    /// # Example
986    /// ```ignore,no_run
987    /// # use google_cloud_bigquery::model::CreateReadSessionRequest;
988    /// let x = CreateReadSessionRequest::new().set_max_stream_count(42);
989    /// ```
990    pub fn set_max_stream_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
991        self.max_stream_count = v.into();
992        self
993    }
994
995    /// Sets the value of [preferred_min_stream_count][crate::write::generated::gapic_storage::model::CreateReadSessionRequest::preferred_min_stream_count].
996    ///
997    /// # Example
998    /// ```ignore,no_run
999    /// # use google_cloud_bigquery::model::CreateReadSessionRequest;
1000    /// let x = CreateReadSessionRequest::new().set_preferred_min_stream_count(42);
1001    /// ```
1002    pub fn set_preferred_min_stream_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1003        self.preferred_min_stream_count = v.into();
1004        self
1005    }
1006}
1007
1008impl wkt::message::Message for CreateReadSessionRequest {
1009    fn typename() -> &'static str {
1010        "type.googleapis.com/google.cloud.bigquery.storage.v1.CreateReadSessionRequest"
1011    }
1012}
1013
1014/// Request message for `ReadRows`.
1015#[derive(Clone, Default, PartialEq)]
1016#[non_exhaustive]
1017pub struct ReadRowsRequest {
1018
1019    /// Required. Stream to read rows from.
1020    pub read_stream: std::string::String,
1021
1022    /// The offset requested must be less than the last row read from Read.
1023    /// Requesting a larger offset is undefined. If not specified, start reading
1024    /// from offset zero.
1025    pub offset: i64,
1026
1027    /// Specifies output serialization options. Only job _default streams are
1028    /// supported.
1029    ///
1030    /// This feature is not yet available.
1031    pub output_format_serialization_options: std::option::Option<crate::write::generated::gapic_storage::model::read_rows_request::OutputFormatSerializationOptions>,
1032
1033    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1034}
1035
1036impl ReadRowsRequest {
1037    /// Creates a new default instance.
1038    pub fn new() -> Self {
1039        std::default::Default::default()
1040    }
1041
1042    /// Sets the value of [read_stream][crate::write::generated::gapic_storage::model::ReadRowsRequest::read_stream].
1043    ///
1044    /// # Example
1045    /// ```ignore,no_run
1046    /// # use google_cloud_bigquery::model::ReadRowsRequest;
1047    /// # let project_id = "project_id";
1048    /// # let location_id = "location_id";
1049    /// # let session_id = "session_id";
1050    /// # let stream_id = "stream_id";
1051    /// let x = ReadRowsRequest::new().set_read_stream(format!("projects/{project_id}/locations/{location_id}/sessions/{session_id}/streams/{stream_id}"));
1052    /// ```
1053    pub fn set_read_stream<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1054        self.read_stream = v.into();
1055        self
1056    }
1057
1058    /// Sets the value of [offset][crate::write::generated::gapic_storage::model::ReadRowsRequest::offset].
1059    ///
1060    /// # Example
1061    /// ```ignore,no_run
1062    /// # use google_cloud_bigquery::model::ReadRowsRequest;
1063    /// let x = ReadRowsRequest::new().set_offset(42);
1064    /// ```
1065    pub fn set_offset<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1066        self.offset = v.into();
1067        self
1068    }
1069
1070    /// Sets the value of [output_format_serialization_options][crate::write::generated::gapic_storage::model::ReadRowsRequest::output_format_serialization_options].
1071    ///
1072    /// Note that all the setters affecting `output_format_serialization_options` are mutually
1073    /// exclusive.
1074    ///
1075    /// # Example
1076    /// ```ignore,no_run
1077    /// # use google_cloud_bigquery::model::ReadRowsRequest;
1078    /// use google_cloud_bigquery::model::ArrowSerializationOptions;
1079    /// let x = ReadRowsRequest::new().set_output_format_serialization_options(Some(
1080    ///     google_cloud_bigquery::model::read_rows_request::OutputFormatSerializationOptions::ArrowSerializationOptions(ArrowSerializationOptions::default().into())));
1081    /// ```
1082    pub fn set_output_format_serialization_options<T: std::convert::Into<std::option::Option<crate::write::generated::gapic_storage::model::read_rows_request::OutputFormatSerializationOptions>>>(mut self, v: T) -> Self
1083    {
1084        self.output_format_serialization_options = v.into();
1085        self
1086    }
1087
1088    /// The value of [output_format_serialization_options][crate::write::generated::gapic_storage::model::ReadRowsRequest::output_format_serialization_options]
1089    /// if it holds a `ArrowSerializationOptions`, `None` if the field is not set or
1090    /// holds a different branch.
1091    pub fn arrow_serialization_options(
1092        &self,
1093    ) -> std::option::Option<
1094        &std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSerializationOptions>,
1095    > {
1096        #[allow(unreachable_patterns)]
1097        self.output_format_serialization_options.as_ref().and_then(|v| match v {
1098            crate::write::generated::gapic_storage::model::read_rows_request::OutputFormatSerializationOptions::ArrowSerializationOptions(v) => std::option::Option::Some(v),
1099            _ => std::option::Option::None,
1100        })
1101    }
1102
1103    /// Sets the value of [output_format_serialization_options][crate::write::generated::gapic_storage::model::ReadRowsRequest::output_format_serialization_options]
1104    /// to hold a `ArrowSerializationOptions`.
1105    ///
1106    /// Note that all the setters affecting `output_format_serialization_options` are
1107    /// mutually exclusive.
1108    ///
1109    /// # Example
1110    /// ```ignore,no_run
1111    /// # use google_cloud_bigquery::model::ReadRowsRequest;
1112    /// use google_cloud_bigquery::model::ArrowSerializationOptions;
1113    /// let x = ReadRowsRequest::new().set_arrow_serialization_options(ArrowSerializationOptions::default()/* use setters */);
1114    /// assert!(x.arrow_serialization_options().is_some());
1115    /// ```
1116    pub fn set_arrow_serialization_options<
1117        T: std::convert::Into<
1118                std::boxed::Box<
1119                    crate::write::generated::gapic_storage::model::ArrowSerializationOptions,
1120                >,
1121            >,
1122    >(
1123        mut self,
1124        v: T,
1125    ) -> Self {
1126        self.output_format_serialization_options = std::option::Option::Some(
1127            crate::write::generated::gapic_storage::model::read_rows_request::OutputFormatSerializationOptions::ArrowSerializationOptions(
1128                v.into()
1129            )
1130        );
1131        self
1132    }
1133}
1134
1135impl wkt::message::Message for ReadRowsRequest {
1136    fn typename() -> &'static str {
1137        "type.googleapis.com/google.cloud.bigquery.storage.v1.ReadRowsRequest"
1138    }
1139}
1140
1141/// Defines additional types related to [ReadRowsRequest].
1142pub mod read_rows_request {
1143    #[allow(unused_imports)]
1144    use super::*;
1145
1146    /// Specifies output serialization options. Only job _default streams are
1147    /// supported.
1148    ///
1149    /// This feature is not yet available.
1150    #[derive(Clone, Debug, PartialEq)]
1151    #[non_exhaustive]
1152    pub enum OutputFormatSerializationOptions {
1153        /// Optional. Options specific to the Apache Arrow output format.
1154        ///
1155        /// This feature is not yet available.
1156        ArrowSerializationOptions(
1157            std::boxed::Box<
1158                crate::write::generated::gapic_storage::model::ArrowSerializationOptions,
1159            >,
1160        ),
1161    }
1162
1163    impl OutputFormatSerializationOptions {
1164        /// Initializes the enum to the [ArrowSerializationOptions](Self::ArrowSerializationOptions) branch.
1165        pub fn from_arrow_serialization_options(
1166            value: impl std::convert::Into<
1167                std::boxed::Box<
1168                    crate::write::generated::gapic_storage::model::ArrowSerializationOptions,
1169                >,
1170            >,
1171        ) -> Self {
1172            Self::ArrowSerializationOptions(value.into())
1173        }
1174    }
1175}
1176
1177/// Information on if the current connection is being throttled.
1178#[derive(Clone, Default, PartialEq)]
1179#[non_exhaustive]
1180pub struct ThrottleState {
1181    /// How much this connection is being throttled. Zero means no throttling,
1182    /// 100 means fully throttled.
1183    pub throttle_percent: i32,
1184
1185    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1186}
1187
1188impl ThrottleState {
1189    /// Creates a new default instance.
1190    pub fn new() -> Self {
1191        std::default::Default::default()
1192    }
1193
1194    /// Sets the value of [throttle_percent][crate::write::generated::gapic_storage::model::ThrottleState::throttle_percent].
1195    ///
1196    /// # Example
1197    /// ```ignore,no_run
1198    /// # use google_cloud_bigquery::model::ThrottleState;
1199    /// let x = ThrottleState::new().set_throttle_percent(42);
1200    /// ```
1201    pub fn set_throttle_percent<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1202        self.throttle_percent = v.into();
1203        self
1204    }
1205}
1206
1207impl wkt::message::Message for ThrottleState {
1208    fn typename() -> &'static str {
1209        "type.googleapis.com/google.cloud.bigquery.storage.v1.ThrottleState"
1210    }
1211}
1212
1213/// Estimated stream statistics for a given read Stream.
1214#[derive(Clone, Default, PartialEq)]
1215#[non_exhaustive]
1216pub struct StreamStats {
1217    /// Represents the progress of the current stream.
1218    pub progress:
1219        std::option::Option<crate::write::generated::gapic_storage::model::stream_stats::Progress>,
1220
1221    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1222}
1223
1224impl StreamStats {
1225    /// Creates a new default instance.
1226    pub fn new() -> Self {
1227        std::default::Default::default()
1228    }
1229
1230    /// Sets the value of [progress][crate::write::generated::gapic_storage::model::StreamStats::progress].
1231    ///
1232    /// # Example
1233    /// ```ignore,no_run
1234    /// # use google_cloud_bigquery::model::StreamStats;
1235    /// use google_cloud_bigquery::model::stream_stats::Progress;
1236    /// let x = StreamStats::new().set_progress(Progress::default()/* use setters */);
1237    /// ```
1238    pub fn set_progress<T>(mut self, v: T) -> Self
1239    where
1240        T: std::convert::Into<
1241                crate::write::generated::gapic_storage::model::stream_stats::Progress,
1242            >,
1243    {
1244        self.progress = std::option::Option::Some(v.into());
1245        self
1246    }
1247
1248    /// Sets or clears the value of [progress][crate::write::generated::gapic_storage::model::StreamStats::progress].
1249    ///
1250    /// # Example
1251    /// ```ignore,no_run
1252    /// # use google_cloud_bigquery::model::StreamStats;
1253    /// use google_cloud_bigquery::model::stream_stats::Progress;
1254    /// let x = StreamStats::new().set_or_clear_progress(Some(Progress::default()/* use setters */));
1255    /// let x = StreamStats::new().set_or_clear_progress(None::<Progress>);
1256    /// ```
1257    pub fn set_or_clear_progress<T>(mut self, v: std::option::Option<T>) -> Self
1258    where
1259        T: std::convert::Into<
1260                crate::write::generated::gapic_storage::model::stream_stats::Progress,
1261            >,
1262    {
1263        self.progress = v.map(|x| x.into());
1264        self
1265    }
1266}
1267
1268impl wkt::message::Message for StreamStats {
1269    fn typename() -> &'static str {
1270        "type.googleapis.com/google.cloud.bigquery.storage.v1.StreamStats"
1271    }
1272}
1273
1274/// Defines additional types related to [StreamStats].
1275pub mod stream_stats {
1276    #[allow(unused_imports)]
1277    use super::*;
1278
1279    #[allow(missing_docs)]
1280    #[derive(Clone, Default, PartialEq)]
1281    #[non_exhaustive]
1282    pub struct Progress {
1283        /// The fraction of rows assigned to the stream that have been processed by
1284        /// the server so far, not including the rows in the current response
1285        /// message.
1286        ///
1287        /// This value, along with `at_response_end`, can be used to interpolate
1288        /// the progress made as the rows in the message are being processed using
1289        /// the following formula: `at_response_start + (at_response_end -
1290        /// at_response_start) * rows_processed_from_response / rows_in_response`.
1291        ///
1292        /// Note that if a filter is provided, the `at_response_end` value of the
1293        /// previous response may not necessarily be equal to the
1294        /// `at_response_start` value of the current response.
1295        pub at_response_start: f64,
1296
1297        /// Similar to `at_response_start`, except that this value includes the
1298        /// rows in the current response.
1299        pub at_response_end: f64,
1300
1301        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1302    }
1303
1304    impl Progress {
1305        /// Creates a new default instance.
1306        pub fn new() -> Self {
1307            std::default::Default::default()
1308        }
1309
1310        /// Sets the value of [at_response_start][crate::write::generated::gapic_storage::model::stream_stats::Progress::at_response_start].
1311        ///
1312        /// # Example
1313        /// ```ignore,no_run
1314        /// # use google_cloud_bigquery::model::stream_stats::Progress;
1315        /// let x = Progress::new().set_at_response_start(42.0);
1316        /// ```
1317        pub fn set_at_response_start<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1318            self.at_response_start = v.into();
1319            self
1320        }
1321
1322        /// Sets the value of [at_response_end][crate::write::generated::gapic_storage::model::stream_stats::Progress::at_response_end].
1323        ///
1324        /// # Example
1325        /// ```ignore,no_run
1326        /// # use google_cloud_bigquery::model::stream_stats::Progress;
1327        /// let x = Progress::new().set_at_response_end(42.0);
1328        /// ```
1329        pub fn set_at_response_end<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1330            self.at_response_end = v.into();
1331            self
1332        }
1333    }
1334
1335    impl wkt::message::Message for Progress {
1336        fn typename() -> &'static str {
1337            "type.googleapis.com/google.cloud.bigquery.storage.v1.StreamStats.Progress"
1338        }
1339    }
1340}
1341
1342/// Response from calling `ReadRows` may include row data, progress and
1343/// throttling information.
1344#[derive(Clone, Default, PartialEq)]
1345#[non_exhaustive]
1346pub struct ReadRowsResponse {
1347    /// Number of serialized rows in the rows block.
1348    pub row_count: i64,
1349
1350    /// Statistics for the stream.
1351    pub stats: std::option::Option<crate::write::generated::gapic_storage::model::StreamStats>,
1352
1353    /// Throttling state. If unset, the latest response still describes
1354    /// the current throttling status.
1355    pub throttle_state:
1356        std::option::Option<crate::write::generated::gapic_storage::model::ThrottleState>,
1357
1358    /// Optional. If the row data in this ReadRowsResponse is compressed, then
1359    /// uncompressed byte size is the original size of the uncompressed row data.
1360    /// If it is set to a value greater than 0, then decompress into a buffer of
1361    /// size uncompressed_byte_size using the compression codec that was requested
1362    /// during session creation time and which is specified in
1363    /// TableReadOptions.response_compression_codec in ReadSession.
1364    /// This value is not set if no response_compression_codec was not requested
1365    /// and it is -1 if the requested compression would not have reduced the size
1366    /// of this ReadRowsResponse's row data. This attempts to match Apache Arrow's
1367    /// behavior described here <https://github.com/apache/arrow/issues/15102> where
1368    /// the uncompressed length may be set to -1 to indicate that the data that
1369    /// follows is not compressed, which can be useful for cases where compression
1370    /// does not yield appreciable savings. When uncompressed_byte_size is not
1371    /// greater than 0, the client should skip decompression.
1372    pub uncompressed_byte_size: std::option::Option<i64>,
1373
1374    /// Output only. The total estimated number of rows in the query results.
1375    /// Only populated when reading data from a BigQuery job.
1376    ///
1377    /// This feature is not yet available.
1378    pub total_estimated_row_count: std::option::Option<i64>,
1379
1380    /// Row data is returned in format specified during session creation.
1381    pub rows: std::option::Option<
1382        crate::write::generated::gapic_storage::model::read_rows_response::Rows,
1383    >,
1384
1385    /// The schema for the read. If read_options.selected_fields is set, the
1386    /// schema may be different from the table schema as it will only contain
1387    /// the selected fields. This schema is equivalent to the one returned by
1388    /// CreateSession. This field is only populated in the first ReadRowsResponse
1389    /// RPC.
1390    pub schema: std::option::Option<
1391        crate::write::generated::gapic_storage::model::read_rows_response::Schema,
1392    >,
1393
1394    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1395}
1396
1397impl ReadRowsResponse {
1398    /// Creates a new default instance.
1399    pub fn new() -> Self {
1400        std::default::Default::default()
1401    }
1402
1403    /// Sets the value of [row_count][crate::write::generated::gapic_storage::model::ReadRowsResponse::row_count].
1404    ///
1405    /// # Example
1406    /// ```ignore,no_run
1407    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1408    /// let x = ReadRowsResponse::new().set_row_count(42);
1409    /// ```
1410    pub fn set_row_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1411        self.row_count = v.into();
1412        self
1413    }
1414
1415    /// Sets the value of [stats][crate::write::generated::gapic_storage::model::ReadRowsResponse::stats].
1416    ///
1417    /// # Example
1418    /// ```ignore,no_run
1419    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1420    /// use google_cloud_bigquery::model::StreamStats;
1421    /// let x = ReadRowsResponse::new().set_stats(StreamStats::default()/* use setters */);
1422    /// ```
1423    pub fn set_stats<T>(mut self, v: T) -> Self
1424    where
1425        T: std::convert::Into<crate::write::generated::gapic_storage::model::StreamStats>,
1426    {
1427        self.stats = std::option::Option::Some(v.into());
1428        self
1429    }
1430
1431    /// Sets or clears the value of [stats][crate::write::generated::gapic_storage::model::ReadRowsResponse::stats].
1432    ///
1433    /// # Example
1434    /// ```ignore,no_run
1435    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1436    /// use google_cloud_bigquery::model::StreamStats;
1437    /// let x = ReadRowsResponse::new().set_or_clear_stats(Some(StreamStats::default()/* use setters */));
1438    /// let x = ReadRowsResponse::new().set_or_clear_stats(None::<StreamStats>);
1439    /// ```
1440    pub fn set_or_clear_stats<T>(mut self, v: std::option::Option<T>) -> Self
1441    where
1442        T: std::convert::Into<crate::write::generated::gapic_storage::model::StreamStats>,
1443    {
1444        self.stats = v.map(|x| x.into());
1445        self
1446    }
1447
1448    /// Sets the value of [throttle_state][crate::write::generated::gapic_storage::model::ReadRowsResponse::throttle_state].
1449    ///
1450    /// # Example
1451    /// ```ignore,no_run
1452    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1453    /// use google_cloud_bigquery::model::ThrottleState;
1454    /// let x = ReadRowsResponse::new().set_throttle_state(ThrottleState::default()/* use setters */);
1455    /// ```
1456    pub fn set_throttle_state<T>(mut self, v: T) -> Self
1457    where
1458        T: std::convert::Into<crate::write::generated::gapic_storage::model::ThrottleState>,
1459    {
1460        self.throttle_state = std::option::Option::Some(v.into());
1461        self
1462    }
1463
1464    /// Sets or clears the value of [throttle_state][crate::write::generated::gapic_storage::model::ReadRowsResponse::throttle_state].
1465    ///
1466    /// # Example
1467    /// ```ignore,no_run
1468    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1469    /// use google_cloud_bigquery::model::ThrottleState;
1470    /// let x = ReadRowsResponse::new().set_or_clear_throttle_state(Some(ThrottleState::default()/* use setters */));
1471    /// let x = ReadRowsResponse::new().set_or_clear_throttle_state(None::<ThrottleState>);
1472    /// ```
1473    pub fn set_or_clear_throttle_state<T>(mut self, v: std::option::Option<T>) -> Self
1474    where
1475        T: std::convert::Into<crate::write::generated::gapic_storage::model::ThrottleState>,
1476    {
1477        self.throttle_state = v.map(|x| x.into());
1478        self
1479    }
1480
1481    /// Sets the value of [uncompressed_byte_size][crate::write::generated::gapic_storage::model::ReadRowsResponse::uncompressed_byte_size].
1482    ///
1483    /// # Example
1484    /// ```ignore,no_run
1485    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1486    /// let x = ReadRowsResponse::new().set_uncompressed_byte_size(42);
1487    /// ```
1488    pub fn set_uncompressed_byte_size<T>(mut self, v: T) -> Self
1489    where
1490        T: std::convert::Into<i64>,
1491    {
1492        self.uncompressed_byte_size = std::option::Option::Some(v.into());
1493        self
1494    }
1495
1496    /// Sets or clears the value of [uncompressed_byte_size][crate::write::generated::gapic_storage::model::ReadRowsResponse::uncompressed_byte_size].
1497    ///
1498    /// # Example
1499    /// ```ignore,no_run
1500    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1501    /// let x = ReadRowsResponse::new().set_or_clear_uncompressed_byte_size(Some(42));
1502    /// let x = ReadRowsResponse::new().set_or_clear_uncompressed_byte_size(None::<i32>);
1503    /// ```
1504    pub fn set_or_clear_uncompressed_byte_size<T>(mut self, v: std::option::Option<T>) -> Self
1505    where
1506        T: std::convert::Into<i64>,
1507    {
1508        self.uncompressed_byte_size = v.map(|x| x.into());
1509        self
1510    }
1511
1512    /// Sets the value of [total_estimated_row_count][crate::write::generated::gapic_storage::model::ReadRowsResponse::total_estimated_row_count].
1513    ///
1514    /// # Example
1515    /// ```ignore,no_run
1516    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1517    /// let x = ReadRowsResponse::new().set_total_estimated_row_count(42);
1518    /// ```
1519    pub fn set_total_estimated_row_count<T>(mut self, v: T) -> Self
1520    where
1521        T: std::convert::Into<i64>,
1522    {
1523        self.total_estimated_row_count = std::option::Option::Some(v.into());
1524        self
1525    }
1526
1527    /// Sets or clears the value of [total_estimated_row_count][crate::write::generated::gapic_storage::model::ReadRowsResponse::total_estimated_row_count].
1528    ///
1529    /// # Example
1530    /// ```ignore,no_run
1531    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1532    /// let x = ReadRowsResponse::new().set_or_clear_total_estimated_row_count(Some(42));
1533    /// let x = ReadRowsResponse::new().set_or_clear_total_estimated_row_count(None::<i32>);
1534    /// ```
1535    pub fn set_or_clear_total_estimated_row_count<T>(mut self, v: std::option::Option<T>) -> Self
1536    where
1537        T: std::convert::Into<i64>,
1538    {
1539        self.total_estimated_row_count = v.map(|x| x.into());
1540        self
1541    }
1542
1543    /// Sets the value of [rows][crate::write::generated::gapic_storage::model::ReadRowsResponse::rows].
1544    ///
1545    /// Note that all the setters affecting `rows` are mutually
1546    /// exclusive.
1547    ///
1548    /// # Example
1549    /// ```ignore,no_run
1550    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1551    /// use google_cloud_bigquery::model::AvroRows;
1552    /// let x = ReadRowsResponse::new().set_rows(Some(
1553    ///     google_cloud_bigquery::model::read_rows_response::Rows::AvroRows(AvroRows::default().into())));
1554    /// ```
1555    pub fn set_rows<
1556        T: std::convert::Into<
1557                std::option::Option<
1558                    crate::write::generated::gapic_storage::model::read_rows_response::Rows,
1559                >,
1560            >,
1561    >(
1562        mut self,
1563        v: T,
1564    ) -> Self {
1565        self.rows = v.into();
1566        self
1567    }
1568
1569    /// The value of [rows][crate::write::generated::gapic_storage::model::ReadRowsResponse::rows]
1570    /// if it holds a `AvroRows`, `None` if the field is not set or
1571    /// holds a different branch.
1572    pub fn avro_rows(
1573        &self,
1574    ) -> std::option::Option<
1575        &std::boxed::Box<crate::write::generated::gapic_storage::model::AvroRows>,
1576    > {
1577        #[allow(unreachable_patterns)]
1578        self.rows.as_ref().and_then(|v| match v {
1579            crate::write::generated::gapic_storage::model::read_rows_response::Rows::AvroRows(
1580                v,
1581            ) => std::option::Option::Some(v),
1582            _ => std::option::Option::None,
1583        })
1584    }
1585
1586    /// Sets the value of [rows][crate::write::generated::gapic_storage::model::ReadRowsResponse::rows]
1587    /// to hold a `AvroRows`.
1588    ///
1589    /// Note that all the setters affecting `rows` are
1590    /// mutually exclusive.
1591    ///
1592    /// # Example
1593    /// ```ignore,no_run
1594    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1595    /// use google_cloud_bigquery::model::AvroRows;
1596    /// let x = ReadRowsResponse::new().set_avro_rows(AvroRows::default()/* use setters */);
1597    /// assert!(x.avro_rows().is_some());
1598    /// assert!(x.arrow_record_batch().is_none());
1599    /// ```
1600    pub fn set_avro_rows<
1601        T: std::convert::Into<
1602                std::boxed::Box<crate::write::generated::gapic_storage::model::AvroRows>,
1603            >,
1604    >(
1605        mut self,
1606        v: T,
1607    ) -> Self {
1608        self.rows = std::option::Option::Some(
1609            crate::write::generated::gapic_storage::model::read_rows_response::Rows::AvroRows(
1610                v.into(),
1611            ),
1612        );
1613        self
1614    }
1615
1616    /// The value of [rows][crate::write::generated::gapic_storage::model::ReadRowsResponse::rows]
1617    /// if it holds a `ArrowRecordBatch`, `None` if the field is not set or
1618    /// holds a different branch.
1619    pub fn arrow_record_batch(
1620        &self,
1621    ) -> std::option::Option<
1622        &std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowRecordBatch>,
1623    > {
1624        #[allow(unreachable_patterns)]
1625        self.rows.as_ref().and_then(|v| match v {
1626            crate::write::generated::gapic_storage::model::read_rows_response::Rows::ArrowRecordBatch(v) => std::option::Option::Some(v),
1627            _ => std::option::Option::None,
1628        })
1629    }
1630
1631    /// Sets the value of [rows][crate::write::generated::gapic_storage::model::ReadRowsResponse::rows]
1632    /// to hold a `ArrowRecordBatch`.
1633    ///
1634    /// Note that all the setters affecting `rows` are
1635    /// mutually exclusive.
1636    ///
1637    /// # Example
1638    /// ```ignore,no_run
1639    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1640    /// use google_cloud_bigquery::model::ArrowRecordBatch;
1641    /// let x = ReadRowsResponse::new().set_arrow_record_batch(ArrowRecordBatch::default()/* use setters */);
1642    /// assert!(x.arrow_record_batch().is_some());
1643    /// assert!(x.avro_rows().is_none());
1644    /// ```
1645    pub fn set_arrow_record_batch<
1646        T: std::convert::Into<
1647                std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowRecordBatch>,
1648            >,
1649    >(
1650        mut self,
1651        v: T,
1652    ) -> Self {
1653        self.rows = std::option::Option::Some(
1654            crate::write::generated::gapic_storage::model::read_rows_response::Rows::ArrowRecordBatch(
1655                v.into()
1656            )
1657        );
1658        self
1659    }
1660
1661    /// Sets the value of [schema][crate::write::generated::gapic_storage::model::ReadRowsResponse::schema].
1662    ///
1663    /// Note that all the setters affecting `schema` are mutually
1664    /// exclusive.
1665    ///
1666    /// # Example
1667    /// ```ignore,no_run
1668    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1669    /// use google_cloud_bigquery::model::AvroSchema;
1670    /// let x = ReadRowsResponse::new().set_schema(Some(
1671    ///     google_cloud_bigquery::model::read_rows_response::Schema::AvroSchema(AvroSchema::default().into())));
1672    /// ```
1673    pub fn set_schema<
1674        T: std::convert::Into<
1675                std::option::Option<
1676                    crate::write::generated::gapic_storage::model::read_rows_response::Schema,
1677                >,
1678            >,
1679    >(
1680        mut self,
1681        v: T,
1682    ) -> Self {
1683        self.schema = v.into();
1684        self
1685    }
1686
1687    /// The value of [schema][crate::write::generated::gapic_storage::model::ReadRowsResponse::schema]
1688    /// if it holds a `AvroSchema`, `None` if the field is not set or
1689    /// holds a different branch.
1690    pub fn avro_schema(
1691        &self,
1692    ) -> std::option::Option<
1693        &std::boxed::Box<crate::write::generated::gapic_storage::model::AvroSchema>,
1694    > {
1695        #[allow(unreachable_patterns)]
1696        self.schema.as_ref().and_then(|v| match v {
1697            crate::write::generated::gapic_storage::model::read_rows_response::Schema::AvroSchema(v) => std::option::Option::Some(v),
1698            _ => std::option::Option::None,
1699        })
1700    }
1701
1702    /// Sets the value of [schema][crate::write::generated::gapic_storage::model::ReadRowsResponse::schema]
1703    /// to hold a `AvroSchema`.
1704    ///
1705    /// Note that all the setters affecting `schema` are
1706    /// mutually exclusive.
1707    ///
1708    /// # Example
1709    /// ```ignore,no_run
1710    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1711    /// use google_cloud_bigquery::model::AvroSchema;
1712    /// let x = ReadRowsResponse::new().set_avro_schema(AvroSchema::default()/* use setters */);
1713    /// assert!(x.avro_schema().is_some());
1714    /// assert!(x.arrow_schema().is_none());
1715    /// ```
1716    pub fn set_avro_schema<
1717        T: std::convert::Into<
1718                std::boxed::Box<crate::write::generated::gapic_storage::model::AvroSchema>,
1719            >,
1720    >(
1721        mut self,
1722        v: T,
1723    ) -> Self {
1724        self.schema = std::option::Option::Some(
1725            crate::write::generated::gapic_storage::model::read_rows_response::Schema::AvroSchema(
1726                v.into(),
1727            ),
1728        );
1729        self
1730    }
1731
1732    /// The value of [schema][crate::write::generated::gapic_storage::model::ReadRowsResponse::schema]
1733    /// if it holds a `ArrowSchema`, `None` if the field is not set or
1734    /// holds a different branch.
1735    pub fn arrow_schema(
1736        &self,
1737    ) -> std::option::Option<
1738        &std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSchema>,
1739    > {
1740        #[allow(unreachable_patterns)]
1741        self.schema.as_ref().and_then(|v| match v {
1742            crate::write::generated::gapic_storage::model::read_rows_response::Schema::ArrowSchema(v) => std::option::Option::Some(v),
1743            _ => std::option::Option::None,
1744        })
1745    }
1746
1747    /// Sets the value of [schema][crate::write::generated::gapic_storage::model::ReadRowsResponse::schema]
1748    /// to hold a `ArrowSchema`.
1749    ///
1750    /// Note that all the setters affecting `schema` are
1751    /// mutually exclusive.
1752    ///
1753    /// # Example
1754    /// ```ignore,no_run
1755    /// # use google_cloud_bigquery::model::ReadRowsResponse;
1756    /// use google_cloud_bigquery::model::ArrowSchema;
1757    /// let x = ReadRowsResponse::new().set_arrow_schema(ArrowSchema::default()/* use setters */);
1758    /// assert!(x.arrow_schema().is_some());
1759    /// assert!(x.avro_schema().is_none());
1760    /// ```
1761    pub fn set_arrow_schema<
1762        T: std::convert::Into<
1763                std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSchema>,
1764            >,
1765    >(
1766        mut self,
1767        v: T,
1768    ) -> Self {
1769        self.schema = std::option::Option::Some(
1770            crate::write::generated::gapic_storage::model::read_rows_response::Schema::ArrowSchema(
1771                v.into(),
1772            ),
1773        );
1774        self
1775    }
1776}
1777
1778impl wkt::message::Message for ReadRowsResponse {
1779    fn typename() -> &'static str {
1780        "type.googleapis.com/google.cloud.bigquery.storage.v1.ReadRowsResponse"
1781    }
1782}
1783
1784/// Defines additional types related to [ReadRowsResponse].
1785pub mod read_rows_response {
1786    #[allow(unused_imports)]
1787    use super::*;
1788
1789    /// Row data is returned in format specified during session creation.
1790    #[derive(Clone, Debug, PartialEq)]
1791    #[non_exhaustive]
1792    pub enum Rows {
1793        /// Serialized row data in AVRO format.
1794        AvroRows(std::boxed::Box<crate::write::generated::gapic_storage::model::AvroRows>),
1795        /// Serialized row data in Arrow RecordBatch format.
1796        ArrowRecordBatch(
1797            std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowRecordBatch>,
1798        ),
1799    }
1800
1801    impl Rows {
1802        /// Initializes the enum to the [AvroRows](Self::AvroRows) branch.
1803        pub fn from_avro_rows(
1804            value: impl std::convert::Into<
1805                std::boxed::Box<crate::write::generated::gapic_storage::model::AvroRows>,
1806            >,
1807        ) -> Self {
1808            Self::AvroRows(value.into())
1809        }
1810        /// Initializes the enum to the [ArrowRecordBatch](Self::ArrowRecordBatch) branch.
1811        pub fn from_arrow_record_batch(
1812            value: impl std::convert::Into<
1813                std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowRecordBatch>,
1814            >,
1815        ) -> Self {
1816            Self::ArrowRecordBatch(value.into())
1817        }
1818    }
1819
1820    /// The schema for the read. If read_options.selected_fields is set, the
1821    /// schema may be different from the table schema as it will only contain
1822    /// the selected fields. This schema is equivalent to the one returned by
1823    /// CreateSession. This field is only populated in the first ReadRowsResponse
1824    /// RPC.
1825    #[derive(Clone, Debug, PartialEq)]
1826    #[non_exhaustive]
1827    pub enum Schema {
1828        /// Output only. Avro schema.
1829        AvroSchema(std::boxed::Box<crate::write::generated::gapic_storage::model::AvroSchema>),
1830        /// Output only. Arrow schema.
1831        ArrowSchema(std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSchema>),
1832    }
1833
1834    impl Schema {
1835        /// Initializes the enum to the [AvroSchema](Self::AvroSchema) branch.
1836        pub fn from_avro_schema(
1837            value: impl std::convert::Into<
1838                std::boxed::Box<crate::write::generated::gapic_storage::model::AvroSchema>,
1839            >,
1840        ) -> Self {
1841            Self::AvroSchema(value.into())
1842        }
1843        /// Initializes the enum to the [ArrowSchema](Self::ArrowSchema) branch.
1844        pub fn from_arrow_schema(
1845            value: impl std::convert::Into<
1846                std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSchema>,
1847            >,
1848        ) -> Self {
1849            Self::ArrowSchema(value.into())
1850        }
1851    }
1852}
1853
1854/// Request message for `SplitReadStream`.
1855#[derive(Clone, Default, PartialEq)]
1856#[non_exhaustive]
1857pub struct SplitReadStreamRequest {
1858    /// Required. Name of the stream to split.
1859    pub name: std::string::String,
1860
1861    /// A value in the range (0.0, 1.0) that specifies the fractional point at
1862    /// which the original stream should be split. The actual split point is
1863    /// evaluated on pre-filtered rows, so if a filter is provided, then there is
1864    /// no guarantee that the division of the rows between the new child streams
1865    /// will be proportional to this fractional value. Additionally, because the
1866    /// server-side unit for assigning data is collections of rows, this fraction
1867    /// will always map to a data storage boundary on the server side.
1868    pub fraction: f64,
1869
1870    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1871}
1872
1873impl SplitReadStreamRequest {
1874    /// Creates a new default instance.
1875    pub fn new() -> Self {
1876        std::default::Default::default()
1877    }
1878
1879    /// Sets the value of [name][crate::write::generated::gapic_storage::model::SplitReadStreamRequest::name].
1880    ///
1881    /// # Example
1882    /// ```ignore,no_run
1883    /// # use google_cloud_bigquery::model::SplitReadStreamRequest;
1884    /// # let project_id = "project_id";
1885    /// # let location_id = "location_id";
1886    /// # let session_id = "session_id";
1887    /// # let stream_id = "stream_id";
1888    /// let x = SplitReadStreamRequest::new().set_name(format!("projects/{project_id}/locations/{location_id}/sessions/{session_id}/streams/{stream_id}"));
1889    /// ```
1890    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1891        self.name = v.into();
1892        self
1893    }
1894
1895    /// Sets the value of [fraction][crate::write::generated::gapic_storage::model::SplitReadStreamRequest::fraction].
1896    ///
1897    /// # Example
1898    /// ```ignore,no_run
1899    /// # use google_cloud_bigquery::model::SplitReadStreamRequest;
1900    /// let x = SplitReadStreamRequest::new().set_fraction(42.0);
1901    /// ```
1902    pub fn set_fraction<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1903        self.fraction = v.into();
1904        self
1905    }
1906}
1907
1908impl wkt::message::Message for SplitReadStreamRequest {
1909    fn typename() -> &'static str {
1910        "type.googleapis.com/google.cloud.bigquery.storage.v1.SplitReadStreamRequest"
1911    }
1912}
1913
1914/// Response message for `SplitReadStream`.
1915#[derive(Clone, Default, PartialEq)]
1916#[non_exhaustive]
1917pub struct SplitReadStreamResponse {
1918    /// Primary stream, which contains the beginning portion of
1919    /// |original_stream|. An empty value indicates that the original stream can no
1920    /// longer be split.
1921    pub primary_stream:
1922        std::option::Option<crate::write::generated::gapic_storage::model::ReadStream>,
1923
1924    /// Remainder stream, which contains the tail of |original_stream|. An empty
1925    /// value indicates that the original stream can no longer be split.
1926    pub remainder_stream:
1927        std::option::Option<crate::write::generated::gapic_storage::model::ReadStream>,
1928
1929    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1930}
1931
1932impl SplitReadStreamResponse {
1933    /// Creates a new default instance.
1934    pub fn new() -> Self {
1935        std::default::Default::default()
1936    }
1937
1938    /// Sets the value of [primary_stream][crate::write::generated::gapic_storage::model::SplitReadStreamResponse::primary_stream].
1939    ///
1940    /// # Example
1941    /// ```ignore,no_run
1942    /// # use google_cloud_bigquery::model::SplitReadStreamResponse;
1943    /// use google_cloud_bigquery::model::ReadStream;
1944    /// let x = SplitReadStreamResponse::new().set_primary_stream(ReadStream::default()/* use setters */);
1945    /// ```
1946    pub fn set_primary_stream<T>(mut self, v: T) -> Self
1947    where
1948        T: std::convert::Into<crate::write::generated::gapic_storage::model::ReadStream>,
1949    {
1950        self.primary_stream = std::option::Option::Some(v.into());
1951        self
1952    }
1953
1954    /// Sets or clears the value of [primary_stream][crate::write::generated::gapic_storage::model::SplitReadStreamResponse::primary_stream].
1955    ///
1956    /// # Example
1957    /// ```ignore,no_run
1958    /// # use google_cloud_bigquery::model::SplitReadStreamResponse;
1959    /// use google_cloud_bigquery::model::ReadStream;
1960    /// let x = SplitReadStreamResponse::new().set_or_clear_primary_stream(Some(ReadStream::default()/* use setters */));
1961    /// let x = SplitReadStreamResponse::new().set_or_clear_primary_stream(None::<ReadStream>);
1962    /// ```
1963    pub fn set_or_clear_primary_stream<T>(mut self, v: std::option::Option<T>) -> Self
1964    where
1965        T: std::convert::Into<crate::write::generated::gapic_storage::model::ReadStream>,
1966    {
1967        self.primary_stream = v.map(|x| x.into());
1968        self
1969    }
1970
1971    /// Sets the value of [remainder_stream][crate::write::generated::gapic_storage::model::SplitReadStreamResponse::remainder_stream].
1972    ///
1973    /// # Example
1974    /// ```ignore,no_run
1975    /// # use google_cloud_bigquery::model::SplitReadStreamResponse;
1976    /// use google_cloud_bigquery::model::ReadStream;
1977    /// let x = SplitReadStreamResponse::new().set_remainder_stream(ReadStream::default()/* use setters */);
1978    /// ```
1979    pub fn set_remainder_stream<T>(mut self, v: T) -> Self
1980    where
1981        T: std::convert::Into<crate::write::generated::gapic_storage::model::ReadStream>,
1982    {
1983        self.remainder_stream = std::option::Option::Some(v.into());
1984        self
1985    }
1986
1987    /// Sets or clears the value of [remainder_stream][crate::write::generated::gapic_storage::model::SplitReadStreamResponse::remainder_stream].
1988    ///
1989    /// # Example
1990    /// ```ignore,no_run
1991    /// # use google_cloud_bigquery::model::SplitReadStreamResponse;
1992    /// use google_cloud_bigquery::model::ReadStream;
1993    /// let x = SplitReadStreamResponse::new().set_or_clear_remainder_stream(Some(ReadStream::default()/* use setters */));
1994    /// let x = SplitReadStreamResponse::new().set_or_clear_remainder_stream(None::<ReadStream>);
1995    /// ```
1996    pub fn set_or_clear_remainder_stream<T>(mut self, v: std::option::Option<T>) -> Self
1997    where
1998        T: std::convert::Into<crate::write::generated::gapic_storage::model::ReadStream>,
1999    {
2000        self.remainder_stream = v.map(|x| x.into());
2001        self
2002    }
2003}
2004
2005impl wkt::message::Message for SplitReadStreamResponse {
2006    fn typename() -> &'static str {
2007        "type.googleapis.com/google.cloud.bigquery.storage.v1.SplitReadStreamResponse"
2008    }
2009}
2010
2011/// Request message for `CreateWriteStream`.
2012#[derive(Clone, Default, PartialEq)]
2013#[non_exhaustive]
2014pub struct CreateWriteStreamRequest {
2015    /// Required. Reference to the table to which the stream belongs, in the format
2016    /// of `projects/{project}/datasets/{dataset}/tables/{table}`.
2017    pub parent: std::string::String,
2018
2019    /// Required. Stream to be created.
2020    pub write_stream:
2021        std::option::Option<crate::write::generated::gapic_storage::model::WriteStream>,
2022
2023    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2024}
2025
2026impl CreateWriteStreamRequest {
2027    /// Creates a new default instance.
2028    pub fn new() -> Self {
2029        std::default::Default::default()
2030    }
2031
2032    /// Sets the value of [parent][crate::write::generated::gapic_storage::model::CreateWriteStreamRequest::parent].
2033    ///
2034    /// # Example
2035    /// ```ignore,no_run
2036    /// # use google_cloud_bigquery::model::CreateWriteStreamRequest;
2037    /// let x = CreateWriteStreamRequest::new().set_parent("example");
2038    /// ```
2039    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2040        self.parent = v.into();
2041        self
2042    }
2043
2044    /// Sets the value of [write_stream][crate::write::generated::gapic_storage::model::CreateWriteStreamRequest::write_stream].
2045    ///
2046    /// # Example
2047    /// ```ignore,no_run
2048    /// # use google_cloud_bigquery::model::CreateWriteStreamRequest;
2049    /// use google_cloud_bigquery::model::WriteStream;
2050    /// let x = CreateWriteStreamRequest::new().set_write_stream(WriteStream::default()/* use setters */);
2051    /// ```
2052    pub fn set_write_stream<T>(mut self, v: T) -> Self
2053    where
2054        T: std::convert::Into<crate::write::generated::gapic_storage::model::WriteStream>,
2055    {
2056        self.write_stream = std::option::Option::Some(v.into());
2057        self
2058    }
2059
2060    /// Sets or clears the value of [write_stream][crate::write::generated::gapic_storage::model::CreateWriteStreamRequest::write_stream].
2061    ///
2062    /// # Example
2063    /// ```ignore,no_run
2064    /// # use google_cloud_bigquery::model::CreateWriteStreamRequest;
2065    /// use google_cloud_bigquery::model::WriteStream;
2066    /// let x = CreateWriteStreamRequest::new().set_or_clear_write_stream(Some(WriteStream::default()/* use setters */));
2067    /// let x = CreateWriteStreamRequest::new().set_or_clear_write_stream(None::<WriteStream>);
2068    /// ```
2069    pub fn set_or_clear_write_stream<T>(mut self, v: std::option::Option<T>) -> Self
2070    where
2071        T: std::convert::Into<crate::write::generated::gapic_storage::model::WriteStream>,
2072    {
2073        self.write_stream = v.map(|x| x.into());
2074        self
2075    }
2076}
2077
2078impl wkt::message::Message for CreateWriteStreamRequest {
2079    fn typename() -> &'static str {
2080        "type.googleapis.com/google.cloud.bigquery.storage.v1.CreateWriteStreamRequest"
2081    }
2082}
2083
2084/// Request message for `AppendRows`.
2085///
2086/// Because AppendRows is a bidirectional streaming RPC, certain parts of the
2087/// AppendRowsRequest need only be specified for the first request before
2088/// switching table destinations. You can also switch table destinations within
2089/// the same connection for the default stream.
2090///
2091/// The size of a single AppendRowsRequest must be less than 20 MB in size.
2092/// Requests larger than this return an error, typically `INVALID_ARGUMENT`.
2093#[derive(Clone, Default, PartialEq)]
2094#[non_exhaustive]
2095pub struct AppendRowsRequest {
2096
2097    /// Required. The write_stream identifies the append operation. It must be
2098    /// provided in the following scenarios:
2099    ///
2100    /// * In the first request to an AppendRows connection.
2101    ///
2102    /// * In all subsequent requests to an AppendRows connection, if you use the
2103    ///   same connection to write to multiple tables or change the input schema for
2104    ///   default streams.
2105    ///
2106    ///
2107    /// For explicitly created write streams, the format is:
2108    ///
2109    /// * `projects/{project}/datasets/{dataset}/tables/{table}/streams/{id}`
2110    ///
2111    /// For the special default stream, the format is:
2112    ///
2113    /// * `projects/{project}/datasets/{dataset}/tables/{table}/streams/_default`.
2114    ///
2115    /// An example of a possible sequence of requests with write_stream fields
2116    /// within a single connection:
2117    ///
2118    /// * r1: {write_stream: stream_name_1}
2119    ///
2120    /// * r2: {write_stream: /*omit*/}
2121    ///
2122    /// * r3: {write_stream: /*omit*/}
2123    ///
2124    /// * r4: {write_stream: stream_name_2}
2125    ///
2126    /// * r5: {write_stream: stream_name_2}
2127    ///
2128    ///
2129    /// The destination changed in request_4, so the write_stream field must be
2130    /// populated in all subsequent requests in this stream.
2131    pub write_stream: std::string::String,
2132
2133    /// If present, the write is only performed if the next append offset is same
2134    /// as the provided value. If not present, the write is performed at the
2135    /// current end of stream. Specifying a value for this field is not allowed
2136    /// when calling AppendRows for the '_default' stream.
2137    pub offset: std::option::Option<wkt::Int64Value>,
2138
2139    /// Id set by client to annotate its identity. Only initial request setting is
2140    /// respected.
2141    pub trace_id: std::string::String,
2142
2143    /// A map to indicate how to interpret missing value for some fields. Missing
2144    /// values are fields present in user schema but missing in rows. The key is
2145    /// the field name. The value is the interpretation of missing values for the
2146    /// field.
2147    ///
2148    /// For example, a map {'foo': NULL_VALUE, 'bar': DEFAULT_VALUE} means all
2149    /// missing values in field foo are interpreted as NULL, all missing values in
2150    /// field bar are interpreted as the default value of field bar in table
2151    /// schema.
2152    ///
2153    /// If a field is not in this map and has missing values, the missing values
2154    /// in this field are interpreted as NULL.
2155    ///
2156    /// This field only applies to the current request, it won't affect other
2157    /// requests on the connection.
2158    ///
2159    /// Currently, field name can only be top-level column name, can't be a struct
2160    /// field path like 'foo.bar'.
2161    pub missing_value_interpretations: std::collections::HashMap<std::string::String,crate::write::generated::gapic_storage::model::append_rows_request::MissingValueInterpretation>,
2162
2163    /// Optional. Default missing value interpretation for all columns in the
2164    /// table. When a value is specified on an `AppendRowsRequest`, it is applied
2165    /// to all requests from that point forward, until a subsequent
2166    /// `AppendRowsRequest` sets it to a different value.
2167    /// `missing_value_interpretation` can override
2168    /// `default_missing_value_interpretation`. For example, if you want to write
2169    /// `NULL` instead of using default values for some columns, you can set
2170    /// `default_missing_value_interpretation` to `DEFAULT_VALUE` and at the same
2171    /// time, set `missing_value_interpretations` to `NULL_VALUE` on those columns.
2172    pub default_missing_value_interpretation: crate::write::generated::gapic_storage::model::append_rows_request::MissingValueInterpretation,
2173
2174    /// Optional. Stats and telemetry data gathered on the client side.
2175    pub client_stats: std::option::Option<crate::write::generated::gapic_storage::model::ClientStats>,
2176
2177    /// Input rows. The `writer_schema` field must be specified at the initial
2178    /// request and currently, it will be ignored if specified in following
2179    /// requests. Following requests must have data in the same format as the
2180    /// initial request.
2181    pub rows: std::option::Option<crate::write::generated::gapic_storage::model::append_rows_request::Rows>,
2182
2183    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2184}
2185
2186impl AppendRowsRequest {
2187    /// Creates a new default instance.
2188    pub fn new() -> Self {
2189        std::default::Default::default()
2190    }
2191
2192    /// Sets the value of [write_stream][crate::write::generated::gapic_storage::model::AppendRowsRequest::write_stream].
2193    ///
2194    /// # Example
2195    /// ```ignore,no_run
2196    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2197    /// # let project_id = "project_id";
2198    /// # let dataset_id = "dataset_id";
2199    /// # let table_id = "table_id";
2200    /// # let stream_id = "stream_id";
2201    /// let x = AppendRowsRequest::new().set_write_stream(format!("projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/streams/{stream_id}"));
2202    /// ```
2203    pub fn set_write_stream<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2204        self.write_stream = v.into();
2205        self
2206    }
2207
2208    /// Sets the value of [offset][crate::write::generated::gapic_storage::model::AppendRowsRequest::offset].
2209    ///
2210    /// # Example
2211    /// ```ignore,no_run
2212    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2213    /// use wkt::Int64Value;
2214    /// let x = AppendRowsRequest::new().set_offset(Int64Value::default()/* use setters */);
2215    /// ```
2216    pub fn set_offset<T>(mut self, v: T) -> Self
2217    where
2218        T: std::convert::Into<wkt::Int64Value>,
2219    {
2220        self.offset = std::option::Option::Some(v.into());
2221        self
2222    }
2223
2224    /// Sets or clears the value of [offset][crate::write::generated::gapic_storage::model::AppendRowsRequest::offset].
2225    ///
2226    /// # Example
2227    /// ```ignore,no_run
2228    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2229    /// use wkt::Int64Value;
2230    /// let x = AppendRowsRequest::new().set_or_clear_offset(Some(Int64Value::default()/* use setters */));
2231    /// let x = AppendRowsRequest::new().set_or_clear_offset(None::<Int64Value>);
2232    /// ```
2233    pub fn set_or_clear_offset<T>(mut self, v: std::option::Option<T>) -> Self
2234    where
2235        T: std::convert::Into<wkt::Int64Value>,
2236    {
2237        self.offset = v.map(|x| x.into());
2238        self
2239    }
2240
2241    /// Sets the value of [trace_id][crate::write::generated::gapic_storage::model::AppendRowsRequest::trace_id].
2242    ///
2243    /// # Example
2244    /// ```ignore,no_run
2245    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2246    /// let x = AppendRowsRequest::new().set_trace_id("example");
2247    /// ```
2248    pub fn set_trace_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2249        self.trace_id = v.into();
2250        self
2251    }
2252
2253    /// Sets the value of [missing_value_interpretations][crate::write::generated::gapic_storage::model::AppendRowsRequest::missing_value_interpretations].
2254    ///
2255    /// # Example
2256    /// ```ignore,no_run
2257    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2258    /// use google_cloud_bigquery::model::append_rows_request::MissingValueInterpretation;
2259    /// let x = AppendRowsRequest::new().set_missing_value_interpretations([
2260    ///     ("key0", MissingValueInterpretation::NullValue),
2261    ///     ("key1", MissingValueInterpretation::DefaultValue),
2262    /// ]);
2263    /// ```
2264    pub fn set_missing_value_interpretations<T, K, V>(mut self, v: T) -> Self
2265    where
2266        T: std::iter::IntoIterator<Item = (K, V)>,
2267        K: std::convert::Into<std::string::String>,
2268        V: std::convert::Into<crate::write::generated::gapic_storage::model::append_rows_request::MissingValueInterpretation>,
2269    {
2270        use std::iter::Iterator;
2271        self.missing_value_interpretations =
2272            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2273        self
2274    }
2275
2276    /// Sets the value of [default_missing_value_interpretation][crate::write::generated::gapic_storage::model::AppendRowsRequest::default_missing_value_interpretation].
2277    ///
2278    /// # Example
2279    /// ```ignore,no_run
2280    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2281    /// use google_cloud_bigquery::model::append_rows_request::MissingValueInterpretation;
2282    /// let x0 = AppendRowsRequest::new().set_default_missing_value_interpretation(MissingValueInterpretation::NullValue);
2283    /// let x1 = AppendRowsRequest::new().set_default_missing_value_interpretation(MissingValueInterpretation::DefaultValue);
2284    /// ```
2285    pub fn set_default_missing_value_interpretation<T: std::convert::Into<crate::write::generated::gapic_storage::model::append_rows_request::MissingValueInterpretation>>(mut self, v: T) -> Self{
2286        self.default_missing_value_interpretation = v.into();
2287        self
2288    }
2289
2290    /// Sets the value of [client_stats][crate::write::generated::gapic_storage::model::AppendRowsRequest::client_stats].
2291    ///
2292    /// # Example
2293    /// ```ignore,no_run
2294    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2295    /// use google_cloud_bigquery::model::ClientStats;
2296    /// let x = AppendRowsRequest::new().set_client_stats(ClientStats::default()/* use setters */);
2297    /// ```
2298    pub fn set_client_stats<T>(mut self, v: T) -> Self
2299    where
2300        T: std::convert::Into<crate::write::generated::gapic_storage::model::ClientStats>,
2301    {
2302        self.client_stats = std::option::Option::Some(v.into());
2303        self
2304    }
2305
2306    /// Sets or clears the value of [client_stats][crate::write::generated::gapic_storage::model::AppendRowsRequest::client_stats].
2307    ///
2308    /// # Example
2309    /// ```ignore,no_run
2310    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2311    /// use google_cloud_bigquery::model::ClientStats;
2312    /// let x = AppendRowsRequest::new().set_or_clear_client_stats(Some(ClientStats::default()/* use setters */));
2313    /// let x = AppendRowsRequest::new().set_or_clear_client_stats(None::<ClientStats>);
2314    /// ```
2315    pub fn set_or_clear_client_stats<T>(mut self, v: std::option::Option<T>) -> Self
2316    where
2317        T: std::convert::Into<crate::write::generated::gapic_storage::model::ClientStats>,
2318    {
2319        self.client_stats = v.map(|x| x.into());
2320        self
2321    }
2322
2323    /// Sets the value of [rows][crate::write::generated::gapic_storage::model::AppendRowsRequest::rows].
2324    ///
2325    /// Note that all the setters affecting `rows` are mutually
2326    /// exclusive.
2327    ///
2328    /// # Example
2329    /// ```ignore,no_run
2330    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2331    /// use google_cloud_bigquery::model::append_rows_request::ProtoData;
2332    /// let x = AppendRowsRequest::new().set_rows(Some(
2333    ///     google_cloud_bigquery::model::append_rows_request::Rows::ProtoRows(ProtoData::default().into())));
2334    /// ```
2335    pub fn set_rows<
2336        T: std::convert::Into<
2337                std::option::Option<
2338                    crate::write::generated::gapic_storage::model::append_rows_request::Rows,
2339                >,
2340            >,
2341    >(
2342        mut self,
2343        v: T,
2344    ) -> Self {
2345        self.rows = v.into();
2346        self
2347    }
2348
2349    /// The value of [rows][crate::write::generated::gapic_storage::model::AppendRowsRequest::rows]
2350    /// if it holds a `ProtoRows`, `None` if the field is not set or
2351    /// holds a different branch.
2352    pub fn proto_rows(
2353        &self,
2354    ) -> std::option::Option<
2355        &std::boxed::Box<
2356            crate::write::generated::gapic_storage::model::append_rows_request::ProtoData,
2357        >,
2358    > {
2359        #[allow(unreachable_patterns)]
2360        self.rows.as_ref().and_then(|v| match v {
2361            crate::write::generated::gapic_storage::model::append_rows_request::Rows::ProtoRows(
2362                v,
2363            ) => std::option::Option::Some(v),
2364            _ => std::option::Option::None,
2365        })
2366    }
2367
2368    /// Sets the value of [rows][crate::write::generated::gapic_storage::model::AppendRowsRequest::rows]
2369    /// to hold a `ProtoRows`.
2370    ///
2371    /// Note that all the setters affecting `rows` are
2372    /// mutually exclusive.
2373    ///
2374    /// # Example
2375    /// ```ignore,no_run
2376    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2377    /// use google_cloud_bigquery::model::append_rows_request::ProtoData;
2378    /// let x = AppendRowsRequest::new().set_proto_rows(ProtoData::default()/* use setters */);
2379    /// assert!(x.proto_rows().is_some());
2380    /// assert!(x.arrow_rows().is_none());
2381    /// ```
2382    pub fn set_proto_rows<
2383        T: std::convert::Into<
2384                std::boxed::Box<
2385                    crate::write::generated::gapic_storage::model::append_rows_request::ProtoData,
2386                >,
2387            >,
2388    >(
2389        mut self,
2390        v: T,
2391    ) -> Self {
2392        self.rows = std::option::Option::Some(
2393            crate::write::generated::gapic_storage::model::append_rows_request::Rows::ProtoRows(
2394                v.into(),
2395            ),
2396        );
2397        self
2398    }
2399
2400    /// The value of [rows][crate::write::generated::gapic_storage::model::AppendRowsRequest::rows]
2401    /// if it holds a `ArrowRows`, `None` if the field is not set or
2402    /// holds a different branch.
2403    pub fn arrow_rows(
2404        &self,
2405    ) -> std::option::Option<
2406        &std::boxed::Box<
2407            crate::write::generated::gapic_storage::model::append_rows_request::ArrowData,
2408        >,
2409    > {
2410        #[allow(unreachable_patterns)]
2411        self.rows.as_ref().and_then(|v| match v {
2412            crate::write::generated::gapic_storage::model::append_rows_request::Rows::ArrowRows(
2413                v,
2414            ) => std::option::Option::Some(v),
2415            _ => std::option::Option::None,
2416        })
2417    }
2418
2419    /// Sets the value of [rows][crate::write::generated::gapic_storage::model::AppendRowsRequest::rows]
2420    /// to hold a `ArrowRows`.
2421    ///
2422    /// Note that all the setters affecting `rows` are
2423    /// mutually exclusive.
2424    ///
2425    /// # Example
2426    /// ```ignore,no_run
2427    /// # use google_cloud_bigquery::model::AppendRowsRequest;
2428    /// use google_cloud_bigquery::model::append_rows_request::ArrowData;
2429    /// let x = AppendRowsRequest::new().set_arrow_rows(ArrowData::default()/* use setters */);
2430    /// assert!(x.arrow_rows().is_some());
2431    /// assert!(x.proto_rows().is_none());
2432    /// ```
2433    pub fn set_arrow_rows<
2434        T: std::convert::Into<
2435                std::boxed::Box<
2436                    crate::write::generated::gapic_storage::model::append_rows_request::ArrowData,
2437                >,
2438            >,
2439    >(
2440        mut self,
2441        v: T,
2442    ) -> Self {
2443        self.rows = std::option::Option::Some(
2444            crate::write::generated::gapic_storage::model::append_rows_request::Rows::ArrowRows(
2445                v.into(),
2446            ),
2447        );
2448        self
2449    }
2450}
2451
2452impl wkt::message::Message for AppendRowsRequest {
2453    fn typename() -> &'static str {
2454        "type.googleapis.com/google.cloud.bigquery.storage.v1.AppendRowsRequest"
2455    }
2456}
2457
2458/// Defines additional types related to [AppendRowsRequest].
2459pub mod append_rows_request {
2460    #[allow(unused_imports)]
2461    use super::*;
2462
2463    /// Arrow schema and data.
2464    #[derive(Clone, Default, PartialEq)]
2465    #[non_exhaustive]
2466    pub struct ArrowData {
2467        /// Optional. Arrow Schema used to serialize the data.
2468        pub writer_schema:
2469            std::option::Option<crate::write::generated::gapic_storage::model::ArrowSchema>,
2470
2471        /// Required. Serialized row data in Arrow format.
2472        pub rows:
2473            std::option::Option<crate::write::generated::gapic_storage::model::ArrowRecordBatch>,
2474
2475        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2476    }
2477
2478    impl ArrowData {
2479        /// Creates a new default instance.
2480        pub fn new() -> Self {
2481            std::default::Default::default()
2482        }
2483
2484        /// Sets the value of [writer_schema][crate::write::generated::gapic_storage::model::append_rows_request::ArrowData::writer_schema].
2485        ///
2486        /// # Example
2487        /// ```ignore,no_run
2488        /// # use google_cloud_bigquery::model::append_rows_request::ArrowData;
2489        /// use google_cloud_bigquery::model::ArrowSchema;
2490        /// let x = ArrowData::new().set_writer_schema(ArrowSchema::default()/* use setters */);
2491        /// ```
2492        pub fn set_writer_schema<T>(mut self, v: T) -> Self
2493        where
2494            T: std::convert::Into<crate::write::generated::gapic_storage::model::ArrowSchema>,
2495        {
2496            self.writer_schema = std::option::Option::Some(v.into());
2497            self
2498        }
2499
2500        /// Sets or clears the value of [writer_schema][crate::write::generated::gapic_storage::model::append_rows_request::ArrowData::writer_schema].
2501        ///
2502        /// # Example
2503        /// ```ignore,no_run
2504        /// # use google_cloud_bigquery::model::append_rows_request::ArrowData;
2505        /// use google_cloud_bigquery::model::ArrowSchema;
2506        /// let x = ArrowData::new().set_or_clear_writer_schema(Some(ArrowSchema::default()/* use setters */));
2507        /// let x = ArrowData::new().set_or_clear_writer_schema(None::<ArrowSchema>);
2508        /// ```
2509        pub fn set_or_clear_writer_schema<T>(mut self, v: std::option::Option<T>) -> Self
2510        where
2511            T: std::convert::Into<crate::write::generated::gapic_storage::model::ArrowSchema>,
2512        {
2513            self.writer_schema = v.map(|x| x.into());
2514            self
2515        }
2516
2517        /// Sets the value of [rows][crate::write::generated::gapic_storage::model::append_rows_request::ArrowData::rows].
2518        ///
2519        /// # Example
2520        /// ```ignore,no_run
2521        /// # use google_cloud_bigquery::model::append_rows_request::ArrowData;
2522        /// use google_cloud_bigquery::model::ArrowRecordBatch;
2523        /// let x = ArrowData::new().set_rows(ArrowRecordBatch::default()/* use setters */);
2524        /// ```
2525        pub fn set_rows<T>(mut self, v: T) -> Self
2526        where
2527            T: std::convert::Into<crate::write::generated::gapic_storage::model::ArrowRecordBatch>,
2528        {
2529            self.rows = std::option::Option::Some(v.into());
2530            self
2531        }
2532
2533        /// Sets or clears the value of [rows][crate::write::generated::gapic_storage::model::append_rows_request::ArrowData::rows].
2534        ///
2535        /// # Example
2536        /// ```ignore,no_run
2537        /// # use google_cloud_bigquery::model::append_rows_request::ArrowData;
2538        /// use google_cloud_bigquery::model::ArrowRecordBatch;
2539        /// let x = ArrowData::new().set_or_clear_rows(Some(ArrowRecordBatch::default()/* use setters */));
2540        /// let x = ArrowData::new().set_or_clear_rows(None::<ArrowRecordBatch>);
2541        /// ```
2542        pub fn set_or_clear_rows<T>(mut self, v: std::option::Option<T>) -> Self
2543        where
2544            T: std::convert::Into<crate::write::generated::gapic_storage::model::ArrowRecordBatch>,
2545        {
2546            self.rows = v.map(|x| x.into());
2547            self
2548        }
2549    }
2550
2551    impl wkt::message::Message for ArrowData {
2552        fn typename() -> &'static str {
2553            "type.googleapis.com/google.cloud.bigquery.storage.v1.AppendRowsRequest.ArrowData"
2554        }
2555    }
2556
2557    /// ProtoData contains the data rows and schema when constructing append
2558    /// requests.
2559    #[derive(Clone, Default, PartialEq)]
2560    #[non_exhaustive]
2561    pub struct ProtoData {
2562        /// Optional. The protocol buffer schema used to serialize the data. Provide
2563        /// this value whenever:
2564        ///
2565        /// * You send the first request of an RPC connection.
2566        ///
2567        /// * You change the input schema.
2568        ///
2569        /// * You specify a new destination table.
2570        ///
2571        pub writer_schema:
2572            std::option::Option<crate::write::generated::gapic_storage::model::ProtoSchema>,
2573
2574        /// Required. Serialized row data in protobuf message format.
2575        /// Currently, the backend expects the serialized rows to adhere to
2576        /// proto2 semantics when appending rows, particularly with respect to
2577        /// how default values are encoded.
2578        pub rows: std::option::Option<crate::write::generated::gapic_storage::model::ProtoRows>,
2579
2580        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2581    }
2582
2583    impl ProtoData {
2584        /// Creates a new default instance.
2585        pub fn new() -> Self {
2586            std::default::Default::default()
2587        }
2588
2589        /// Sets the value of [writer_schema][crate::write::generated::gapic_storage::model::append_rows_request::ProtoData::writer_schema].
2590        ///
2591        /// # Example
2592        /// ```ignore,no_run
2593        /// # use google_cloud_bigquery::model::append_rows_request::ProtoData;
2594        /// use google_cloud_bigquery::model::ProtoSchema;
2595        /// let x = ProtoData::new().set_writer_schema(ProtoSchema::default()/* use setters */);
2596        /// ```
2597        pub fn set_writer_schema<T>(mut self, v: T) -> Self
2598        where
2599            T: std::convert::Into<crate::write::generated::gapic_storage::model::ProtoSchema>,
2600        {
2601            self.writer_schema = std::option::Option::Some(v.into());
2602            self
2603        }
2604
2605        /// Sets or clears the value of [writer_schema][crate::write::generated::gapic_storage::model::append_rows_request::ProtoData::writer_schema].
2606        ///
2607        /// # Example
2608        /// ```ignore,no_run
2609        /// # use google_cloud_bigquery::model::append_rows_request::ProtoData;
2610        /// use google_cloud_bigquery::model::ProtoSchema;
2611        /// let x = ProtoData::new().set_or_clear_writer_schema(Some(ProtoSchema::default()/* use setters */));
2612        /// let x = ProtoData::new().set_or_clear_writer_schema(None::<ProtoSchema>);
2613        /// ```
2614        pub fn set_or_clear_writer_schema<T>(mut self, v: std::option::Option<T>) -> Self
2615        where
2616            T: std::convert::Into<crate::write::generated::gapic_storage::model::ProtoSchema>,
2617        {
2618            self.writer_schema = v.map(|x| x.into());
2619            self
2620        }
2621
2622        /// Sets the value of [rows][crate::write::generated::gapic_storage::model::append_rows_request::ProtoData::rows].
2623        ///
2624        /// # Example
2625        /// ```ignore,no_run
2626        /// # use google_cloud_bigquery::model::append_rows_request::ProtoData;
2627        /// use google_cloud_bigquery::model::ProtoRows;
2628        /// let x = ProtoData::new().set_rows(ProtoRows::default()/* use setters */);
2629        /// ```
2630        pub fn set_rows<T>(mut self, v: T) -> Self
2631        where
2632            T: std::convert::Into<crate::write::generated::gapic_storage::model::ProtoRows>,
2633        {
2634            self.rows = std::option::Option::Some(v.into());
2635            self
2636        }
2637
2638        /// Sets or clears the value of [rows][crate::write::generated::gapic_storage::model::append_rows_request::ProtoData::rows].
2639        ///
2640        /// # Example
2641        /// ```ignore,no_run
2642        /// # use google_cloud_bigquery::model::append_rows_request::ProtoData;
2643        /// use google_cloud_bigquery::model::ProtoRows;
2644        /// let x = ProtoData::new().set_or_clear_rows(Some(ProtoRows::default()/* use setters */));
2645        /// let x = ProtoData::new().set_or_clear_rows(None::<ProtoRows>);
2646        /// ```
2647        pub fn set_or_clear_rows<T>(mut self, v: std::option::Option<T>) -> Self
2648        where
2649            T: std::convert::Into<crate::write::generated::gapic_storage::model::ProtoRows>,
2650        {
2651            self.rows = v.map(|x| x.into());
2652            self
2653        }
2654    }
2655
2656    impl wkt::message::Message for ProtoData {
2657        fn typename() -> &'static str {
2658            "type.googleapis.com/google.cloud.bigquery.storage.v1.AppendRowsRequest.ProtoData"
2659        }
2660    }
2661
2662    /// An enum to indicate how to interpret missing values of fields that are
2663    /// present in user schema but missing in rows. A missing value can represent a
2664    /// NULL or a column default value defined in BigQuery table schema.
2665    ///
2666    /// # Working with unknown values
2667    ///
2668    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2669    /// additional enum variants at any time. Adding new variants is not considered
2670    /// a breaking change. Applications should write their code in anticipation of:
2671    ///
2672    /// - New values appearing in future releases of the client library, **and**
2673    /// - New values received dynamically, without application changes.
2674    ///
2675    /// Please consult the [Working with enums] section in the user guide for some
2676    /// guidelines.
2677    ///
2678    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2679    #[derive(Clone, Debug, PartialEq)]
2680    #[non_exhaustive]
2681    pub enum MissingValueInterpretation {
2682        /// Invalid missing value interpretation. Requests with this value will be
2683        /// rejected.
2684        Unspecified,
2685        /// Missing value is interpreted as NULL.
2686        NullValue,
2687        /// Missing value is interpreted as column default value if declared in the
2688        /// table schema, NULL otherwise.
2689        DefaultValue,
2690        /// If set, the enum was initialized with an unknown value.
2691        ///
2692        /// Applications can examine the value using [MissingValueInterpretation::value] or
2693        /// [MissingValueInterpretation::name].
2694        UnknownValue(missing_value_interpretation::UnknownValue),
2695    }
2696
2697    #[doc(hidden)]
2698    pub mod missing_value_interpretation {
2699        #[allow(unused_imports)]
2700        use super::*;
2701        #[derive(Clone, Debug, PartialEq)]
2702        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2703    }
2704
2705    impl MissingValueInterpretation {
2706        /// Gets the enum value.
2707        ///
2708        /// Returns `None` if the enum contains an unknown value deserialized from
2709        /// the string representation of enums.
2710        pub fn value(&self) -> std::option::Option<i32> {
2711            match self {
2712                Self::Unspecified => std::option::Option::Some(0),
2713                Self::NullValue => std::option::Option::Some(1),
2714                Self::DefaultValue => std::option::Option::Some(2),
2715                Self::UnknownValue(u) => u.0.value(),
2716            }
2717        }
2718
2719        /// Gets the enum value as a string.
2720        ///
2721        /// Returns `None` if the enum contains an unknown value deserialized from
2722        /// the integer representation of enums.
2723        pub fn name(&self) -> std::option::Option<&str> {
2724            match self {
2725                Self::Unspecified => {
2726                    std::option::Option::Some("MISSING_VALUE_INTERPRETATION_UNSPECIFIED")
2727                }
2728                Self::NullValue => std::option::Option::Some("NULL_VALUE"),
2729                Self::DefaultValue => std::option::Option::Some("DEFAULT_VALUE"),
2730                Self::UnknownValue(u) => u.0.name(),
2731            }
2732        }
2733    }
2734
2735    impl std::default::Default for MissingValueInterpretation {
2736        fn default() -> Self {
2737            use std::convert::From;
2738            Self::from(0)
2739        }
2740    }
2741
2742    impl std::fmt::Display for MissingValueInterpretation {
2743        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2744            wkt::internal::display_enum(f, self.name(), self.value())
2745        }
2746    }
2747
2748    impl std::convert::From<i32> for MissingValueInterpretation {
2749        fn from(value: i32) -> Self {
2750            match value {
2751                0 => Self::Unspecified,
2752                1 => Self::NullValue,
2753                2 => Self::DefaultValue,
2754                _ => Self::UnknownValue(missing_value_interpretation::UnknownValue(
2755                    wkt::internal::UnknownEnumValue::Integer(value),
2756                )),
2757            }
2758        }
2759    }
2760
2761    impl std::convert::From<&str> for MissingValueInterpretation {
2762        fn from(value: &str) -> Self {
2763            use std::string::ToString;
2764            match value {
2765                "MISSING_VALUE_INTERPRETATION_UNSPECIFIED" => Self::Unspecified,
2766                "NULL_VALUE" => Self::NullValue,
2767                "DEFAULT_VALUE" => Self::DefaultValue,
2768                _ => Self::UnknownValue(missing_value_interpretation::UnknownValue(
2769                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2770                )),
2771            }
2772        }
2773    }
2774
2775    impl serde::ser::Serialize for MissingValueInterpretation {
2776        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2777        where
2778            S: serde::Serializer,
2779        {
2780            match self {
2781                Self::Unspecified => serializer.serialize_i32(0),
2782                Self::NullValue => serializer.serialize_i32(1),
2783                Self::DefaultValue => serializer.serialize_i32(2),
2784                Self::UnknownValue(u) => u.0.serialize(serializer),
2785            }
2786        }
2787    }
2788
2789    impl<'de> serde::de::Deserialize<'de> for MissingValueInterpretation {
2790        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2791        where
2792            D: serde::Deserializer<'de>,
2793        {
2794            deserializer.deserialize_any(wkt::internal::EnumVisitor::<MissingValueInterpretation>::new(
2795                ".google.cloud.bigquery.storage.v1.AppendRowsRequest.MissingValueInterpretation"))
2796        }
2797    }
2798
2799    /// Input rows. The `writer_schema` field must be specified at the initial
2800    /// request and currently, it will be ignored if specified in following
2801    /// requests. Following requests must have data in the same format as the
2802    /// initial request.
2803    #[derive(Clone, Debug, PartialEq)]
2804    #[non_exhaustive]
2805    pub enum Rows {
2806        /// Rows in proto format.
2807        ProtoRows(
2808            std::boxed::Box<
2809                crate::write::generated::gapic_storage::model::append_rows_request::ProtoData,
2810            >,
2811        ),
2812        /// Rows in arrow format.
2813        ArrowRows(
2814            std::boxed::Box<
2815                crate::write::generated::gapic_storage::model::append_rows_request::ArrowData,
2816            >,
2817        ),
2818    }
2819
2820    impl Rows {
2821        /// Initializes the enum to the [ProtoRows](Self::ProtoRows) branch.
2822        pub fn from_proto_rows(
2823            value: impl std::convert::Into<
2824                std::boxed::Box<
2825                    crate::write::generated::gapic_storage::model::append_rows_request::ProtoData,
2826                >,
2827            >,
2828        ) -> Self {
2829            Self::ProtoRows(value.into())
2830        }
2831        /// Initializes the enum to the [ArrowRows](Self::ArrowRows) branch.
2832        pub fn from_arrow_rows(
2833            value: impl std::convert::Into<
2834                std::boxed::Box<
2835                    crate::write::generated::gapic_storage::model::append_rows_request::ArrowData,
2836                >,
2837            >,
2838        ) -> Self {
2839            Self::ArrowRows(value.into())
2840        }
2841    }
2842}
2843
2844/// Response message for `AppendRows`.
2845#[derive(Clone, Default, PartialEq)]
2846#[non_exhaustive]
2847pub struct AppendRowsResponse {
2848    /// If backend detects a schema update, pass it to user so that user can
2849    /// use it to input new type of message. It will be empty when no schema
2850    /// updates have occurred.
2851    pub updated_schema:
2852        std::option::Option<crate::write::generated::gapic_storage::model::TableSchema>,
2853
2854    /// If a request failed due to corrupted rows, no rows in the batch will be
2855    /// appended. The API will return row level error info, so that the caller can
2856    /// remove the bad rows and retry the request.
2857    pub row_errors: std::vec::Vec<crate::write::generated::gapic_storage::model::RowError>,
2858
2859    /// The target of the append operation. Matches the write_stream in the
2860    /// corresponding request.
2861    pub write_stream: std::string::String,
2862
2863    #[allow(missing_docs)]
2864    pub response: std::option::Option<
2865        crate::write::generated::gapic_storage::model::append_rows_response::Response,
2866    >,
2867
2868    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2869}
2870
2871impl AppendRowsResponse {
2872    /// Creates a new default instance.
2873    pub fn new() -> Self {
2874        std::default::Default::default()
2875    }
2876
2877    /// Sets the value of [updated_schema][crate::write::generated::gapic_storage::model::AppendRowsResponse::updated_schema].
2878    ///
2879    /// # Example
2880    /// ```ignore,no_run
2881    /// # use google_cloud_bigquery::model::AppendRowsResponse;
2882    /// use google_cloud_bigquery::model::TableSchema;
2883    /// let x = AppendRowsResponse::new().set_updated_schema(TableSchema::default()/* use setters */);
2884    /// ```
2885    pub fn set_updated_schema<T>(mut self, v: T) -> Self
2886    where
2887        T: std::convert::Into<crate::write::generated::gapic_storage::model::TableSchema>,
2888    {
2889        self.updated_schema = std::option::Option::Some(v.into());
2890        self
2891    }
2892
2893    /// Sets or clears the value of [updated_schema][crate::write::generated::gapic_storage::model::AppendRowsResponse::updated_schema].
2894    ///
2895    /// # Example
2896    /// ```ignore,no_run
2897    /// # use google_cloud_bigquery::model::AppendRowsResponse;
2898    /// use google_cloud_bigquery::model::TableSchema;
2899    /// let x = AppendRowsResponse::new().set_or_clear_updated_schema(Some(TableSchema::default()/* use setters */));
2900    /// let x = AppendRowsResponse::new().set_or_clear_updated_schema(None::<TableSchema>);
2901    /// ```
2902    pub fn set_or_clear_updated_schema<T>(mut self, v: std::option::Option<T>) -> Self
2903    where
2904        T: std::convert::Into<crate::write::generated::gapic_storage::model::TableSchema>,
2905    {
2906        self.updated_schema = v.map(|x| x.into());
2907        self
2908    }
2909
2910    /// Sets the value of [row_errors][crate::write::generated::gapic_storage::model::AppendRowsResponse::row_errors].
2911    ///
2912    /// # Example
2913    /// ```ignore,no_run
2914    /// # use google_cloud_bigquery::model::AppendRowsResponse;
2915    /// use google_cloud_bigquery::model::RowError;
2916    /// let x = AppendRowsResponse::new()
2917    ///     .set_row_errors([
2918    ///         RowError::default()/* use setters */,
2919    ///         RowError::default()/* use (different) setters */,
2920    ///     ]);
2921    /// ```
2922    pub fn set_row_errors<T, V>(mut self, v: T) -> Self
2923    where
2924        T: std::iter::IntoIterator<Item = V>,
2925        V: std::convert::Into<crate::write::generated::gapic_storage::model::RowError>,
2926    {
2927        use std::iter::Iterator;
2928        self.row_errors = v.into_iter().map(|i| i.into()).collect();
2929        self
2930    }
2931
2932    /// Sets the value of [write_stream][crate::write::generated::gapic_storage::model::AppendRowsResponse::write_stream].
2933    ///
2934    /// # Example
2935    /// ```ignore,no_run
2936    /// # use google_cloud_bigquery::model::AppendRowsResponse;
2937    /// let x = AppendRowsResponse::new().set_write_stream("example");
2938    /// ```
2939    pub fn set_write_stream<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2940        self.write_stream = v.into();
2941        self
2942    }
2943
2944    /// Sets the value of [response][crate::write::generated::gapic_storage::model::AppendRowsResponse::response].
2945    ///
2946    /// Note that all the setters affecting `response` are mutually
2947    /// exclusive.
2948    ///
2949    /// # Example
2950    /// ```ignore,no_run
2951    /// # use google_cloud_bigquery::model::AppendRowsResponse;
2952    /// use google_cloud_bigquery::model::append_rows_response::AppendResult;
2953    /// let x = AppendRowsResponse::new().set_response(Some(
2954    ///     google_cloud_bigquery::model::append_rows_response::Response::AppendResult(AppendResult::default().into())));
2955    /// ```
2956    pub fn set_response<
2957        T: std::convert::Into<
2958                std::option::Option<
2959                    crate::write::generated::gapic_storage::model::append_rows_response::Response,
2960                >,
2961            >,
2962    >(
2963        mut self,
2964        v: T,
2965    ) -> Self {
2966        self.response = v.into();
2967        self
2968    }
2969
2970    /// The value of [response][crate::write::generated::gapic_storage::model::AppendRowsResponse::response]
2971    /// if it holds a `AppendResult`, `None` if the field is not set or
2972    /// holds a different branch.
2973    pub fn append_result(
2974        &self,
2975    ) -> std::option::Option<
2976        &std::boxed::Box<
2977            crate::write::generated::gapic_storage::model::append_rows_response::AppendResult,
2978        >,
2979    > {
2980        #[allow(unreachable_patterns)]
2981        self.response.as_ref().and_then(|v| match v {
2982            crate::write::generated::gapic_storage::model::append_rows_response::Response::AppendResult(v) => std::option::Option::Some(v),
2983            _ => std::option::Option::None,
2984        })
2985    }
2986
2987    /// Sets the value of [response][crate::write::generated::gapic_storage::model::AppendRowsResponse::response]
2988    /// to hold a `AppendResult`.
2989    ///
2990    /// Note that all the setters affecting `response` are
2991    /// mutually exclusive.
2992    ///
2993    /// # Example
2994    /// ```ignore,no_run
2995    /// # use google_cloud_bigquery::model::AppendRowsResponse;
2996    /// use google_cloud_bigquery::model::append_rows_response::AppendResult;
2997    /// let x = AppendRowsResponse::new().set_append_result(AppendResult::default()/* use setters */);
2998    /// assert!(x.append_result().is_some());
2999    /// assert!(x.error().is_none());
3000    /// ```
3001    pub fn set_append_result<T: std::convert::Into<std::boxed::Box<crate::write::generated::gapic_storage::model::append_rows_response::AppendResult>>>(mut self, v: T) -> Self{
3002        self.response = std::option::Option::Some(
3003            crate::write::generated::gapic_storage::model::append_rows_response::Response::AppendResult(
3004                v.into()
3005            )
3006        );
3007        self
3008    }
3009
3010    /// The value of [response][crate::write::generated::gapic_storage::model::AppendRowsResponse::response]
3011    /// if it holds a `Error`, `None` if the field is not set or
3012    /// holds a different branch.
3013    pub fn error(&self) -> std::option::Option<&std::boxed::Box<google_cloud_rpc::model::Status>> {
3014        #[allow(unreachable_patterns)]
3015        self.response.as_ref().and_then(|v| match v {
3016            crate::write::generated::gapic_storage::model::append_rows_response::Response::Error(v) => std::option::Option::Some(v),
3017            _ => std::option::Option::None,
3018        })
3019    }
3020
3021    /// Sets the value of [response][crate::write::generated::gapic_storage::model::AppendRowsResponse::response]
3022    /// to hold a `Error`.
3023    ///
3024    /// Note that all the setters affecting `response` are
3025    /// mutually exclusive.
3026    ///
3027    /// # Example
3028    /// ```ignore,no_run
3029    /// # use google_cloud_bigquery::model::AppendRowsResponse;
3030    /// use google_cloud_rpc::model::Status;
3031    /// let x = AppendRowsResponse::new().set_error(Status::default()/* use setters */);
3032    /// assert!(x.error().is_some());
3033    /// assert!(x.append_result().is_none());
3034    /// ```
3035    pub fn set_error<T: std::convert::Into<std::boxed::Box<google_cloud_rpc::model::Status>>>(
3036        mut self,
3037        v: T,
3038    ) -> Self {
3039        self.response = std::option::Option::Some(
3040            crate::write::generated::gapic_storage::model::append_rows_response::Response::Error(
3041                v.into(),
3042            ),
3043        );
3044        self
3045    }
3046}
3047
3048impl wkt::message::Message for AppendRowsResponse {
3049    fn typename() -> &'static str {
3050        "type.googleapis.com/google.cloud.bigquery.storage.v1.AppendRowsResponse"
3051    }
3052}
3053
3054/// Defines additional types related to [AppendRowsResponse].
3055pub mod append_rows_response {
3056    #[allow(unused_imports)]
3057    use super::*;
3058
3059    /// AppendResult is returned for successful append requests.
3060    #[derive(Clone, Default, PartialEq)]
3061    #[non_exhaustive]
3062    pub struct AppendResult {
3063        /// The row offset at which the last append occurred. The offset will not be
3064        /// set if appending using default streams.
3065        pub offset: std::option::Option<wkt::Int64Value>,
3066
3067        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3068    }
3069
3070    impl AppendResult {
3071        /// Creates a new default instance.
3072        pub fn new() -> Self {
3073            std::default::Default::default()
3074        }
3075
3076        /// Sets the value of [offset][crate::write::generated::gapic_storage::model::append_rows_response::AppendResult::offset].
3077        ///
3078        /// # Example
3079        /// ```ignore,no_run
3080        /// # use google_cloud_bigquery::model::append_rows_response::AppendResult;
3081        /// use wkt::Int64Value;
3082        /// let x = AppendResult::new().set_offset(Int64Value::default()/* use setters */);
3083        /// ```
3084        pub fn set_offset<T>(mut self, v: T) -> Self
3085        where
3086            T: std::convert::Into<wkt::Int64Value>,
3087        {
3088            self.offset = std::option::Option::Some(v.into());
3089            self
3090        }
3091
3092        /// Sets or clears the value of [offset][crate::write::generated::gapic_storage::model::append_rows_response::AppendResult::offset].
3093        ///
3094        /// # Example
3095        /// ```ignore,no_run
3096        /// # use google_cloud_bigquery::model::append_rows_response::AppendResult;
3097        /// use wkt::Int64Value;
3098        /// let x = AppendResult::new().set_or_clear_offset(Some(Int64Value::default()/* use setters */));
3099        /// let x = AppendResult::new().set_or_clear_offset(None::<Int64Value>);
3100        /// ```
3101        pub fn set_or_clear_offset<T>(mut self, v: std::option::Option<T>) -> Self
3102        where
3103            T: std::convert::Into<wkt::Int64Value>,
3104        {
3105            self.offset = v.map(|x| x.into());
3106            self
3107        }
3108    }
3109
3110    impl wkt::message::Message for AppendResult {
3111        fn typename() -> &'static str {
3112            "type.googleapis.com/google.cloud.bigquery.storage.v1.AppendRowsResponse.AppendResult"
3113        }
3114    }
3115
3116    #[allow(missing_docs)]
3117    #[derive(Clone, Debug, PartialEq)]
3118    #[non_exhaustive]
3119    pub enum Response {
3120        /// Result if the append is successful.
3121        AppendResult(
3122            std::boxed::Box<
3123                crate::write::generated::gapic_storage::model::append_rows_response::AppendResult,
3124            >,
3125        ),
3126        /// Error returned when problems were encountered.  If present,
3127        /// it indicates rows were not accepted into the system.
3128        /// Users can retry or continue with other append requests within the
3129        /// same connection.
3130        ///
3131        /// Additional information about error signalling:
3132        ///
3133        /// ALREADY_EXISTS: Happens when an append specified an offset, and the
3134        /// backend already has received data at this offset.  Typically encountered
3135        /// in retry scenarios, and can be ignored.
3136        ///
3137        /// OUT_OF_RANGE: Returned when the specified offset in the stream is beyond
3138        /// the current end of the stream.
3139        ///
3140        /// INVALID_ARGUMENT: Indicates a malformed request or data.
3141        ///
3142        /// ABORTED: Request processing is aborted because of prior failures.  The
3143        /// request can be retried if previous failure is addressed.
3144        ///
3145        /// INTERNAL: Indicates server side error(s) that can be retried.
3146        Error(std::boxed::Box<google_cloud_rpc::model::Status>),
3147    }
3148
3149    impl Response {
3150        /// Initializes the enum to the [AppendResult](Self::AppendResult) branch.
3151        pub fn from_append_result(
3152            value: impl std::convert::Into<std::boxed::Box<crate::write::generated::gapic_storage::model::append_rows_response::AppendResult>>,
3153        ) -> Self {
3154            Self::AppendResult(value.into())
3155        }
3156        /// Initializes the enum to the [Error](Self::Error) branch.
3157        pub fn from_error(
3158            value: impl std::convert::Into<std::boxed::Box<google_cloud_rpc::model::Status>>,
3159        ) -> Self {
3160            Self::Error(value.into())
3161        }
3162    }
3163}
3164
3165/// Request message for `GetWriteStreamRequest`.
3166#[derive(Clone, Default, PartialEq)]
3167#[non_exhaustive]
3168pub struct GetWriteStreamRequest {
3169    /// Required. Name of the stream to get, in the form of
3170    /// `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
3171    pub name: std::string::String,
3172
3173    /// Indicates whether to get full or partial view of the WriteStream. If
3174    /// not set, view returned will be basic.
3175    pub view: crate::write::generated::gapic_storage::model::WriteStreamView,
3176
3177    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3178}
3179
3180impl GetWriteStreamRequest {
3181    /// Creates a new default instance.
3182    pub fn new() -> Self {
3183        std::default::Default::default()
3184    }
3185
3186    /// Sets the value of [name][crate::write::generated::gapic_storage::model::GetWriteStreamRequest::name].
3187    ///
3188    /// # Example
3189    /// ```ignore,no_run
3190    /// # use google_cloud_bigquery::model::GetWriteStreamRequest;
3191    /// # let project_id = "project_id";
3192    /// # let dataset_id = "dataset_id";
3193    /// # let table_id = "table_id";
3194    /// # let stream_id = "stream_id";
3195    /// let x = GetWriteStreamRequest::new().set_name(format!("projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/streams/{stream_id}"));
3196    /// ```
3197    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3198        self.name = v.into();
3199        self
3200    }
3201
3202    /// Sets the value of [view][crate::write::generated::gapic_storage::model::GetWriteStreamRequest::view].
3203    ///
3204    /// # Example
3205    /// ```ignore,no_run
3206    /// # use google_cloud_bigquery::model::GetWriteStreamRequest;
3207    /// use google_cloud_bigquery::model::WriteStreamView;
3208    /// let x0 = GetWriteStreamRequest::new().set_view(WriteStreamView::Basic);
3209    /// let x1 = GetWriteStreamRequest::new().set_view(WriteStreamView::Full);
3210    /// ```
3211    pub fn set_view<
3212        T: std::convert::Into<crate::write::generated::gapic_storage::model::WriteStreamView>,
3213    >(
3214        mut self,
3215        v: T,
3216    ) -> Self {
3217        self.view = v.into();
3218        self
3219    }
3220}
3221
3222impl wkt::message::Message for GetWriteStreamRequest {
3223    fn typename() -> &'static str {
3224        "type.googleapis.com/google.cloud.bigquery.storage.v1.GetWriteStreamRequest"
3225    }
3226}
3227
3228/// Request message for `BatchCommitWriteStreams`.
3229#[derive(Clone, Default, PartialEq)]
3230#[non_exhaustive]
3231pub struct BatchCommitWriteStreamsRequest {
3232    /// Required. Parent table that all the streams should belong to, in the form
3233    /// of `projects/{project}/datasets/{dataset}/tables/{table}`.
3234    pub parent: std::string::String,
3235
3236    /// Required. The group of streams that will be committed atomically.
3237    pub write_streams: std::vec::Vec<std::string::String>,
3238
3239    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3240}
3241
3242impl BatchCommitWriteStreamsRequest {
3243    /// Creates a new default instance.
3244    pub fn new() -> Self {
3245        std::default::Default::default()
3246    }
3247
3248    /// Sets the value of [parent][crate::write::generated::gapic_storage::model::BatchCommitWriteStreamsRequest::parent].
3249    ///
3250    /// # Example
3251    /// ```ignore,no_run
3252    /// # use google_cloud_bigquery::model::BatchCommitWriteStreamsRequest;
3253    /// let x = BatchCommitWriteStreamsRequest::new().set_parent("example");
3254    /// ```
3255    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3256        self.parent = v.into();
3257        self
3258    }
3259
3260    /// Sets the value of [write_streams][crate::write::generated::gapic_storage::model::BatchCommitWriteStreamsRequest::write_streams].
3261    ///
3262    /// # Example
3263    /// ```ignore,no_run
3264    /// # use google_cloud_bigquery::model::BatchCommitWriteStreamsRequest;
3265    /// let x = BatchCommitWriteStreamsRequest::new().set_write_streams(["a", "b", "c"]);
3266    /// ```
3267    pub fn set_write_streams<T, V>(mut self, v: T) -> Self
3268    where
3269        T: std::iter::IntoIterator<Item = V>,
3270        V: std::convert::Into<std::string::String>,
3271    {
3272        use std::iter::Iterator;
3273        self.write_streams = v.into_iter().map(|i| i.into()).collect();
3274        self
3275    }
3276}
3277
3278impl wkt::message::Message for BatchCommitWriteStreamsRequest {
3279    fn typename() -> &'static str {
3280        "type.googleapis.com/google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsRequest"
3281    }
3282}
3283
3284/// Response message for `BatchCommitWriteStreams`.
3285#[derive(Clone, Default, PartialEq)]
3286#[non_exhaustive]
3287pub struct BatchCommitWriteStreamsResponse {
3288    /// The time at which streams were committed in microseconds granularity.
3289    /// This field will only exist when there are no stream errors.
3290    /// **Note** if this field is not set, it means the commit was not successful.
3291    pub commit_time: std::option::Option<wkt::Timestamp>,
3292
3293    /// Stream level error if commit failed. Only streams with error will be in
3294    /// the list.
3295    /// If empty, there is no error and all streams are committed successfully.
3296    /// If non empty, certain streams have errors and ZERO stream is committed due
3297    /// to atomicity guarantee.
3298    pub stream_errors: std::vec::Vec<crate::write::generated::gapic_storage::model::StorageError>,
3299
3300    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3301}
3302
3303impl BatchCommitWriteStreamsResponse {
3304    /// Creates a new default instance.
3305    pub fn new() -> Self {
3306        std::default::Default::default()
3307    }
3308
3309    /// Sets the value of [commit_time][crate::write::generated::gapic_storage::model::BatchCommitWriteStreamsResponse::commit_time].
3310    ///
3311    /// # Example
3312    /// ```ignore,no_run
3313    /// # use google_cloud_bigquery::model::BatchCommitWriteStreamsResponse;
3314    /// use wkt::Timestamp;
3315    /// let x = BatchCommitWriteStreamsResponse::new().set_commit_time(Timestamp::default()/* use setters */);
3316    /// ```
3317    pub fn set_commit_time<T>(mut self, v: T) -> Self
3318    where
3319        T: std::convert::Into<wkt::Timestamp>,
3320    {
3321        self.commit_time = std::option::Option::Some(v.into());
3322        self
3323    }
3324
3325    /// Sets or clears the value of [commit_time][crate::write::generated::gapic_storage::model::BatchCommitWriteStreamsResponse::commit_time].
3326    ///
3327    /// # Example
3328    /// ```ignore,no_run
3329    /// # use google_cloud_bigquery::model::BatchCommitWriteStreamsResponse;
3330    /// use wkt::Timestamp;
3331    /// let x = BatchCommitWriteStreamsResponse::new().set_or_clear_commit_time(Some(Timestamp::default()/* use setters */));
3332    /// let x = BatchCommitWriteStreamsResponse::new().set_or_clear_commit_time(None::<Timestamp>);
3333    /// ```
3334    pub fn set_or_clear_commit_time<T>(mut self, v: std::option::Option<T>) -> Self
3335    where
3336        T: std::convert::Into<wkt::Timestamp>,
3337    {
3338        self.commit_time = v.map(|x| x.into());
3339        self
3340    }
3341
3342    /// Sets the value of [stream_errors][crate::write::generated::gapic_storage::model::BatchCommitWriteStreamsResponse::stream_errors].
3343    ///
3344    /// # Example
3345    /// ```ignore,no_run
3346    /// # use google_cloud_bigquery::model::BatchCommitWriteStreamsResponse;
3347    /// use google_cloud_bigquery::model::StorageError;
3348    /// let x = BatchCommitWriteStreamsResponse::new()
3349    ///     .set_stream_errors([
3350    ///         StorageError::default()/* use setters */,
3351    ///         StorageError::default()/* use (different) setters */,
3352    ///     ]);
3353    /// ```
3354    pub fn set_stream_errors<T, V>(mut self, v: T) -> Self
3355    where
3356        T: std::iter::IntoIterator<Item = V>,
3357        V: std::convert::Into<crate::write::generated::gapic_storage::model::StorageError>,
3358    {
3359        use std::iter::Iterator;
3360        self.stream_errors = v.into_iter().map(|i| i.into()).collect();
3361        self
3362    }
3363}
3364
3365impl wkt::message::Message for BatchCommitWriteStreamsResponse {
3366    fn typename() -> &'static str {
3367        "type.googleapis.com/google.cloud.bigquery.storage.v1.BatchCommitWriteStreamsResponse"
3368    }
3369}
3370
3371/// Request message for invoking `FinalizeWriteStream`.
3372#[derive(Clone, Default, PartialEq)]
3373#[non_exhaustive]
3374pub struct FinalizeWriteStreamRequest {
3375    /// Required. Name of the stream to finalize, in the form of
3376    /// `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
3377    pub name: std::string::String,
3378
3379    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3380}
3381
3382impl FinalizeWriteStreamRequest {
3383    /// Creates a new default instance.
3384    pub fn new() -> Self {
3385        std::default::Default::default()
3386    }
3387
3388    /// Sets the value of [name][crate::write::generated::gapic_storage::model::FinalizeWriteStreamRequest::name].
3389    ///
3390    /// # Example
3391    /// ```ignore,no_run
3392    /// # use google_cloud_bigquery::model::FinalizeWriteStreamRequest;
3393    /// # let project_id = "project_id";
3394    /// # let dataset_id = "dataset_id";
3395    /// # let table_id = "table_id";
3396    /// # let stream_id = "stream_id";
3397    /// let x = FinalizeWriteStreamRequest::new().set_name(format!("projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/streams/{stream_id}"));
3398    /// ```
3399    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3400        self.name = v.into();
3401        self
3402    }
3403}
3404
3405impl wkt::message::Message for FinalizeWriteStreamRequest {
3406    fn typename() -> &'static str {
3407        "type.googleapis.com/google.cloud.bigquery.storage.v1.FinalizeWriteStreamRequest"
3408    }
3409}
3410
3411/// Response message for `FinalizeWriteStream`.
3412#[derive(Clone, Default, PartialEq)]
3413#[non_exhaustive]
3414pub struct FinalizeWriteStreamResponse {
3415    /// Number of rows in the finalized stream.
3416    pub row_count: i64,
3417
3418    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3419}
3420
3421impl FinalizeWriteStreamResponse {
3422    /// Creates a new default instance.
3423    pub fn new() -> Self {
3424        std::default::Default::default()
3425    }
3426
3427    /// Sets the value of [row_count][crate::write::generated::gapic_storage::model::FinalizeWriteStreamResponse::row_count].
3428    ///
3429    /// # Example
3430    /// ```ignore,no_run
3431    /// # use google_cloud_bigquery::model::FinalizeWriteStreamResponse;
3432    /// let x = FinalizeWriteStreamResponse::new().set_row_count(42);
3433    /// ```
3434    pub fn set_row_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3435        self.row_count = v.into();
3436        self
3437    }
3438}
3439
3440impl wkt::message::Message for FinalizeWriteStreamResponse {
3441    fn typename() -> &'static str {
3442        "type.googleapis.com/google.cloud.bigquery.storage.v1.FinalizeWriteStreamResponse"
3443    }
3444}
3445
3446/// Request message for `FlushRows`.
3447#[derive(Clone, Default, PartialEq)]
3448#[non_exhaustive]
3449pub struct FlushRowsRequest {
3450    /// Required. The stream that is the target of the flush operation.
3451    pub write_stream: std::string::String,
3452
3453    /// Ending offset of the flush operation. Rows before this offset(including
3454    /// this offset) will be flushed.
3455    pub offset: std::option::Option<wkt::Int64Value>,
3456
3457    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3458}
3459
3460impl FlushRowsRequest {
3461    /// Creates a new default instance.
3462    pub fn new() -> Self {
3463        std::default::Default::default()
3464    }
3465
3466    /// Sets the value of [write_stream][crate::write::generated::gapic_storage::model::FlushRowsRequest::write_stream].
3467    ///
3468    /// # Example
3469    /// ```ignore,no_run
3470    /// # use google_cloud_bigquery::model::FlushRowsRequest;
3471    /// # let project_id = "project_id";
3472    /// # let dataset_id = "dataset_id";
3473    /// # let table_id = "table_id";
3474    /// # let stream_id = "stream_id";
3475    /// let x = FlushRowsRequest::new().set_write_stream(format!("projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/streams/{stream_id}"));
3476    /// ```
3477    pub fn set_write_stream<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3478        self.write_stream = v.into();
3479        self
3480    }
3481
3482    /// Sets the value of [offset][crate::write::generated::gapic_storage::model::FlushRowsRequest::offset].
3483    ///
3484    /// # Example
3485    /// ```ignore,no_run
3486    /// # use google_cloud_bigquery::model::FlushRowsRequest;
3487    /// use wkt::Int64Value;
3488    /// let x = FlushRowsRequest::new().set_offset(Int64Value::default()/* use setters */);
3489    /// ```
3490    pub fn set_offset<T>(mut self, v: T) -> Self
3491    where
3492        T: std::convert::Into<wkt::Int64Value>,
3493    {
3494        self.offset = std::option::Option::Some(v.into());
3495        self
3496    }
3497
3498    /// Sets or clears the value of [offset][crate::write::generated::gapic_storage::model::FlushRowsRequest::offset].
3499    ///
3500    /// # Example
3501    /// ```ignore,no_run
3502    /// # use google_cloud_bigquery::model::FlushRowsRequest;
3503    /// use wkt::Int64Value;
3504    /// let x = FlushRowsRequest::new().set_or_clear_offset(Some(Int64Value::default()/* use setters */));
3505    /// let x = FlushRowsRequest::new().set_or_clear_offset(None::<Int64Value>);
3506    /// ```
3507    pub fn set_or_clear_offset<T>(mut self, v: std::option::Option<T>) -> Self
3508    where
3509        T: std::convert::Into<wkt::Int64Value>,
3510    {
3511        self.offset = v.map(|x| x.into());
3512        self
3513    }
3514}
3515
3516impl wkt::message::Message for FlushRowsRequest {
3517    fn typename() -> &'static str {
3518        "type.googleapis.com/google.cloud.bigquery.storage.v1.FlushRowsRequest"
3519    }
3520}
3521
3522/// Respond message for `FlushRows`.
3523#[derive(Clone, Default, PartialEq)]
3524#[non_exhaustive]
3525pub struct FlushRowsResponse {
3526    /// The rows before this offset (including this offset) are flushed.
3527    pub offset: i64,
3528
3529    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3530}
3531
3532impl FlushRowsResponse {
3533    /// Creates a new default instance.
3534    pub fn new() -> Self {
3535        std::default::Default::default()
3536    }
3537
3538    /// Sets the value of [offset][crate::write::generated::gapic_storage::model::FlushRowsResponse::offset].
3539    ///
3540    /// # Example
3541    /// ```ignore,no_run
3542    /// # use google_cloud_bigquery::model::FlushRowsResponse;
3543    /// let x = FlushRowsResponse::new().set_offset(42);
3544    /// ```
3545    pub fn set_offset<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3546        self.offset = v.into();
3547        self
3548    }
3549}
3550
3551impl wkt::message::Message for FlushRowsResponse {
3552    fn typename() -> &'static str {
3553        "type.googleapis.com/google.cloud.bigquery.storage.v1.FlushRowsResponse"
3554    }
3555}
3556
3557/// Structured custom BigQuery Storage error message. The error can be attached
3558/// as error details in the returned rpc Status. In particular, the use of error
3559/// codes allows more structured error handling, and reduces the need to evaluate
3560/// unstructured error text strings.
3561#[derive(Clone, Default, PartialEq)]
3562#[non_exhaustive]
3563pub struct StorageError {
3564    /// BigQuery Storage specific error code.
3565    pub code: crate::write::generated::gapic_storage::model::storage_error::StorageErrorCode,
3566
3567    /// Name of the failed entity.
3568    pub entity: std::string::String,
3569
3570    /// Message that describes the error.
3571    pub error_message: std::string::String,
3572
3573    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3574}
3575
3576impl StorageError {
3577    /// Creates a new default instance.
3578    pub fn new() -> Self {
3579        std::default::Default::default()
3580    }
3581
3582    /// Sets the value of [code][crate::write::generated::gapic_storage::model::StorageError::code].
3583    ///
3584    /// # Example
3585    /// ```ignore,no_run
3586    /// # use google_cloud_bigquery::model::StorageError;
3587    /// use google_cloud_bigquery::model::storage_error::StorageErrorCode;
3588    /// let x0 = StorageError::new().set_code(StorageErrorCode::TableNotFound);
3589    /// let x1 = StorageError::new().set_code(StorageErrorCode::StreamAlreadyCommitted);
3590    /// let x2 = StorageError::new().set_code(StorageErrorCode::StreamNotFound);
3591    /// ```
3592    pub fn set_code<
3593        T: std::convert::Into<
3594                crate::write::generated::gapic_storage::model::storage_error::StorageErrorCode,
3595            >,
3596    >(
3597        mut self,
3598        v: T,
3599    ) -> Self {
3600        self.code = v.into();
3601        self
3602    }
3603
3604    /// Sets the value of [entity][crate::write::generated::gapic_storage::model::StorageError::entity].
3605    ///
3606    /// # Example
3607    /// ```ignore,no_run
3608    /// # use google_cloud_bigquery::model::StorageError;
3609    /// let x = StorageError::new().set_entity("example");
3610    /// ```
3611    pub fn set_entity<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3612        self.entity = v.into();
3613        self
3614    }
3615
3616    /// Sets the value of [error_message][crate::write::generated::gapic_storage::model::StorageError::error_message].
3617    ///
3618    /// # Example
3619    /// ```ignore,no_run
3620    /// # use google_cloud_bigquery::model::StorageError;
3621    /// let x = StorageError::new().set_error_message("example");
3622    /// ```
3623    pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3624        self.error_message = v.into();
3625        self
3626    }
3627}
3628
3629impl wkt::message::Message for StorageError {
3630    fn typename() -> &'static str {
3631        "type.googleapis.com/google.cloud.bigquery.storage.v1.StorageError"
3632    }
3633}
3634
3635/// Defines additional types related to [StorageError].
3636pub mod storage_error {
3637    #[allow(unused_imports)]
3638    use super::*;
3639
3640    /// Error code for `StorageError`.
3641    ///
3642    /// # Working with unknown values
3643    ///
3644    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3645    /// additional enum variants at any time. Adding new variants is not considered
3646    /// a breaking change. Applications should write their code in anticipation of:
3647    ///
3648    /// - New values appearing in future releases of the client library, **and**
3649    /// - New values received dynamically, without application changes.
3650    ///
3651    /// Please consult the [Working with enums] section in the user guide for some
3652    /// guidelines.
3653    ///
3654    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3655    #[derive(Clone, Debug, PartialEq)]
3656    #[non_exhaustive]
3657    pub enum StorageErrorCode {
3658        /// Default error.
3659        Unspecified,
3660        /// Table is not found in the system.
3661        TableNotFound,
3662        /// Stream is already committed.
3663        StreamAlreadyCommitted,
3664        /// Stream is not found.
3665        StreamNotFound,
3666        /// Invalid Stream type.
3667        /// For example, you try to commit a stream that is not pending.
3668        InvalidStreamType,
3669        /// Invalid Stream state.
3670        /// For example, you try to commit a stream that is not finalized or is
3671        /// garbaged.
3672        InvalidStreamState,
3673        /// Stream is finalized.
3674        StreamFinalized,
3675        /// There is a schema mismatch and it is caused by user schema has extra
3676        /// field than bigquery schema.
3677        SchemaMismatchExtraFields,
3678        /// Offset already exists.
3679        OffsetAlreadyExists,
3680        /// Offset out of range.
3681        OffsetOutOfRange,
3682        /// Customer-managed encryption key (CMEK) not provided for CMEK-enabled
3683        /// data.
3684        CmekNotProvided,
3685        /// Customer-managed encryption key (CMEK) was incorrectly provided.
3686        InvalidCmekProvided,
3687        /// There is an encryption error while using customer-managed encryption key.
3688        CmekEncryptionError,
3689        /// Key Management Service (KMS) service returned an error, which can be
3690        /// retried.
3691        KmsServiceError,
3692        /// Permission denied while using customer-managed encryption key.
3693        KmsPermissionDenied,
3694        /// If set, the enum was initialized with an unknown value.
3695        ///
3696        /// Applications can examine the value using [StorageErrorCode::value] or
3697        /// [StorageErrorCode::name].
3698        UnknownValue(storage_error_code::UnknownValue),
3699    }
3700
3701    #[doc(hidden)]
3702    pub mod storage_error_code {
3703        #[allow(unused_imports)]
3704        use super::*;
3705        #[derive(Clone, Debug, PartialEq)]
3706        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3707    }
3708
3709    impl StorageErrorCode {
3710        /// Gets the enum value.
3711        ///
3712        /// Returns `None` if the enum contains an unknown value deserialized from
3713        /// the string representation of enums.
3714        pub fn value(&self) -> std::option::Option<i32> {
3715            match self {
3716                Self::Unspecified => std::option::Option::Some(0),
3717                Self::TableNotFound => std::option::Option::Some(1),
3718                Self::StreamAlreadyCommitted => std::option::Option::Some(2),
3719                Self::StreamNotFound => std::option::Option::Some(3),
3720                Self::InvalidStreamType => std::option::Option::Some(4),
3721                Self::InvalidStreamState => std::option::Option::Some(5),
3722                Self::StreamFinalized => std::option::Option::Some(6),
3723                Self::SchemaMismatchExtraFields => std::option::Option::Some(7),
3724                Self::OffsetAlreadyExists => std::option::Option::Some(8),
3725                Self::OffsetOutOfRange => std::option::Option::Some(9),
3726                Self::CmekNotProvided => std::option::Option::Some(10),
3727                Self::InvalidCmekProvided => std::option::Option::Some(11),
3728                Self::CmekEncryptionError => std::option::Option::Some(12),
3729                Self::KmsServiceError => std::option::Option::Some(13),
3730                Self::KmsPermissionDenied => std::option::Option::Some(14),
3731                Self::UnknownValue(u) => u.0.value(),
3732            }
3733        }
3734
3735        /// Gets the enum value as a string.
3736        ///
3737        /// Returns `None` if the enum contains an unknown value deserialized from
3738        /// the integer representation of enums.
3739        pub fn name(&self) -> std::option::Option<&str> {
3740            match self {
3741                Self::Unspecified => std::option::Option::Some("STORAGE_ERROR_CODE_UNSPECIFIED"),
3742                Self::TableNotFound => std::option::Option::Some("TABLE_NOT_FOUND"),
3743                Self::StreamAlreadyCommitted => {
3744                    std::option::Option::Some("STREAM_ALREADY_COMMITTED")
3745                }
3746                Self::StreamNotFound => std::option::Option::Some("STREAM_NOT_FOUND"),
3747                Self::InvalidStreamType => std::option::Option::Some("INVALID_STREAM_TYPE"),
3748                Self::InvalidStreamState => std::option::Option::Some("INVALID_STREAM_STATE"),
3749                Self::StreamFinalized => std::option::Option::Some("STREAM_FINALIZED"),
3750                Self::SchemaMismatchExtraFields => {
3751                    std::option::Option::Some("SCHEMA_MISMATCH_EXTRA_FIELDS")
3752                }
3753                Self::OffsetAlreadyExists => std::option::Option::Some("OFFSET_ALREADY_EXISTS"),
3754                Self::OffsetOutOfRange => std::option::Option::Some("OFFSET_OUT_OF_RANGE"),
3755                Self::CmekNotProvided => std::option::Option::Some("CMEK_NOT_PROVIDED"),
3756                Self::InvalidCmekProvided => std::option::Option::Some("INVALID_CMEK_PROVIDED"),
3757                Self::CmekEncryptionError => std::option::Option::Some("CMEK_ENCRYPTION_ERROR"),
3758                Self::KmsServiceError => std::option::Option::Some("KMS_SERVICE_ERROR"),
3759                Self::KmsPermissionDenied => std::option::Option::Some("KMS_PERMISSION_DENIED"),
3760                Self::UnknownValue(u) => u.0.name(),
3761            }
3762        }
3763    }
3764
3765    impl std::default::Default for StorageErrorCode {
3766        fn default() -> Self {
3767            use std::convert::From;
3768            Self::from(0)
3769        }
3770    }
3771
3772    impl std::fmt::Display for StorageErrorCode {
3773        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3774            wkt::internal::display_enum(f, self.name(), self.value())
3775        }
3776    }
3777
3778    impl std::convert::From<i32> for StorageErrorCode {
3779        fn from(value: i32) -> Self {
3780            match value {
3781                0 => Self::Unspecified,
3782                1 => Self::TableNotFound,
3783                2 => Self::StreamAlreadyCommitted,
3784                3 => Self::StreamNotFound,
3785                4 => Self::InvalidStreamType,
3786                5 => Self::InvalidStreamState,
3787                6 => Self::StreamFinalized,
3788                7 => Self::SchemaMismatchExtraFields,
3789                8 => Self::OffsetAlreadyExists,
3790                9 => Self::OffsetOutOfRange,
3791                10 => Self::CmekNotProvided,
3792                11 => Self::InvalidCmekProvided,
3793                12 => Self::CmekEncryptionError,
3794                13 => Self::KmsServiceError,
3795                14 => Self::KmsPermissionDenied,
3796                _ => Self::UnknownValue(storage_error_code::UnknownValue(
3797                    wkt::internal::UnknownEnumValue::Integer(value),
3798                )),
3799            }
3800        }
3801    }
3802
3803    impl std::convert::From<&str> for StorageErrorCode {
3804        fn from(value: &str) -> Self {
3805            use std::string::ToString;
3806            match value {
3807                "STORAGE_ERROR_CODE_UNSPECIFIED" => Self::Unspecified,
3808                "TABLE_NOT_FOUND" => Self::TableNotFound,
3809                "STREAM_ALREADY_COMMITTED" => Self::StreamAlreadyCommitted,
3810                "STREAM_NOT_FOUND" => Self::StreamNotFound,
3811                "INVALID_STREAM_TYPE" => Self::InvalidStreamType,
3812                "INVALID_STREAM_STATE" => Self::InvalidStreamState,
3813                "STREAM_FINALIZED" => Self::StreamFinalized,
3814                "SCHEMA_MISMATCH_EXTRA_FIELDS" => Self::SchemaMismatchExtraFields,
3815                "OFFSET_ALREADY_EXISTS" => Self::OffsetAlreadyExists,
3816                "OFFSET_OUT_OF_RANGE" => Self::OffsetOutOfRange,
3817                "CMEK_NOT_PROVIDED" => Self::CmekNotProvided,
3818                "INVALID_CMEK_PROVIDED" => Self::InvalidCmekProvided,
3819                "CMEK_ENCRYPTION_ERROR" => Self::CmekEncryptionError,
3820                "KMS_SERVICE_ERROR" => Self::KmsServiceError,
3821                "KMS_PERMISSION_DENIED" => Self::KmsPermissionDenied,
3822                _ => Self::UnknownValue(storage_error_code::UnknownValue(
3823                    wkt::internal::UnknownEnumValue::String(value.to_string()),
3824                )),
3825            }
3826        }
3827    }
3828
3829    impl serde::ser::Serialize for StorageErrorCode {
3830        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3831        where
3832            S: serde::Serializer,
3833        {
3834            match self {
3835                Self::Unspecified => serializer.serialize_i32(0),
3836                Self::TableNotFound => serializer.serialize_i32(1),
3837                Self::StreamAlreadyCommitted => serializer.serialize_i32(2),
3838                Self::StreamNotFound => serializer.serialize_i32(3),
3839                Self::InvalidStreamType => serializer.serialize_i32(4),
3840                Self::InvalidStreamState => serializer.serialize_i32(5),
3841                Self::StreamFinalized => serializer.serialize_i32(6),
3842                Self::SchemaMismatchExtraFields => serializer.serialize_i32(7),
3843                Self::OffsetAlreadyExists => serializer.serialize_i32(8),
3844                Self::OffsetOutOfRange => serializer.serialize_i32(9),
3845                Self::CmekNotProvided => serializer.serialize_i32(10),
3846                Self::InvalidCmekProvided => serializer.serialize_i32(11),
3847                Self::CmekEncryptionError => serializer.serialize_i32(12),
3848                Self::KmsServiceError => serializer.serialize_i32(13),
3849                Self::KmsPermissionDenied => serializer.serialize_i32(14),
3850                Self::UnknownValue(u) => u.0.serialize(serializer),
3851            }
3852        }
3853    }
3854
3855    impl<'de> serde::de::Deserialize<'de> for StorageErrorCode {
3856        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3857        where
3858            D: serde::Deserializer<'de>,
3859        {
3860            deserializer.deserialize_any(wkt::internal::EnumVisitor::<StorageErrorCode>::new(
3861                ".google.cloud.bigquery.storage.v1.StorageError.StorageErrorCode",
3862            ))
3863        }
3864    }
3865}
3866
3867/// The message that presents row level error info in a request.
3868#[derive(Clone, Default, PartialEq)]
3869#[non_exhaustive]
3870pub struct RowError {
3871    /// Index of the malformed row in the request.
3872    pub index: i64,
3873
3874    /// Structured error reason for a row error.
3875    pub code: crate::write::generated::gapic_storage::model::row_error::RowErrorCode,
3876
3877    /// Description of the issue encountered when processing the row.
3878    pub message: std::string::String,
3879
3880    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3881}
3882
3883impl RowError {
3884    /// Creates a new default instance.
3885    pub fn new() -> Self {
3886        std::default::Default::default()
3887    }
3888
3889    /// Sets the value of [index][crate::write::generated::gapic_storage::model::RowError::index].
3890    ///
3891    /// # Example
3892    /// ```ignore,no_run
3893    /// # use google_cloud_bigquery::model::RowError;
3894    /// let x = RowError::new().set_index(42);
3895    /// ```
3896    pub fn set_index<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3897        self.index = v.into();
3898        self
3899    }
3900
3901    /// Sets the value of [code][crate::write::generated::gapic_storage::model::RowError::code].
3902    ///
3903    /// # Example
3904    /// ```ignore,no_run
3905    /// # use google_cloud_bigquery::model::RowError;
3906    /// use google_cloud_bigquery::model::row_error::RowErrorCode;
3907    /// let x0 = RowError::new().set_code(RowErrorCode::FieldsError);
3908    /// ```
3909    pub fn set_code<
3910        T: std::convert::Into<crate::write::generated::gapic_storage::model::row_error::RowErrorCode>,
3911    >(
3912        mut self,
3913        v: T,
3914    ) -> Self {
3915        self.code = v.into();
3916        self
3917    }
3918
3919    /// Sets the value of [message][crate::write::generated::gapic_storage::model::RowError::message].
3920    ///
3921    /// # Example
3922    /// ```ignore,no_run
3923    /// # use google_cloud_bigquery::model::RowError;
3924    /// let x = RowError::new().set_message("example");
3925    /// ```
3926    pub fn set_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3927        self.message = v.into();
3928        self
3929    }
3930}
3931
3932impl wkt::message::Message for RowError {
3933    fn typename() -> &'static str {
3934        "type.googleapis.com/google.cloud.bigquery.storage.v1.RowError"
3935    }
3936}
3937
3938/// Defines additional types related to [RowError].
3939pub mod row_error {
3940    #[allow(unused_imports)]
3941    use super::*;
3942
3943    /// Error code for `RowError`.
3944    ///
3945    /// # Working with unknown values
3946    ///
3947    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3948    /// additional enum variants at any time. Adding new variants is not considered
3949    /// a breaking change. Applications should write their code in anticipation of:
3950    ///
3951    /// - New values appearing in future releases of the client library, **and**
3952    /// - New values received dynamically, without application changes.
3953    ///
3954    /// Please consult the [Working with enums] section in the user guide for some
3955    /// guidelines.
3956    ///
3957    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3958    #[derive(Clone, Debug, PartialEq)]
3959    #[non_exhaustive]
3960    pub enum RowErrorCode {
3961        /// Default error.
3962        Unspecified,
3963        /// One or more fields in the row has errors.
3964        FieldsError,
3965        /// If set, the enum was initialized with an unknown value.
3966        ///
3967        /// Applications can examine the value using [RowErrorCode::value] or
3968        /// [RowErrorCode::name].
3969        UnknownValue(row_error_code::UnknownValue),
3970    }
3971
3972    #[doc(hidden)]
3973    pub mod row_error_code {
3974        #[allow(unused_imports)]
3975        use super::*;
3976        #[derive(Clone, Debug, PartialEq)]
3977        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3978    }
3979
3980    impl RowErrorCode {
3981        /// Gets the enum value.
3982        ///
3983        /// Returns `None` if the enum contains an unknown value deserialized from
3984        /// the string representation of enums.
3985        pub fn value(&self) -> std::option::Option<i32> {
3986            match self {
3987                Self::Unspecified => std::option::Option::Some(0),
3988                Self::FieldsError => std::option::Option::Some(1),
3989                Self::UnknownValue(u) => u.0.value(),
3990            }
3991        }
3992
3993        /// Gets the enum value as a string.
3994        ///
3995        /// Returns `None` if the enum contains an unknown value deserialized from
3996        /// the integer representation of enums.
3997        pub fn name(&self) -> std::option::Option<&str> {
3998            match self {
3999                Self::Unspecified => std::option::Option::Some("ROW_ERROR_CODE_UNSPECIFIED"),
4000                Self::FieldsError => std::option::Option::Some("FIELDS_ERROR"),
4001                Self::UnknownValue(u) => u.0.name(),
4002            }
4003        }
4004    }
4005
4006    impl std::default::Default for RowErrorCode {
4007        fn default() -> Self {
4008            use std::convert::From;
4009            Self::from(0)
4010        }
4011    }
4012
4013    impl std::fmt::Display for RowErrorCode {
4014        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4015            wkt::internal::display_enum(f, self.name(), self.value())
4016        }
4017    }
4018
4019    impl std::convert::From<i32> for RowErrorCode {
4020        fn from(value: i32) -> Self {
4021            match value {
4022                0 => Self::Unspecified,
4023                1 => Self::FieldsError,
4024                _ => Self::UnknownValue(row_error_code::UnknownValue(
4025                    wkt::internal::UnknownEnumValue::Integer(value),
4026                )),
4027            }
4028        }
4029    }
4030
4031    impl std::convert::From<&str> for RowErrorCode {
4032        fn from(value: &str) -> Self {
4033            use std::string::ToString;
4034            match value {
4035                "ROW_ERROR_CODE_UNSPECIFIED" => Self::Unspecified,
4036                "FIELDS_ERROR" => Self::FieldsError,
4037                _ => Self::UnknownValue(row_error_code::UnknownValue(
4038                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4039                )),
4040            }
4041        }
4042    }
4043
4044    impl serde::ser::Serialize for RowErrorCode {
4045        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4046        where
4047            S: serde::Serializer,
4048        {
4049            match self {
4050                Self::Unspecified => serializer.serialize_i32(0),
4051                Self::FieldsError => serializer.serialize_i32(1),
4052                Self::UnknownValue(u) => u.0.serialize(serializer),
4053            }
4054        }
4055    }
4056
4057    impl<'de> serde::de::Deserialize<'de> for RowErrorCode {
4058        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4059        where
4060            D: serde::Deserializer<'de>,
4061        {
4062            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RowErrorCode>::new(
4063                ".google.cloud.bigquery.storage.v1.RowError.RowErrorCode",
4064            ))
4065        }
4066    }
4067}
4068
4069/// Stats and telemetry data gathered on the client side about requests
4070/// being sent to the BigQuery Storage service, for internal use only.
4071#[derive(Clone, Default, PartialEq)]
4072#[non_exhaustive]
4073pub struct ClientStats {
4074    /// Optional. Per-request stats.
4075    pub request_stats: std::option::Option<
4076        crate::write::generated::gapic_storage::model::client_stats::RequestStats,
4077    >,
4078
4079    /// Optional. Windowed stats.
4080    pub window_stats: std::option::Option<
4081        crate::write::generated::gapic_storage::model::client_stats::WindowStats,
4082    >,
4083
4084    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4085}
4086
4087impl ClientStats {
4088    /// Creates a new default instance.
4089    pub fn new() -> Self {
4090        std::default::Default::default()
4091    }
4092
4093    /// Sets the value of [request_stats][crate::write::generated::gapic_storage::model::ClientStats::request_stats].
4094    ///
4095    /// # Example
4096    /// ```ignore,no_run
4097    /// # use google_cloud_bigquery::model::ClientStats;
4098    /// use google_cloud_bigquery::model::client_stats::RequestStats;
4099    /// let x = ClientStats::new().set_request_stats(RequestStats::default()/* use setters */);
4100    /// ```
4101    pub fn set_request_stats<T>(mut self, v: T) -> Self
4102    where
4103        T: std::convert::Into<
4104                crate::write::generated::gapic_storage::model::client_stats::RequestStats,
4105            >,
4106    {
4107        self.request_stats = std::option::Option::Some(v.into());
4108        self
4109    }
4110
4111    /// Sets or clears the value of [request_stats][crate::write::generated::gapic_storage::model::ClientStats::request_stats].
4112    ///
4113    /// # Example
4114    /// ```ignore,no_run
4115    /// # use google_cloud_bigquery::model::ClientStats;
4116    /// use google_cloud_bigquery::model::client_stats::RequestStats;
4117    /// let x = ClientStats::new().set_or_clear_request_stats(Some(RequestStats::default()/* use setters */));
4118    /// let x = ClientStats::new().set_or_clear_request_stats(None::<RequestStats>);
4119    /// ```
4120    pub fn set_or_clear_request_stats<T>(mut self, v: std::option::Option<T>) -> Self
4121    where
4122        T: std::convert::Into<
4123                crate::write::generated::gapic_storage::model::client_stats::RequestStats,
4124            >,
4125    {
4126        self.request_stats = v.map(|x| x.into());
4127        self
4128    }
4129
4130    /// Sets the value of [window_stats][crate::write::generated::gapic_storage::model::ClientStats::window_stats].
4131    ///
4132    /// # Example
4133    /// ```ignore,no_run
4134    /// # use google_cloud_bigquery::model::ClientStats;
4135    /// use google_cloud_bigquery::model::client_stats::WindowStats;
4136    /// let x = ClientStats::new().set_window_stats(WindowStats::default()/* use setters */);
4137    /// ```
4138    pub fn set_window_stats<T>(mut self, v: T) -> Self
4139    where
4140        T: std::convert::Into<
4141                crate::write::generated::gapic_storage::model::client_stats::WindowStats,
4142            >,
4143    {
4144        self.window_stats = std::option::Option::Some(v.into());
4145        self
4146    }
4147
4148    /// Sets or clears the value of [window_stats][crate::write::generated::gapic_storage::model::ClientStats::window_stats].
4149    ///
4150    /// # Example
4151    /// ```ignore,no_run
4152    /// # use google_cloud_bigquery::model::ClientStats;
4153    /// use google_cloud_bigquery::model::client_stats::WindowStats;
4154    /// let x = ClientStats::new().set_or_clear_window_stats(Some(WindowStats::default()/* use setters */));
4155    /// let x = ClientStats::new().set_or_clear_window_stats(None::<WindowStats>);
4156    /// ```
4157    pub fn set_or_clear_window_stats<T>(mut self, v: std::option::Option<T>) -> Self
4158    where
4159        T: std::convert::Into<
4160                crate::write::generated::gapic_storage::model::client_stats::WindowStats,
4161            >,
4162    {
4163        self.window_stats = v.map(|x| x.into());
4164        self
4165    }
4166}
4167
4168impl wkt::message::Message for ClientStats {
4169    fn typename() -> &'static str {
4170        "type.googleapis.com/google.cloud.bigquery.storage.v1.ClientStats"
4171    }
4172}
4173
4174/// Defines additional types related to [ClientStats].
4175pub mod client_stats {
4176    #[allow(unused_imports)]
4177    use super::*;
4178
4179    /// Stats and telemetry data gathered on the client side about a single
4180    /// request.
4181    #[derive(Clone, Default, PartialEq)]
4182    #[non_exhaustive]
4183    pub struct RequestStats {
4184        /// Optional. Timestamp indicating when the request was sent over the
4185        /// network, expressed in epoch milliseconds.
4186        pub send_time_millis: std::option::Option<i64>,
4187
4188        /// Optional. Number of pending requests at the moment this request was sent.
4189        /// This includes requests waiting to be sent, and those that are inflight.
4190        pub queued_requests_count: std::option::Option<i64>,
4191
4192        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4193    }
4194
4195    impl RequestStats {
4196        /// Creates a new default instance.
4197        pub fn new() -> Self {
4198            std::default::Default::default()
4199        }
4200
4201        /// Sets the value of [send_time_millis][crate::write::generated::gapic_storage::model::client_stats::RequestStats::send_time_millis].
4202        ///
4203        /// # Example
4204        /// ```ignore,no_run
4205        /// # use google_cloud_bigquery::model::client_stats::RequestStats;
4206        /// let x = RequestStats::new().set_send_time_millis(42);
4207        /// ```
4208        pub fn set_send_time_millis<T>(mut self, v: T) -> Self
4209        where
4210            T: std::convert::Into<i64>,
4211        {
4212            self.send_time_millis = std::option::Option::Some(v.into());
4213            self
4214        }
4215
4216        /// Sets or clears the value of [send_time_millis][crate::write::generated::gapic_storage::model::client_stats::RequestStats::send_time_millis].
4217        ///
4218        /// # Example
4219        /// ```ignore,no_run
4220        /// # use google_cloud_bigquery::model::client_stats::RequestStats;
4221        /// let x = RequestStats::new().set_or_clear_send_time_millis(Some(42));
4222        /// let x = RequestStats::new().set_or_clear_send_time_millis(None::<i32>);
4223        /// ```
4224        pub fn set_or_clear_send_time_millis<T>(mut self, v: std::option::Option<T>) -> Self
4225        where
4226            T: std::convert::Into<i64>,
4227        {
4228            self.send_time_millis = v.map(|x| x.into());
4229            self
4230        }
4231
4232        /// Sets the value of [queued_requests_count][crate::write::generated::gapic_storage::model::client_stats::RequestStats::queued_requests_count].
4233        ///
4234        /// # Example
4235        /// ```ignore,no_run
4236        /// # use google_cloud_bigquery::model::client_stats::RequestStats;
4237        /// let x = RequestStats::new().set_queued_requests_count(42);
4238        /// ```
4239        pub fn set_queued_requests_count<T>(mut self, v: T) -> Self
4240        where
4241            T: std::convert::Into<i64>,
4242        {
4243            self.queued_requests_count = std::option::Option::Some(v.into());
4244            self
4245        }
4246
4247        /// Sets or clears the value of [queued_requests_count][crate::write::generated::gapic_storage::model::client_stats::RequestStats::queued_requests_count].
4248        ///
4249        /// # Example
4250        /// ```ignore,no_run
4251        /// # use google_cloud_bigquery::model::client_stats::RequestStats;
4252        /// let x = RequestStats::new().set_or_clear_queued_requests_count(Some(42));
4253        /// let x = RequestStats::new().set_or_clear_queued_requests_count(None::<i32>);
4254        /// ```
4255        pub fn set_or_clear_queued_requests_count<T>(mut self, v: std::option::Option<T>) -> Self
4256        where
4257            T: std::convert::Into<i64>,
4258        {
4259            self.queued_requests_count = v.map(|x| x.into());
4260            self
4261        }
4262    }
4263
4264    impl wkt::message::Message for RequestStats {
4265        fn typename() -> &'static str {
4266            "type.googleapis.com/google.cloud.bigquery.storage.v1.ClientStats.RequestStats"
4267        }
4268    }
4269
4270    /// Aggregate connection metrics over a window interval.
4271    #[derive(Clone, Default, PartialEq)]
4272    #[non_exhaustive]
4273    pub struct WindowStats {
4274        /// Optional. The maximum response latency observed in the window, expressed
4275        /// in milliseconds.
4276        pub max_response_latency_millis: std::option::Option<i64>,
4277
4278        /// Optional. The average response latency observed in the window, expressed
4279        /// in milliseconds.
4280        pub avg_response_latency_millis: std::option::Option<i64>,
4281
4282        /// Optional. The longest time spent waiting without receiving a response in
4283        /// the window. This could exceed max_response_latency_millis because the
4284        /// latter is evaluated only when a response is received. Expressed in
4285        /// milliseconds.
4286        pub longest_wait_no_response_millis: std::option::Option<i64>,
4287
4288        /// Optional. How many requests were sent in the window.
4289        pub requests_sent_count: std::option::Option<i64>,
4290
4291        /// Optional. How many responses were received in the window.
4292        pub responses_received_count: std::option::Option<i64>,
4293
4294        /// Optional. How many bytes were sent in the window.
4295        pub bytes_sent_count: std::option::Option<i64>,
4296
4297        /// Optional. Start time of the window interval for which these stats are
4298        /// aggregated, expressed in epoch milliseconds.
4299        pub window_start_time_epoch_millis: std::option::Option<i64>,
4300
4301        /// Optional. Duration of the window interval for which these stats are
4302        /// aggregated, expressed in milliseconds.
4303        pub window_millis: std::option::Option<i64>,
4304
4305        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4306    }
4307
4308    impl WindowStats {
4309        /// Creates a new default instance.
4310        pub fn new() -> Self {
4311            std::default::Default::default()
4312        }
4313
4314        /// Sets the value of [max_response_latency_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::max_response_latency_millis].
4315        ///
4316        /// # Example
4317        /// ```ignore,no_run
4318        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4319        /// let x = WindowStats::new().set_max_response_latency_millis(42);
4320        /// ```
4321        pub fn set_max_response_latency_millis<T>(mut self, v: T) -> Self
4322        where
4323            T: std::convert::Into<i64>,
4324        {
4325            self.max_response_latency_millis = std::option::Option::Some(v.into());
4326            self
4327        }
4328
4329        /// Sets or clears the value of [max_response_latency_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::max_response_latency_millis].
4330        ///
4331        /// # Example
4332        /// ```ignore,no_run
4333        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4334        /// let x = WindowStats::new().set_or_clear_max_response_latency_millis(Some(42));
4335        /// let x = WindowStats::new().set_or_clear_max_response_latency_millis(None::<i32>);
4336        /// ```
4337        pub fn set_or_clear_max_response_latency_millis<T>(
4338            mut self,
4339            v: std::option::Option<T>,
4340        ) -> Self
4341        where
4342            T: std::convert::Into<i64>,
4343        {
4344            self.max_response_latency_millis = v.map(|x| x.into());
4345            self
4346        }
4347
4348        /// Sets the value of [avg_response_latency_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::avg_response_latency_millis].
4349        ///
4350        /// # Example
4351        /// ```ignore,no_run
4352        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4353        /// let x = WindowStats::new().set_avg_response_latency_millis(42);
4354        /// ```
4355        pub fn set_avg_response_latency_millis<T>(mut self, v: T) -> Self
4356        where
4357            T: std::convert::Into<i64>,
4358        {
4359            self.avg_response_latency_millis = std::option::Option::Some(v.into());
4360            self
4361        }
4362
4363        /// Sets or clears the value of [avg_response_latency_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::avg_response_latency_millis].
4364        ///
4365        /// # Example
4366        /// ```ignore,no_run
4367        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4368        /// let x = WindowStats::new().set_or_clear_avg_response_latency_millis(Some(42));
4369        /// let x = WindowStats::new().set_or_clear_avg_response_latency_millis(None::<i32>);
4370        /// ```
4371        pub fn set_or_clear_avg_response_latency_millis<T>(
4372            mut self,
4373            v: std::option::Option<T>,
4374        ) -> Self
4375        where
4376            T: std::convert::Into<i64>,
4377        {
4378            self.avg_response_latency_millis = v.map(|x| x.into());
4379            self
4380        }
4381
4382        /// Sets the value of [longest_wait_no_response_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::longest_wait_no_response_millis].
4383        ///
4384        /// # Example
4385        /// ```ignore,no_run
4386        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4387        /// let x = WindowStats::new().set_longest_wait_no_response_millis(42);
4388        /// ```
4389        pub fn set_longest_wait_no_response_millis<T>(mut self, v: T) -> Self
4390        where
4391            T: std::convert::Into<i64>,
4392        {
4393            self.longest_wait_no_response_millis = std::option::Option::Some(v.into());
4394            self
4395        }
4396
4397        /// Sets or clears the value of [longest_wait_no_response_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::longest_wait_no_response_millis].
4398        ///
4399        /// # Example
4400        /// ```ignore,no_run
4401        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4402        /// let x = WindowStats::new().set_or_clear_longest_wait_no_response_millis(Some(42));
4403        /// let x = WindowStats::new().set_or_clear_longest_wait_no_response_millis(None::<i32>);
4404        /// ```
4405        pub fn set_or_clear_longest_wait_no_response_millis<T>(
4406            mut self,
4407            v: std::option::Option<T>,
4408        ) -> Self
4409        where
4410            T: std::convert::Into<i64>,
4411        {
4412            self.longest_wait_no_response_millis = v.map(|x| x.into());
4413            self
4414        }
4415
4416        /// Sets the value of [requests_sent_count][crate::write::generated::gapic_storage::model::client_stats::WindowStats::requests_sent_count].
4417        ///
4418        /// # Example
4419        /// ```ignore,no_run
4420        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4421        /// let x = WindowStats::new().set_requests_sent_count(42);
4422        /// ```
4423        pub fn set_requests_sent_count<T>(mut self, v: T) -> Self
4424        where
4425            T: std::convert::Into<i64>,
4426        {
4427            self.requests_sent_count = std::option::Option::Some(v.into());
4428            self
4429        }
4430
4431        /// Sets or clears the value of [requests_sent_count][crate::write::generated::gapic_storage::model::client_stats::WindowStats::requests_sent_count].
4432        ///
4433        /// # Example
4434        /// ```ignore,no_run
4435        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4436        /// let x = WindowStats::new().set_or_clear_requests_sent_count(Some(42));
4437        /// let x = WindowStats::new().set_or_clear_requests_sent_count(None::<i32>);
4438        /// ```
4439        pub fn set_or_clear_requests_sent_count<T>(mut self, v: std::option::Option<T>) -> Self
4440        where
4441            T: std::convert::Into<i64>,
4442        {
4443            self.requests_sent_count = v.map(|x| x.into());
4444            self
4445        }
4446
4447        /// Sets the value of [responses_received_count][crate::write::generated::gapic_storage::model::client_stats::WindowStats::responses_received_count].
4448        ///
4449        /// # Example
4450        /// ```ignore,no_run
4451        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4452        /// let x = WindowStats::new().set_responses_received_count(42);
4453        /// ```
4454        pub fn set_responses_received_count<T>(mut self, v: T) -> Self
4455        where
4456            T: std::convert::Into<i64>,
4457        {
4458            self.responses_received_count = std::option::Option::Some(v.into());
4459            self
4460        }
4461
4462        /// Sets or clears the value of [responses_received_count][crate::write::generated::gapic_storage::model::client_stats::WindowStats::responses_received_count].
4463        ///
4464        /// # Example
4465        /// ```ignore,no_run
4466        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4467        /// let x = WindowStats::new().set_or_clear_responses_received_count(Some(42));
4468        /// let x = WindowStats::new().set_or_clear_responses_received_count(None::<i32>);
4469        /// ```
4470        pub fn set_or_clear_responses_received_count<T>(mut self, v: std::option::Option<T>) -> Self
4471        where
4472            T: std::convert::Into<i64>,
4473        {
4474            self.responses_received_count = v.map(|x| x.into());
4475            self
4476        }
4477
4478        /// Sets the value of [bytes_sent_count][crate::write::generated::gapic_storage::model::client_stats::WindowStats::bytes_sent_count].
4479        ///
4480        /// # Example
4481        /// ```ignore,no_run
4482        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4483        /// let x = WindowStats::new().set_bytes_sent_count(42);
4484        /// ```
4485        pub fn set_bytes_sent_count<T>(mut self, v: T) -> Self
4486        where
4487            T: std::convert::Into<i64>,
4488        {
4489            self.bytes_sent_count = std::option::Option::Some(v.into());
4490            self
4491        }
4492
4493        /// Sets or clears the value of [bytes_sent_count][crate::write::generated::gapic_storage::model::client_stats::WindowStats::bytes_sent_count].
4494        ///
4495        /// # Example
4496        /// ```ignore,no_run
4497        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4498        /// let x = WindowStats::new().set_or_clear_bytes_sent_count(Some(42));
4499        /// let x = WindowStats::new().set_or_clear_bytes_sent_count(None::<i32>);
4500        /// ```
4501        pub fn set_or_clear_bytes_sent_count<T>(mut self, v: std::option::Option<T>) -> Self
4502        where
4503            T: std::convert::Into<i64>,
4504        {
4505            self.bytes_sent_count = v.map(|x| x.into());
4506            self
4507        }
4508
4509        /// Sets the value of [window_start_time_epoch_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::window_start_time_epoch_millis].
4510        ///
4511        /// # Example
4512        /// ```ignore,no_run
4513        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4514        /// let x = WindowStats::new().set_window_start_time_epoch_millis(42);
4515        /// ```
4516        pub fn set_window_start_time_epoch_millis<T>(mut self, v: T) -> Self
4517        where
4518            T: std::convert::Into<i64>,
4519        {
4520            self.window_start_time_epoch_millis = std::option::Option::Some(v.into());
4521            self
4522        }
4523
4524        /// Sets or clears the value of [window_start_time_epoch_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::window_start_time_epoch_millis].
4525        ///
4526        /// # Example
4527        /// ```ignore,no_run
4528        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4529        /// let x = WindowStats::new().set_or_clear_window_start_time_epoch_millis(Some(42));
4530        /// let x = WindowStats::new().set_or_clear_window_start_time_epoch_millis(None::<i32>);
4531        /// ```
4532        pub fn set_or_clear_window_start_time_epoch_millis<T>(
4533            mut self,
4534            v: std::option::Option<T>,
4535        ) -> Self
4536        where
4537            T: std::convert::Into<i64>,
4538        {
4539            self.window_start_time_epoch_millis = v.map(|x| x.into());
4540            self
4541        }
4542
4543        /// Sets the value of [window_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::window_millis].
4544        ///
4545        /// # Example
4546        /// ```ignore,no_run
4547        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4548        /// let x = WindowStats::new().set_window_millis(42);
4549        /// ```
4550        pub fn set_window_millis<T>(mut self, v: T) -> Self
4551        where
4552            T: std::convert::Into<i64>,
4553        {
4554            self.window_millis = std::option::Option::Some(v.into());
4555            self
4556        }
4557
4558        /// Sets or clears the value of [window_millis][crate::write::generated::gapic_storage::model::client_stats::WindowStats::window_millis].
4559        ///
4560        /// # Example
4561        /// ```ignore,no_run
4562        /// # use google_cloud_bigquery::model::client_stats::WindowStats;
4563        /// let x = WindowStats::new().set_or_clear_window_millis(Some(42));
4564        /// let x = WindowStats::new().set_or_clear_window_millis(None::<i32>);
4565        /// ```
4566        pub fn set_or_clear_window_millis<T>(mut self, v: std::option::Option<T>) -> Self
4567        where
4568            T: std::convert::Into<i64>,
4569        {
4570            self.window_millis = v.map(|x| x.into());
4571            self
4572        }
4573    }
4574
4575    impl wkt::message::Message for WindowStats {
4576        fn typename() -> &'static str {
4577            "type.googleapis.com/google.cloud.bigquery.storage.v1.ClientStats.WindowStats"
4578        }
4579    }
4580}
4581
4582/// Information about the ReadSession.
4583#[derive(Clone, Default, PartialEq)]
4584#[non_exhaustive]
4585pub struct ReadSession {
4586    /// Output only. Unique identifier for the session, in the form
4587    /// `projects/{project_id}/locations/{location}/sessions/{session_id}`.
4588    pub name: std::string::String,
4589
4590    /// Output only. Time at which the session becomes invalid. After this time,
4591    /// subsequent requests to read this Session will return errors. The
4592    /// expire_time is automatically assigned and currently cannot be specified or
4593    /// updated.
4594    pub expire_time: std::option::Option<wkt::Timestamp>,
4595
4596    /// Immutable. Data format of the output data. DATA_FORMAT_UNSPECIFIED not
4597    /// supported.
4598    pub data_format: crate::write::generated::gapic_storage::model::DataFormat,
4599
4600    /// Immutable. Table that this ReadSession is reading from, in the form
4601    /// `projects/{project_id}/datasets/{dataset_id}/tables/{table_id}`
4602    pub table: std::string::String,
4603
4604    /// Optional. Any modifiers which are applied when reading from the specified
4605    /// table.
4606    pub table_modifiers: std::option::Option<
4607        crate::write::generated::gapic_storage::model::read_session::TableModifiers,
4608    >,
4609
4610    /// Optional. Read options for this session (e.g. column selection, filters).
4611    pub read_options: std::option::Option<
4612        crate::write::generated::gapic_storage::model::read_session::TableReadOptions,
4613    >,
4614
4615    /// Output only. A list of streams created with the session.
4616    ///
4617    /// At least one stream is created with the session. In the future, larger
4618    /// request_stream_count values *may* result in this list being unpopulated,
4619    /// in that case, the user will need to use a List method to get the streams
4620    /// instead, which is not yet available.
4621    pub streams: std::vec::Vec<crate::write::generated::gapic_storage::model::ReadStream>,
4622
4623    /// Output only. An estimate on the number of bytes this session will scan when
4624    /// all streams are completely consumed. This estimate is based on
4625    /// metadata from the table which might be incomplete or stale.
4626    pub estimated_total_bytes_scanned: i64,
4627
4628    /// Output only. A pre-projected estimate of the total physical size of files
4629    /// (in bytes) that this session will scan when all streams are consumed. This
4630    /// estimate is independent of the selected columns and can be based on
4631    /// incomplete or stale metadata from the table.  This field is only set for
4632    /// BigLake tables.
4633    pub estimated_total_physical_file_size: i64,
4634
4635    /// Output only. An estimate on the number of rows present in this session's
4636    /// streams. This estimate is based on metadata from the table which might be
4637    /// incomplete or stale.
4638    pub estimated_row_count: i64,
4639
4640    /// Optional. ID set by client to annotate a session identity.  This does not
4641    /// need to be strictly unique, but instead the same ID should be used to group
4642    /// logically connected sessions (e.g. All using the same ID for all sessions
4643    /// needed to complete a Spark SQL query is reasonable).
4644    ///
4645    /// Maximum length is 256 bytes.
4646    pub trace_id: std::string::String,
4647
4648    /// The schema for the read. If read_options.selected_fields is set, the
4649    /// schema may be different from the table schema as it will only contain
4650    /// the selected fields.
4651    pub schema:
4652        std::option::Option<crate::write::generated::gapic_storage::model::read_session::Schema>,
4653
4654    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4655}
4656
4657impl ReadSession {
4658    /// Creates a new default instance.
4659    pub fn new() -> Self {
4660        std::default::Default::default()
4661    }
4662
4663    /// Sets the value of [name][crate::write::generated::gapic_storage::model::ReadSession::name].
4664    ///
4665    /// # Example
4666    /// ```ignore,no_run
4667    /// # use google_cloud_bigquery::model::ReadSession;
4668    /// # let project_id = "project_id";
4669    /// # let location_id = "location_id";
4670    /// # let session_id = "session_id";
4671    /// let x = ReadSession::new().set_name(format!("projects/{project_id}/locations/{location_id}/sessions/{session_id}"));
4672    /// ```
4673    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4674        self.name = v.into();
4675        self
4676    }
4677
4678    /// Sets the value of [expire_time][crate::write::generated::gapic_storage::model::ReadSession::expire_time].
4679    ///
4680    /// # Example
4681    /// ```ignore,no_run
4682    /// # use google_cloud_bigquery::model::ReadSession;
4683    /// use wkt::Timestamp;
4684    /// let x = ReadSession::new().set_expire_time(Timestamp::default()/* use setters */);
4685    /// ```
4686    pub fn set_expire_time<T>(mut self, v: T) -> Self
4687    where
4688        T: std::convert::Into<wkt::Timestamp>,
4689    {
4690        self.expire_time = std::option::Option::Some(v.into());
4691        self
4692    }
4693
4694    /// Sets or clears the value of [expire_time][crate::write::generated::gapic_storage::model::ReadSession::expire_time].
4695    ///
4696    /// # Example
4697    /// ```ignore,no_run
4698    /// # use google_cloud_bigquery::model::ReadSession;
4699    /// use wkt::Timestamp;
4700    /// let x = ReadSession::new().set_or_clear_expire_time(Some(Timestamp::default()/* use setters */));
4701    /// let x = ReadSession::new().set_or_clear_expire_time(None::<Timestamp>);
4702    /// ```
4703    pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
4704    where
4705        T: std::convert::Into<wkt::Timestamp>,
4706    {
4707        self.expire_time = v.map(|x| x.into());
4708        self
4709    }
4710
4711    /// Sets the value of [data_format][crate::write::generated::gapic_storage::model::ReadSession::data_format].
4712    ///
4713    /// # Example
4714    /// ```ignore,no_run
4715    /// # use google_cloud_bigquery::model::ReadSession;
4716    /// use google_cloud_bigquery::model::DataFormat;
4717    /// let x0 = ReadSession::new().set_data_format(DataFormat::Avro);
4718    /// let x1 = ReadSession::new().set_data_format(DataFormat::Arrow);
4719    /// ```
4720    pub fn set_data_format<
4721        T: std::convert::Into<crate::write::generated::gapic_storage::model::DataFormat>,
4722    >(
4723        mut self,
4724        v: T,
4725    ) -> Self {
4726        self.data_format = v.into();
4727        self
4728    }
4729
4730    /// Sets the value of [table][crate::write::generated::gapic_storage::model::ReadSession::table].
4731    ///
4732    /// # Example
4733    /// ```ignore,no_run
4734    /// # use google_cloud_bigquery::model::ReadSession;
4735    /// let x = ReadSession::new().set_table("example");
4736    /// ```
4737    pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4738        self.table = v.into();
4739        self
4740    }
4741
4742    /// Sets the value of [table_modifiers][crate::write::generated::gapic_storage::model::ReadSession::table_modifiers].
4743    ///
4744    /// # Example
4745    /// ```ignore,no_run
4746    /// # use google_cloud_bigquery::model::ReadSession;
4747    /// use google_cloud_bigquery::model::read_session::TableModifiers;
4748    /// let x = ReadSession::new().set_table_modifiers(TableModifiers::default()/* use setters */);
4749    /// ```
4750    pub fn set_table_modifiers<T>(mut self, v: T) -> Self
4751    where
4752        T: std::convert::Into<
4753                crate::write::generated::gapic_storage::model::read_session::TableModifiers,
4754            >,
4755    {
4756        self.table_modifiers = std::option::Option::Some(v.into());
4757        self
4758    }
4759
4760    /// Sets or clears the value of [table_modifiers][crate::write::generated::gapic_storage::model::ReadSession::table_modifiers].
4761    ///
4762    /// # Example
4763    /// ```ignore,no_run
4764    /// # use google_cloud_bigquery::model::ReadSession;
4765    /// use google_cloud_bigquery::model::read_session::TableModifiers;
4766    /// let x = ReadSession::new().set_or_clear_table_modifiers(Some(TableModifiers::default()/* use setters */));
4767    /// let x = ReadSession::new().set_or_clear_table_modifiers(None::<TableModifiers>);
4768    /// ```
4769    pub fn set_or_clear_table_modifiers<T>(mut self, v: std::option::Option<T>) -> Self
4770    where
4771        T: std::convert::Into<
4772                crate::write::generated::gapic_storage::model::read_session::TableModifiers,
4773            >,
4774    {
4775        self.table_modifiers = v.map(|x| x.into());
4776        self
4777    }
4778
4779    /// Sets the value of [read_options][crate::write::generated::gapic_storage::model::ReadSession::read_options].
4780    ///
4781    /// # Example
4782    /// ```ignore,no_run
4783    /// # use google_cloud_bigquery::model::ReadSession;
4784    /// use google_cloud_bigquery::model::read_session::TableReadOptions;
4785    /// let x = ReadSession::new().set_read_options(TableReadOptions::default()/* use setters */);
4786    /// ```
4787    pub fn set_read_options<T>(mut self, v: T) -> Self
4788    where
4789        T: std::convert::Into<
4790                crate::write::generated::gapic_storage::model::read_session::TableReadOptions,
4791            >,
4792    {
4793        self.read_options = std::option::Option::Some(v.into());
4794        self
4795    }
4796
4797    /// Sets or clears the value of [read_options][crate::write::generated::gapic_storage::model::ReadSession::read_options].
4798    ///
4799    /// # Example
4800    /// ```ignore,no_run
4801    /// # use google_cloud_bigquery::model::ReadSession;
4802    /// use google_cloud_bigquery::model::read_session::TableReadOptions;
4803    /// let x = ReadSession::new().set_or_clear_read_options(Some(TableReadOptions::default()/* use setters */));
4804    /// let x = ReadSession::new().set_or_clear_read_options(None::<TableReadOptions>);
4805    /// ```
4806    pub fn set_or_clear_read_options<T>(mut self, v: std::option::Option<T>) -> Self
4807    where
4808        T: std::convert::Into<
4809                crate::write::generated::gapic_storage::model::read_session::TableReadOptions,
4810            >,
4811    {
4812        self.read_options = v.map(|x| x.into());
4813        self
4814    }
4815
4816    /// Sets the value of [streams][crate::write::generated::gapic_storage::model::ReadSession::streams].
4817    ///
4818    /// # Example
4819    /// ```ignore,no_run
4820    /// # use google_cloud_bigquery::model::ReadSession;
4821    /// use google_cloud_bigquery::model::ReadStream;
4822    /// let x = ReadSession::new()
4823    ///     .set_streams([
4824    ///         ReadStream::default()/* use setters */,
4825    ///         ReadStream::default()/* use (different) setters */,
4826    ///     ]);
4827    /// ```
4828    pub fn set_streams<T, V>(mut self, v: T) -> Self
4829    where
4830        T: std::iter::IntoIterator<Item = V>,
4831        V: std::convert::Into<crate::write::generated::gapic_storage::model::ReadStream>,
4832    {
4833        use std::iter::Iterator;
4834        self.streams = v.into_iter().map(|i| i.into()).collect();
4835        self
4836    }
4837
4838    /// Sets the value of [estimated_total_bytes_scanned][crate::write::generated::gapic_storage::model::ReadSession::estimated_total_bytes_scanned].
4839    ///
4840    /// # Example
4841    /// ```ignore,no_run
4842    /// # use google_cloud_bigquery::model::ReadSession;
4843    /// let x = ReadSession::new().set_estimated_total_bytes_scanned(42);
4844    /// ```
4845    pub fn set_estimated_total_bytes_scanned<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4846        self.estimated_total_bytes_scanned = v.into();
4847        self
4848    }
4849
4850    /// Sets the value of [estimated_total_physical_file_size][crate::write::generated::gapic_storage::model::ReadSession::estimated_total_physical_file_size].
4851    ///
4852    /// # Example
4853    /// ```ignore,no_run
4854    /// # use google_cloud_bigquery::model::ReadSession;
4855    /// let x = ReadSession::new().set_estimated_total_physical_file_size(42);
4856    /// ```
4857    pub fn set_estimated_total_physical_file_size<T: std::convert::Into<i64>>(
4858        mut self,
4859        v: T,
4860    ) -> Self {
4861        self.estimated_total_physical_file_size = v.into();
4862        self
4863    }
4864
4865    /// Sets the value of [estimated_row_count][crate::write::generated::gapic_storage::model::ReadSession::estimated_row_count].
4866    ///
4867    /// # Example
4868    /// ```ignore,no_run
4869    /// # use google_cloud_bigquery::model::ReadSession;
4870    /// let x = ReadSession::new().set_estimated_row_count(42);
4871    /// ```
4872    pub fn set_estimated_row_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
4873        self.estimated_row_count = v.into();
4874        self
4875    }
4876
4877    /// Sets the value of [trace_id][crate::write::generated::gapic_storage::model::ReadSession::trace_id].
4878    ///
4879    /// # Example
4880    /// ```ignore,no_run
4881    /// # use google_cloud_bigquery::model::ReadSession;
4882    /// let x = ReadSession::new().set_trace_id("example");
4883    /// ```
4884    pub fn set_trace_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4885        self.trace_id = v.into();
4886        self
4887    }
4888
4889    /// Sets the value of [schema][crate::write::generated::gapic_storage::model::ReadSession::schema].
4890    ///
4891    /// Note that all the setters affecting `schema` are mutually
4892    /// exclusive.
4893    ///
4894    /// # Example
4895    /// ```ignore,no_run
4896    /// # use google_cloud_bigquery::model::ReadSession;
4897    /// use google_cloud_bigquery::model::AvroSchema;
4898    /// let x = ReadSession::new().set_schema(Some(
4899    ///     google_cloud_bigquery::model::read_session::Schema::AvroSchema(AvroSchema::default().into())));
4900    /// ```
4901    pub fn set_schema<
4902        T: std::convert::Into<
4903                std::option::Option<
4904                    crate::write::generated::gapic_storage::model::read_session::Schema,
4905                >,
4906            >,
4907    >(
4908        mut self,
4909        v: T,
4910    ) -> Self {
4911        self.schema = v.into();
4912        self
4913    }
4914
4915    /// The value of [schema][crate::write::generated::gapic_storage::model::ReadSession::schema]
4916    /// if it holds a `AvroSchema`, `None` if the field is not set or
4917    /// holds a different branch.
4918    pub fn avro_schema(
4919        &self,
4920    ) -> std::option::Option<
4921        &std::boxed::Box<crate::write::generated::gapic_storage::model::AvroSchema>,
4922    > {
4923        #[allow(unreachable_patterns)]
4924        self.schema.as_ref().and_then(|v| match v {
4925            crate::write::generated::gapic_storage::model::read_session::Schema::AvroSchema(v) => {
4926                std::option::Option::Some(v)
4927            }
4928            _ => std::option::Option::None,
4929        })
4930    }
4931
4932    /// Sets the value of [schema][crate::write::generated::gapic_storage::model::ReadSession::schema]
4933    /// to hold a `AvroSchema`.
4934    ///
4935    /// Note that all the setters affecting `schema` are
4936    /// mutually exclusive.
4937    ///
4938    /// # Example
4939    /// ```ignore,no_run
4940    /// # use google_cloud_bigquery::model::ReadSession;
4941    /// use google_cloud_bigquery::model::AvroSchema;
4942    /// let x = ReadSession::new().set_avro_schema(AvroSchema::default()/* use setters */);
4943    /// assert!(x.avro_schema().is_some());
4944    /// assert!(x.arrow_schema().is_none());
4945    /// ```
4946    pub fn set_avro_schema<
4947        T: std::convert::Into<
4948                std::boxed::Box<crate::write::generated::gapic_storage::model::AvroSchema>,
4949            >,
4950    >(
4951        mut self,
4952        v: T,
4953    ) -> Self {
4954        self.schema = std::option::Option::Some(
4955            crate::write::generated::gapic_storage::model::read_session::Schema::AvroSchema(
4956                v.into(),
4957            ),
4958        );
4959        self
4960    }
4961
4962    /// The value of [schema][crate::write::generated::gapic_storage::model::ReadSession::schema]
4963    /// if it holds a `ArrowSchema`, `None` if the field is not set or
4964    /// holds a different branch.
4965    pub fn arrow_schema(
4966        &self,
4967    ) -> std::option::Option<
4968        &std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSchema>,
4969    > {
4970        #[allow(unreachable_patterns)]
4971        self.schema.as_ref().and_then(|v| match v {
4972            crate::write::generated::gapic_storage::model::read_session::Schema::ArrowSchema(v) => {
4973                std::option::Option::Some(v)
4974            }
4975            _ => std::option::Option::None,
4976        })
4977    }
4978
4979    /// Sets the value of [schema][crate::write::generated::gapic_storage::model::ReadSession::schema]
4980    /// to hold a `ArrowSchema`.
4981    ///
4982    /// Note that all the setters affecting `schema` are
4983    /// mutually exclusive.
4984    ///
4985    /// # Example
4986    /// ```ignore,no_run
4987    /// # use google_cloud_bigquery::model::ReadSession;
4988    /// use google_cloud_bigquery::model::ArrowSchema;
4989    /// let x = ReadSession::new().set_arrow_schema(ArrowSchema::default()/* use setters */);
4990    /// assert!(x.arrow_schema().is_some());
4991    /// assert!(x.avro_schema().is_none());
4992    /// ```
4993    pub fn set_arrow_schema<
4994        T: std::convert::Into<
4995                std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSchema>,
4996            >,
4997    >(
4998        mut self,
4999        v: T,
5000    ) -> Self {
5001        self.schema = std::option::Option::Some(
5002            crate::write::generated::gapic_storage::model::read_session::Schema::ArrowSchema(
5003                v.into(),
5004            ),
5005        );
5006        self
5007    }
5008}
5009
5010impl wkt::message::Message for ReadSession {
5011    fn typename() -> &'static str {
5012        "type.googleapis.com/google.cloud.bigquery.storage.v1.ReadSession"
5013    }
5014}
5015
5016/// Defines additional types related to [ReadSession].
5017pub mod read_session {
5018    #[allow(unused_imports)]
5019    use super::*;
5020
5021    /// Additional attributes when reading a table.
5022    #[derive(Clone, Default, PartialEq)]
5023    #[non_exhaustive]
5024    pub struct TableModifiers {
5025        /// The snapshot time of the table. If not set, interpreted as now.
5026        pub snapshot_time: std::option::Option<wkt::Timestamp>,
5027
5028        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5029    }
5030
5031    impl TableModifiers {
5032        /// Creates a new default instance.
5033        pub fn new() -> Self {
5034            std::default::Default::default()
5035        }
5036
5037        /// Sets the value of [snapshot_time][crate::write::generated::gapic_storage::model::read_session::TableModifiers::snapshot_time].
5038        ///
5039        /// # Example
5040        /// ```ignore,no_run
5041        /// # use google_cloud_bigquery::model::read_session::TableModifiers;
5042        /// use wkt::Timestamp;
5043        /// let x = TableModifiers::new().set_snapshot_time(Timestamp::default()/* use setters */);
5044        /// ```
5045        pub fn set_snapshot_time<T>(mut self, v: T) -> Self
5046        where
5047            T: std::convert::Into<wkt::Timestamp>,
5048        {
5049            self.snapshot_time = std::option::Option::Some(v.into());
5050            self
5051        }
5052
5053        /// Sets or clears the value of [snapshot_time][crate::write::generated::gapic_storage::model::read_session::TableModifiers::snapshot_time].
5054        ///
5055        /// # Example
5056        /// ```ignore,no_run
5057        /// # use google_cloud_bigquery::model::read_session::TableModifiers;
5058        /// use wkt::Timestamp;
5059        /// let x = TableModifiers::new().set_or_clear_snapshot_time(Some(Timestamp::default()/* use setters */));
5060        /// let x = TableModifiers::new().set_or_clear_snapshot_time(None::<Timestamp>);
5061        /// ```
5062        pub fn set_or_clear_snapshot_time<T>(mut self, v: std::option::Option<T>) -> Self
5063        where
5064            T: std::convert::Into<wkt::Timestamp>,
5065        {
5066            self.snapshot_time = v.map(|x| x.into());
5067            self
5068        }
5069    }
5070
5071    impl wkt::message::Message for TableModifiers {
5072        fn typename() -> &'static str {
5073            "type.googleapis.com/google.cloud.bigquery.storage.v1.ReadSession.TableModifiers"
5074        }
5075    }
5076
5077    /// Options dictating how we read a table.
5078    #[derive(Clone, Default, PartialEq)]
5079    #[non_exhaustive]
5080    pub struct TableReadOptions {
5081
5082        /// Optional. The names of the fields in the table to be returned. If no
5083        /// field names are specified, then all fields in the table are returned.
5084        ///
5085        /// Nested fields -- the child elements of a STRUCT field -- can be selected
5086        /// individually using their fully-qualified names, and will be returned as
5087        /// record fields containing only the selected nested fields. If a STRUCT
5088        /// field is specified in the selected fields list, all of the child elements
5089        /// will be returned.
5090        ///
5091        /// As an example, consider a table with the following schema:
5092        ///
5093        /// {
5094        /// "name": "struct_field",
5095        /// "type": "RECORD",
5096        /// "mode": "NULLABLE",
5097        /// "fields": [
5098        /// {
5099        /// "name": "string_field1",
5100        /// "type": "STRING",
5101        /// .              "mode": "NULLABLE"
5102        /// },
5103        /// {
5104        /// "name": "string_field2",
5105        /// "type": "STRING",
5106        /// "mode": "NULLABLE"
5107        /// }
5108        /// ]
5109        /// }
5110        ///
5111        /// Specifying "struct_field" in the selected fields list will result in a
5112        /// read session schema with the following logical structure:
5113        ///
5114        /// struct_field {
5115        /// string_field1
5116        /// string_field2
5117        /// }
5118        ///
5119        /// Specifying "struct_field.string_field1" in the selected fields list will
5120        /// result in a read session schema with the following logical structure:
5121        ///
5122        /// struct_field {
5123        /// string_field1
5124        /// }
5125        ///
5126        /// The order of the fields in the read session schema is derived from the
5127        /// table schema and does not correspond to the order in which the fields are
5128        /// specified in this list.
5129        pub selected_fields: std::vec::Vec<std::string::String>,
5130
5131        /// SQL text filtering statement, similar to a WHERE clause in a query.
5132        /// Aggregates are not supported.
5133        ///
5134        /// Examples: "int_field > 5"
5135        /// "date_field = CAST('2014-9-27' as DATE)"
5136        /// "nullable_field is not NULL"
5137        /// "st_equals(geo_field, st_geofromtext("POINT(2, 2)"))"
5138        /// "numeric_field BETWEEN 1.0 AND 5.0"
5139        ///
5140        /// Restricted to a maximum length for 1 MB.
5141        pub row_restriction: std::string::String,
5142
5143        /// Optional. Specifies a table sampling percentage. Specifically, the query
5144        /// planner will use TABLESAMPLE SYSTEM (sample_percentage PERCENT). The
5145        /// sampling percentage is applied at the data block granularity. It will
5146        /// randomly choose for each data block whether to read the rows in that data
5147        /// block. For more details, see
5148        /// <https://cloud.google.com/bigquery/docs/table-sampling>)
5149        pub sample_percentage: std::option::Option<f64>,
5150
5151        /// Optional. Set response_compression_codec when creating a read session to
5152        /// enable application-level compression of ReadRows responses.
5153        pub response_compression_codec: std::option::Option<crate::write::generated::gapic_storage::model::read_session::table_read_options::ResponseCompressionCodec>,
5154
5155        #[allow(missing_docs)]
5156        pub output_format_serialization_options: std::option::Option<crate::write::generated::gapic_storage::model::read_session::table_read_options::OutputFormatSerializationOptions>,
5157
5158        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5159    }
5160
5161    impl TableReadOptions {
5162        /// Creates a new default instance.
5163        pub fn new() -> Self {
5164            std::default::Default::default()
5165        }
5166
5167        /// Sets the value of [selected_fields][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::selected_fields].
5168        ///
5169        /// # Example
5170        /// ```ignore,no_run
5171        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5172        /// let x = TableReadOptions::new().set_selected_fields(["a", "b", "c"]);
5173        /// ```
5174        pub fn set_selected_fields<T, V>(mut self, v: T) -> Self
5175        where
5176            T: std::iter::IntoIterator<Item = V>,
5177            V: std::convert::Into<std::string::String>,
5178        {
5179            use std::iter::Iterator;
5180            self.selected_fields = v.into_iter().map(|i| i.into()).collect();
5181            self
5182        }
5183
5184        /// Sets the value of [row_restriction][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::row_restriction].
5185        ///
5186        /// # Example
5187        /// ```ignore,no_run
5188        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5189        /// let x = TableReadOptions::new().set_row_restriction("example");
5190        /// ```
5191        pub fn set_row_restriction<T: std::convert::Into<std::string::String>>(
5192            mut self,
5193            v: T,
5194        ) -> Self {
5195            self.row_restriction = v.into();
5196            self
5197        }
5198
5199        /// Sets the value of [sample_percentage][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::sample_percentage].
5200        ///
5201        /// # Example
5202        /// ```ignore,no_run
5203        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5204        /// let x = TableReadOptions::new().set_sample_percentage(42.0);
5205        /// ```
5206        pub fn set_sample_percentage<T>(mut self, v: T) -> Self
5207        where
5208            T: std::convert::Into<f64>,
5209        {
5210            self.sample_percentage = std::option::Option::Some(v.into());
5211            self
5212        }
5213
5214        /// Sets or clears the value of [sample_percentage][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::sample_percentage].
5215        ///
5216        /// # Example
5217        /// ```ignore,no_run
5218        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5219        /// let x = TableReadOptions::new().set_or_clear_sample_percentage(Some(42.0));
5220        /// let x = TableReadOptions::new().set_or_clear_sample_percentage(None::<f32>);
5221        /// ```
5222        pub fn set_or_clear_sample_percentage<T>(mut self, v: std::option::Option<T>) -> Self
5223        where
5224            T: std::convert::Into<f64>,
5225        {
5226            self.sample_percentage = v.map(|x| x.into());
5227            self
5228        }
5229
5230        /// Sets the value of [response_compression_codec][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::response_compression_codec].
5231        ///
5232        /// # Example
5233        /// ```ignore,no_run
5234        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5235        /// use google_cloud_bigquery::model::read_session::table_read_options::ResponseCompressionCodec;
5236        /// let x0 = TableReadOptions::new().set_response_compression_codec(ResponseCompressionCodec::Lz4);
5237        /// ```
5238        pub fn set_response_compression_codec<T>(mut self, v: T) -> Self
5239        where T: std::convert::Into<crate::write::generated::gapic_storage::model::read_session::table_read_options::ResponseCompressionCodec>
5240        {
5241            self.response_compression_codec = std::option::Option::Some(v.into());
5242            self
5243        }
5244
5245        /// Sets or clears the value of [response_compression_codec][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::response_compression_codec].
5246        ///
5247        /// # Example
5248        /// ```ignore,no_run
5249        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5250        /// use google_cloud_bigquery::model::read_session::table_read_options::ResponseCompressionCodec;
5251        /// let x0 = TableReadOptions::new().set_or_clear_response_compression_codec(Some(ResponseCompressionCodec::Lz4));
5252        /// let x_none = TableReadOptions::new().set_or_clear_response_compression_codec(None::<ResponseCompressionCodec>);
5253        /// ```
5254        pub fn set_or_clear_response_compression_codec<T>(mut self, v: std::option::Option<T>) -> Self
5255        where T: std::convert::Into<crate::write::generated::gapic_storage::model::read_session::table_read_options::ResponseCompressionCodec>
5256        {
5257            self.response_compression_codec = v.map(|x| x.into());
5258            self
5259        }
5260
5261        /// Sets the value of [output_format_serialization_options][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::output_format_serialization_options].
5262        ///
5263        /// Note that all the setters affecting `output_format_serialization_options` are mutually
5264        /// exclusive.
5265        ///
5266        /// # Example
5267        /// ```ignore,no_run
5268        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5269        /// use google_cloud_bigquery::model::ArrowSerializationOptions;
5270        /// let x = TableReadOptions::new().set_output_format_serialization_options(Some(
5271        ///     google_cloud_bigquery::model::read_session::table_read_options::OutputFormatSerializationOptions::ArrowSerializationOptions(ArrowSerializationOptions::default().into())));
5272        /// ```
5273        pub fn set_output_format_serialization_options<T: std::convert::Into<std::option::Option<crate::write::generated::gapic_storage::model::read_session::table_read_options::OutputFormatSerializationOptions>>>(mut self, v: T) -> Self
5274        {
5275            self.output_format_serialization_options = v.into();
5276            self
5277        }
5278
5279        /// The value of [output_format_serialization_options][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::output_format_serialization_options]
5280        /// if it holds a `ArrowSerializationOptions`, `None` if the field is not set or
5281        /// holds a different branch.
5282        pub fn arrow_serialization_options(
5283            &self,
5284        ) -> std::option::Option<
5285            &std::boxed::Box<
5286                crate::write::generated::gapic_storage::model::ArrowSerializationOptions,
5287            >,
5288        > {
5289            #[allow(unreachable_patterns)]
5290            self.output_format_serialization_options.as_ref().and_then(|v| match v {
5291                crate::write::generated::gapic_storage::model::read_session::table_read_options::OutputFormatSerializationOptions::ArrowSerializationOptions(v) => std::option::Option::Some(v),
5292                _ => std::option::Option::None,
5293            })
5294        }
5295
5296        /// Sets the value of [output_format_serialization_options][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::output_format_serialization_options]
5297        /// to hold a `ArrowSerializationOptions`.
5298        ///
5299        /// Note that all the setters affecting `output_format_serialization_options` are
5300        /// mutually exclusive.
5301        ///
5302        /// # Example
5303        /// ```ignore,no_run
5304        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5305        /// use google_cloud_bigquery::model::ArrowSerializationOptions;
5306        /// let x = TableReadOptions::new().set_arrow_serialization_options(ArrowSerializationOptions::default()/* use setters */);
5307        /// assert!(x.arrow_serialization_options().is_some());
5308        /// assert!(x.avro_serialization_options().is_none());
5309        /// ```
5310        pub fn set_arrow_serialization_options<
5311            T: std::convert::Into<
5312                    std::boxed::Box<
5313                        crate::write::generated::gapic_storage::model::ArrowSerializationOptions,
5314                    >,
5315                >,
5316        >(
5317            mut self,
5318            v: T,
5319        ) -> Self {
5320            self.output_format_serialization_options = std::option::Option::Some(
5321                crate::write::generated::gapic_storage::model::read_session::table_read_options::OutputFormatSerializationOptions::ArrowSerializationOptions(
5322                    v.into()
5323                )
5324            );
5325            self
5326        }
5327
5328        /// The value of [output_format_serialization_options][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::output_format_serialization_options]
5329        /// if it holds a `AvroSerializationOptions`, `None` if the field is not set or
5330        /// holds a different branch.
5331        pub fn avro_serialization_options(
5332            &self,
5333        ) -> std::option::Option<
5334            &std::boxed::Box<
5335                crate::write::generated::gapic_storage::model::AvroSerializationOptions,
5336            >,
5337        > {
5338            #[allow(unreachable_patterns)]
5339            self.output_format_serialization_options.as_ref().and_then(|v| match v {
5340                crate::write::generated::gapic_storage::model::read_session::table_read_options::OutputFormatSerializationOptions::AvroSerializationOptions(v) => std::option::Option::Some(v),
5341                _ => std::option::Option::None,
5342            })
5343        }
5344
5345        /// Sets the value of [output_format_serialization_options][crate::write::generated::gapic_storage::model::read_session::TableReadOptions::output_format_serialization_options]
5346        /// to hold a `AvroSerializationOptions`.
5347        ///
5348        /// Note that all the setters affecting `output_format_serialization_options` are
5349        /// mutually exclusive.
5350        ///
5351        /// # Example
5352        /// ```ignore,no_run
5353        /// # use google_cloud_bigquery::model::read_session::TableReadOptions;
5354        /// use google_cloud_bigquery::model::AvroSerializationOptions;
5355        /// let x = TableReadOptions::new().set_avro_serialization_options(AvroSerializationOptions::default()/* use setters */);
5356        /// assert!(x.avro_serialization_options().is_some());
5357        /// assert!(x.arrow_serialization_options().is_none());
5358        /// ```
5359        pub fn set_avro_serialization_options<
5360            T: std::convert::Into<
5361                    std::boxed::Box<
5362                        crate::write::generated::gapic_storage::model::AvroSerializationOptions,
5363                    >,
5364                >,
5365        >(
5366            mut self,
5367            v: T,
5368        ) -> Self {
5369            self.output_format_serialization_options = std::option::Option::Some(
5370                crate::write::generated::gapic_storage::model::read_session::table_read_options::OutputFormatSerializationOptions::AvroSerializationOptions(
5371                    v.into()
5372                )
5373            );
5374            self
5375        }
5376    }
5377
5378    impl wkt::message::Message for TableReadOptions {
5379        fn typename() -> &'static str {
5380            "type.googleapis.com/google.cloud.bigquery.storage.v1.ReadSession.TableReadOptions"
5381        }
5382    }
5383
5384    /// Defines additional types related to [TableReadOptions].
5385    pub mod table_read_options {
5386        #[allow(unused_imports)]
5387        use super::*;
5388
5389        /// Specifies which compression codec to attempt on the entire serialized
5390        /// response payload (either Arrow record batch or Avro rows). This is
5391        /// not to be confused with the Apache Arrow native compression codecs
5392        /// specified in ArrowSerializationOptions. For performance reasons, when
5393        /// creating a read session requesting Arrow responses, setting both native
5394        /// Arrow compression and application-level response compression will not be
5395        /// allowed - choose, at most, one kind of compression.
5396        ///
5397        /// # Working with unknown values
5398        ///
5399        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5400        /// additional enum variants at any time. Adding new variants is not considered
5401        /// a breaking change. Applications should write their code in anticipation of:
5402        ///
5403        /// - New values appearing in future releases of the client library, **and**
5404        /// - New values received dynamically, without application changes.
5405        ///
5406        /// Please consult the [Working with enums] section in the user guide for some
5407        /// guidelines.
5408        ///
5409        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5410        #[derive(Clone, Debug, PartialEq)]
5411        #[non_exhaustive]
5412        pub enum ResponseCompressionCodec {
5413            /// Default is no compression.
5414            Unspecified,
5415            /// Use raw LZ4 compression.
5416            Lz4,
5417            /// If set, the enum was initialized with an unknown value.
5418            ///
5419            /// Applications can examine the value using [ResponseCompressionCodec::value] or
5420            /// [ResponseCompressionCodec::name].
5421            UnknownValue(response_compression_codec::UnknownValue),
5422        }
5423
5424        #[doc(hidden)]
5425        pub mod response_compression_codec {
5426            #[allow(unused_imports)]
5427            use super::*;
5428            #[derive(Clone, Debug, PartialEq)]
5429            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5430        }
5431
5432        impl ResponseCompressionCodec {
5433            /// Gets the enum value.
5434            ///
5435            /// Returns `None` if the enum contains an unknown value deserialized from
5436            /// the string representation of enums.
5437            pub fn value(&self) -> std::option::Option<i32> {
5438                match self {
5439                    Self::Unspecified => std::option::Option::Some(0),
5440                    Self::Lz4 => std::option::Option::Some(2),
5441                    Self::UnknownValue(u) => u.0.value(),
5442                }
5443            }
5444
5445            /// Gets the enum value as a string.
5446            ///
5447            /// Returns `None` if the enum contains an unknown value deserialized from
5448            /// the integer representation of enums.
5449            pub fn name(&self) -> std::option::Option<&str> {
5450                match self {
5451                    Self::Unspecified => {
5452                        std::option::Option::Some("RESPONSE_COMPRESSION_CODEC_UNSPECIFIED")
5453                    }
5454                    Self::Lz4 => std::option::Option::Some("RESPONSE_COMPRESSION_CODEC_LZ4"),
5455                    Self::UnknownValue(u) => u.0.name(),
5456                }
5457            }
5458        }
5459
5460        impl std::default::Default for ResponseCompressionCodec {
5461            fn default() -> Self {
5462                use std::convert::From;
5463                Self::from(0)
5464            }
5465        }
5466
5467        impl std::fmt::Display for ResponseCompressionCodec {
5468            fn fmt(
5469                &self,
5470                f: &mut std::fmt::Formatter<'_>,
5471            ) -> std::result::Result<(), std::fmt::Error> {
5472                wkt::internal::display_enum(f, self.name(), self.value())
5473            }
5474        }
5475
5476        impl std::convert::From<i32> for ResponseCompressionCodec {
5477            fn from(value: i32) -> Self {
5478                match value {
5479                    0 => Self::Unspecified,
5480                    2 => Self::Lz4,
5481                    _ => Self::UnknownValue(response_compression_codec::UnknownValue(
5482                        wkt::internal::UnknownEnumValue::Integer(value),
5483                    )),
5484                }
5485            }
5486        }
5487
5488        impl std::convert::From<&str> for ResponseCompressionCodec {
5489            fn from(value: &str) -> Self {
5490                use std::string::ToString;
5491                match value {
5492                    "RESPONSE_COMPRESSION_CODEC_UNSPECIFIED" => Self::Unspecified,
5493                    "RESPONSE_COMPRESSION_CODEC_LZ4" => Self::Lz4,
5494                    _ => Self::UnknownValue(response_compression_codec::UnknownValue(
5495                        wkt::internal::UnknownEnumValue::String(value.to_string()),
5496                    )),
5497                }
5498            }
5499        }
5500
5501        impl serde::ser::Serialize for ResponseCompressionCodec {
5502            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5503            where
5504                S: serde::Serializer,
5505            {
5506                match self {
5507                    Self::Unspecified => serializer.serialize_i32(0),
5508                    Self::Lz4 => serializer.serialize_i32(2),
5509                    Self::UnknownValue(u) => u.0.serialize(serializer),
5510                }
5511            }
5512        }
5513
5514        impl<'de> serde::de::Deserialize<'de> for ResponseCompressionCodec {
5515            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5516            where
5517                D: serde::Deserializer<'de>,
5518            {
5519                deserializer.deserialize_any(wkt::internal::EnumVisitor::<ResponseCompressionCodec>::new(
5520                    ".google.cloud.bigquery.storage.v1.ReadSession.TableReadOptions.ResponseCompressionCodec"))
5521            }
5522        }
5523
5524        #[allow(missing_docs)]
5525        #[derive(Clone, Debug, PartialEq)]
5526        #[non_exhaustive]
5527        pub enum OutputFormatSerializationOptions {
5528            /// Optional. Options specific to the Apache Arrow output format.
5529            ArrowSerializationOptions(
5530                std::boxed::Box<
5531                    crate::write::generated::gapic_storage::model::ArrowSerializationOptions,
5532                >,
5533            ),
5534            /// Optional. Options specific to the Apache Avro output format
5535            AvroSerializationOptions(
5536                std::boxed::Box<
5537                    crate::write::generated::gapic_storage::model::AvroSerializationOptions,
5538                >,
5539            ),
5540        }
5541
5542        impl OutputFormatSerializationOptions {
5543            /// Initializes the enum to the [ArrowSerializationOptions](Self::ArrowSerializationOptions) branch.
5544            pub fn from_arrow_serialization_options(
5545                value: impl std::convert::Into<
5546                    std::boxed::Box<
5547                        crate::write::generated::gapic_storage::model::ArrowSerializationOptions,
5548                    >,
5549                >,
5550            ) -> Self {
5551                Self::ArrowSerializationOptions(value.into())
5552            }
5553            /// Initializes the enum to the [AvroSerializationOptions](Self::AvroSerializationOptions) branch.
5554            pub fn from_avro_serialization_options(
5555                value: impl std::convert::Into<
5556                    std::boxed::Box<
5557                        crate::write::generated::gapic_storage::model::AvroSerializationOptions,
5558                    >,
5559                >,
5560            ) -> Self {
5561                Self::AvroSerializationOptions(value.into())
5562            }
5563        }
5564    }
5565
5566    /// The schema for the read. If read_options.selected_fields is set, the
5567    /// schema may be different from the table schema as it will only contain
5568    /// the selected fields.
5569    #[derive(Clone, Debug, PartialEq)]
5570    #[non_exhaustive]
5571    pub enum Schema {
5572        /// Output only. Avro schema.
5573        AvroSchema(std::boxed::Box<crate::write::generated::gapic_storage::model::AvroSchema>),
5574        /// Output only. Arrow schema.
5575        ArrowSchema(std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSchema>),
5576    }
5577
5578    impl Schema {
5579        /// Initializes the enum to the [AvroSchema](Self::AvroSchema) branch.
5580        pub fn from_avro_schema(
5581            value: impl std::convert::Into<
5582                std::boxed::Box<crate::write::generated::gapic_storage::model::AvroSchema>,
5583            >,
5584        ) -> Self {
5585            Self::AvroSchema(value.into())
5586        }
5587        /// Initializes the enum to the [ArrowSchema](Self::ArrowSchema) branch.
5588        pub fn from_arrow_schema(
5589            value: impl std::convert::Into<
5590                std::boxed::Box<crate::write::generated::gapic_storage::model::ArrowSchema>,
5591            >,
5592        ) -> Self {
5593            Self::ArrowSchema(value.into())
5594        }
5595    }
5596}
5597
5598/// Information about a single stream that gets data out of the storage system.
5599/// Most of the information about `ReadStream` instances is aggregated, making
5600/// `ReadStream` lightweight.
5601#[derive(Clone, Default, PartialEq)]
5602#[non_exhaustive]
5603pub struct ReadStream {
5604    /// Output only. Name of the stream, in the form
5605    /// `projects/{project_id}/locations/{location}/sessions/{session_id}/streams/{stream_id}`.
5606    pub name: std::string::String,
5607
5608    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5609}
5610
5611impl ReadStream {
5612    /// Creates a new default instance.
5613    pub fn new() -> Self {
5614        std::default::Default::default()
5615    }
5616
5617    /// Sets the value of [name][crate::write::generated::gapic_storage::model::ReadStream::name].
5618    ///
5619    /// # Example
5620    /// ```ignore,no_run
5621    /// # use google_cloud_bigquery::model::ReadStream;
5622    /// # let project_id = "project_id";
5623    /// # let location_id = "location_id";
5624    /// # let session_id = "session_id";
5625    /// # let stream_id = "stream_id";
5626    /// let x = ReadStream::new().set_name(format!("projects/{project_id}/locations/{location_id}/sessions/{session_id}/streams/{stream_id}"));
5627    /// ```
5628    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5629        self.name = v.into();
5630        self
5631    }
5632}
5633
5634impl wkt::message::Message for ReadStream {
5635    fn typename() -> &'static str {
5636        "type.googleapis.com/google.cloud.bigquery.storage.v1.ReadStream"
5637    }
5638}
5639
5640/// Information about a single stream that gets data inside the storage system.
5641#[derive(Clone, Default, PartialEq)]
5642#[non_exhaustive]
5643pub struct WriteStream {
5644    /// Output only. Name of the stream, in the form
5645    /// `projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream}`.
5646    pub name: std::string::String,
5647
5648    /// Immutable. Type of the stream.
5649    pub r#type: crate::write::generated::gapic_storage::model::write_stream::Type,
5650
5651    /// Output only. Create time of the stream. For the _default stream, this is
5652    /// the creation_time of the table.
5653    pub create_time: std::option::Option<wkt::Timestamp>,
5654
5655    /// Output only. Commit time of the stream.
5656    /// If a stream is of `COMMITTED` type, then it will have a commit_time same as
5657    /// `create_time`. If the stream is of `PENDING` type, empty commit_time
5658    /// means it is not committed.
5659    pub commit_time: std::option::Option<wkt::Timestamp>,
5660
5661    /// Output only. The schema of the destination table. It is only returned in
5662    /// `CreateWriteStream` response. Caller should generate data that's
5663    /// compatible with this schema to send in initial `AppendRowsRequest`.
5664    /// The table schema could go out of date during the life time of the stream.
5665    pub table_schema:
5666        std::option::Option<crate::write::generated::gapic_storage::model::TableSchema>,
5667
5668    /// Immutable. Mode of the stream.
5669    pub write_mode: crate::write::generated::gapic_storage::model::write_stream::WriteMode,
5670
5671    /// Output only. The geographic location where the stream's dataset resides.
5672    /// See <https://cloud.google.com/bigquery/docs/locations> for supported
5673    /// locations.
5674    pub location: std::string::String,
5675
5676    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5677}
5678
5679impl WriteStream {
5680    /// Creates a new default instance.
5681    pub fn new() -> Self {
5682        std::default::Default::default()
5683    }
5684
5685    /// Sets the value of [name][crate::write::generated::gapic_storage::model::WriteStream::name].
5686    ///
5687    /// # Example
5688    /// ```ignore,no_run
5689    /// # use google_cloud_bigquery::model::WriteStream;
5690    /// # let project_id = "project_id";
5691    /// # let dataset_id = "dataset_id";
5692    /// # let table_id = "table_id";
5693    /// # let stream_id = "stream_id";
5694    /// let x = WriteStream::new().set_name(format!("projects/{project_id}/datasets/{dataset_id}/tables/{table_id}/streams/{stream_id}"));
5695    /// ```
5696    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5697        self.name = v.into();
5698        self
5699    }
5700
5701    /// Sets the value of [r#type][crate::write::generated::gapic_storage::model::WriteStream::type].
5702    ///
5703    /// # Example
5704    /// ```ignore,no_run
5705    /// # use google_cloud_bigquery::model::WriteStream;
5706    /// use google_cloud_bigquery::model::write_stream::Type;
5707    /// let x0 = WriteStream::new().set_type(Type::Committed);
5708    /// let x1 = WriteStream::new().set_type(Type::Pending);
5709    /// let x2 = WriteStream::new().set_type(Type::Buffered);
5710    /// ```
5711    pub fn set_type<
5712        T: std::convert::Into<crate::write::generated::gapic_storage::model::write_stream::Type>,
5713    >(
5714        mut self,
5715        v: T,
5716    ) -> Self {
5717        self.r#type = v.into();
5718        self
5719    }
5720
5721    /// Sets the value of [create_time][crate::write::generated::gapic_storage::model::WriteStream::create_time].
5722    ///
5723    /// # Example
5724    /// ```ignore,no_run
5725    /// # use google_cloud_bigquery::model::WriteStream;
5726    /// use wkt::Timestamp;
5727    /// let x = WriteStream::new().set_create_time(Timestamp::default()/* use setters */);
5728    /// ```
5729    pub fn set_create_time<T>(mut self, v: T) -> Self
5730    where
5731        T: std::convert::Into<wkt::Timestamp>,
5732    {
5733        self.create_time = std::option::Option::Some(v.into());
5734        self
5735    }
5736
5737    /// Sets or clears the value of [create_time][crate::write::generated::gapic_storage::model::WriteStream::create_time].
5738    ///
5739    /// # Example
5740    /// ```ignore,no_run
5741    /// # use google_cloud_bigquery::model::WriteStream;
5742    /// use wkt::Timestamp;
5743    /// let x = WriteStream::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
5744    /// let x = WriteStream::new().set_or_clear_create_time(None::<Timestamp>);
5745    /// ```
5746    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
5747    where
5748        T: std::convert::Into<wkt::Timestamp>,
5749    {
5750        self.create_time = v.map(|x| x.into());
5751        self
5752    }
5753
5754    /// Sets the value of [commit_time][crate::write::generated::gapic_storage::model::WriteStream::commit_time].
5755    ///
5756    /// # Example
5757    /// ```ignore,no_run
5758    /// # use google_cloud_bigquery::model::WriteStream;
5759    /// use wkt::Timestamp;
5760    /// let x = WriteStream::new().set_commit_time(Timestamp::default()/* use setters */);
5761    /// ```
5762    pub fn set_commit_time<T>(mut self, v: T) -> Self
5763    where
5764        T: std::convert::Into<wkt::Timestamp>,
5765    {
5766        self.commit_time = std::option::Option::Some(v.into());
5767        self
5768    }
5769
5770    /// Sets or clears the value of [commit_time][crate::write::generated::gapic_storage::model::WriteStream::commit_time].
5771    ///
5772    /// # Example
5773    /// ```ignore,no_run
5774    /// # use google_cloud_bigquery::model::WriteStream;
5775    /// use wkt::Timestamp;
5776    /// let x = WriteStream::new().set_or_clear_commit_time(Some(Timestamp::default()/* use setters */));
5777    /// let x = WriteStream::new().set_or_clear_commit_time(None::<Timestamp>);
5778    /// ```
5779    pub fn set_or_clear_commit_time<T>(mut self, v: std::option::Option<T>) -> Self
5780    where
5781        T: std::convert::Into<wkt::Timestamp>,
5782    {
5783        self.commit_time = v.map(|x| x.into());
5784        self
5785    }
5786
5787    /// Sets the value of [table_schema][crate::write::generated::gapic_storage::model::WriteStream::table_schema].
5788    ///
5789    /// # Example
5790    /// ```ignore,no_run
5791    /// # use google_cloud_bigquery::model::WriteStream;
5792    /// use google_cloud_bigquery::model::TableSchema;
5793    /// let x = WriteStream::new().set_table_schema(TableSchema::default()/* use setters */);
5794    /// ```
5795    pub fn set_table_schema<T>(mut self, v: T) -> Self
5796    where
5797        T: std::convert::Into<crate::write::generated::gapic_storage::model::TableSchema>,
5798    {
5799        self.table_schema = std::option::Option::Some(v.into());
5800        self
5801    }
5802
5803    /// Sets or clears the value of [table_schema][crate::write::generated::gapic_storage::model::WriteStream::table_schema].
5804    ///
5805    /// # Example
5806    /// ```ignore,no_run
5807    /// # use google_cloud_bigquery::model::WriteStream;
5808    /// use google_cloud_bigquery::model::TableSchema;
5809    /// let x = WriteStream::new().set_or_clear_table_schema(Some(TableSchema::default()/* use setters */));
5810    /// let x = WriteStream::new().set_or_clear_table_schema(None::<TableSchema>);
5811    /// ```
5812    pub fn set_or_clear_table_schema<T>(mut self, v: std::option::Option<T>) -> Self
5813    where
5814        T: std::convert::Into<crate::write::generated::gapic_storage::model::TableSchema>,
5815    {
5816        self.table_schema = v.map(|x| x.into());
5817        self
5818    }
5819
5820    /// Sets the value of [write_mode][crate::write::generated::gapic_storage::model::WriteStream::write_mode].
5821    ///
5822    /// # Example
5823    /// ```ignore,no_run
5824    /// # use google_cloud_bigquery::model::WriteStream;
5825    /// use google_cloud_bigquery::model::write_stream::WriteMode;
5826    /// let x0 = WriteStream::new().set_write_mode(WriteMode::Insert);
5827    /// ```
5828    pub fn set_write_mode<
5829        T: std::convert::Into<crate::write::generated::gapic_storage::model::write_stream::WriteMode>,
5830    >(
5831        mut self,
5832        v: T,
5833    ) -> Self {
5834        self.write_mode = v.into();
5835        self
5836    }
5837
5838    /// Sets the value of [location][crate::write::generated::gapic_storage::model::WriteStream::location].
5839    ///
5840    /// # Example
5841    /// ```ignore,no_run
5842    /// # use google_cloud_bigquery::model::WriteStream;
5843    /// let x = WriteStream::new().set_location("example");
5844    /// ```
5845    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5846        self.location = v.into();
5847        self
5848    }
5849}
5850
5851impl wkt::message::Message for WriteStream {
5852    fn typename() -> &'static str {
5853        "type.googleapis.com/google.cloud.bigquery.storage.v1.WriteStream"
5854    }
5855}
5856
5857/// Defines additional types related to [WriteStream].
5858pub mod write_stream {
5859    #[allow(unused_imports)]
5860    use super::*;
5861
5862    /// Type enum of the stream.
5863    ///
5864    /// # Working with unknown values
5865    ///
5866    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5867    /// additional enum variants at any time. Adding new variants is not considered
5868    /// a breaking change. Applications should write their code in anticipation of:
5869    ///
5870    /// - New values appearing in future releases of the client library, **and**
5871    /// - New values received dynamically, without application changes.
5872    ///
5873    /// Please consult the [Working with enums] section in the user guide for some
5874    /// guidelines.
5875    ///
5876    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5877    #[derive(Clone, Debug, PartialEq)]
5878    #[non_exhaustive]
5879    pub enum Type {
5880        /// Unknown type.
5881        Unspecified,
5882        /// Data will commit automatically and appear as soon as the write is
5883        /// acknowledged.
5884        Committed,
5885        /// Data is invisible until the stream is committed.
5886        Pending,
5887        /// Data is only visible up to the offset to which it was flushed.
5888        Buffered,
5889        /// If set, the enum was initialized with an unknown value.
5890        ///
5891        /// Applications can examine the value using [Type::value] or
5892        /// [Type::name].
5893        UnknownValue(r#type::UnknownValue),
5894    }
5895
5896    #[doc(hidden)]
5897    pub mod r#type {
5898        #[allow(unused_imports)]
5899        use super::*;
5900        #[derive(Clone, Debug, PartialEq)]
5901        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5902    }
5903
5904    impl Type {
5905        /// Gets the enum value.
5906        ///
5907        /// Returns `None` if the enum contains an unknown value deserialized from
5908        /// the string representation of enums.
5909        pub fn value(&self) -> std::option::Option<i32> {
5910            match self {
5911                Self::Unspecified => std::option::Option::Some(0),
5912                Self::Committed => std::option::Option::Some(1),
5913                Self::Pending => std::option::Option::Some(2),
5914                Self::Buffered => std::option::Option::Some(3),
5915                Self::UnknownValue(u) => u.0.value(),
5916            }
5917        }
5918
5919        /// Gets the enum value as a string.
5920        ///
5921        /// Returns `None` if the enum contains an unknown value deserialized from
5922        /// the integer representation of enums.
5923        pub fn name(&self) -> std::option::Option<&str> {
5924            match self {
5925                Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
5926                Self::Committed => std::option::Option::Some("COMMITTED"),
5927                Self::Pending => std::option::Option::Some("PENDING"),
5928                Self::Buffered => std::option::Option::Some("BUFFERED"),
5929                Self::UnknownValue(u) => u.0.name(),
5930            }
5931        }
5932    }
5933
5934    impl std::default::Default for Type {
5935        fn default() -> Self {
5936            use std::convert::From;
5937            Self::from(0)
5938        }
5939    }
5940
5941    impl std::fmt::Display for Type {
5942        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5943            wkt::internal::display_enum(f, self.name(), self.value())
5944        }
5945    }
5946
5947    impl std::convert::From<i32> for Type {
5948        fn from(value: i32) -> Self {
5949            match value {
5950                0 => Self::Unspecified,
5951                1 => Self::Committed,
5952                2 => Self::Pending,
5953                3 => Self::Buffered,
5954                _ => Self::UnknownValue(r#type::UnknownValue(
5955                    wkt::internal::UnknownEnumValue::Integer(value),
5956                )),
5957            }
5958        }
5959    }
5960
5961    impl std::convert::From<&str> for Type {
5962        fn from(value: &str) -> Self {
5963            use std::string::ToString;
5964            match value {
5965                "TYPE_UNSPECIFIED" => Self::Unspecified,
5966                "COMMITTED" => Self::Committed,
5967                "PENDING" => Self::Pending,
5968                "BUFFERED" => Self::Buffered,
5969                _ => Self::UnknownValue(r#type::UnknownValue(
5970                    wkt::internal::UnknownEnumValue::String(value.to_string()),
5971                )),
5972            }
5973        }
5974    }
5975
5976    impl serde::ser::Serialize for Type {
5977        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5978        where
5979            S: serde::Serializer,
5980        {
5981            match self {
5982                Self::Unspecified => serializer.serialize_i32(0),
5983                Self::Committed => serializer.serialize_i32(1),
5984                Self::Pending => serializer.serialize_i32(2),
5985                Self::Buffered => serializer.serialize_i32(3),
5986                Self::UnknownValue(u) => u.0.serialize(serializer),
5987            }
5988        }
5989    }
5990
5991    impl<'de> serde::de::Deserialize<'de> for Type {
5992        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5993        where
5994            D: serde::Deserializer<'de>,
5995        {
5996            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
5997                ".google.cloud.bigquery.storage.v1.WriteStream.Type",
5998            ))
5999        }
6000    }
6001
6002    /// Mode enum of the stream.
6003    ///
6004    /// # Working with unknown values
6005    ///
6006    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6007    /// additional enum variants at any time. Adding new variants is not considered
6008    /// a breaking change. Applications should write their code in anticipation of:
6009    ///
6010    /// - New values appearing in future releases of the client library, **and**
6011    /// - New values received dynamically, without application changes.
6012    ///
6013    /// Please consult the [Working with enums] section in the user guide for some
6014    /// guidelines.
6015    ///
6016    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6017    #[derive(Clone, Debug, PartialEq)]
6018    #[non_exhaustive]
6019    pub enum WriteMode {
6020        /// Unknown type.
6021        Unspecified,
6022        /// Insert new records into the table.
6023        /// It is the default value if customers do not specify it.
6024        Insert,
6025        /// If set, the enum was initialized with an unknown value.
6026        ///
6027        /// Applications can examine the value using [WriteMode::value] or
6028        /// [WriteMode::name].
6029        UnknownValue(write_mode::UnknownValue),
6030    }
6031
6032    #[doc(hidden)]
6033    pub mod write_mode {
6034        #[allow(unused_imports)]
6035        use super::*;
6036        #[derive(Clone, Debug, PartialEq)]
6037        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6038    }
6039
6040    impl WriteMode {
6041        /// Gets the enum value.
6042        ///
6043        /// Returns `None` if the enum contains an unknown value deserialized from
6044        /// the string representation of enums.
6045        pub fn value(&self) -> std::option::Option<i32> {
6046            match self {
6047                Self::Unspecified => std::option::Option::Some(0),
6048                Self::Insert => std::option::Option::Some(1),
6049                Self::UnknownValue(u) => u.0.value(),
6050            }
6051        }
6052
6053        /// Gets the enum value as a string.
6054        ///
6055        /// Returns `None` if the enum contains an unknown value deserialized from
6056        /// the integer representation of enums.
6057        pub fn name(&self) -> std::option::Option<&str> {
6058            match self {
6059                Self::Unspecified => std::option::Option::Some("WRITE_MODE_UNSPECIFIED"),
6060                Self::Insert => std::option::Option::Some("INSERT"),
6061                Self::UnknownValue(u) => u.0.name(),
6062            }
6063        }
6064    }
6065
6066    impl std::default::Default for WriteMode {
6067        fn default() -> Self {
6068            use std::convert::From;
6069            Self::from(0)
6070        }
6071    }
6072
6073    impl std::fmt::Display for WriteMode {
6074        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6075            wkt::internal::display_enum(f, self.name(), self.value())
6076        }
6077    }
6078
6079    impl std::convert::From<i32> for WriteMode {
6080        fn from(value: i32) -> Self {
6081            match value {
6082                0 => Self::Unspecified,
6083                1 => Self::Insert,
6084                _ => Self::UnknownValue(write_mode::UnknownValue(
6085                    wkt::internal::UnknownEnumValue::Integer(value),
6086                )),
6087            }
6088        }
6089    }
6090
6091    impl std::convert::From<&str> for WriteMode {
6092        fn from(value: &str) -> Self {
6093            use std::string::ToString;
6094            match value {
6095                "WRITE_MODE_UNSPECIFIED" => Self::Unspecified,
6096                "INSERT" => Self::Insert,
6097                _ => Self::UnknownValue(write_mode::UnknownValue(
6098                    wkt::internal::UnknownEnumValue::String(value.to_string()),
6099                )),
6100            }
6101        }
6102    }
6103
6104    impl serde::ser::Serialize for WriteMode {
6105        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6106        where
6107            S: serde::Serializer,
6108        {
6109            match self {
6110                Self::Unspecified => serializer.serialize_i32(0),
6111                Self::Insert => serializer.serialize_i32(1),
6112                Self::UnknownValue(u) => u.0.serialize(serializer),
6113            }
6114        }
6115    }
6116
6117    impl<'de> serde::de::Deserialize<'de> for WriteMode {
6118        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6119        where
6120            D: serde::Deserializer<'de>,
6121        {
6122            deserializer.deserialize_any(wkt::internal::EnumVisitor::<WriteMode>::new(
6123                ".google.cloud.bigquery.storage.v1.WriteStream.WriteMode",
6124            ))
6125        }
6126    }
6127}
6128
6129/// Schema of a table. This schema is a subset of
6130/// google.cloud.bigquery.v2.TableSchema containing information necessary to
6131/// generate valid message to write to BigQuery.
6132#[derive(Clone, Default, PartialEq)]
6133#[non_exhaustive]
6134pub struct TableSchema {
6135    /// Describes the fields in a table.
6136    pub fields: std::vec::Vec<crate::write::generated::gapic_storage::model::TableFieldSchema>,
6137
6138    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6139}
6140
6141impl TableSchema {
6142    /// Creates a new default instance.
6143    pub fn new() -> Self {
6144        std::default::Default::default()
6145    }
6146
6147    /// Sets the value of [fields][crate::write::generated::gapic_storage::model::TableSchema::fields].
6148    ///
6149    /// # Example
6150    /// ```ignore,no_run
6151    /// # use google_cloud_bigquery::model::TableSchema;
6152    /// use google_cloud_bigquery::model::TableFieldSchema;
6153    /// let x = TableSchema::new()
6154    ///     .set_fields([
6155    ///         TableFieldSchema::default()/* use setters */,
6156    ///         TableFieldSchema::default()/* use (different) setters */,
6157    ///     ]);
6158    /// ```
6159    pub fn set_fields<T, V>(mut self, v: T) -> Self
6160    where
6161        T: std::iter::IntoIterator<Item = V>,
6162        V: std::convert::Into<crate::write::generated::gapic_storage::model::TableFieldSchema>,
6163    {
6164        use std::iter::Iterator;
6165        self.fields = v.into_iter().map(|i| i.into()).collect();
6166        self
6167    }
6168}
6169
6170impl wkt::message::Message for TableSchema {
6171    fn typename() -> &'static str {
6172        "type.googleapis.com/google.cloud.bigquery.storage.v1.TableSchema"
6173    }
6174}
6175
6176/// TableFieldSchema defines a single field/column within a table schema.
6177#[derive(Clone, Default, PartialEq)]
6178#[non_exhaustive]
6179pub struct TableFieldSchema {
6180    /// Required. The field name. The name must contain only letters (a-z, A-Z),
6181    /// numbers (0-9), or underscores (_), and must start with a letter or
6182    /// underscore. The maximum length is 128 characters.
6183    pub name: std::string::String,
6184
6185    /// Required. The field data type.
6186    pub r#type: crate::write::generated::gapic_storage::model::table_field_schema::Type,
6187
6188    /// Optional. The field mode. The default value is NULLABLE.
6189    pub mode: crate::write::generated::gapic_storage::model::table_field_schema::Mode,
6190
6191    /// Optional. Describes the nested schema fields if the type property is set to
6192    /// STRUCT.
6193    pub fields: std::vec::Vec<crate::write::generated::gapic_storage::model::TableFieldSchema>,
6194
6195    /// Optional. The field description. The maximum length is 1,024 characters.
6196    pub description: std::string::String,
6197
6198    /// Optional. Maximum length of values of this field for STRINGS or BYTES.
6199    ///
6200    /// If max_length is not specified, no maximum length constraint is imposed
6201    /// on this field.
6202    ///
6203    /// If type = "STRING", then max_length represents the maximum UTF-8
6204    /// length of strings in this field.
6205    ///
6206    /// If type = "BYTES", then max_length represents the maximum number of
6207    /// bytes in this field.
6208    ///
6209    /// It is invalid to set this field if type is not "STRING" or "BYTES".
6210    pub max_length: i64,
6211
6212    /// Optional. Precision (maximum number of total digits in base 10) and scale
6213    /// (maximum number of digits in the fractional part in base 10) constraints
6214    /// for values of this field for NUMERIC or BIGNUMERIC.
6215    ///
6216    /// It is invalid to set precision or scale if type is not "NUMERIC" or
6217    /// "BIGNUMERIC".
6218    ///
6219    /// If precision and scale are not specified, no value range constraint is
6220    /// imposed on this field insofar as values are permitted by the type.
6221    ///
6222    /// Values of this NUMERIC or BIGNUMERIC field must be in this range when:
6223    ///
6224    /// * Precision (P) and scale (S) are specified:
6225    ///   [-10^(P-S) + 10^(-S), 10^(P-S) - 10^(-S)]
6226    /// * Precision (P) is specified but not scale (and thus scale is
6227    ///   interpreted to be equal to zero):
6228    ///   [-10^P + 1, 10^P - 1].
6229    ///
6230    /// Acceptable values for precision and scale if both are specified:
6231    ///
6232    /// * If type = "NUMERIC":
6233    ///   1 <= precision - scale <= 29 and 0 <= scale <= 9.
6234    /// * If type = "BIGNUMERIC":
6235    ///   1 <= precision - scale <= 38 and 0 <= scale <= 38.
6236    ///
6237    /// Acceptable values for precision if only precision is specified but not
6238    /// scale (and thus scale is interpreted to be equal to zero):
6239    ///
6240    /// * If type = "NUMERIC": 1 <= precision <= 29.
6241    /// * If type = "BIGNUMERIC": 1 <= precision <= 38.
6242    ///
6243    /// If scale is specified but not precision, then it is invalid.
6244    pub precision: i64,
6245
6246    /// Optional. See documentation for precision.
6247    pub scale: i64,
6248
6249    /// Optional. A SQL expression to specify the [default value]
6250    /// (<https://cloud.google.com/bigquery/docs/default-values>) for this field.
6251    pub default_value_expression: std::string::String,
6252
6253    /// Optional. Precision (maximum number of total digits in base 10) for seconds
6254    /// of TIMESTAMP type.
6255    ///
6256    /// Possible values include:
6257    ///
6258    /// * 6 (Default, for TIMESTAMP type with microsecond precision)
6259    /// * 12 (For TIMESTAMP type with picosecond precision)
6260    pub timestamp_precision: std::option::Option<wkt::Int64Value>,
6261
6262    /// Optional. The subtype of the RANGE, if the type of this field is RANGE. If
6263    /// the type is RANGE, this field is required. Possible values for the field
6264    /// element type of a RANGE include:
6265    ///
6266    /// * DATE
6267    /// * DATETIME
6268    /// * TIMESTAMP
6269    pub range_element_type: std::option::Option<
6270        crate::write::generated::gapic_storage::model::table_field_schema::FieldElementType,
6271    >,
6272
6273    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6274}
6275
6276impl TableFieldSchema {
6277    /// Creates a new default instance.
6278    pub fn new() -> Self {
6279        std::default::Default::default()
6280    }
6281
6282    /// Sets the value of [name][crate::write::generated::gapic_storage::model::TableFieldSchema::name].
6283    ///
6284    /// # Example
6285    /// ```ignore,no_run
6286    /// # use google_cloud_bigquery::model::TableFieldSchema;
6287    /// let x = TableFieldSchema::new().set_name("example");
6288    /// ```
6289    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6290        self.name = v.into();
6291        self
6292    }
6293
6294    /// Sets the value of [r#type][crate::write::generated::gapic_storage::model::TableFieldSchema::type].
6295    ///
6296    /// # Example
6297    /// ```ignore,no_run
6298    /// # use google_cloud_bigquery::model::TableFieldSchema;
6299    /// use google_cloud_bigquery::model::table_field_schema::Type;
6300    /// let x0 = TableFieldSchema::new().set_type(Type::String);
6301    /// let x1 = TableFieldSchema::new().set_type(Type::Int64);
6302    /// let x2 = TableFieldSchema::new().set_type(Type::Double);
6303    /// ```
6304    pub fn set_type<
6305        T: std::convert::Into<crate::write::generated::gapic_storage::model::table_field_schema::Type>,
6306    >(
6307        mut self,
6308        v: T,
6309    ) -> Self {
6310        self.r#type = v.into();
6311        self
6312    }
6313
6314    /// Sets the value of [mode][crate::write::generated::gapic_storage::model::TableFieldSchema::mode].
6315    ///
6316    /// # Example
6317    /// ```ignore,no_run
6318    /// # use google_cloud_bigquery::model::TableFieldSchema;
6319    /// use google_cloud_bigquery::model::table_field_schema::Mode;
6320    /// let x0 = TableFieldSchema::new().set_mode(Mode::Nullable);
6321    /// let x1 = TableFieldSchema::new().set_mode(Mode::Required);
6322    /// let x2 = TableFieldSchema::new().set_mode(Mode::Repeated);
6323    /// ```
6324    pub fn set_mode<
6325        T: std::convert::Into<crate::write::generated::gapic_storage::model::table_field_schema::Mode>,
6326    >(
6327        mut self,
6328        v: T,
6329    ) -> Self {
6330        self.mode = v.into();
6331        self
6332    }
6333
6334    /// Sets the value of [fields][crate::write::generated::gapic_storage::model::TableFieldSchema::fields].
6335    ///
6336    /// # Example
6337    /// ```ignore,no_run
6338    /// # use google_cloud_bigquery::model::TableFieldSchema;
6339    /// let x = TableFieldSchema::new()
6340    ///     .set_fields([
6341    ///         TableFieldSchema::default()/* use setters */,
6342    ///         TableFieldSchema::default()/* use (different) setters */,
6343    ///     ]);
6344    /// ```
6345    pub fn set_fields<T, V>(mut self, v: T) -> Self
6346    where
6347        T: std::iter::IntoIterator<Item = V>,
6348        V: std::convert::Into<crate::write::generated::gapic_storage::model::TableFieldSchema>,
6349    {
6350        use std::iter::Iterator;
6351        self.fields = v.into_iter().map(|i| i.into()).collect();
6352        self
6353    }
6354
6355    /// Sets the value of [description][crate::write::generated::gapic_storage::model::TableFieldSchema::description].
6356    ///
6357    /// # Example
6358    /// ```ignore,no_run
6359    /// # use google_cloud_bigquery::model::TableFieldSchema;
6360    /// let x = TableFieldSchema::new().set_description("example");
6361    /// ```
6362    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6363        self.description = v.into();
6364        self
6365    }
6366
6367    /// Sets the value of [max_length][crate::write::generated::gapic_storage::model::TableFieldSchema::max_length].
6368    ///
6369    /// # Example
6370    /// ```ignore,no_run
6371    /// # use google_cloud_bigquery::model::TableFieldSchema;
6372    /// let x = TableFieldSchema::new().set_max_length(42);
6373    /// ```
6374    pub fn set_max_length<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6375        self.max_length = v.into();
6376        self
6377    }
6378
6379    /// Sets the value of [precision][crate::write::generated::gapic_storage::model::TableFieldSchema::precision].
6380    ///
6381    /// # Example
6382    /// ```ignore,no_run
6383    /// # use google_cloud_bigquery::model::TableFieldSchema;
6384    /// let x = TableFieldSchema::new().set_precision(42);
6385    /// ```
6386    pub fn set_precision<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6387        self.precision = v.into();
6388        self
6389    }
6390
6391    /// Sets the value of [scale][crate::write::generated::gapic_storage::model::TableFieldSchema::scale].
6392    ///
6393    /// # Example
6394    /// ```ignore,no_run
6395    /// # use google_cloud_bigquery::model::TableFieldSchema;
6396    /// let x = TableFieldSchema::new().set_scale(42);
6397    /// ```
6398    pub fn set_scale<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6399        self.scale = v.into();
6400        self
6401    }
6402
6403    /// Sets the value of [default_value_expression][crate::write::generated::gapic_storage::model::TableFieldSchema::default_value_expression].
6404    ///
6405    /// # Example
6406    /// ```ignore,no_run
6407    /// # use google_cloud_bigquery::model::TableFieldSchema;
6408    /// let x = TableFieldSchema::new().set_default_value_expression("example");
6409    /// ```
6410    pub fn set_default_value_expression<T: std::convert::Into<std::string::String>>(
6411        mut self,
6412        v: T,
6413    ) -> Self {
6414        self.default_value_expression = v.into();
6415        self
6416    }
6417
6418    /// Sets the value of [timestamp_precision][crate::write::generated::gapic_storage::model::TableFieldSchema::timestamp_precision].
6419    ///
6420    /// # Example
6421    /// ```ignore,no_run
6422    /// # use google_cloud_bigquery::model::TableFieldSchema;
6423    /// use wkt::Int64Value;
6424    /// let x = TableFieldSchema::new().set_timestamp_precision(Int64Value::default()/* use setters */);
6425    /// ```
6426    pub fn set_timestamp_precision<T>(mut self, v: T) -> Self
6427    where
6428        T: std::convert::Into<wkt::Int64Value>,
6429    {
6430        self.timestamp_precision = std::option::Option::Some(v.into());
6431        self
6432    }
6433
6434    /// Sets or clears the value of [timestamp_precision][crate::write::generated::gapic_storage::model::TableFieldSchema::timestamp_precision].
6435    ///
6436    /// # Example
6437    /// ```ignore,no_run
6438    /// # use google_cloud_bigquery::model::TableFieldSchema;
6439    /// use wkt::Int64Value;
6440    /// let x = TableFieldSchema::new().set_or_clear_timestamp_precision(Some(Int64Value::default()/* use setters */));
6441    /// let x = TableFieldSchema::new().set_or_clear_timestamp_precision(None::<Int64Value>);
6442    /// ```
6443    pub fn set_or_clear_timestamp_precision<T>(mut self, v: std::option::Option<T>) -> Self
6444    where
6445        T: std::convert::Into<wkt::Int64Value>,
6446    {
6447        self.timestamp_precision = v.map(|x| x.into());
6448        self
6449    }
6450
6451    /// Sets the value of [range_element_type][crate::write::generated::gapic_storage::model::TableFieldSchema::range_element_type].
6452    ///
6453    /// # Example
6454    /// ```ignore,no_run
6455    /// # use google_cloud_bigquery::model::TableFieldSchema;
6456    /// use google_cloud_bigquery::model::table_field_schema::FieldElementType;
6457    /// let x = TableFieldSchema::new().set_range_element_type(FieldElementType::default()/* use setters */);
6458    /// ```
6459    pub fn set_range_element_type<T>(mut self, v: T) -> Self
6460    where
6461        T: std::convert::Into<
6462                crate::write::generated::gapic_storage::model::table_field_schema::FieldElementType,
6463            >,
6464    {
6465        self.range_element_type = std::option::Option::Some(v.into());
6466        self
6467    }
6468
6469    /// Sets or clears the value of [range_element_type][crate::write::generated::gapic_storage::model::TableFieldSchema::range_element_type].
6470    ///
6471    /// # Example
6472    /// ```ignore,no_run
6473    /// # use google_cloud_bigquery::model::TableFieldSchema;
6474    /// use google_cloud_bigquery::model::table_field_schema::FieldElementType;
6475    /// let x = TableFieldSchema::new().set_or_clear_range_element_type(Some(FieldElementType::default()/* use setters */));
6476    /// let x = TableFieldSchema::new().set_or_clear_range_element_type(None::<FieldElementType>);
6477    /// ```
6478    pub fn set_or_clear_range_element_type<T>(mut self, v: std::option::Option<T>) -> Self
6479    where
6480        T: std::convert::Into<
6481                crate::write::generated::gapic_storage::model::table_field_schema::FieldElementType,
6482            >,
6483    {
6484        self.range_element_type = v.map(|x| x.into());
6485        self
6486    }
6487}
6488
6489impl wkt::message::Message for TableFieldSchema {
6490    fn typename() -> &'static str {
6491        "type.googleapis.com/google.cloud.bigquery.storage.v1.TableFieldSchema"
6492    }
6493}
6494
6495/// Defines additional types related to [TableFieldSchema].
6496pub mod table_field_schema {
6497    #[allow(unused_imports)]
6498    use super::*;
6499
6500    /// Represents the type of a field element.
6501    #[derive(Clone, Default, PartialEq)]
6502    #[non_exhaustive]
6503    pub struct FieldElementType {
6504        /// Required. The type of a field element.
6505        pub r#type: crate::write::generated::gapic_storage::model::table_field_schema::Type,
6506
6507        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6508    }
6509
6510    impl FieldElementType {
6511        /// Creates a new default instance.
6512        pub fn new() -> Self {
6513            std::default::Default::default()
6514        }
6515
6516        /// Sets the value of [r#type][crate::write::generated::gapic_storage::model::table_field_schema::FieldElementType::type].
6517        ///
6518        /// # Example
6519        /// ```ignore,no_run
6520        /// # use google_cloud_bigquery::model::table_field_schema::FieldElementType;
6521        /// use google_cloud_bigquery::model::table_field_schema::Type;
6522        /// let x0 = FieldElementType::new().set_type(Type::String);
6523        /// let x1 = FieldElementType::new().set_type(Type::Int64);
6524        /// let x2 = FieldElementType::new().set_type(Type::Double);
6525        /// ```
6526        pub fn set_type<
6527            T: std::convert::Into<
6528                    crate::write::generated::gapic_storage::model::table_field_schema::Type,
6529                >,
6530        >(
6531            mut self,
6532            v: T,
6533        ) -> Self {
6534            self.r#type = v.into();
6535            self
6536        }
6537    }
6538
6539    impl wkt::message::Message for FieldElementType {
6540        fn typename() -> &'static str {
6541            "type.googleapis.com/google.cloud.bigquery.storage.v1.TableFieldSchema.FieldElementType"
6542        }
6543    }
6544
6545    /// Enum for [Type].
6546    ///
6547    /// # Working with unknown values
6548    ///
6549    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6550    /// additional enum variants at any time. Adding new variants is not considered
6551    /// a breaking change. Applications should write their code in anticipation of:
6552    ///
6553    /// - New values appearing in future releases of the client library, **and**
6554    /// - New values received dynamically, without application changes.
6555    ///
6556    /// Please consult the [Working with enums] section in the user guide for some
6557    /// guidelines.
6558    ///
6559    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6560    #[derive(Clone, Debug, PartialEq)]
6561    #[non_exhaustive]
6562    pub enum Type {
6563        /// Illegal value
6564        Unspecified,
6565        /// 64K, UTF8
6566        String,
6567        /// 64-bit signed
6568        Int64,
6569        /// 64-bit IEEE floating point
6570        Double,
6571        /// Aggregate type
6572        Struct,
6573        /// 64K, Binary
6574        Bytes,
6575        /// 2-valued
6576        Bool,
6577        /// 64-bit signed usec since UTC epoch
6578        Timestamp,
6579        /// Civil date - Year, Month, Day
6580        Date,
6581        /// Civil time - Hour, Minute, Second, Microseconds
6582        Time,
6583        /// Combination of civil date and civil time
6584        Datetime,
6585        /// Geography object
6586        Geography,
6587        /// Numeric value
6588        Numeric,
6589        /// BigNumeric value
6590        Bignumeric,
6591        /// Interval
6592        Interval,
6593        /// JSON, String
6594        Json,
6595        /// RANGE
6596        Range,
6597        /// If set, the enum was initialized with an unknown value.
6598        ///
6599        /// Applications can examine the value using [Type::value] or
6600        /// [Type::name].
6601        UnknownValue(r#type::UnknownValue),
6602    }
6603
6604    #[doc(hidden)]
6605    pub mod r#type {
6606        #[allow(unused_imports)]
6607        use super::*;
6608        #[derive(Clone, Debug, PartialEq)]
6609        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6610    }
6611
6612    impl Type {
6613        /// Gets the enum value.
6614        ///
6615        /// Returns `None` if the enum contains an unknown value deserialized from
6616        /// the string representation of enums.
6617        pub fn value(&self) -> std::option::Option<i32> {
6618            match self {
6619                Self::Unspecified => std::option::Option::Some(0),
6620                Self::String => std::option::Option::Some(1),
6621                Self::Int64 => std::option::Option::Some(2),
6622                Self::Double => std::option::Option::Some(3),
6623                Self::Struct => std::option::Option::Some(4),
6624                Self::Bytes => std::option::Option::Some(5),
6625                Self::Bool => std::option::Option::Some(6),
6626                Self::Timestamp => std::option::Option::Some(7),
6627                Self::Date => std::option::Option::Some(8),
6628                Self::Time => std::option::Option::Some(9),
6629                Self::Datetime => std::option::Option::Some(10),
6630                Self::Geography => std::option::Option::Some(11),
6631                Self::Numeric => std::option::Option::Some(12),
6632                Self::Bignumeric => std::option::Option::Some(13),
6633                Self::Interval => std::option::Option::Some(14),
6634                Self::Json => std::option::Option::Some(15),
6635                Self::Range => std::option::Option::Some(16),
6636                Self::UnknownValue(u) => u.0.value(),
6637            }
6638        }
6639
6640        /// Gets the enum value as a string.
6641        ///
6642        /// Returns `None` if the enum contains an unknown value deserialized from
6643        /// the integer representation of enums.
6644        pub fn name(&self) -> std::option::Option<&str> {
6645            match self {
6646                Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
6647                Self::String => std::option::Option::Some("STRING"),
6648                Self::Int64 => std::option::Option::Some("INT64"),
6649                Self::Double => std::option::Option::Some("DOUBLE"),
6650                Self::Struct => std::option::Option::Some("STRUCT"),
6651                Self::Bytes => std::option::Option::Some("BYTES"),
6652                Self::Bool => std::option::Option::Some("BOOL"),
6653                Self::Timestamp => std::option::Option::Some("TIMESTAMP"),
6654                Self::Date => std::option::Option::Some("DATE"),
6655                Self::Time => std::option::Option::Some("TIME"),
6656                Self::Datetime => std::option::Option::Some("DATETIME"),
6657                Self::Geography => std::option::Option::Some("GEOGRAPHY"),
6658                Self::Numeric => std::option::Option::Some("NUMERIC"),
6659                Self::Bignumeric => std::option::Option::Some("BIGNUMERIC"),
6660                Self::Interval => std::option::Option::Some("INTERVAL"),
6661                Self::Json => std::option::Option::Some("JSON"),
6662                Self::Range => std::option::Option::Some("RANGE"),
6663                Self::UnknownValue(u) => u.0.name(),
6664            }
6665        }
6666    }
6667
6668    impl std::default::Default for Type {
6669        fn default() -> Self {
6670            use std::convert::From;
6671            Self::from(0)
6672        }
6673    }
6674
6675    impl std::fmt::Display for Type {
6676        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6677            wkt::internal::display_enum(f, self.name(), self.value())
6678        }
6679    }
6680
6681    impl std::convert::From<i32> for Type {
6682        fn from(value: i32) -> Self {
6683            match value {
6684                0 => Self::Unspecified,
6685                1 => Self::String,
6686                2 => Self::Int64,
6687                3 => Self::Double,
6688                4 => Self::Struct,
6689                5 => Self::Bytes,
6690                6 => Self::Bool,
6691                7 => Self::Timestamp,
6692                8 => Self::Date,
6693                9 => Self::Time,
6694                10 => Self::Datetime,
6695                11 => Self::Geography,
6696                12 => Self::Numeric,
6697                13 => Self::Bignumeric,
6698                14 => Self::Interval,
6699                15 => Self::Json,
6700                16 => Self::Range,
6701                _ => Self::UnknownValue(r#type::UnknownValue(
6702                    wkt::internal::UnknownEnumValue::Integer(value),
6703                )),
6704            }
6705        }
6706    }
6707
6708    impl std::convert::From<&str> for Type {
6709        fn from(value: &str) -> Self {
6710            use std::string::ToString;
6711            match value {
6712                "TYPE_UNSPECIFIED" => Self::Unspecified,
6713                "STRING" => Self::String,
6714                "INT64" => Self::Int64,
6715                "DOUBLE" => Self::Double,
6716                "STRUCT" => Self::Struct,
6717                "BYTES" => Self::Bytes,
6718                "BOOL" => Self::Bool,
6719                "TIMESTAMP" => Self::Timestamp,
6720                "DATE" => Self::Date,
6721                "TIME" => Self::Time,
6722                "DATETIME" => Self::Datetime,
6723                "GEOGRAPHY" => Self::Geography,
6724                "NUMERIC" => Self::Numeric,
6725                "BIGNUMERIC" => Self::Bignumeric,
6726                "INTERVAL" => Self::Interval,
6727                "JSON" => Self::Json,
6728                "RANGE" => Self::Range,
6729                _ => Self::UnknownValue(r#type::UnknownValue(
6730                    wkt::internal::UnknownEnumValue::String(value.to_string()),
6731                )),
6732            }
6733        }
6734    }
6735
6736    impl serde::ser::Serialize for Type {
6737        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6738        where
6739            S: serde::Serializer,
6740        {
6741            match self {
6742                Self::Unspecified => serializer.serialize_i32(0),
6743                Self::String => serializer.serialize_i32(1),
6744                Self::Int64 => serializer.serialize_i32(2),
6745                Self::Double => serializer.serialize_i32(3),
6746                Self::Struct => serializer.serialize_i32(4),
6747                Self::Bytes => serializer.serialize_i32(5),
6748                Self::Bool => serializer.serialize_i32(6),
6749                Self::Timestamp => serializer.serialize_i32(7),
6750                Self::Date => serializer.serialize_i32(8),
6751                Self::Time => serializer.serialize_i32(9),
6752                Self::Datetime => serializer.serialize_i32(10),
6753                Self::Geography => serializer.serialize_i32(11),
6754                Self::Numeric => serializer.serialize_i32(12),
6755                Self::Bignumeric => serializer.serialize_i32(13),
6756                Self::Interval => serializer.serialize_i32(14),
6757                Self::Json => serializer.serialize_i32(15),
6758                Self::Range => serializer.serialize_i32(16),
6759                Self::UnknownValue(u) => u.0.serialize(serializer),
6760            }
6761        }
6762    }
6763
6764    impl<'de> serde::de::Deserialize<'de> for Type {
6765        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6766        where
6767            D: serde::Deserializer<'de>,
6768        {
6769            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
6770                ".google.cloud.bigquery.storage.v1.TableFieldSchema.Type",
6771            ))
6772        }
6773    }
6774
6775    /// Enum for [Mode].
6776    ///
6777    /// # Working with unknown values
6778    ///
6779    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6780    /// additional enum variants at any time. Adding new variants is not considered
6781    /// a breaking change. Applications should write their code in anticipation of:
6782    ///
6783    /// - New values appearing in future releases of the client library, **and**
6784    /// - New values received dynamically, without application changes.
6785    ///
6786    /// Please consult the [Working with enums] section in the user guide for some
6787    /// guidelines.
6788    ///
6789    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6790    #[derive(Clone, Debug, PartialEq)]
6791    #[non_exhaustive]
6792    pub enum Mode {
6793        /// Illegal value
6794        Unspecified,
6795        #[allow(missing_docs)]
6796        Nullable,
6797        #[allow(missing_docs)]
6798        Required,
6799        #[allow(missing_docs)]
6800        Repeated,
6801        /// If set, the enum was initialized with an unknown value.
6802        ///
6803        /// Applications can examine the value using [Mode::value] or
6804        /// [Mode::name].
6805        UnknownValue(mode::UnknownValue),
6806    }
6807
6808    #[doc(hidden)]
6809    pub mod mode {
6810        #[allow(unused_imports)]
6811        use super::*;
6812        #[derive(Clone, Debug, PartialEq)]
6813        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6814    }
6815
6816    impl Mode {
6817        /// Gets the enum value.
6818        ///
6819        /// Returns `None` if the enum contains an unknown value deserialized from
6820        /// the string representation of enums.
6821        pub fn value(&self) -> std::option::Option<i32> {
6822            match self {
6823                Self::Unspecified => std::option::Option::Some(0),
6824                Self::Nullable => std::option::Option::Some(1),
6825                Self::Required => std::option::Option::Some(2),
6826                Self::Repeated => std::option::Option::Some(3),
6827                Self::UnknownValue(u) => u.0.value(),
6828            }
6829        }
6830
6831        /// Gets the enum value as a string.
6832        ///
6833        /// Returns `None` if the enum contains an unknown value deserialized from
6834        /// the integer representation of enums.
6835        pub fn name(&self) -> std::option::Option<&str> {
6836            match self {
6837                Self::Unspecified => std::option::Option::Some("MODE_UNSPECIFIED"),
6838                Self::Nullable => std::option::Option::Some("NULLABLE"),
6839                Self::Required => std::option::Option::Some("REQUIRED"),
6840                Self::Repeated => std::option::Option::Some("REPEATED"),
6841                Self::UnknownValue(u) => u.0.name(),
6842            }
6843        }
6844    }
6845
6846    impl std::default::Default for Mode {
6847        fn default() -> Self {
6848            use std::convert::From;
6849            Self::from(0)
6850        }
6851    }
6852
6853    impl std::fmt::Display for Mode {
6854        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6855            wkt::internal::display_enum(f, self.name(), self.value())
6856        }
6857    }
6858
6859    impl std::convert::From<i32> for Mode {
6860        fn from(value: i32) -> Self {
6861            match value {
6862                0 => Self::Unspecified,
6863                1 => Self::Nullable,
6864                2 => Self::Required,
6865                3 => Self::Repeated,
6866                _ => Self::UnknownValue(mode::UnknownValue(
6867                    wkt::internal::UnknownEnumValue::Integer(value),
6868                )),
6869            }
6870        }
6871    }
6872
6873    impl std::convert::From<&str> for Mode {
6874        fn from(value: &str) -> Self {
6875            use std::string::ToString;
6876            match value {
6877                "MODE_UNSPECIFIED" => Self::Unspecified,
6878                "NULLABLE" => Self::Nullable,
6879                "REQUIRED" => Self::Required,
6880                "REPEATED" => Self::Repeated,
6881                _ => Self::UnknownValue(mode::UnknownValue(
6882                    wkt::internal::UnknownEnumValue::String(value.to_string()),
6883                )),
6884            }
6885        }
6886    }
6887
6888    impl serde::ser::Serialize for Mode {
6889        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6890        where
6891            S: serde::Serializer,
6892        {
6893            match self {
6894                Self::Unspecified => serializer.serialize_i32(0),
6895                Self::Nullable => serializer.serialize_i32(1),
6896                Self::Required => serializer.serialize_i32(2),
6897                Self::Repeated => serializer.serialize_i32(3),
6898                Self::UnknownValue(u) => u.0.serialize(serializer),
6899            }
6900        }
6901    }
6902
6903    impl<'de> serde::de::Deserialize<'de> for Mode {
6904        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6905        where
6906            D: serde::Deserializer<'de>,
6907        {
6908            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Mode>::new(
6909                ".google.cloud.bigquery.storage.v1.TableFieldSchema.Mode",
6910            ))
6911        }
6912    }
6913}
6914
6915/// Data format for input or output data.
6916///
6917/// # Working with unknown values
6918///
6919/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6920/// additional enum variants at any time. Adding new variants is not considered
6921/// a breaking change. Applications should write their code in anticipation of:
6922///
6923/// - New values appearing in future releases of the client library, **and**
6924/// - New values received dynamically, without application changes.
6925///
6926/// Please consult the [Working with enums] section in the user guide for some
6927/// guidelines.
6928///
6929/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6930#[derive(Clone, Debug, PartialEq)]
6931#[non_exhaustive]
6932pub enum DataFormat {
6933    /// Data format is unspecified.
6934    Unspecified,
6935    /// Avro is a standard open source row based file format.
6936    /// See <https://avro.apache.org/> for more details.
6937    Avro,
6938    /// Arrow is a standard open source column-based message format.
6939    /// See <https://arrow.apache.org/> for more details.
6940    Arrow,
6941    /// If set, the enum was initialized with an unknown value.
6942    ///
6943    /// Applications can examine the value using [DataFormat::value] or
6944    /// [DataFormat::name].
6945    UnknownValue(data_format::UnknownValue),
6946}
6947
6948#[doc(hidden)]
6949pub mod data_format {
6950    #[allow(unused_imports)]
6951    use super::*;
6952    #[derive(Clone, Debug, PartialEq)]
6953    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6954}
6955
6956impl DataFormat {
6957    /// Gets the enum value.
6958    ///
6959    /// Returns `None` if the enum contains an unknown value deserialized from
6960    /// the string representation of enums.
6961    pub fn value(&self) -> std::option::Option<i32> {
6962        match self {
6963            Self::Unspecified => std::option::Option::Some(0),
6964            Self::Avro => std::option::Option::Some(1),
6965            Self::Arrow => std::option::Option::Some(2),
6966            Self::UnknownValue(u) => u.0.value(),
6967        }
6968    }
6969
6970    /// Gets the enum value as a string.
6971    ///
6972    /// Returns `None` if the enum contains an unknown value deserialized from
6973    /// the integer representation of enums.
6974    pub fn name(&self) -> std::option::Option<&str> {
6975        match self {
6976            Self::Unspecified => std::option::Option::Some("DATA_FORMAT_UNSPECIFIED"),
6977            Self::Avro => std::option::Option::Some("AVRO"),
6978            Self::Arrow => std::option::Option::Some("ARROW"),
6979            Self::UnknownValue(u) => u.0.name(),
6980        }
6981    }
6982}
6983
6984impl std::default::Default for DataFormat {
6985    fn default() -> Self {
6986        use std::convert::From;
6987        Self::from(0)
6988    }
6989}
6990
6991impl std::fmt::Display for DataFormat {
6992    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6993        wkt::internal::display_enum(f, self.name(), self.value())
6994    }
6995}
6996
6997impl std::convert::From<i32> for DataFormat {
6998    fn from(value: i32) -> Self {
6999        match value {
7000            0 => Self::Unspecified,
7001            1 => Self::Avro,
7002            2 => Self::Arrow,
7003            _ => Self::UnknownValue(data_format::UnknownValue(
7004                wkt::internal::UnknownEnumValue::Integer(value),
7005            )),
7006        }
7007    }
7008}
7009
7010impl std::convert::From<&str> for DataFormat {
7011    fn from(value: &str) -> Self {
7012        use std::string::ToString;
7013        match value {
7014            "DATA_FORMAT_UNSPECIFIED" => Self::Unspecified,
7015            "AVRO" => Self::Avro,
7016            "ARROW" => Self::Arrow,
7017            _ => Self::UnknownValue(data_format::UnknownValue(
7018                wkt::internal::UnknownEnumValue::String(value.to_string()),
7019            )),
7020        }
7021    }
7022}
7023
7024impl serde::ser::Serialize for DataFormat {
7025    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7026    where
7027        S: serde::Serializer,
7028    {
7029        match self {
7030            Self::Unspecified => serializer.serialize_i32(0),
7031            Self::Avro => serializer.serialize_i32(1),
7032            Self::Arrow => serializer.serialize_i32(2),
7033            Self::UnknownValue(u) => u.0.serialize(serializer),
7034        }
7035    }
7036}
7037
7038impl<'de> serde::de::Deserialize<'de> for DataFormat {
7039    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7040    where
7041        D: serde::Deserializer<'de>,
7042    {
7043        deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataFormat>::new(
7044            ".google.cloud.bigquery.storage.v1.DataFormat",
7045        ))
7046    }
7047}
7048
7049/// WriteStreamView is a view enum that controls what details about a write
7050/// stream should be returned.
7051///
7052/// # Working with unknown values
7053///
7054/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7055/// additional enum variants at any time. Adding new variants is not considered
7056/// a breaking change. Applications should write their code in anticipation of:
7057///
7058/// - New values appearing in future releases of the client library, **and**
7059/// - New values received dynamically, without application changes.
7060///
7061/// Please consult the [Working with enums] section in the user guide for some
7062/// guidelines.
7063///
7064/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
7065#[derive(Clone, Debug, PartialEq)]
7066#[non_exhaustive]
7067pub enum WriteStreamView {
7068    /// The default / unset value.
7069    Unspecified,
7070    /// The BASIC projection returns basic metadata about a write stream.  The
7071    /// basic view does not include schema information.  This is the default view
7072    /// returned by GetWriteStream.
7073    Basic,
7074    /// The FULL projection returns all available write stream metadata, including
7075    /// the schema.  CreateWriteStream returns the full projection of write stream
7076    /// metadata.
7077    Full,
7078    /// If set, the enum was initialized with an unknown value.
7079    ///
7080    /// Applications can examine the value using [WriteStreamView::value] or
7081    /// [WriteStreamView::name].
7082    UnknownValue(write_stream_view::UnknownValue),
7083}
7084
7085#[doc(hidden)]
7086pub mod write_stream_view {
7087    #[allow(unused_imports)]
7088    use super::*;
7089    #[derive(Clone, Debug, PartialEq)]
7090    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7091}
7092
7093impl WriteStreamView {
7094    /// Gets the enum value.
7095    ///
7096    /// Returns `None` if the enum contains an unknown value deserialized from
7097    /// the string representation of enums.
7098    pub fn value(&self) -> std::option::Option<i32> {
7099        match self {
7100            Self::Unspecified => std::option::Option::Some(0),
7101            Self::Basic => std::option::Option::Some(1),
7102            Self::Full => std::option::Option::Some(2),
7103            Self::UnknownValue(u) => u.0.value(),
7104        }
7105    }
7106
7107    /// Gets the enum value as a string.
7108    ///
7109    /// Returns `None` if the enum contains an unknown value deserialized from
7110    /// the integer representation of enums.
7111    pub fn name(&self) -> std::option::Option<&str> {
7112        match self {
7113            Self::Unspecified => std::option::Option::Some("WRITE_STREAM_VIEW_UNSPECIFIED"),
7114            Self::Basic => std::option::Option::Some("BASIC"),
7115            Self::Full => std::option::Option::Some("FULL"),
7116            Self::UnknownValue(u) => u.0.name(),
7117        }
7118    }
7119}
7120
7121impl std::default::Default for WriteStreamView {
7122    fn default() -> Self {
7123        use std::convert::From;
7124        Self::from(0)
7125    }
7126}
7127
7128impl std::fmt::Display for WriteStreamView {
7129    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7130        wkt::internal::display_enum(f, self.name(), self.value())
7131    }
7132}
7133
7134impl std::convert::From<i32> for WriteStreamView {
7135    fn from(value: i32) -> Self {
7136        match value {
7137            0 => Self::Unspecified,
7138            1 => Self::Basic,
7139            2 => Self::Full,
7140            _ => Self::UnknownValue(write_stream_view::UnknownValue(
7141                wkt::internal::UnknownEnumValue::Integer(value),
7142            )),
7143        }
7144    }
7145}
7146
7147impl std::convert::From<&str> for WriteStreamView {
7148    fn from(value: &str) -> Self {
7149        use std::string::ToString;
7150        match value {
7151            "WRITE_STREAM_VIEW_UNSPECIFIED" => Self::Unspecified,
7152            "BASIC" => Self::Basic,
7153            "FULL" => Self::Full,
7154            _ => Self::UnknownValue(write_stream_view::UnknownValue(
7155                wkt::internal::UnknownEnumValue::String(value.to_string()),
7156            )),
7157        }
7158    }
7159}
7160
7161impl serde::ser::Serialize for WriteStreamView {
7162    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7163    where
7164        S: serde::Serializer,
7165    {
7166        match self {
7167            Self::Unspecified => serializer.serialize_i32(0),
7168            Self::Basic => serializer.serialize_i32(1),
7169            Self::Full => serializer.serialize_i32(2),
7170            Self::UnknownValue(u) => u.0.serialize(serializer),
7171        }
7172    }
7173}
7174
7175impl<'de> serde::de::Deserialize<'de> for WriteStreamView {
7176    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7177    where
7178        D: serde::Deserializer<'de>,
7179    {
7180        deserializer.deserialize_any(wkt::internal::EnumVisitor::<WriteStreamView>::new(
7181            ".google.cloud.bigquery.storage.v1.WriteStreamView",
7182        ))
7183    }
7184}