Skip to main content

google_cloud_spanner/generated/gapic_dataplane/
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/// Spanner Change Streams enable customers to capture and stream out changes to
27/// their Spanner databases in real-time. A change stream
28/// can be created with option partition_mode='IMMUTABLE_KEY_RANGE' or
29/// partition_mode='MUTABLE_KEY_RANGE'.
30///
31/// This message is only used in Change Streams created with the option
32/// partition_mode='MUTABLE_KEY_RANGE'. Spanner automatically creates a special
33/// Table-Valued Function (TVF) along with each Change Streams. The function
34/// provides access to the change stream's records. The function is named
35/// READ_<change_stream_name> (where <change_stream_name> is the
36/// name of the change stream), and it returns a table with only one column
37/// called ChangeRecord.
38#[derive(Clone, Default, PartialEq)]
39#[non_exhaustive]
40pub struct ChangeStreamRecord {
41    /// One of the change stream subrecords.
42    pub record: std::option::Option<crate::model::change_stream_record::Record>,
43
44    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
45}
46
47impl ChangeStreamRecord {
48    /// Creates a new default instance.
49    pub fn new() -> Self {
50        std::default::Default::default()
51    }
52
53    /// Sets the value of [record][crate::model::ChangeStreamRecord::record].
54    ///
55    /// Note that all the setters affecting `record` are mutually
56    /// exclusive.
57    pub fn set_record<
58        T: std::convert::Into<std::option::Option<crate::model::change_stream_record::Record>>,
59    >(
60        mut self,
61        v: T,
62    ) -> Self {
63        self.record = v.into();
64        self
65    }
66
67    /// The value of [record][crate::model::ChangeStreamRecord::record]
68    /// if it holds a `DataChangeRecord`, `None` if the field is not set or
69    /// holds a different branch.
70    pub fn data_change_record(
71        &self,
72    ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>>
73    {
74        #[allow(unreachable_patterns)]
75        self.record.as_ref().and_then(|v| match v {
76            crate::model::change_stream_record::Record::DataChangeRecord(v) => {
77                std::option::Option::Some(v)
78            }
79            _ => std::option::Option::None,
80        })
81    }
82
83    /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
84    /// to hold a `DataChangeRecord`.
85    ///
86    /// Note that all the setters affecting `record` are
87    /// mutually exclusive.
88    pub fn set_data_change_record<
89        T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>>,
90    >(
91        mut self,
92        v: T,
93    ) -> Self {
94        self.record = std::option::Option::Some(
95            crate::model::change_stream_record::Record::DataChangeRecord(v.into()),
96        );
97        self
98    }
99
100    /// The value of [record][crate::model::ChangeStreamRecord::record]
101    /// if it holds a `HeartbeatRecord`, `None` if the field is not set or
102    /// holds a different branch.
103    pub fn heartbeat_record(
104        &self,
105    ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>>
106    {
107        #[allow(unreachable_patterns)]
108        self.record.as_ref().and_then(|v| match v {
109            crate::model::change_stream_record::Record::HeartbeatRecord(v) => {
110                std::option::Option::Some(v)
111            }
112            _ => std::option::Option::None,
113        })
114    }
115
116    /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
117    /// to hold a `HeartbeatRecord`.
118    ///
119    /// Note that all the setters affecting `record` are
120    /// mutually exclusive.
121    pub fn set_heartbeat_record<
122        T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>>,
123    >(
124        mut self,
125        v: T,
126    ) -> Self {
127        self.record = std::option::Option::Some(
128            crate::model::change_stream_record::Record::HeartbeatRecord(v.into()),
129        );
130        self
131    }
132
133    /// The value of [record][crate::model::ChangeStreamRecord::record]
134    /// if it holds a `PartitionStartRecord`, `None` if the field is not set or
135    /// holds a different branch.
136    pub fn partition_start_record(
137        &self,
138    ) -> std::option::Option<
139        &std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
140    > {
141        #[allow(unreachable_patterns)]
142        self.record.as_ref().and_then(|v| match v {
143            crate::model::change_stream_record::Record::PartitionStartRecord(v) => {
144                std::option::Option::Some(v)
145            }
146            _ => std::option::Option::None,
147        })
148    }
149
150    /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
151    /// to hold a `PartitionStartRecord`.
152    ///
153    /// Note that all the setters affecting `record` are
154    /// mutually exclusive.
155    pub fn set_partition_start_record<
156        T: std::convert::Into<
157                std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
158            >,
159    >(
160        mut self,
161        v: T,
162    ) -> Self {
163        self.record = std::option::Option::Some(
164            crate::model::change_stream_record::Record::PartitionStartRecord(v.into()),
165        );
166        self
167    }
168
169    /// The value of [record][crate::model::ChangeStreamRecord::record]
170    /// if it holds a `PartitionEndRecord`, `None` if the field is not set or
171    /// holds a different branch.
172    pub fn partition_end_record(
173        &self,
174    ) -> std::option::Option<&std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>>
175    {
176        #[allow(unreachable_patterns)]
177        self.record.as_ref().and_then(|v| match v {
178            crate::model::change_stream_record::Record::PartitionEndRecord(v) => {
179                std::option::Option::Some(v)
180            }
181            _ => std::option::Option::None,
182        })
183    }
184
185    /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
186    /// to hold a `PartitionEndRecord`.
187    ///
188    /// Note that all the setters affecting `record` are
189    /// mutually exclusive.
190    pub fn set_partition_end_record<
191        T: std::convert::Into<std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>>,
192    >(
193        mut self,
194        v: T,
195    ) -> Self {
196        self.record = std::option::Option::Some(
197            crate::model::change_stream_record::Record::PartitionEndRecord(v.into()),
198        );
199        self
200    }
201
202    /// The value of [record][crate::model::ChangeStreamRecord::record]
203    /// if it holds a `PartitionEventRecord`, `None` if the field is not set or
204    /// holds a different branch.
205    pub fn partition_event_record(
206        &self,
207    ) -> std::option::Option<
208        &std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
209    > {
210        #[allow(unreachable_patterns)]
211        self.record.as_ref().and_then(|v| match v {
212            crate::model::change_stream_record::Record::PartitionEventRecord(v) => {
213                std::option::Option::Some(v)
214            }
215            _ => std::option::Option::None,
216        })
217    }
218
219    /// Sets the value of [record][crate::model::ChangeStreamRecord::record]
220    /// to hold a `PartitionEventRecord`.
221    ///
222    /// Note that all the setters affecting `record` are
223    /// mutually exclusive.
224    pub fn set_partition_event_record<
225        T: std::convert::Into<
226                std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
227            >,
228    >(
229        mut self,
230        v: T,
231    ) -> Self {
232        self.record = std::option::Option::Some(
233            crate::model::change_stream_record::Record::PartitionEventRecord(v.into()),
234        );
235        self
236    }
237}
238
239impl wkt::message::Message for ChangeStreamRecord {
240    fn typename() -> &'static str {
241        "type.googleapis.com/google.spanner.v1.ChangeStreamRecord"
242    }
243}
244
245/// Defines additional types related to [ChangeStreamRecord].
246pub mod change_stream_record {
247    #[allow(unused_imports)]
248    use super::*;
249
250    /// A data change record contains a set of changes to a table with the same
251    /// modification type (insert, update, or delete) committed at the same commit
252    /// timestamp in one change stream partition for the same transaction. Multiple
253    /// data change records can be returned for the same transaction across
254    /// multiple change stream partitions.
255    #[derive(Clone, Default, PartialEq)]
256    #[non_exhaustive]
257    pub struct DataChangeRecord {
258        /// Indicates the timestamp in which the change was committed.
259        /// DataChangeRecord.commit_timestamps,
260        /// PartitionStartRecord.start_timestamps,
261        /// PartitionEventRecord.commit_timestamps, and
262        /// PartitionEndRecord.end_timestamps can have the same value in the same
263        /// partition.
264        pub commit_timestamp: std::option::Option<wkt::Timestamp>,
265
266        /// Record sequence numbers are unique and monotonically increasing (but not
267        /// necessarily contiguous) for a specific timestamp across record
268        /// types in the same partition. To guarantee ordered processing, the reader
269        /// should process records (of potentially different types) in
270        /// record_sequence order for a specific timestamp in the same partition.
271        ///
272        /// The record sequence number ordering across partitions is only meaningful
273        /// in the context of a specific transaction. Record sequence numbers are
274        /// unique across partitions for a specific transaction. Sort the
275        /// DataChangeRecords for the same
276        /// [server_transaction_id][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.server_transaction_id]
277        /// by
278        /// [record_sequence][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.record_sequence]
279        /// to reconstruct the ordering of the changes within the transaction.
280        ///
281        /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.record_sequence]: crate::model::change_stream_record::DataChangeRecord::record_sequence
282        /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.server_transaction_id]: crate::model::change_stream_record::DataChangeRecord::server_transaction_id
283        pub record_sequence: std::string::String,
284
285        /// Provides a globally unique string that represents the transaction in
286        /// which the change was committed. Multiple transactions can have the same
287        /// commit timestamp, but each transaction has a unique
288        /// server_transaction_id.
289        pub server_transaction_id: std::string::String,
290
291        /// Indicates whether this is the last record for a transaction in the
292        /// current partition. Clients can use this field to determine when all
293        /// records for a transaction in the current partition have been received.
294        pub is_last_record_in_transaction_in_partition: bool,
295
296        /// Name of the table affected by the change.
297        pub table: std::string::String,
298
299        /// Provides metadata describing the columns associated with the
300        /// [mods][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.mods] listed
301        /// below.
302        ///
303        /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.mods]: crate::model::change_stream_record::DataChangeRecord::mods
304        pub column_metadata:
305            std::vec::Vec<crate::model::change_stream_record::data_change_record::ColumnMetadata>,
306
307        /// Describes the changes that were made.
308        pub mods: std::vec::Vec<crate::model::change_stream_record::data_change_record::Mod>,
309
310        /// Describes the type of change.
311        pub mod_type: crate::model::change_stream_record::data_change_record::ModType,
312
313        /// Describes the value capture type that was specified in the change stream
314        /// configuration when this change was captured.
315        pub value_capture_type:
316            crate::model::change_stream_record::data_change_record::ValueCaptureType,
317
318        /// Indicates the number of data change records that are part of this
319        /// transaction across all change stream partitions. This value can be used
320        /// to assemble all the records associated with a particular transaction.
321        pub number_of_records_in_transaction: i32,
322
323        /// Indicates the number of partitions that return data change records for
324        /// this transaction. This value can be helpful in assembling all records
325        /// associated with a particular transaction.
326        pub number_of_partitions_in_transaction: i32,
327
328        /// Indicates the transaction tag associated with this transaction.
329        pub transaction_tag: std::string::String,
330
331        /// Indicates whether the transaction is a system transaction. System
332        /// transactions include those issued by time-to-live (TTL), column backfill,
333        /// etc.
334        pub is_system_transaction: bool,
335
336        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
337    }
338
339    impl DataChangeRecord {
340        /// Creates a new default instance.
341        pub fn new() -> Self {
342            std::default::Default::default()
343        }
344
345        /// Sets the value of [commit_timestamp][crate::model::change_stream_record::DataChangeRecord::commit_timestamp].
346        pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
347        where
348            T: std::convert::Into<wkt::Timestamp>,
349        {
350            self.commit_timestamp = std::option::Option::Some(v.into());
351            self
352        }
353
354        /// Sets or clears the value of [commit_timestamp][crate::model::change_stream_record::DataChangeRecord::commit_timestamp].
355        pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
356        where
357            T: std::convert::Into<wkt::Timestamp>,
358        {
359            self.commit_timestamp = v.map(|x| x.into());
360            self
361        }
362
363        /// Sets the value of [record_sequence][crate::model::change_stream_record::DataChangeRecord::record_sequence].
364        pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
365            mut self,
366            v: T,
367        ) -> Self {
368            self.record_sequence = v.into();
369            self
370        }
371
372        /// Sets the value of [server_transaction_id][crate::model::change_stream_record::DataChangeRecord::server_transaction_id].
373        pub fn set_server_transaction_id<T: std::convert::Into<std::string::String>>(
374            mut self,
375            v: T,
376        ) -> Self {
377            self.server_transaction_id = v.into();
378            self
379        }
380
381        /// Sets the value of [is_last_record_in_transaction_in_partition][crate::model::change_stream_record::DataChangeRecord::is_last_record_in_transaction_in_partition].
382        pub fn set_is_last_record_in_transaction_in_partition<T: std::convert::Into<bool>>(
383            mut self,
384            v: T,
385        ) -> Self {
386            self.is_last_record_in_transaction_in_partition = v.into();
387            self
388        }
389
390        /// Sets the value of [table][crate::model::change_stream_record::DataChangeRecord::table].
391        pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
392            self.table = v.into();
393            self
394        }
395
396        /// Sets the value of [column_metadata][crate::model::change_stream_record::DataChangeRecord::column_metadata].
397        pub fn set_column_metadata<T, V>(mut self, v: T) -> Self
398        where
399            T: std::iter::IntoIterator<Item = V>,
400            V: std::convert::Into<
401                    crate::model::change_stream_record::data_change_record::ColumnMetadata,
402                >,
403        {
404            use std::iter::Iterator;
405            self.column_metadata = v.into_iter().map(|i| i.into()).collect();
406            self
407        }
408
409        /// Sets the value of [mods][crate::model::change_stream_record::DataChangeRecord::mods].
410        pub fn set_mods<T, V>(mut self, v: T) -> Self
411        where
412            T: std::iter::IntoIterator<Item = V>,
413            V: std::convert::Into<crate::model::change_stream_record::data_change_record::Mod>,
414        {
415            use std::iter::Iterator;
416            self.mods = v.into_iter().map(|i| i.into()).collect();
417            self
418        }
419
420        /// Sets the value of [mod_type][crate::model::change_stream_record::DataChangeRecord::mod_type].
421        pub fn set_mod_type<
422            T: std::convert::Into<crate::model::change_stream_record::data_change_record::ModType>,
423        >(
424            mut self,
425            v: T,
426        ) -> Self {
427            self.mod_type = v.into();
428            self
429        }
430
431        /// Sets the value of [value_capture_type][crate::model::change_stream_record::DataChangeRecord::value_capture_type].
432        pub fn set_value_capture_type<
433            T: std::convert::Into<
434                    crate::model::change_stream_record::data_change_record::ValueCaptureType,
435                >,
436        >(
437            mut self,
438            v: T,
439        ) -> Self {
440            self.value_capture_type = v.into();
441            self
442        }
443
444        /// Sets the value of [number_of_records_in_transaction][crate::model::change_stream_record::DataChangeRecord::number_of_records_in_transaction].
445        pub fn set_number_of_records_in_transaction<T: std::convert::Into<i32>>(
446            mut self,
447            v: T,
448        ) -> Self {
449            self.number_of_records_in_transaction = v.into();
450            self
451        }
452
453        /// Sets the value of [number_of_partitions_in_transaction][crate::model::change_stream_record::DataChangeRecord::number_of_partitions_in_transaction].
454        pub fn set_number_of_partitions_in_transaction<T: std::convert::Into<i32>>(
455            mut self,
456            v: T,
457        ) -> Self {
458            self.number_of_partitions_in_transaction = v.into();
459            self
460        }
461
462        /// Sets the value of [transaction_tag][crate::model::change_stream_record::DataChangeRecord::transaction_tag].
463        pub fn set_transaction_tag<T: std::convert::Into<std::string::String>>(
464            mut self,
465            v: T,
466        ) -> Self {
467            self.transaction_tag = v.into();
468            self
469        }
470
471        /// Sets the value of [is_system_transaction][crate::model::change_stream_record::DataChangeRecord::is_system_transaction].
472        pub fn set_is_system_transaction<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
473            self.is_system_transaction = v.into();
474            self
475        }
476    }
477
478    impl wkt::message::Message for DataChangeRecord {
479        fn typename() -> &'static str {
480            "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord"
481        }
482    }
483
484    /// Defines additional types related to [DataChangeRecord].
485    pub mod data_change_record {
486        #[allow(unused_imports)]
487        use super::*;
488
489        /// Metadata for a column.
490        #[derive(Clone, Default, PartialEq)]
491        #[non_exhaustive]
492        pub struct ColumnMetadata {
493            /// Name of the column.
494            pub name: std::string::String,
495
496            /// Type of the column.
497            pub r#type: std::option::Option<crate::model::Type>,
498
499            /// Indicates whether the column is a primary key column.
500            pub is_primary_key: bool,
501
502            /// Ordinal position of the column based on the original table definition
503            /// in the schema starting with a value of 1.
504            pub ordinal_position: i64,
505
506            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
507        }
508
509        impl ColumnMetadata {
510            /// Creates a new default instance.
511            pub fn new() -> Self {
512                std::default::Default::default()
513            }
514
515            /// Sets the value of [name][crate::model::change_stream_record::data_change_record::ColumnMetadata::name].
516            pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
517                self.name = v.into();
518                self
519            }
520
521            /// Sets the value of [r#type][crate::model::change_stream_record::data_change_record::ColumnMetadata::type].
522            pub fn set_type<T>(mut self, v: T) -> Self
523            where
524                T: std::convert::Into<crate::model::Type>,
525            {
526                self.r#type = std::option::Option::Some(v.into());
527                self
528            }
529
530            /// Sets or clears the value of [r#type][crate::model::change_stream_record::data_change_record::ColumnMetadata::type].
531            pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
532            where
533                T: std::convert::Into<crate::model::Type>,
534            {
535                self.r#type = v.map(|x| x.into());
536                self
537            }
538
539            /// Sets the value of [is_primary_key][crate::model::change_stream_record::data_change_record::ColumnMetadata::is_primary_key].
540            pub fn set_is_primary_key<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
541                self.is_primary_key = v.into();
542                self
543            }
544
545            /// Sets the value of [ordinal_position][crate::model::change_stream_record::data_change_record::ColumnMetadata::ordinal_position].
546            pub fn set_ordinal_position<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
547                self.ordinal_position = v.into();
548                self
549            }
550        }
551
552        impl wkt::message::Message for ColumnMetadata {
553            fn typename() -> &'static str {
554                "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ColumnMetadata"
555            }
556        }
557
558        /// Returns the value and associated metadata for a particular field of the
559        /// [Mod][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod].
560        ///
561        /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod]: crate::model::change_stream_record::data_change_record::Mod
562        #[derive(Clone, Default, PartialEq)]
563        #[non_exhaustive]
564        pub struct ModValue {
565            /// Index within the repeated
566            /// [column_metadata][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.column_metadata]
567            /// field, to obtain the column metadata for the column that was modified.
568            ///
569            /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.column_metadata]: crate::model::change_stream_record::DataChangeRecord::column_metadata
570            pub column_metadata_index: i32,
571
572            /// The value of the column.
573            pub value: std::option::Option<wkt::Value>,
574
575            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
576        }
577
578        impl ModValue {
579            /// Creates a new default instance.
580            pub fn new() -> Self {
581                std::default::Default::default()
582            }
583
584            /// Sets the value of [column_metadata_index][crate::model::change_stream_record::data_change_record::ModValue::column_metadata_index].
585            pub fn set_column_metadata_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
586                self.column_metadata_index = v.into();
587                self
588            }
589
590            /// Sets the value of [value][crate::model::change_stream_record::data_change_record::ModValue::value].
591            pub fn set_value<T>(mut self, v: T) -> Self
592            where
593                T: std::convert::Into<wkt::Value>,
594            {
595                self.value = std::option::Option::Some(v.into());
596                self
597            }
598
599            /// Sets or clears the value of [value][crate::model::change_stream_record::data_change_record::ModValue::value].
600            pub fn set_or_clear_value<T>(mut self, v: std::option::Option<T>) -> Self
601            where
602                T: std::convert::Into<wkt::Value>,
603            {
604                self.value = v.map(|x| x.into());
605                self
606            }
607        }
608
609        impl wkt::message::Message for ModValue {
610            fn typename() -> &'static str {
611                "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModValue"
612            }
613        }
614
615        /// A mod describes all data changes in a watched table row.
616        #[derive(Clone, Default, PartialEq)]
617        #[non_exhaustive]
618        pub struct Mod {
619            /// Returns the value of the primary key of the modified row.
620            pub keys:
621                std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
622
623            /// Returns the old values before the change for the modified columns.
624            /// Always empty for
625            /// [INSERT][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.INSERT],
626            /// or if old values are not being captured specified by
627            /// [value_capture_type][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType].
628            ///
629            /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.INSERT]: crate::model::change_stream_record::data_change_record::ModType::Insert
630            /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType]: crate::model::change_stream_record::data_change_record::ValueCaptureType
631            pub old_values:
632                std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
633
634            /// Returns the new values after the change for the modified columns.
635            /// Always empty for
636            /// [DELETE][google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.DELETE].
637            ///
638            /// [google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType.DELETE]: crate::model::change_stream_record::data_change_record::ModType::Delete
639            pub new_values:
640                std::vec::Vec<crate::model::change_stream_record::data_change_record::ModValue>,
641
642            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
643        }
644
645        impl Mod {
646            /// Creates a new default instance.
647            pub fn new() -> Self {
648                std::default::Default::default()
649            }
650
651            /// Sets the value of [keys][crate::model::change_stream_record::data_change_record::Mod::keys].
652            pub fn set_keys<T, V>(mut self, v: T) -> Self
653            where
654                T: std::iter::IntoIterator<Item = V>,
655                V: std::convert::Into<
656                        crate::model::change_stream_record::data_change_record::ModValue,
657                    >,
658            {
659                use std::iter::Iterator;
660                self.keys = v.into_iter().map(|i| i.into()).collect();
661                self
662            }
663
664            /// Sets the value of [old_values][crate::model::change_stream_record::data_change_record::Mod::old_values].
665            pub fn set_old_values<T, V>(mut self, v: T) -> Self
666            where
667                T: std::iter::IntoIterator<Item = V>,
668                V: std::convert::Into<
669                        crate::model::change_stream_record::data_change_record::ModValue,
670                    >,
671            {
672                use std::iter::Iterator;
673                self.old_values = v.into_iter().map(|i| i.into()).collect();
674                self
675            }
676
677            /// Sets the value of [new_values][crate::model::change_stream_record::data_change_record::Mod::new_values].
678            pub fn set_new_values<T, V>(mut self, v: T) -> Self
679            where
680                T: std::iter::IntoIterator<Item = V>,
681                V: std::convert::Into<
682                        crate::model::change_stream_record::data_change_record::ModValue,
683                    >,
684            {
685                use std::iter::Iterator;
686                self.new_values = v.into_iter().map(|i| i.into()).collect();
687                self
688            }
689        }
690
691        impl wkt::message::Message for Mod {
692            fn typename() -> &'static str {
693                "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.DataChangeRecord.Mod"
694            }
695        }
696
697        /// Mod type describes the type of change Spanner applied to the data. For
698        /// example, if the client submits an INSERT_OR_UPDATE request, Spanner will
699        /// perform an insert if there is no existing row and return ModType INSERT.
700        /// Alternatively, if there is an existing row, Spanner will perform an
701        /// update and return ModType UPDATE.
702        ///
703        /// # Working with unknown values
704        ///
705        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
706        /// additional enum variants at any time. Adding new variants is not considered
707        /// a breaking change. Applications should write their code in anticipation of:
708        ///
709        /// - New values appearing in future releases of the client library, **and**
710        /// - New values received dynamically, without application changes.
711        ///
712        /// Please consult the [Working with enums] section in the user guide for some
713        /// guidelines.
714        ///
715        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
716        #[derive(Clone, Debug, PartialEq)]
717        #[non_exhaustive]
718        pub enum ModType {
719            /// Not specified.
720            Unspecified,
721            /// Indicates data was inserted.
722            Insert,
723            /// Indicates existing data was updated.
724            Update,
725            /// Indicates existing data was deleted.
726            Delete,
727            /// If set, the enum was initialized with an unknown value.
728            ///
729            /// Applications can examine the value using [ModType::value] or
730            /// [ModType::name].
731            UnknownValue(mod_type::UnknownValue),
732        }
733
734        #[doc(hidden)]
735        pub mod mod_type {
736            #[allow(unused_imports)]
737            use super::*;
738            #[derive(Clone, Debug, PartialEq)]
739            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
740        }
741
742        impl ModType {
743            /// Gets the enum value.
744            ///
745            /// Returns `None` if the enum contains an unknown value deserialized from
746            /// the string representation of enums.
747            pub fn value(&self) -> std::option::Option<i32> {
748                match self {
749                    Self::Unspecified => std::option::Option::Some(0),
750                    Self::Insert => std::option::Option::Some(10),
751                    Self::Update => std::option::Option::Some(20),
752                    Self::Delete => std::option::Option::Some(30),
753                    Self::UnknownValue(u) => u.0.value(),
754                }
755            }
756
757            /// Gets the enum value as a string.
758            ///
759            /// Returns `None` if the enum contains an unknown value deserialized from
760            /// the integer representation of enums.
761            pub fn name(&self) -> std::option::Option<&str> {
762                match self {
763                    Self::Unspecified => std::option::Option::Some("MOD_TYPE_UNSPECIFIED"),
764                    Self::Insert => std::option::Option::Some("INSERT"),
765                    Self::Update => std::option::Option::Some("UPDATE"),
766                    Self::Delete => std::option::Option::Some("DELETE"),
767                    Self::UnknownValue(u) => u.0.name(),
768                }
769            }
770        }
771
772        impl std::default::Default for ModType {
773            fn default() -> Self {
774                use std::convert::From;
775                Self::from(0)
776            }
777        }
778
779        impl std::fmt::Display for ModType {
780            fn fmt(
781                &self,
782                f: &mut std::fmt::Formatter<'_>,
783            ) -> std::result::Result<(), std::fmt::Error> {
784                wkt::internal::display_enum(f, self.name(), self.value())
785            }
786        }
787
788        impl std::convert::From<i32> for ModType {
789            fn from(value: i32) -> Self {
790                match value {
791                    0 => Self::Unspecified,
792                    10 => Self::Insert,
793                    20 => Self::Update,
794                    30 => Self::Delete,
795                    _ => Self::UnknownValue(mod_type::UnknownValue(
796                        wkt::internal::UnknownEnumValue::Integer(value),
797                    )),
798                }
799            }
800        }
801
802        impl std::convert::From<&str> for ModType {
803            fn from(value: &str) -> Self {
804                use std::string::ToString;
805                match value {
806                    "MOD_TYPE_UNSPECIFIED" => Self::Unspecified,
807                    "INSERT" => Self::Insert,
808                    "UPDATE" => Self::Update,
809                    "DELETE" => Self::Delete,
810                    _ => Self::UnknownValue(mod_type::UnknownValue(
811                        wkt::internal::UnknownEnumValue::String(value.to_string()),
812                    )),
813                }
814            }
815        }
816
817        impl serde::ser::Serialize for ModType {
818            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
819            where
820                S: serde::Serializer,
821            {
822                match self {
823                    Self::Unspecified => serializer.serialize_i32(0),
824                    Self::Insert => serializer.serialize_i32(10),
825                    Self::Update => serializer.serialize_i32(20),
826                    Self::Delete => serializer.serialize_i32(30),
827                    Self::UnknownValue(u) => u.0.serialize(serializer),
828                }
829            }
830        }
831
832        impl<'de> serde::de::Deserialize<'de> for ModType {
833            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
834            where
835                D: serde::Deserializer<'de>,
836            {
837                deserializer.deserialize_any(wkt::internal::EnumVisitor::<ModType>::new(
838                    ".google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ModType",
839                ))
840            }
841        }
842
843        /// Value capture type describes which values are recorded in the data
844        /// change record.
845        ///
846        /// # Working with unknown values
847        ///
848        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
849        /// additional enum variants at any time. Adding new variants is not considered
850        /// a breaking change. Applications should write their code in anticipation of:
851        ///
852        /// - New values appearing in future releases of the client library, **and**
853        /// - New values received dynamically, without application changes.
854        ///
855        /// Please consult the [Working with enums] section in the user guide for some
856        /// guidelines.
857        ///
858        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
859        #[derive(Clone, Debug, PartialEq)]
860        #[non_exhaustive]
861        pub enum ValueCaptureType {
862            /// Not specified.
863            Unspecified,
864            /// Records both old and new values of the modified watched columns.
865            OldAndNewValues,
866            /// Records only new values of the modified watched columns.
867            NewValues,
868            /// Records new values of all watched columns, including modified and
869            /// unmodified columns.
870            NewRow,
871            /// Records the new values of all watched columns, including modified and
872            /// unmodified columns. Also records the old values of the modified
873            /// columns.
874            NewRowAndOldValues,
875            /// If set, the enum was initialized with an unknown value.
876            ///
877            /// Applications can examine the value using [ValueCaptureType::value] or
878            /// [ValueCaptureType::name].
879            UnknownValue(value_capture_type::UnknownValue),
880        }
881
882        #[doc(hidden)]
883        pub mod value_capture_type {
884            #[allow(unused_imports)]
885            use super::*;
886            #[derive(Clone, Debug, PartialEq)]
887            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
888        }
889
890        impl ValueCaptureType {
891            /// Gets the enum value.
892            ///
893            /// Returns `None` if the enum contains an unknown value deserialized from
894            /// the string representation of enums.
895            pub fn value(&self) -> std::option::Option<i32> {
896                match self {
897                    Self::Unspecified => std::option::Option::Some(0),
898                    Self::OldAndNewValues => std::option::Option::Some(10),
899                    Self::NewValues => std::option::Option::Some(20),
900                    Self::NewRow => std::option::Option::Some(30),
901                    Self::NewRowAndOldValues => std::option::Option::Some(40),
902                    Self::UnknownValue(u) => u.0.value(),
903                }
904            }
905
906            /// Gets the enum value as a string.
907            ///
908            /// Returns `None` if the enum contains an unknown value deserialized from
909            /// the integer representation of enums.
910            pub fn name(&self) -> std::option::Option<&str> {
911                match self {
912                    Self::Unspecified => {
913                        std::option::Option::Some("VALUE_CAPTURE_TYPE_UNSPECIFIED")
914                    }
915                    Self::OldAndNewValues => std::option::Option::Some("OLD_AND_NEW_VALUES"),
916                    Self::NewValues => std::option::Option::Some("NEW_VALUES"),
917                    Self::NewRow => std::option::Option::Some("NEW_ROW"),
918                    Self::NewRowAndOldValues => std::option::Option::Some("NEW_ROW_AND_OLD_VALUES"),
919                    Self::UnknownValue(u) => u.0.name(),
920                }
921            }
922        }
923
924        impl std::default::Default for ValueCaptureType {
925            fn default() -> Self {
926                use std::convert::From;
927                Self::from(0)
928            }
929        }
930
931        impl std::fmt::Display for ValueCaptureType {
932            fn fmt(
933                &self,
934                f: &mut std::fmt::Formatter<'_>,
935            ) -> std::result::Result<(), std::fmt::Error> {
936                wkt::internal::display_enum(f, self.name(), self.value())
937            }
938        }
939
940        impl std::convert::From<i32> for ValueCaptureType {
941            fn from(value: i32) -> Self {
942                match value {
943                    0 => Self::Unspecified,
944                    10 => Self::OldAndNewValues,
945                    20 => Self::NewValues,
946                    30 => Self::NewRow,
947                    40 => Self::NewRowAndOldValues,
948                    _ => Self::UnknownValue(value_capture_type::UnknownValue(
949                        wkt::internal::UnknownEnumValue::Integer(value),
950                    )),
951                }
952            }
953        }
954
955        impl std::convert::From<&str> for ValueCaptureType {
956            fn from(value: &str) -> Self {
957                use std::string::ToString;
958                match value {
959                    "VALUE_CAPTURE_TYPE_UNSPECIFIED" => Self::Unspecified,
960                    "OLD_AND_NEW_VALUES" => Self::OldAndNewValues,
961                    "NEW_VALUES" => Self::NewValues,
962                    "NEW_ROW" => Self::NewRow,
963                    "NEW_ROW_AND_OLD_VALUES" => Self::NewRowAndOldValues,
964                    _ => Self::UnknownValue(value_capture_type::UnknownValue(
965                        wkt::internal::UnknownEnumValue::String(value.to_string()),
966                    )),
967                }
968            }
969        }
970
971        impl serde::ser::Serialize for ValueCaptureType {
972            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
973            where
974                S: serde::Serializer,
975            {
976                match self {
977                    Self::Unspecified => serializer.serialize_i32(0),
978                    Self::OldAndNewValues => serializer.serialize_i32(10),
979                    Self::NewValues => serializer.serialize_i32(20),
980                    Self::NewRow => serializer.serialize_i32(30),
981                    Self::NewRowAndOldValues => serializer.serialize_i32(40),
982                    Self::UnknownValue(u) => u.0.serialize(serializer),
983                }
984            }
985        }
986
987        impl<'de> serde::de::Deserialize<'de> for ValueCaptureType {
988            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
989            where
990                D: serde::Deserializer<'de>,
991            {
992                deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValueCaptureType>::new(
993                    ".google.spanner.v1.ChangeStreamRecord.DataChangeRecord.ValueCaptureType",
994                ))
995            }
996        }
997    }
998
999    /// A heartbeat record is returned as a progress indicator, when there are no
1000    /// data changes or any other partition record types in the change stream
1001    /// partition.
1002    #[derive(Clone, Default, PartialEq)]
1003    #[non_exhaustive]
1004    pub struct HeartbeatRecord {
1005        /// Indicates the timestamp at which the query has returned all the records
1006        /// in the change stream partition with timestamp <= heartbeat timestamp.
1007        /// The heartbeat timestamp will not be the same as the timestamps of other
1008        /// record types in the same partition.
1009        pub timestamp: std::option::Option<wkt::Timestamp>,
1010
1011        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1012    }
1013
1014    impl HeartbeatRecord {
1015        /// Creates a new default instance.
1016        pub fn new() -> Self {
1017            std::default::Default::default()
1018        }
1019
1020        /// Sets the value of [timestamp][crate::model::change_stream_record::HeartbeatRecord::timestamp].
1021        pub fn set_timestamp<T>(mut self, v: T) -> Self
1022        where
1023            T: std::convert::Into<wkt::Timestamp>,
1024        {
1025            self.timestamp = std::option::Option::Some(v.into());
1026            self
1027        }
1028
1029        /// Sets or clears the value of [timestamp][crate::model::change_stream_record::HeartbeatRecord::timestamp].
1030        pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1031        where
1032            T: std::convert::Into<wkt::Timestamp>,
1033        {
1034            self.timestamp = v.map(|x| x.into());
1035            self
1036        }
1037    }
1038
1039    impl wkt::message::Message for HeartbeatRecord {
1040        fn typename() -> &'static str {
1041            "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.HeartbeatRecord"
1042        }
1043    }
1044
1045    /// A partition start record serves as a notification that the client should
1046    /// schedule the partitions to be queried. PartitionStartRecord returns
1047    /// information about one or more partitions.
1048    #[derive(Clone, Default, PartialEq)]
1049    #[non_exhaustive]
1050    pub struct PartitionStartRecord {
1051        /// Start timestamp at which the partitions should be queried to return
1052        /// change stream records with timestamps >= start_timestamp.
1053        /// DataChangeRecord.commit_timestamps,
1054        /// PartitionStartRecord.start_timestamps,
1055        /// PartitionEventRecord.commit_timestamps, and
1056        /// PartitionEndRecord.end_timestamps can have the same value in the same
1057        /// partition.
1058        pub start_timestamp: std::option::Option<wkt::Timestamp>,
1059
1060        /// Record sequence numbers are unique and monotonically increasing (but not
1061        /// necessarily contiguous) for a specific timestamp across record
1062        /// types in the same partition. To guarantee ordered processing, the reader
1063        /// should process records (of potentially different types) in
1064        /// record_sequence order for a specific timestamp in the same partition.
1065        pub record_sequence: std::string::String,
1066
1067        /// Unique partition identifiers to be used in queries.
1068        pub partition_tokens: std::vec::Vec<std::string::String>,
1069
1070        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1071    }
1072
1073    impl PartitionStartRecord {
1074        /// Creates a new default instance.
1075        pub fn new() -> Self {
1076            std::default::Default::default()
1077        }
1078
1079        /// Sets the value of [start_timestamp][crate::model::change_stream_record::PartitionStartRecord::start_timestamp].
1080        pub fn set_start_timestamp<T>(mut self, v: T) -> Self
1081        where
1082            T: std::convert::Into<wkt::Timestamp>,
1083        {
1084            self.start_timestamp = std::option::Option::Some(v.into());
1085            self
1086        }
1087
1088        /// Sets or clears the value of [start_timestamp][crate::model::change_stream_record::PartitionStartRecord::start_timestamp].
1089        pub fn set_or_clear_start_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1090        where
1091            T: std::convert::Into<wkt::Timestamp>,
1092        {
1093            self.start_timestamp = v.map(|x| x.into());
1094            self
1095        }
1096
1097        /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionStartRecord::record_sequence].
1098        pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1099            mut self,
1100            v: T,
1101        ) -> Self {
1102            self.record_sequence = v.into();
1103            self
1104        }
1105
1106        /// Sets the value of [partition_tokens][crate::model::change_stream_record::PartitionStartRecord::partition_tokens].
1107        pub fn set_partition_tokens<T, V>(mut self, v: T) -> Self
1108        where
1109            T: std::iter::IntoIterator<Item = V>,
1110            V: std::convert::Into<std::string::String>,
1111        {
1112            use std::iter::Iterator;
1113            self.partition_tokens = v.into_iter().map(|i| i.into()).collect();
1114            self
1115        }
1116    }
1117
1118    impl wkt::message::Message for PartitionStartRecord {
1119        fn typename() -> &'static str {
1120            "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionStartRecord"
1121        }
1122    }
1123
1124    /// A partition end record serves as a notification that the client should stop
1125    /// reading the partition. No further records are expected to be retrieved on
1126    /// it.
1127    #[derive(Clone, Default, PartialEq)]
1128    #[non_exhaustive]
1129    pub struct PartitionEndRecord {
1130        /// End timestamp at which the change stream partition is terminated. All
1131        /// changes generated by this partition will have timestamps <=
1132        /// end_timestamp. DataChangeRecord.commit_timestamps,
1133        /// PartitionStartRecord.start_timestamps,
1134        /// PartitionEventRecord.commit_timestamps, and
1135        /// PartitionEndRecord.end_timestamps can have the same value in the same
1136        /// partition. PartitionEndRecord is the last record returned for a
1137        /// partition.
1138        pub end_timestamp: std::option::Option<wkt::Timestamp>,
1139
1140        /// Record sequence numbers are unique and monotonically increasing (but not
1141        /// necessarily contiguous) for a specific timestamp across record
1142        /// types in the same partition. To guarantee ordered processing, the reader
1143        /// should process records (of potentially different types) in
1144        /// record_sequence order for a specific timestamp in the same partition.
1145        pub record_sequence: std::string::String,
1146
1147        /// Unique partition identifier describing the terminated change stream
1148        /// partition.
1149        /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEndRecord.partition_token]
1150        /// is equal to the partition token of the change stream partition currently
1151        /// queried to return this PartitionEndRecord.
1152        ///
1153        /// [google.spanner.v1.ChangeStreamRecord.PartitionEndRecord.partition_token]: crate::model::change_stream_record::PartitionEndRecord::partition_token
1154        pub partition_token: std::string::String,
1155
1156        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1157    }
1158
1159    impl PartitionEndRecord {
1160        /// Creates a new default instance.
1161        pub fn new() -> Self {
1162            std::default::Default::default()
1163        }
1164
1165        /// Sets the value of [end_timestamp][crate::model::change_stream_record::PartitionEndRecord::end_timestamp].
1166        pub fn set_end_timestamp<T>(mut self, v: T) -> Self
1167        where
1168            T: std::convert::Into<wkt::Timestamp>,
1169        {
1170            self.end_timestamp = std::option::Option::Some(v.into());
1171            self
1172        }
1173
1174        /// Sets or clears the value of [end_timestamp][crate::model::change_stream_record::PartitionEndRecord::end_timestamp].
1175        pub fn set_or_clear_end_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1176        where
1177            T: std::convert::Into<wkt::Timestamp>,
1178        {
1179            self.end_timestamp = v.map(|x| x.into());
1180            self
1181        }
1182
1183        /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionEndRecord::record_sequence].
1184        pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1185            mut self,
1186            v: T,
1187        ) -> Self {
1188            self.record_sequence = v.into();
1189            self
1190        }
1191
1192        /// Sets the value of [partition_token][crate::model::change_stream_record::PartitionEndRecord::partition_token].
1193        pub fn set_partition_token<T: std::convert::Into<std::string::String>>(
1194            mut self,
1195            v: T,
1196        ) -> Self {
1197            self.partition_token = v.into();
1198            self
1199        }
1200    }
1201
1202    impl wkt::message::Message for PartitionEndRecord {
1203        fn typename() -> &'static str {
1204            "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEndRecord"
1205        }
1206    }
1207
1208    /// A partition event record describes key range changes for a change stream
1209    /// partition. The changes to a row defined by its primary key can be captured
1210    /// in one change stream partition for a specific time range, and then be
1211    /// captured in a different change stream partition for a different time range.
1212    /// This movement of key ranges across change stream partitions is a reflection
1213    /// of activities, such as Spanner's dynamic splitting and load balancing, etc.
1214    /// Processing this event is needed if users want to guarantee processing of
1215    /// the changes for any key in timestamp order. If time ordered processing of
1216    /// changes for a primary key is not needed, this event can be ignored.
1217    /// To guarantee time ordered processing for each primary key, if the event
1218    /// describes move-ins, the reader of this partition needs to wait until the
1219    /// readers of the source partitions have processed all records with timestamps
1220    /// <= this PartitionEventRecord.commit_timestamp, before advancing beyond this
1221    /// PartitionEventRecord. If the event describes move-outs, the reader can
1222    /// notify the readers of the destination partitions that they can continue
1223    /// processing.
1224    #[derive(Clone, Default, PartialEq)]
1225    #[non_exhaustive]
1226    pub struct PartitionEventRecord {
1227        /// Indicates the commit timestamp at which the key range change occurred.
1228        /// DataChangeRecord.commit_timestamps,
1229        /// PartitionStartRecord.start_timestamps,
1230        /// PartitionEventRecord.commit_timestamps, and
1231        /// PartitionEndRecord.end_timestamps can have the same value in the same
1232        /// partition.
1233        pub commit_timestamp: std::option::Option<wkt::Timestamp>,
1234
1235        /// Record sequence numbers are unique and monotonically increasing (but not
1236        /// necessarily contiguous) for a specific timestamp across record
1237        /// types in the same partition. To guarantee ordered processing, the reader
1238        /// should process records (of potentially different types) in
1239        /// record_sequence order for a specific timestamp in the same partition.
1240        pub record_sequence: std::string::String,
1241
1242        /// Unique partition identifier describing the partition this event
1243        /// occurred on.
1244        /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1245        /// is equal to the partition token of the change stream partition currently
1246        /// queried to return this PartitionEventRecord.
1247        ///
1248        /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1249        pub partition_token: std::string::String,
1250
1251        /// Set when one or more key ranges are moved into the change stream
1252        /// partition identified by
1253        /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1254        ///
1255        /// Example: Two key ranges are moved into partition (P1) from partition (P2)
1256        /// and partition (P3) in a single transaction at timestamp T.
1257        ///
1258        /// The PartitionEventRecord returned in P1 will reflect the move as:
1259        ///
1260        /// PartitionEventRecord {
1261        /// commit_timestamp: T
1262        /// partition_token: "P1"
1263        /// move_in_events {
1264        /// source_partition_token: "P2"
1265        /// }
1266        /// move_in_events {
1267        /// source_partition_token: "P3"
1268        /// }
1269        /// }
1270        ///
1271        /// The PartitionEventRecord returned in P2 will reflect the move as:
1272        ///
1273        /// PartitionEventRecord {
1274        /// commit_timestamp: T
1275        /// partition_token: "P2"
1276        /// move_out_events {
1277        /// destination_partition_token: "P1"
1278        /// }
1279        /// }
1280        ///
1281        /// The PartitionEventRecord returned in P3 will reflect the move as:
1282        ///
1283        /// PartitionEventRecord {
1284        /// commit_timestamp: T
1285        /// partition_token: "P3"
1286        /// move_out_events {
1287        /// destination_partition_token: "P1"
1288        /// }
1289        /// }
1290        ///
1291        /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1292        pub move_in_events:
1293            std::vec::Vec<crate::model::change_stream_record::partition_event_record::MoveInEvent>,
1294
1295        /// Set when one or more key ranges are moved out of the change stream
1296        /// partition identified by
1297        /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1298        ///
1299        /// Example: Two key ranges are moved out of partition (P1) to partition (P2)
1300        /// and partition (P3) in a single transaction at timestamp T.
1301        ///
1302        /// The PartitionEventRecord returned in P1 will reflect the move as:
1303        ///
1304        /// PartitionEventRecord {
1305        /// commit_timestamp: T
1306        /// partition_token: "P1"
1307        /// move_out_events {
1308        /// destination_partition_token: "P2"
1309        /// }
1310        /// move_out_events {
1311        /// destination_partition_token: "P3"
1312        /// }
1313        /// }
1314        ///
1315        /// The PartitionEventRecord returned in P2 will reflect the move as:
1316        ///
1317        /// PartitionEventRecord {
1318        /// commit_timestamp: T
1319        /// partition_token: "P2"
1320        /// move_in_events {
1321        /// source_partition_token: "P1"
1322        /// }
1323        /// }
1324        ///
1325        /// The PartitionEventRecord returned in P3 will reflect the move as:
1326        ///
1327        /// PartitionEventRecord {
1328        /// commit_timestamp: T
1329        /// partition_token: "P3"
1330        /// move_in_events {
1331        /// source_partition_token: "P1"
1332        /// }
1333        /// }
1334        ///
1335        /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1336        pub move_out_events:
1337            std::vec::Vec<crate::model::change_stream_record::partition_event_record::MoveOutEvent>,
1338
1339        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1340    }
1341
1342    impl PartitionEventRecord {
1343        /// Creates a new default instance.
1344        pub fn new() -> Self {
1345            std::default::Default::default()
1346        }
1347
1348        /// Sets the value of [commit_timestamp][crate::model::change_stream_record::PartitionEventRecord::commit_timestamp].
1349        pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
1350        where
1351            T: std::convert::Into<wkt::Timestamp>,
1352        {
1353            self.commit_timestamp = std::option::Option::Some(v.into());
1354            self
1355        }
1356
1357        /// Sets or clears the value of [commit_timestamp][crate::model::change_stream_record::PartitionEventRecord::commit_timestamp].
1358        pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1359        where
1360            T: std::convert::Into<wkt::Timestamp>,
1361        {
1362            self.commit_timestamp = v.map(|x| x.into());
1363            self
1364        }
1365
1366        /// Sets the value of [record_sequence][crate::model::change_stream_record::PartitionEventRecord::record_sequence].
1367        pub fn set_record_sequence<T: std::convert::Into<std::string::String>>(
1368            mut self,
1369            v: T,
1370        ) -> Self {
1371            self.record_sequence = v.into();
1372            self
1373        }
1374
1375        /// Sets the value of [partition_token][crate::model::change_stream_record::PartitionEventRecord::partition_token].
1376        pub fn set_partition_token<T: std::convert::Into<std::string::String>>(
1377            mut self,
1378            v: T,
1379        ) -> Self {
1380            self.partition_token = v.into();
1381            self
1382        }
1383
1384        /// Sets the value of [move_in_events][crate::model::change_stream_record::PartitionEventRecord::move_in_events].
1385        pub fn set_move_in_events<T, V>(mut self, v: T) -> Self
1386        where
1387            T: std::iter::IntoIterator<Item = V>,
1388            V: std::convert::Into<
1389                    crate::model::change_stream_record::partition_event_record::MoveInEvent,
1390                >,
1391        {
1392            use std::iter::Iterator;
1393            self.move_in_events = v.into_iter().map(|i| i.into()).collect();
1394            self
1395        }
1396
1397        /// Sets the value of [move_out_events][crate::model::change_stream_record::PartitionEventRecord::move_out_events].
1398        pub fn set_move_out_events<T, V>(mut self, v: T) -> Self
1399        where
1400            T: std::iter::IntoIterator<Item = V>,
1401            V: std::convert::Into<
1402                    crate::model::change_stream_record::partition_event_record::MoveOutEvent,
1403                >,
1404        {
1405            use std::iter::Iterator;
1406            self.move_out_events = v.into_iter().map(|i| i.into()).collect();
1407            self
1408        }
1409    }
1410
1411    impl wkt::message::Message for PartitionEventRecord {
1412        fn typename() -> &'static str {
1413            "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord"
1414        }
1415    }
1416
1417    /// Defines additional types related to [PartitionEventRecord].
1418    pub mod partition_event_record {
1419        #[allow(unused_imports)]
1420        use super::*;
1421
1422        /// Describes move-in of the key ranges into the change stream partition
1423        /// identified by
1424        /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1425        ///
1426        /// To maintain processing the changes for a particular key in timestamp
1427        /// order, the query processing the change stream partition identified by
1428        /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1429        /// should not advance beyond the partition event record commit timestamp
1430        /// until the queries processing the source change stream partitions have
1431        /// processed all change stream records with timestamps <= the partition
1432        /// event record commit timestamp.
1433        ///
1434        /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1435        #[derive(Clone, Default, PartialEq)]
1436        #[non_exhaustive]
1437        pub struct MoveInEvent {
1438            /// An unique partition identifier describing the source change stream
1439            /// partition that recorded changes for the key range that is moving
1440            /// into this partition.
1441            pub source_partition_token: std::string::String,
1442
1443            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1444        }
1445
1446        impl MoveInEvent {
1447            /// Creates a new default instance.
1448            pub fn new() -> Self {
1449                std::default::Default::default()
1450            }
1451
1452            /// Sets the value of [source_partition_token][crate::model::change_stream_record::partition_event_record::MoveInEvent::source_partition_token].
1453            pub fn set_source_partition_token<T: std::convert::Into<std::string::String>>(
1454                mut self,
1455                v: T,
1456            ) -> Self {
1457                self.source_partition_token = v.into();
1458                self
1459            }
1460        }
1461
1462        impl wkt::message::Message for MoveInEvent {
1463            fn typename() -> &'static str {
1464                "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveInEvent"
1465            }
1466        }
1467
1468        /// Describes move-out of the key ranges out of the change stream partition
1469        /// identified by
1470        /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token].
1471        ///
1472        /// To maintain processing the changes for a particular key in timestamp
1473        /// order, the query processing the
1474        /// [MoveOutEvent][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent]
1475        /// in the partition identified by
1476        /// [partition_token][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]
1477        /// should inform the queries processing the destination partitions that
1478        /// they can unblock and proceed processing records past the
1479        /// [commit_timestamp][google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.commit_timestamp].
1480        ///
1481        /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent]: crate::model::change_stream_record::partition_event_record::MoveOutEvent
1482        /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.commit_timestamp]: crate::model::change_stream_record::PartitionEventRecord::commit_timestamp
1483        /// [google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.partition_token]: crate::model::change_stream_record::PartitionEventRecord::partition_token
1484        #[derive(Clone, Default, PartialEq)]
1485        #[non_exhaustive]
1486        pub struct MoveOutEvent {
1487            /// An unique partition identifier describing the destination change
1488            /// stream partition that will record changes for the key range that is
1489            /// moving out of this partition.
1490            pub destination_partition_token: std::string::String,
1491
1492            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1493        }
1494
1495        impl MoveOutEvent {
1496            /// Creates a new default instance.
1497            pub fn new() -> Self {
1498                std::default::Default::default()
1499            }
1500
1501            /// Sets the value of [destination_partition_token][crate::model::change_stream_record::partition_event_record::MoveOutEvent::destination_partition_token].
1502            pub fn set_destination_partition_token<T: std::convert::Into<std::string::String>>(
1503                mut self,
1504                v: T,
1505            ) -> Self {
1506                self.destination_partition_token = v.into();
1507                self
1508            }
1509        }
1510
1511        impl wkt::message::Message for MoveOutEvent {
1512            fn typename() -> &'static str {
1513                "type.googleapis.com/google.spanner.v1.ChangeStreamRecord.PartitionEventRecord.MoveOutEvent"
1514            }
1515        }
1516    }
1517
1518    /// One of the change stream subrecords.
1519    #[derive(Clone, Debug, PartialEq)]
1520    #[non_exhaustive]
1521    pub enum Record {
1522        /// Data change record describing a data change for a change stream
1523        /// partition.
1524        DataChangeRecord(std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>),
1525        /// Heartbeat record describing a heartbeat for a change stream partition.
1526        HeartbeatRecord(std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>),
1527        /// Partition start record describing a new change stream partition.
1528        PartitionStartRecord(
1529            std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
1530        ),
1531        /// Partition end record describing a terminated change stream partition.
1532        PartitionEndRecord(std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>),
1533        /// Partition event record describing key range changes for a change stream
1534        /// partition.
1535        PartitionEventRecord(
1536            std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
1537        ),
1538    }
1539
1540    impl Record {
1541        /// Initializes the enum to the [DataChangeRecord](Self::DataChangeRecord) branch.
1542        pub fn from_data_change_record(
1543            value: impl std::convert::Into<
1544                std::boxed::Box<crate::model::change_stream_record::DataChangeRecord>,
1545            >,
1546        ) -> Self {
1547            Self::DataChangeRecord(value.into())
1548        }
1549        /// Initializes the enum to the [HeartbeatRecord](Self::HeartbeatRecord) branch.
1550        pub fn from_heartbeat_record(
1551            value: impl std::convert::Into<
1552                std::boxed::Box<crate::model::change_stream_record::HeartbeatRecord>,
1553            >,
1554        ) -> Self {
1555            Self::HeartbeatRecord(value.into())
1556        }
1557        /// Initializes the enum to the [PartitionStartRecord](Self::PartitionStartRecord) branch.
1558        pub fn from_partition_start_record(
1559            value: impl std::convert::Into<
1560                std::boxed::Box<crate::model::change_stream_record::PartitionStartRecord>,
1561            >,
1562        ) -> Self {
1563            Self::PartitionStartRecord(value.into())
1564        }
1565        /// Initializes the enum to the [PartitionEndRecord](Self::PartitionEndRecord) branch.
1566        pub fn from_partition_end_record(
1567            value: impl std::convert::Into<
1568                std::boxed::Box<crate::model::change_stream_record::PartitionEndRecord>,
1569            >,
1570        ) -> Self {
1571            Self::PartitionEndRecord(value.into())
1572        }
1573        /// Initializes the enum to the [PartitionEventRecord](Self::PartitionEventRecord) branch.
1574        pub fn from_partition_event_record(
1575            value: impl std::convert::Into<
1576                std::boxed::Box<crate::model::change_stream_record::PartitionEventRecord>,
1577            >,
1578        ) -> Self {
1579            Self::PartitionEventRecord(value.into())
1580        }
1581    }
1582}
1583
1584/// The response for [Commit][google.spanner.v1.Spanner.Commit].
1585///
1586/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
1587#[derive(Clone, Default, PartialEq)]
1588#[non_exhaustive]
1589pub struct CommitResponse {
1590    /// The Cloud Spanner timestamp at which the transaction committed.
1591    pub commit_timestamp: std::option::Option<wkt::Timestamp>,
1592
1593    /// The statistics about this `Commit`. Not returned by default.
1594    /// For more information, see
1595    /// [CommitRequest.return_commit_stats][google.spanner.v1.CommitRequest.return_commit_stats].
1596    ///
1597    /// [google.spanner.v1.CommitRequest.return_commit_stats]: crate::model::CommitRequest::return_commit_stats
1598    pub commit_stats: std::option::Option<crate::model::commit_response::CommitStats>,
1599
1600    /// If `TransactionOptions.isolation_level` is set to
1601    /// `IsolationLevel.REPEATABLE_READ`, then the snapshot timestamp is the
1602    /// timestamp at which all reads in the transaction ran. This timestamp is
1603    /// never returned.
1604    pub snapshot_timestamp: std::option::Option<wkt::Timestamp>,
1605
1606    /// Optional. A cache update expresses a set of changes the client should
1607    /// incorporate into its location cache. The client should discard the changes
1608    /// if they are older than the data it already has. This data can be obtained
1609    /// in response to requests that included a `RoutingHint` field, but may also
1610    /// be obtained by explicit location-fetching RPCs which may be added in the
1611    /// future.
1612    pub cache_update: std::option::Option<crate::model::CacheUpdate>,
1613
1614    /// The isolation level used for the read-write transaction.
1615    pub isolation_level: crate::model::transaction_options::IsolationLevel,
1616
1617    /// The read lock mode used for the read-write transaction.
1618    pub read_lock_mode: crate::model::transaction_options::read_write::ReadLockMode,
1619
1620    /// You must examine and retry the commit if the following is populated.
1621    pub multiplexed_session_retry:
1622        std::option::Option<crate::model::commit_response::MultiplexedSessionRetry>,
1623
1624    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1625}
1626
1627impl CommitResponse {
1628    /// Creates a new default instance.
1629    pub fn new() -> Self {
1630        std::default::Default::default()
1631    }
1632
1633    /// Sets the value of [commit_timestamp][crate::model::CommitResponse::commit_timestamp].
1634    pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
1635    where
1636        T: std::convert::Into<wkt::Timestamp>,
1637    {
1638        self.commit_timestamp = std::option::Option::Some(v.into());
1639        self
1640    }
1641
1642    /// Sets or clears the value of [commit_timestamp][crate::model::CommitResponse::commit_timestamp].
1643    pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1644    where
1645        T: std::convert::Into<wkt::Timestamp>,
1646    {
1647        self.commit_timestamp = v.map(|x| x.into());
1648        self
1649    }
1650
1651    /// Sets the value of [commit_stats][crate::model::CommitResponse::commit_stats].
1652    pub fn set_commit_stats<T>(mut self, v: T) -> Self
1653    where
1654        T: std::convert::Into<crate::model::commit_response::CommitStats>,
1655    {
1656        self.commit_stats = std::option::Option::Some(v.into());
1657        self
1658    }
1659
1660    /// Sets or clears the value of [commit_stats][crate::model::CommitResponse::commit_stats].
1661    pub fn set_or_clear_commit_stats<T>(mut self, v: std::option::Option<T>) -> Self
1662    where
1663        T: std::convert::Into<crate::model::commit_response::CommitStats>,
1664    {
1665        self.commit_stats = v.map(|x| x.into());
1666        self
1667    }
1668
1669    /// Sets the value of [snapshot_timestamp][crate::model::CommitResponse::snapshot_timestamp].
1670    pub fn set_snapshot_timestamp<T>(mut self, v: T) -> Self
1671    where
1672        T: std::convert::Into<wkt::Timestamp>,
1673    {
1674        self.snapshot_timestamp = std::option::Option::Some(v.into());
1675        self
1676    }
1677
1678    /// Sets or clears the value of [snapshot_timestamp][crate::model::CommitResponse::snapshot_timestamp].
1679    pub fn set_or_clear_snapshot_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
1680    where
1681        T: std::convert::Into<wkt::Timestamp>,
1682    {
1683        self.snapshot_timestamp = v.map(|x| x.into());
1684        self
1685    }
1686
1687    /// Sets the value of [cache_update][crate::model::CommitResponse::cache_update].
1688    pub fn set_cache_update<T>(mut self, v: T) -> Self
1689    where
1690        T: std::convert::Into<crate::model::CacheUpdate>,
1691    {
1692        self.cache_update = std::option::Option::Some(v.into());
1693        self
1694    }
1695
1696    /// Sets or clears the value of [cache_update][crate::model::CommitResponse::cache_update].
1697    pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
1698    where
1699        T: std::convert::Into<crate::model::CacheUpdate>,
1700    {
1701        self.cache_update = v.map(|x| x.into());
1702        self
1703    }
1704
1705    /// Sets the value of [isolation_level][crate::model::CommitResponse::isolation_level].
1706    pub fn set_isolation_level<
1707        T: std::convert::Into<crate::model::transaction_options::IsolationLevel>,
1708    >(
1709        mut self,
1710        v: T,
1711    ) -> Self {
1712        self.isolation_level = v.into();
1713        self
1714    }
1715
1716    /// Sets the value of [read_lock_mode][crate::model::CommitResponse::read_lock_mode].
1717    pub fn set_read_lock_mode<
1718        T: std::convert::Into<crate::model::transaction_options::read_write::ReadLockMode>,
1719    >(
1720        mut self,
1721        v: T,
1722    ) -> Self {
1723        self.read_lock_mode = v.into();
1724        self
1725    }
1726
1727    /// Sets the value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry].
1728    ///
1729    /// Note that all the setters affecting `multiplexed_session_retry` are mutually
1730    /// exclusive.
1731    pub fn set_multiplexed_session_retry<
1732        T: std::convert::Into<
1733                std::option::Option<crate::model::commit_response::MultiplexedSessionRetry>,
1734            >,
1735    >(
1736        mut self,
1737        v: T,
1738    ) -> Self {
1739        self.multiplexed_session_retry = v.into();
1740        self
1741    }
1742
1743    /// The value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry]
1744    /// if it holds a `PrecommitToken`, `None` if the field is not set or
1745    /// holds a different branch.
1746    pub fn precommit_token(
1747        &self,
1748    ) -> std::option::Option<&std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>> {
1749        #[allow(unreachable_patterns)]
1750        self.multiplexed_session_retry
1751            .as_ref()
1752            .and_then(|v| match v {
1753                crate::model::commit_response::MultiplexedSessionRetry::PrecommitToken(v) => {
1754                    std::option::Option::Some(v)
1755                }
1756                _ => std::option::Option::None,
1757            })
1758    }
1759
1760    /// Sets the value of [multiplexed_session_retry][crate::model::CommitResponse::multiplexed_session_retry]
1761    /// to hold a `PrecommitToken`.
1762    ///
1763    /// Note that all the setters affecting `multiplexed_session_retry` are
1764    /// mutually exclusive.
1765    pub fn set_precommit_token<
1766        T: std::convert::Into<std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>>,
1767    >(
1768        mut self,
1769        v: T,
1770    ) -> Self {
1771        self.multiplexed_session_retry = std::option::Option::Some(
1772            crate::model::commit_response::MultiplexedSessionRetry::PrecommitToken(v.into()),
1773        );
1774        self
1775    }
1776}
1777
1778impl wkt::message::Message for CommitResponse {
1779    fn typename() -> &'static str {
1780        "type.googleapis.com/google.spanner.v1.CommitResponse"
1781    }
1782}
1783
1784/// Defines additional types related to [CommitResponse].
1785pub mod commit_response {
1786    #[allow(unused_imports)]
1787    use super::*;
1788
1789    /// Additional statistics about a commit.
1790    #[derive(Clone, Default, PartialEq)]
1791    #[non_exhaustive]
1792    pub struct CommitStats {
1793        /// The total number of mutations for the transaction. Knowing the
1794        /// `mutation_count` value can help you maximize the number of mutations
1795        /// in a transaction and minimize the number of API round trips. You can
1796        /// also monitor this value to prevent transactions from exceeding the system
1797        /// [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data).
1798        /// If the number of mutations exceeds the limit, the server returns
1799        /// [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT).
1800        pub mutation_count: i64,
1801
1802        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1803    }
1804
1805    impl CommitStats {
1806        /// Creates a new default instance.
1807        pub fn new() -> Self {
1808            std::default::Default::default()
1809        }
1810
1811        /// Sets the value of [mutation_count][crate::model::commit_response::CommitStats::mutation_count].
1812        pub fn set_mutation_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1813            self.mutation_count = v.into();
1814            self
1815        }
1816    }
1817
1818    impl wkt::message::Message for CommitStats {
1819        fn typename() -> &'static str {
1820            "type.googleapis.com/google.spanner.v1.CommitResponse.CommitStats"
1821        }
1822    }
1823
1824    /// You must examine and retry the commit if the following is populated.
1825    #[derive(Clone, Debug, PartialEq)]
1826    #[non_exhaustive]
1827    pub enum MultiplexedSessionRetry {
1828        /// If specified, transaction has not committed yet.
1829        /// You must retry the commit with the new precommit token.
1830        PrecommitToken(std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>),
1831    }
1832
1833    impl MultiplexedSessionRetry {
1834        /// Initializes the enum to the [PrecommitToken](Self::PrecommitToken) branch.
1835        pub fn from_precommit_token(
1836            value: impl std::convert::Into<
1837                std::boxed::Box<crate::model::MultiplexedSessionPrecommitToken>,
1838            >,
1839        ) -> Self {
1840            Self::PrecommitToken(value.into())
1841        }
1842    }
1843}
1844
1845/// KeyRange represents a range of rows in a table or index.
1846///
1847/// A range has a start key and an end key. These keys can be open or
1848/// closed, indicating if the range includes rows with that key.
1849///
1850/// Keys are represented by lists, where the ith value in the list
1851/// corresponds to the ith component of the table or index primary key.
1852/// Individual values are encoded as described
1853/// [here][google.spanner.v1.TypeCode].
1854///
1855/// For example, consider the following table definition:
1856///
1857/// ```norust
1858/// CREATE TABLE UserEvents (
1859///   UserName STRING(MAX),
1860///   EventDate STRING(10)
1861/// ) PRIMARY KEY(UserName, EventDate);
1862/// ```
1863///
1864/// The following keys name rows in this table:
1865///
1866/// ```norust
1867/// ["Bob", "2014-09-23"]
1868/// ["Alfred", "2015-06-12"]
1869/// ```
1870///
1871/// Since the `UserEvents` table's `PRIMARY KEY` clause names two
1872/// columns, each `UserEvents` key has two elements; the first is the
1873/// `UserName`, and the second is the `EventDate`.
1874///
1875/// Key ranges with multiple components are interpreted
1876/// lexicographically by component using the table or index key's declared
1877/// sort order. For example, the following range returns all events for
1878/// user `"Bob"` that occurred in the year 2015:
1879///
1880/// ```norust
1881/// "start_closed": ["Bob", "2015-01-01"]
1882/// "end_closed": ["Bob", "2015-12-31"]
1883/// ```
1884///
1885/// Start and end keys can omit trailing key components. This affects the
1886/// inclusion and exclusion of rows that exactly match the provided key
1887/// components: if the key is closed, then rows that exactly match the
1888/// provided components are included; if the key is open, then rows
1889/// that exactly match are not included.
1890///
1891/// For example, the following range includes all events for `"Bob"` that
1892/// occurred during and after the year 2000:
1893///
1894/// ```norust
1895/// "start_closed": ["Bob", "2000-01-01"]
1896/// "end_closed": ["Bob"]
1897/// ```
1898///
1899/// The next example retrieves all events for `"Bob"`:
1900///
1901/// ```norust
1902/// "start_closed": ["Bob"]
1903/// "end_closed": ["Bob"]
1904/// ```
1905///
1906/// To retrieve events before the year 2000:
1907///
1908/// ```norust
1909/// "start_closed": ["Bob"]
1910/// "end_open": ["Bob", "2000-01-01"]
1911/// ```
1912///
1913/// The following range includes all rows in the table:
1914///
1915/// ```norust
1916/// "start_closed": []
1917/// "end_closed": []
1918/// ```
1919///
1920/// This range returns all users whose `UserName` begins with any
1921/// character from A to C:
1922///
1923/// ```norust
1924/// "start_closed": ["A"]
1925/// "end_open": ["D"]
1926/// ```
1927///
1928/// This range returns all users whose `UserName` begins with B:
1929///
1930/// ```norust
1931/// "start_closed": ["B"]
1932/// "end_open": ["C"]
1933/// ```
1934///
1935/// Key ranges honor column sort order. For example, suppose a table is
1936/// defined as follows:
1937///
1938/// ```norust
1939/// CREATE TABLE DescendingSortedTable {
1940///   Key INT64,
1941///   ...
1942/// ) PRIMARY KEY(Key DESC);
1943/// ```
1944///
1945/// The following range retrieves all rows with key values between 1
1946/// and 100 inclusive:
1947///
1948/// ```norust
1949/// "start_closed": ["100"]
1950/// "end_closed": ["1"]
1951/// ```
1952///
1953/// Note that 100 is passed as the start, and 1 is passed as the end,
1954/// because `Key` is a descending column in the schema.
1955///
1956/// [google.spanner.v1.TypeCode]: crate::model::TypeCode
1957#[derive(Clone, Default, PartialEq)]
1958#[non_exhaustive]
1959pub struct KeyRange {
1960    /// The start key must be provided. It can be either closed or open.
1961    pub start_key_type: std::option::Option<crate::model::key_range::StartKeyType>,
1962
1963    /// The end key must be provided. It can be either closed or open.
1964    pub end_key_type: std::option::Option<crate::model::key_range::EndKeyType>,
1965
1966    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1967}
1968
1969impl KeyRange {
1970    /// Creates a new default instance.
1971    pub fn new() -> Self {
1972        std::default::Default::default()
1973    }
1974
1975    /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type].
1976    ///
1977    /// Note that all the setters affecting `start_key_type` are mutually
1978    /// exclusive.
1979    pub fn set_start_key_type<
1980        T: std::convert::Into<std::option::Option<crate::model::key_range::StartKeyType>>,
1981    >(
1982        mut self,
1983        v: T,
1984    ) -> Self {
1985        self.start_key_type = v.into();
1986        self
1987    }
1988
1989    /// The value of [start_key_type][crate::model::KeyRange::start_key_type]
1990    /// if it holds a `StartClosed`, `None` if the field is not set or
1991    /// holds a different branch.
1992    pub fn start_closed(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
1993        #[allow(unreachable_patterns)]
1994        self.start_key_type.as_ref().and_then(|v| match v {
1995            crate::model::key_range::StartKeyType::StartClosed(v) => std::option::Option::Some(v),
1996            _ => std::option::Option::None,
1997        })
1998    }
1999
2000    /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type]
2001    /// to hold a `StartClosed`.
2002    ///
2003    /// Note that all the setters affecting `start_key_type` are
2004    /// mutually exclusive.
2005    pub fn set_start_closed<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2006        mut self,
2007        v: T,
2008    ) -> Self {
2009        self.start_key_type =
2010            std::option::Option::Some(crate::model::key_range::StartKeyType::StartClosed(v.into()));
2011        self
2012    }
2013
2014    /// The value of [start_key_type][crate::model::KeyRange::start_key_type]
2015    /// if it holds a `StartOpen`, `None` if the field is not set or
2016    /// holds a different branch.
2017    pub fn start_open(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2018        #[allow(unreachable_patterns)]
2019        self.start_key_type.as_ref().and_then(|v| match v {
2020            crate::model::key_range::StartKeyType::StartOpen(v) => std::option::Option::Some(v),
2021            _ => std::option::Option::None,
2022        })
2023    }
2024
2025    /// Sets the value of [start_key_type][crate::model::KeyRange::start_key_type]
2026    /// to hold a `StartOpen`.
2027    ///
2028    /// Note that all the setters affecting `start_key_type` are
2029    /// mutually exclusive.
2030    pub fn set_start_open<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2031        mut self,
2032        v: T,
2033    ) -> Self {
2034        self.start_key_type =
2035            std::option::Option::Some(crate::model::key_range::StartKeyType::StartOpen(v.into()));
2036        self
2037    }
2038
2039    /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type].
2040    ///
2041    /// Note that all the setters affecting `end_key_type` are mutually
2042    /// exclusive.
2043    pub fn set_end_key_type<
2044        T: std::convert::Into<std::option::Option<crate::model::key_range::EndKeyType>>,
2045    >(
2046        mut self,
2047        v: T,
2048    ) -> Self {
2049        self.end_key_type = v.into();
2050        self
2051    }
2052
2053    /// The value of [end_key_type][crate::model::KeyRange::end_key_type]
2054    /// if it holds a `EndClosed`, `None` if the field is not set or
2055    /// holds a different branch.
2056    pub fn end_closed(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2057        #[allow(unreachable_patterns)]
2058        self.end_key_type.as_ref().and_then(|v| match v {
2059            crate::model::key_range::EndKeyType::EndClosed(v) => std::option::Option::Some(v),
2060            _ => std::option::Option::None,
2061        })
2062    }
2063
2064    /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type]
2065    /// to hold a `EndClosed`.
2066    ///
2067    /// Note that all the setters affecting `end_key_type` are
2068    /// mutually exclusive.
2069    pub fn set_end_closed<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2070        mut self,
2071        v: T,
2072    ) -> Self {
2073        self.end_key_type =
2074            std::option::Option::Some(crate::model::key_range::EndKeyType::EndClosed(v.into()));
2075        self
2076    }
2077
2078    /// The value of [end_key_type][crate::model::KeyRange::end_key_type]
2079    /// if it holds a `EndOpen`, `None` if the field is not set or
2080    /// holds a different branch.
2081    pub fn end_open(&self) -> std::option::Option<&std::boxed::Box<wkt::ListValue>> {
2082        #[allow(unreachable_patterns)]
2083        self.end_key_type.as_ref().and_then(|v| match v {
2084            crate::model::key_range::EndKeyType::EndOpen(v) => std::option::Option::Some(v),
2085            _ => std::option::Option::None,
2086        })
2087    }
2088
2089    /// Sets the value of [end_key_type][crate::model::KeyRange::end_key_type]
2090    /// to hold a `EndOpen`.
2091    ///
2092    /// Note that all the setters affecting `end_key_type` are
2093    /// mutually exclusive.
2094    pub fn set_end_open<T: std::convert::Into<std::boxed::Box<wkt::ListValue>>>(
2095        mut self,
2096        v: T,
2097    ) -> Self {
2098        self.end_key_type =
2099            std::option::Option::Some(crate::model::key_range::EndKeyType::EndOpen(v.into()));
2100        self
2101    }
2102}
2103
2104impl wkt::message::Message for KeyRange {
2105    fn typename() -> &'static str {
2106        "type.googleapis.com/google.spanner.v1.KeyRange"
2107    }
2108}
2109
2110/// Defines additional types related to [KeyRange].
2111pub mod key_range {
2112    #[allow(unused_imports)]
2113    use super::*;
2114
2115    /// The start key must be provided. It can be either closed or open.
2116    #[derive(Clone, Debug, PartialEq)]
2117    #[non_exhaustive]
2118    pub enum StartKeyType {
2119        /// If the start is closed, then the range includes all rows whose
2120        /// first `len(start_closed)` key columns exactly match `start_closed`.
2121        StartClosed(std::boxed::Box<wkt::ListValue>),
2122        /// If the start is open, then the range excludes rows whose first
2123        /// `len(start_open)` key columns exactly match `start_open`.
2124        StartOpen(std::boxed::Box<wkt::ListValue>),
2125    }
2126
2127    impl StartKeyType {
2128        /// Initializes the enum to the [StartClosed](Self::StartClosed) branch.
2129        pub fn from_start_closed(
2130            value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2131        ) -> Self {
2132            Self::StartClosed(value.into())
2133        }
2134        /// Initializes the enum to the [StartOpen](Self::StartOpen) branch.
2135        pub fn from_start_open(
2136            value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2137        ) -> Self {
2138            Self::StartOpen(value.into())
2139        }
2140    }
2141
2142    /// The end key must be provided. It can be either closed or open.
2143    #[derive(Clone, Debug, PartialEq)]
2144    #[non_exhaustive]
2145    pub enum EndKeyType {
2146        /// If the end is closed, then the range includes all rows whose
2147        /// first `len(end_closed)` key columns exactly match `end_closed`.
2148        EndClosed(std::boxed::Box<wkt::ListValue>),
2149        /// If the end is open, then the range excludes rows whose first
2150        /// `len(end_open)` key columns exactly match `end_open`.
2151        EndOpen(std::boxed::Box<wkt::ListValue>),
2152    }
2153
2154    impl EndKeyType {
2155        /// Initializes the enum to the [EndClosed](Self::EndClosed) branch.
2156        pub fn from_end_closed(
2157            value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2158        ) -> Self {
2159            Self::EndClosed(value.into())
2160        }
2161        /// Initializes the enum to the [EndOpen](Self::EndOpen) branch.
2162        pub fn from_end_open(
2163            value: impl std::convert::Into<std::boxed::Box<wkt::ListValue>>,
2164        ) -> Self {
2165            Self::EndOpen(value.into())
2166        }
2167    }
2168}
2169
2170/// `KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All
2171/// the keys are expected to be in the same table or index. The keys need
2172/// not be sorted in any particular way.
2173///
2174/// If the same key is specified multiple times in the set (for example
2175/// if two ranges, two keys, or a key and a range overlap), Cloud Spanner
2176/// behaves as if the key were only specified once.
2177#[derive(Clone, Default, PartialEq)]
2178#[non_exhaustive]
2179pub struct KeySet {
2180    /// A list of specific keys. Entries in `keys` should have exactly as
2181    /// many elements as there are columns in the primary or index key
2182    /// with which this `KeySet` is used.  Individual key values are
2183    /// encoded as described [here][google.spanner.v1.TypeCode].
2184    ///
2185    /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
2186    pub keys: std::vec::Vec<wkt::ListValue>,
2187
2188    /// A list of key ranges. See [KeyRange][google.spanner.v1.KeyRange] for more
2189    /// information about key range specifications.
2190    ///
2191    /// [google.spanner.v1.KeyRange]: crate::model::KeyRange
2192    pub ranges: std::vec::Vec<crate::model::KeyRange>,
2193
2194    /// For convenience `all` can be set to `true` to indicate that this
2195    /// `KeySet` matches all keys in the table or index. Note that any keys
2196    /// specified in `keys` or `ranges` are only yielded once.
2197    pub all: bool,
2198
2199    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2200}
2201
2202impl KeySet {
2203    /// Creates a new default instance.
2204    pub fn new() -> Self {
2205        std::default::Default::default()
2206    }
2207
2208    /// Sets the value of [keys][crate::model::KeySet::keys].
2209    pub fn set_keys<T, V>(mut self, v: T) -> Self
2210    where
2211        T: std::iter::IntoIterator<Item = V>,
2212        V: std::convert::Into<wkt::ListValue>,
2213    {
2214        use std::iter::Iterator;
2215        self.keys = v.into_iter().map(|i| i.into()).collect();
2216        self
2217    }
2218
2219    /// Sets the value of [ranges][crate::model::KeySet::ranges].
2220    pub fn set_ranges<T, V>(mut self, v: T) -> Self
2221    where
2222        T: std::iter::IntoIterator<Item = V>,
2223        V: std::convert::Into<crate::model::KeyRange>,
2224    {
2225        use std::iter::Iterator;
2226        self.ranges = v.into_iter().map(|i| i.into()).collect();
2227        self
2228    }
2229
2230    /// Sets the value of [all][crate::model::KeySet::all].
2231    pub fn set_all<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2232        self.all = v.into();
2233        self
2234    }
2235}
2236
2237impl wkt::message::Message for KeySet {
2238    fn typename() -> &'static str {
2239        "type.googleapis.com/google.spanner.v1.KeySet"
2240    }
2241}
2242
2243/// A `Range` represents a range of keys in a database. The keys themselves
2244/// are encoded in "sortable string format", also known as ssformat. Consult
2245/// Spanner's open source client libraries for details on the encoding.
2246///
2247/// Each range represents a contiguous range of rows, possibly from multiple
2248/// tables/indexes. Each range is associated with a single paxos group (known as
2249/// a "group" throughout this API), a split (which names the exact range within
2250/// the group), and a generation that can be used to determine whether a given
2251/// `Range` represents a newer or older location for the key range.
2252#[derive(Clone, Default, PartialEq)]
2253#[non_exhaustive]
2254pub struct Range {
2255    /// The start key of the range, inclusive. Encoded in "sortable string format"
2256    /// (ssformat).
2257    pub start_key: ::bytes::Bytes,
2258
2259    /// The limit key of the range, exclusive. Encoded in "sortable string format"
2260    /// (ssformat).
2261    pub limit_key: ::bytes::Bytes,
2262
2263    /// The UID of the paxos group where this range is stored. UIDs are unique
2264    /// within the database. References `Group.group_uid`.
2265    pub group_uid: u64,
2266
2267    /// A group can store multiple ranges of keys. Each key range is named by an
2268    /// ID (the split ID). Within a group, split IDs are unique. The `split_id`
2269    /// names the exact split in `group_uid` where this range is stored.
2270    pub split_id: u64,
2271
2272    /// `generation` indicates the freshness of the range information contained
2273    /// in this proto. Generations can be compared lexicographically; if generation
2274    /// A is greater than generation B, then the `Range` corresponding to A is
2275    /// newer than the `Range` corresponding to B, and should be used
2276    /// preferentially.
2277    pub generation: ::bytes::Bytes,
2278
2279    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2280}
2281
2282impl Range {
2283    /// Creates a new default instance.
2284    pub fn new() -> Self {
2285        std::default::Default::default()
2286    }
2287
2288    /// Sets the value of [start_key][crate::model::Range::start_key].
2289    pub fn set_start_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2290        self.start_key = v.into();
2291        self
2292    }
2293
2294    /// Sets the value of [limit_key][crate::model::Range::limit_key].
2295    pub fn set_limit_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2296        self.limit_key = v.into();
2297        self
2298    }
2299
2300    /// Sets the value of [group_uid][crate::model::Range::group_uid].
2301    pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2302        self.group_uid = v.into();
2303        self
2304    }
2305
2306    /// Sets the value of [split_id][crate::model::Range::split_id].
2307    pub fn set_split_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2308        self.split_id = v.into();
2309        self
2310    }
2311
2312    /// Sets the value of [generation][crate::model::Range::generation].
2313    pub fn set_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2314        self.generation = v.into();
2315        self
2316    }
2317}
2318
2319impl wkt::message::Message for Range {
2320    fn typename() -> &'static str {
2321        "type.googleapis.com/google.spanner.v1.Range"
2322    }
2323}
2324
2325/// A `Tablet` represents a single replica of a `Group`. A tablet is served by a
2326/// single server at a time, and can move between servers due to server death or
2327/// simply load balancing.
2328#[derive(Clone, Default, PartialEq)]
2329#[non_exhaustive]
2330pub struct Tablet {
2331    /// The UID of the tablet, unique within the database. Matches the
2332    /// `tablet_uids` and `leader_tablet_uid` fields in `Group`.
2333    pub tablet_uid: u64,
2334
2335    /// The address of the server that is serving this tablet -- either an IP
2336    /// address or DNS hostname and a port number.
2337    pub server_address: std::string::String,
2338
2339    /// Where this tablet is located. This is the name of a Google Cloud region,
2340    /// such as "us-central1".
2341    pub location: std::string::String,
2342
2343    /// The role of the tablet.
2344    pub role: crate::model::tablet::Role,
2345
2346    /// `incarnation` indicates the freshness of the tablet information contained
2347    /// in this proto. Incarnations can be compared lexicographically; if
2348    /// incarnation A is greater than incarnation B, then the `Tablet`
2349    /// corresponding to A is newer than the `Tablet` corresponding to B, and
2350    /// should be used preferentially.
2351    pub incarnation: ::bytes::Bytes,
2352
2353    /// Distances help the client pick the closest tablet out of the list of
2354    /// tablets for a given request. Tablets with lower distances should generally
2355    /// be preferred. Tablets with the same distance are approximately equally
2356    /// close; the client can choose arbitrarily.
2357    ///
2358    /// Distances do not correspond precisely to expected latency, geographical
2359    /// distance, or anything else. Distances should be compared only between
2360    /// tablets of the same group; they are not meaningful between different
2361    /// groups.
2362    ///
2363    /// A value of zero indicates that the tablet may be in the same zone as
2364    /// the client, and have minimum network latency. A value less than or equal to
2365    /// five indicates that the tablet is thought to be in the same region as the
2366    /// client, and may have a few milliseconds of network latency. Values greater
2367    /// than five are most likely in a different region, with non-trivial network
2368    /// latency.
2369    ///
2370    /// Clients should use the following algorithm:
2371    ///
2372    /// * If the request is using a directed read, eliminate any tablets that
2373    ///   do not match the directed read's target zone and/or replica type.
2374    /// * (Read-write transactions only) Choose leader tablet if it has an
2375    ///   distance <=5.
2376    /// * Group and sort tablets by distance. Choose a random
2377    ///   tablet with the lowest distance. If the request
2378    ///   is not a directed read, only consider replicas with distances <=5.
2379    /// * Send the request to the fallback endpoint.
2380    ///
2381    /// The tablet picked by this algorithm may be skipped, either because it is
2382    /// marked as `skip` by the server or because the corresponding server is
2383    /// unreachable, flow controlled, etc. Skipped tablets should be added to the
2384    /// `skipped_tablet_uid` field in `RoutingHint`; the algorithm above should
2385    /// then be re-run without including the skipped tablet(s) to pick the next
2386    /// best tablet.
2387    pub distance: u32,
2388
2389    /// If true, the tablet should not be chosen by the client. Typically, this
2390    /// signals that the tablet is unhealthy in some way. Tablets with `skip`
2391    /// set to true should be reported back to the server in
2392    /// `RoutingHint.skipped_tablet_uid`; this cues the server to send updated
2393    /// information for this tablet should it become usable again.
2394    pub skip: bool,
2395
2396    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2397}
2398
2399impl Tablet {
2400    /// Creates a new default instance.
2401    pub fn new() -> Self {
2402        std::default::Default::default()
2403    }
2404
2405    /// Sets the value of [tablet_uid][crate::model::Tablet::tablet_uid].
2406    pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2407        self.tablet_uid = v.into();
2408        self
2409    }
2410
2411    /// Sets the value of [server_address][crate::model::Tablet::server_address].
2412    pub fn set_server_address<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2413        self.server_address = v.into();
2414        self
2415    }
2416
2417    /// Sets the value of [location][crate::model::Tablet::location].
2418    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2419        self.location = v.into();
2420        self
2421    }
2422
2423    /// Sets the value of [role][crate::model::Tablet::role].
2424    pub fn set_role<T: std::convert::Into<crate::model::tablet::Role>>(mut self, v: T) -> Self {
2425        self.role = v.into();
2426        self
2427    }
2428
2429    /// Sets the value of [incarnation][crate::model::Tablet::incarnation].
2430    pub fn set_incarnation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2431        self.incarnation = v.into();
2432        self
2433    }
2434
2435    /// Sets the value of [distance][crate::model::Tablet::distance].
2436    pub fn set_distance<T: std::convert::Into<u32>>(mut self, v: T) -> Self {
2437        self.distance = v.into();
2438        self
2439    }
2440
2441    /// Sets the value of [skip][crate::model::Tablet::skip].
2442    pub fn set_skip<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2443        self.skip = v.into();
2444        self
2445    }
2446}
2447
2448impl wkt::message::Message for Tablet {
2449    fn typename() -> &'static str {
2450        "type.googleapis.com/google.spanner.v1.Tablet"
2451    }
2452}
2453
2454/// Defines additional types related to [Tablet].
2455pub mod tablet {
2456    #[allow(unused_imports)]
2457    use super::*;
2458
2459    /// Indicates the role of the tablet.
2460    ///
2461    /// # Working with unknown values
2462    ///
2463    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2464    /// additional enum variants at any time. Adding new variants is not considered
2465    /// a breaking change. Applications should write their code in anticipation of:
2466    ///
2467    /// - New values appearing in future releases of the client library, **and**
2468    /// - New values received dynamically, without application changes.
2469    ///
2470    /// Please consult the [Working with enums] section in the user guide for some
2471    /// guidelines.
2472    ///
2473    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2474    #[derive(Clone, Debug, PartialEq)]
2475    #[non_exhaustive]
2476    pub enum Role {
2477        /// Not specified.
2478        Unspecified,
2479        /// The tablet can perform reads and (if elected leader) writes.
2480        ReadWrite,
2481        /// The tablet can only perform reads.
2482        ReadOnly,
2483        /// If set, the enum was initialized with an unknown value.
2484        ///
2485        /// Applications can examine the value using [Role::value] or
2486        /// [Role::name].
2487        UnknownValue(role::UnknownValue),
2488    }
2489
2490    #[doc(hidden)]
2491    pub mod role {
2492        #[allow(unused_imports)]
2493        use super::*;
2494        #[derive(Clone, Debug, PartialEq)]
2495        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2496    }
2497
2498    impl Role {
2499        /// Gets the enum value.
2500        ///
2501        /// Returns `None` if the enum contains an unknown value deserialized from
2502        /// the string representation of enums.
2503        pub fn value(&self) -> std::option::Option<i32> {
2504            match self {
2505                Self::Unspecified => std::option::Option::Some(0),
2506                Self::ReadWrite => std::option::Option::Some(1),
2507                Self::ReadOnly => std::option::Option::Some(2),
2508                Self::UnknownValue(u) => u.0.value(),
2509            }
2510        }
2511
2512        /// Gets the enum value as a string.
2513        ///
2514        /// Returns `None` if the enum contains an unknown value deserialized from
2515        /// the integer representation of enums.
2516        pub fn name(&self) -> std::option::Option<&str> {
2517            match self {
2518                Self::Unspecified => std::option::Option::Some("ROLE_UNSPECIFIED"),
2519                Self::ReadWrite => std::option::Option::Some("READ_WRITE"),
2520                Self::ReadOnly => std::option::Option::Some("READ_ONLY"),
2521                Self::UnknownValue(u) => u.0.name(),
2522            }
2523        }
2524    }
2525
2526    impl std::default::Default for Role {
2527        fn default() -> Self {
2528            use std::convert::From;
2529            Self::from(0)
2530        }
2531    }
2532
2533    impl std::fmt::Display for Role {
2534        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2535            wkt::internal::display_enum(f, self.name(), self.value())
2536        }
2537    }
2538
2539    impl std::convert::From<i32> for Role {
2540        fn from(value: i32) -> Self {
2541            match value {
2542                0 => Self::Unspecified,
2543                1 => Self::ReadWrite,
2544                2 => Self::ReadOnly,
2545                _ => Self::UnknownValue(role::UnknownValue(
2546                    wkt::internal::UnknownEnumValue::Integer(value),
2547                )),
2548            }
2549        }
2550    }
2551
2552    impl std::convert::From<&str> for Role {
2553        fn from(value: &str) -> Self {
2554            use std::string::ToString;
2555            match value {
2556                "ROLE_UNSPECIFIED" => Self::Unspecified,
2557                "READ_WRITE" => Self::ReadWrite,
2558                "READ_ONLY" => Self::ReadOnly,
2559                _ => Self::UnknownValue(role::UnknownValue(
2560                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2561                )),
2562            }
2563        }
2564    }
2565
2566    impl serde::ser::Serialize for Role {
2567        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2568        where
2569            S: serde::Serializer,
2570        {
2571            match self {
2572                Self::Unspecified => serializer.serialize_i32(0),
2573                Self::ReadWrite => serializer.serialize_i32(1),
2574                Self::ReadOnly => serializer.serialize_i32(2),
2575                Self::UnknownValue(u) => u.0.serialize(serializer),
2576            }
2577        }
2578    }
2579
2580    impl<'de> serde::de::Deserialize<'de> for Role {
2581        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2582        where
2583            D: serde::Deserializer<'de>,
2584        {
2585            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Role>::new(
2586                ".google.spanner.v1.Tablet.Role",
2587            ))
2588        }
2589    }
2590}
2591
2592/// A `Group` represents a paxos group in a database. A group is a set of
2593/// tablets that are replicated across multiple servers. Groups may have a leader
2594/// tablet. Groups store one (or sometimes more) ranges of keys.
2595#[derive(Clone, Default, PartialEq)]
2596#[non_exhaustive]
2597pub struct Group {
2598    /// The UID of the paxos group, unique within the database. Matches the
2599    /// `group_uid` field in `Range`.
2600    pub group_uid: u64,
2601
2602    /// A list of tablets that are part of the group. Note that this list may not
2603    /// be exhaustive; it will only include tablets the server considers useful
2604    /// to the client. The returned list is ordered ascending by distance.
2605    ///
2606    /// Tablet UIDs reference `Tablet.tablet_uid`.
2607    pub tablets: std::vec::Vec<crate::model::Tablet>,
2608
2609    /// The last known leader tablet of the group as an index into `tablets`. May
2610    /// be negative if the group has no known leader.
2611    pub leader_index: i32,
2612
2613    /// `generation` indicates the freshness of the group information (including
2614    /// leader information) contained in this proto. Generations can be compared
2615    /// lexicographically; if generation A is greater than generation B, then the
2616    /// `Group` corresponding to A is newer than the `Group` corresponding to B,
2617    /// and should be used preferentially.
2618    pub generation: ::bytes::Bytes,
2619
2620    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2621}
2622
2623impl Group {
2624    /// Creates a new default instance.
2625    pub fn new() -> Self {
2626        std::default::Default::default()
2627    }
2628
2629    /// Sets the value of [group_uid][crate::model::Group::group_uid].
2630    pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2631        self.group_uid = v.into();
2632        self
2633    }
2634
2635    /// Sets the value of [tablets][crate::model::Group::tablets].
2636    pub fn set_tablets<T, V>(mut self, v: T) -> Self
2637    where
2638        T: std::iter::IntoIterator<Item = V>,
2639        V: std::convert::Into<crate::model::Tablet>,
2640    {
2641        use std::iter::Iterator;
2642        self.tablets = v.into_iter().map(|i| i.into()).collect();
2643        self
2644    }
2645
2646    /// Sets the value of [leader_index][crate::model::Group::leader_index].
2647    pub fn set_leader_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2648        self.leader_index = v.into();
2649        self
2650    }
2651
2652    /// Sets the value of [generation][crate::model::Group::generation].
2653    pub fn set_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2654        self.generation = v.into();
2655        self
2656    }
2657}
2658
2659impl wkt::message::Message for Group {
2660    fn typename() -> &'static str {
2661        "type.googleapis.com/google.spanner.v1.Group"
2662    }
2663}
2664
2665/// A `KeyRecipe` provides the metadata required to translate reads, mutations,
2666/// and queries into a byte array in "sortable string format" (ssformat)that can
2667/// be used with `Range`s to route requests. Note that the client *must* tolerate
2668/// `KeyRecipe`s that appear to be invalid, since the `KeyRecipe` format may
2669/// change over time. Requests with invalid `KeyRecipe`s should be routed to a
2670/// default server.
2671#[derive(Clone, Default, PartialEq)]
2672#[non_exhaustive]
2673pub struct KeyRecipe {
2674    /// Parts are in the order they should appear in the encoded key.
2675    pub part: std::vec::Vec<crate::model::key_recipe::Part>,
2676
2677    /// A recipe can be associated with a table, index, or query. Tables recipes
2678    /// are used to encode read and write keys; index recipes are used for index
2679    /// reads, and query recipes are used only for SQL queries.
2680    pub target: std::option::Option<crate::model::key_recipe::Target>,
2681
2682    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2683}
2684
2685impl KeyRecipe {
2686    /// Creates a new default instance.
2687    pub fn new() -> Self {
2688        std::default::Default::default()
2689    }
2690
2691    /// Sets the value of [part][crate::model::KeyRecipe::part].
2692    pub fn set_part<T, V>(mut self, v: T) -> Self
2693    where
2694        T: std::iter::IntoIterator<Item = V>,
2695        V: std::convert::Into<crate::model::key_recipe::Part>,
2696    {
2697        use std::iter::Iterator;
2698        self.part = v.into_iter().map(|i| i.into()).collect();
2699        self
2700    }
2701
2702    /// Sets the value of [target][crate::model::KeyRecipe::target].
2703    ///
2704    /// Note that all the setters affecting `target` are mutually
2705    /// exclusive.
2706    pub fn set_target<
2707        T: std::convert::Into<std::option::Option<crate::model::key_recipe::Target>>,
2708    >(
2709        mut self,
2710        v: T,
2711    ) -> Self {
2712        self.target = v.into();
2713        self
2714    }
2715
2716    /// The value of [target][crate::model::KeyRecipe::target]
2717    /// if it holds a `TableName`, `None` if the field is not set or
2718    /// holds a different branch.
2719    pub fn table_name(&self) -> std::option::Option<&std::string::String> {
2720        #[allow(unreachable_patterns)]
2721        self.target.as_ref().and_then(|v| match v {
2722            crate::model::key_recipe::Target::TableName(v) => std::option::Option::Some(v),
2723            _ => std::option::Option::None,
2724        })
2725    }
2726
2727    /// Sets the value of [target][crate::model::KeyRecipe::target]
2728    /// to hold a `TableName`.
2729    ///
2730    /// Note that all the setters affecting `target` are
2731    /// mutually exclusive.
2732    pub fn set_table_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2733        self.target =
2734            std::option::Option::Some(crate::model::key_recipe::Target::TableName(v.into()));
2735        self
2736    }
2737
2738    /// The value of [target][crate::model::KeyRecipe::target]
2739    /// if it holds a `IndexName`, `None` if the field is not set or
2740    /// holds a different branch.
2741    pub fn index_name(&self) -> std::option::Option<&std::string::String> {
2742        #[allow(unreachable_patterns)]
2743        self.target.as_ref().and_then(|v| match v {
2744            crate::model::key_recipe::Target::IndexName(v) => std::option::Option::Some(v),
2745            _ => std::option::Option::None,
2746        })
2747    }
2748
2749    /// Sets the value of [target][crate::model::KeyRecipe::target]
2750    /// to hold a `IndexName`.
2751    ///
2752    /// Note that all the setters affecting `target` are
2753    /// mutually exclusive.
2754    pub fn set_index_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2755        self.target =
2756            std::option::Option::Some(crate::model::key_recipe::Target::IndexName(v.into()));
2757        self
2758    }
2759
2760    /// The value of [target][crate::model::KeyRecipe::target]
2761    /// if it holds a `OperationUid`, `None` if the field is not set or
2762    /// holds a different branch.
2763    pub fn operation_uid(&self) -> std::option::Option<&u64> {
2764        #[allow(unreachable_patterns)]
2765        self.target.as_ref().and_then(|v| match v {
2766            crate::model::key_recipe::Target::OperationUid(v) => std::option::Option::Some(v),
2767            _ => std::option::Option::None,
2768        })
2769    }
2770
2771    /// Sets the value of [target][crate::model::KeyRecipe::target]
2772    /// to hold a `OperationUid`.
2773    ///
2774    /// Note that all the setters affecting `target` are
2775    /// mutually exclusive.
2776    pub fn set_operation_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
2777        self.target =
2778            std::option::Option::Some(crate::model::key_recipe::Target::OperationUid(v.into()));
2779        self
2780    }
2781}
2782
2783impl wkt::message::Message for KeyRecipe {
2784    fn typename() -> &'static str {
2785        "type.googleapis.com/google.spanner.v1.KeyRecipe"
2786    }
2787}
2788
2789/// Defines additional types related to [KeyRecipe].
2790pub mod key_recipe {
2791    #[allow(unused_imports)]
2792    use super::*;
2793
2794    /// An ssformat key is composed of a sequence of tag numbers and key column
2795    /// values. `Part` represents a single tag or key column value.
2796    #[derive(Clone, Default, PartialEq)]
2797    #[non_exhaustive]
2798    pub struct Part {
2799        /// If non-zero, `tag` is the only field present in this `Part`. The part
2800        /// is encoded by appending `tag` to the ssformat key.
2801        pub tag: u32,
2802
2803        /// Whether the key column is sorted ascending or descending. Only present
2804        /// if `tag` is zero.
2805        pub order: crate::model::key_recipe::part::Order,
2806
2807        /// How NULLs are represented in the encoded key part. Only present if `tag`
2808        /// is zero.
2809        pub null_order: crate::model::key_recipe::part::NullOrder,
2810
2811        /// The type of the key part. Only present if `tag` is zero.
2812        pub r#type: std::option::Option<crate::model::Type>,
2813
2814        /// It is a repeated field to support fetching key columns from nested
2815        /// structs, such as `STRUCT` query parameters.
2816        pub struct_identifiers: std::vec::Vec<i32>,
2817
2818        /// Only present if `tag` is zero.
2819        pub value_type: std::option::Option<crate::model::key_recipe::part::ValueType>,
2820
2821        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2822    }
2823
2824    impl Part {
2825        /// Creates a new default instance.
2826        pub fn new() -> Self {
2827            std::default::Default::default()
2828        }
2829
2830        /// Sets the value of [tag][crate::model::key_recipe::Part::tag].
2831        pub fn set_tag<T: std::convert::Into<u32>>(mut self, v: T) -> Self {
2832            self.tag = v.into();
2833            self
2834        }
2835
2836        /// Sets the value of [order][crate::model::key_recipe::Part::order].
2837        pub fn set_order<T: std::convert::Into<crate::model::key_recipe::part::Order>>(
2838            mut self,
2839            v: T,
2840        ) -> Self {
2841            self.order = v.into();
2842            self
2843        }
2844
2845        /// Sets the value of [null_order][crate::model::key_recipe::Part::null_order].
2846        pub fn set_null_order<T: std::convert::Into<crate::model::key_recipe::part::NullOrder>>(
2847            mut self,
2848            v: T,
2849        ) -> Self {
2850            self.null_order = v.into();
2851            self
2852        }
2853
2854        /// Sets the value of [r#type][crate::model::key_recipe::Part::type].
2855        pub fn set_type<T>(mut self, v: T) -> Self
2856        where
2857            T: std::convert::Into<crate::model::Type>,
2858        {
2859            self.r#type = std::option::Option::Some(v.into());
2860            self
2861        }
2862
2863        /// Sets or clears the value of [r#type][crate::model::key_recipe::Part::type].
2864        pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
2865        where
2866            T: std::convert::Into<crate::model::Type>,
2867        {
2868            self.r#type = v.map(|x| x.into());
2869            self
2870        }
2871
2872        /// Sets the value of [struct_identifiers][crate::model::key_recipe::Part::struct_identifiers].
2873        pub fn set_struct_identifiers<T, V>(mut self, v: T) -> Self
2874        where
2875            T: std::iter::IntoIterator<Item = V>,
2876            V: std::convert::Into<i32>,
2877        {
2878            use std::iter::Iterator;
2879            self.struct_identifiers = v.into_iter().map(|i| i.into()).collect();
2880            self
2881        }
2882
2883        /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type].
2884        ///
2885        /// Note that all the setters affecting `value_type` are mutually
2886        /// exclusive.
2887        pub fn set_value_type<
2888            T: std::convert::Into<std::option::Option<crate::model::key_recipe::part::ValueType>>,
2889        >(
2890            mut self,
2891            v: T,
2892        ) -> Self {
2893            self.value_type = v.into();
2894            self
2895        }
2896
2897        /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2898        /// if it holds a `Identifier`, `None` if the field is not set or
2899        /// holds a different branch.
2900        pub fn identifier(&self) -> std::option::Option<&std::string::String> {
2901            #[allow(unreachable_patterns)]
2902            self.value_type.as_ref().and_then(|v| match v {
2903                crate::model::key_recipe::part::ValueType::Identifier(v) => {
2904                    std::option::Option::Some(v)
2905                }
2906                _ => std::option::Option::None,
2907            })
2908        }
2909
2910        /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2911        /// to hold a `Identifier`.
2912        ///
2913        /// Note that all the setters affecting `value_type` are
2914        /// mutually exclusive.
2915        pub fn set_identifier<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2916            self.value_type = std::option::Option::Some(
2917                crate::model::key_recipe::part::ValueType::Identifier(v.into()),
2918            );
2919            self
2920        }
2921
2922        /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2923        /// if it holds a `Value`, `None` if the field is not set or
2924        /// holds a different branch.
2925        pub fn value(&self) -> std::option::Option<&std::boxed::Box<wkt::Value>> {
2926            #[allow(unreachable_patterns)]
2927            self.value_type.as_ref().and_then(|v| match v {
2928                crate::model::key_recipe::part::ValueType::Value(v) => std::option::Option::Some(v),
2929                _ => std::option::Option::None,
2930            })
2931        }
2932
2933        /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2934        /// to hold a `Value`.
2935        ///
2936        /// Note that all the setters affecting `value_type` are
2937        /// mutually exclusive.
2938        pub fn set_value<T: std::convert::Into<std::boxed::Box<wkt::Value>>>(
2939            mut self,
2940            v: T,
2941        ) -> Self {
2942            self.value_type = std::option::Option::Some(
2943                crate::model::key_recipe::part::ValueType::Value(v.into()),
2944            );
2945            self
2946        }
2947
2948        /// The value of [value_type][crate::model::key_recipe::Part::value_type]
2949        /// if it holds a `Random`, `None` if the field is not set or
2950        /// holds a different branch.
2951        pub fn random(&self) -> std::option::Option<&bool> {
2952            #[allow(unreachable_patterns)]
2953            self.value_type.as_ref().and_then(|v| match v {
2954                crate::model::key_recipe::part::ValueType::Random(v) => {
2955                    std::option::Option::Some(v)
2956                }
2957                _ => std::option::Option::None,
2958            })
2959        }
2960
2961        /// Sets the value of [value_type][crate::model::key_recipe::Part::value_type]
2962        /// to hold a `Random`.
2963        ///
2964        /// Note that all the setters affecting `value_type` are
2965        /// mutually exclusive.
2966        pub fn set_random<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2967            self.value_type = std::option::Option::Some(
2968                crate::model::key_recipe::part::ValueType::Random(v.into()),
2969            );
2970            self
2971        }
2972    }
2973
2974    impl wkt::message::Message for Part {
2975        fn typename() -> &'static str {
2976            "type.googleapis.com/google.spanner.v1.KeyRecipe.Part"
2977        }
2978    }
2979
2980    /// Defines additional types related to [Part].
2981    pub mod part {
2982        #[allow(unused_imports)]
2983        use super::*;
2984
2985        /// The remaining fields encode column values.
2986        ///
2987        /// # Working with unknown values
2988        ///
2989        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2990        /// additional enum variants at any time. Adding new variants is not considered
2991        /// a breaking change. Applications should write their code in anticipation of:
2992        ///
2993        /// - New values appearing in future releases of the client library, **and**
2994        /// - New values received dynamically, without application changes.
2995        ///
2996        /// Please consult the [Working with enums] section in the user guide for some
2997        /// guidelines.
2998        ///
2999        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3000        #[derive(Clone, Debug, PartialEq)]
3001        #[non_exhaustive]
3002        pub enum Order {
3003            /// Default value, equivalent to `ASCENDING`.
3004            Unspecified,
3005            /// The key is ascending - corresponds to `ASC` in the schema definition.
3006            Ascending,
3007            /// The key is descending - corresponds to `DESC` in the schema definition.
3008            Descending,
3009            /// If set, the enum was initialized with an unknown value.
3010            ///
3011            /// Applications can examine the value using [Order::value] or
3012            /// [Order::name].
3013            UnknownValue(order::UnknownValue),
3014        }
3015
3016        #[doc(hidden)]
3017        pub mod order {
3018            #[allow(unused_imports)]
3019            use super::*;
3020            #[derive(Clone, Debug, PartialEq)]
3021            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3022        }
3023
3024        impl Order {
3025            /// Gets the enum value.
3026            ///
3027            /// Returns `None` if the enum contains an unknown value deserialized from
3028            /// the string representation of enums.
3029            pub fn value(&self) -> std::option::Option<i32> {
3030                match self {
3031                    Self::Unspecified => std::option::Option::Some(0),
3032                    Self::Ascending => std::option::Option::Some(1),
3033                    Self::Descending => std::option::Option::Some(2),
3034                    Self::UnknownValue(u) => u.0.value(),
3035                }
3036            }
3037
3038            /// Gets the enum value as a string.
3039            ///
3040            /// Returns `None` if the enum contains an unknown value deserialized from
3041            /// the integer representation of enums.
3042            pub fn name(&self) -> std::option::Option<&str> {
3043                match self {
3044                    Self::Unspecified => std::option::Option::Some("ORDER_UNSPECIFIED"),
3045                    Self::Ascending => std::option::Option::Some("ASCENDING"),
3046                    Self::Descending => std::option::Option::Some("DESCENDING"),
3047                    Self::UnknownValue(u) => u.0.name(),
3048                }
3049            }
3050        }
3051
3052        impl std::default::Default for Order {
3053            fn default() -> Self {
3054                use std::convert::From;
3055                Self::from(0)
3056            }
3057        }
3058
3059        impl std::fmt::Display for Order {
3060            fn fmt(
3061                &self,
3062                f: &mut std::fmt::Formatter<'_>,
3063            ) -> std::result::Result<(), std::fmt::Error> {
3064                wkt::internal::display_enum(f, self.name(), self.value())
3065            }
3066        }
3067
3068        impl std::convert::From<i32> for Order {
3069            fn from(value: i32) -> Self {
3070                match value {
3071                    0 => Self::Unspecified,
3072                    1 => Self::Ascending,
3073                    2 => Self::Descending,
3074                    _ => Self::UnknownValue(order::UnknownValue(
3075                        wkt::internal::UnknownEnumValue::Integer(value),
3076                    )),
3077                }
3078            }
3079        }
3080
3081        impl std::convert::From<&str> for Order {
3082            fn from(value: &str) -> Self {
3083                use std::string::ToString;
3084                match value {
3085                    "ORDER_UNSPECIFIED" => Self::Unspecified,
3086                    "ASCENDING" => Self::Ascending,
3087                    "DESCENDING" => Self::Descending,
3088                    _ => Self::UnknownValue(order::UnknownValue(
3089                        wkt::internal::UnknownEnumValue::String(value.to_string()),
3090                    )),
3091                }
3092            }
3093        }
3094
3095        impl serde::ser::Serialize for Order {
3096            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3097            where
3098                S: serde::Serializer,
3099            {
3100                match self {
3101                    Self::Unspecified => serializer.serialize_i32(0),
3102                    Self::Ascending => serializer.serialize_i32(1),
3103                    Self::Descending => serializer.serialize_i32(2),
3104                    Self::UnknownValue(u) => u.0.serialize(serializer),
3105                }
3106            }
3107        }
3108
3109        impl<'de> serde::de::Deserialize<'de> for Order {
3110            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3111            where
3112                D: serde::Deserializer<'de>,
3113            {
3114                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Order>::new(
3115                    ".google.spanner.v1.KeyRecipe.Part.Order",
3116                ))
3117            }
3118        }
3119
3120        /// The null order of the key column. This dictates where NULL values sort
3121        /// in the sorted order. Note that columns which are `NOT NULL` can have a
3122        /// special encoding.
3123        ///
3124        /// # Working with unknown values
3125        ///
3126        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3127        /// additional enum variants at any time. Adding new variants is not considered
3128        /// a breaking change. Applications should write their code in anticipation of:
3129        ///
3130        /// - New values appearing in future releases of the client library, **and**
3131        /// - New values received dynamically, without application changes.
3132        ///
3133        /// Please consult the [Working with enums] section in the user guide for some
3134        /// guidelines.
3135        ///
3136        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3137        #[derive(Clone, Debug, PartialEq)]
3138        #[non_exhaustive]
3139        pub enum NullOrder {
3140            /// Default value. This value is unused.
3141            Unspecified,
3142            /// NULL values sort before any non-NULL values.
3143            NullsFirst,
3144            /// NULL values sort after any non-NULL values.
3145            NullsLast,
3146            /// The column does not support NULL values.
3147            NotNull,
3148            /// If set, the enum was initialized with an unknown value.
3149            ///
3150            /// Applications can examine the value using [NullOrder::value] or
3151            /// [NullOrder::name].
3152            UnknownValue(null_order::UnknownValue),
3153        }
3154
3155        #[doc(hidden)]
3156        pub mod null_order {
3157            #[allow(unused_imports)]
3158            use super::*;
3159            #[derive(Clone, Debug, PartialEq)]
3160            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3161        }
3162
3163        impl NullOrder {
3164            /// Gets the enum value.
3165            ///
3166            /// Returns `None` if the enum contains an unknown value deserialized from
3167            /// the string representation of enums.
3168            pub fn value(&self) -> std::option::Option<i32> {
3169                match self {
3170                    Self::Unspecified => std::option::Option::Some(0),
3171                    Self::NullsFirst => std::option::Option::Some(1),
3172                    Self::NullsLast => std::option::Option::Some(2),
3173                    Self::NotNull => std::option::Option::Some(3),
3174                    Self::UnknownValue(u) => u.0.value(),
3175                }
3176            }
3177
3178            /// Gets the enum value as a string.
3179            ///
3180            /// Returns `None` if the enum contains an unknown value deserialized from
3181            /// the integer representation of enums.
3182            pub fn name(&self) -> std::option::Option<&str> {
3183                match self {
3184                    Self::Unspecified => std::option::Option::Some("NULL_ORDER_UNSPECIFIED"),
3185                    Self::NullsFirst => std::option::Option::Some("NULLS_FIRST"),
3186                    Self::NullsLast => std::option::Option::Some("NULLS_LAST"),
3187                    Self::NotNull => std::option::Option::Some("NOT_NULL"),
3188                    Self::UnknownValue(u) => u.0.name(),
3189                }
3190            }
3191        }
3192
3193        impl std::default::Default for NullOrder {
3194            fn default() -> Self {
3195                use std::convert::From;
3196                Self::from(0)
3197            }
3198        }
3199
3200        impl std::fmt::Display for NullOrder {
3201            fn fmt(
3202                &self,
3203                f: &mut std::fmt::Formatter<'_>,
3204            ) -> std::result::Result<(), std::fmt::Error> {
3205                wkt::internal::display_enum(f, self.name(), self.value())
3206            }
3207        }
3208
3209        impl std::convert::From<i32> for NullOrder {
3210            fn from(value: i32) -> Self {
3211                match value {
3212                    0 => Self::Unspecified,
3213                    1 => Self::NullsFirst,
3214                    2 => Self::NullsLast,
3215                    3 => Self::NotNull,
3216                    _ => Self::UnknownValue(null_order::UnknownValue(
3217                        wkt::internal::UnknownEnumValue::Integer(value),
3218                    )),
3219                }
3220            }
3221        }
3222
3223        impl std::convert::From<&str> for NullOrder {
3224            fn from(value: &str) -> Self {
3225                use std::string::ToString;
3226                match value {
3227                    "NULL_ORDER_UNSPECIFIED" => Self::Unspecified,
3228                    "NULLS_FIRST" => Self::NullsFirst,
3229                    "NULLS_LAST" => Self::NullsLast,
3230                    "NOT_NULL" => Self::NotNull,
3231                    _ => Self::UnknownValue(null_order::UnknownValue(
3232                        wkt::internal::UnknownEnumValue::String(value.to_string()),
3233                    )),
3234                }
3235            }
3236        }
3237
3238        impl serde::ser::Serialize for NullOrder {
3239            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3240            where
3241                S: serde::Serializer,
3242            {
3243                match self {
3244                    Self::Unspecified => serializer.serialize_i32(0),
3245                    Self::NullsFirst => serializer.serialize_i32(1),
3246                    Self::NullsLast => serializer.serialize_i32(2),
3247                    Self::NotNull => serializer.serialize_i32(3),
3248                    Self::UnknownValue(u) => u.0.serialize(serializer),
3249                }
3250            }
3251        }
3252
3253        impl<'de> serde::de::Deserialize<'de> for NullOrder {
3254            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3255            where
3256                D: serde::Deserializer<'de>,
3257            {
3258                deserializer.deserialize_any(wkt::internal::EnumVisitor::<NullOrder>::new(
3259                    ".google.spanner.v1.KeyRecipe.Part.NullOrder",
3260                ))
3261            }
3262        }
3263
3264        /// Only present if `tag` is zero.
3265        #[derive(Clone, Debug, PartialEq)]
3266        #[non_exhaustive]
3267        pub enum ValueType {
3268            /// `identifier` is the name of the column or query parameter.
3269            Identifier(std::string::String),
3270            /// The constant value of the key part.
3271            /// It is present when query uses a constant as a part of the key.
3272            Value(std::boxed::Box<wkt::Value>),
3273            /// If true, the client is responsible to fill in the value randomly.
3274            /// It's relevant only for the INT64 type.
3275            Random(bool),
3276        }
3277
3278        impl ValueType {
3279            /// Initializes the enum to the [Identifier](Self::Identifier) branch.
3280            pub fn from_identifier(value: impl std::convert::Into<std::string::String>) -> Self {
3281                Self::Identifier(value.into())
3282            }
3283            /// Initializes the enum to the [Value](Self::Value) branch.
3284            pub fn from_value(value: impl std::convert::Into<std::boxed::Box<wkt::Value>>) -> Self {
3285                Self::Value(value.into())
3286            }
3287            /// Initializes the enum to the [Random](Self::Random) branch.
3288            pub fn from_random(value: impl std::convert::Into<bool>) -> Self {
3289                Self::Random(value.into())
3290            }
3291        }
3292    }
3293
3294    /// A recipe can be associated with a table, index, or query. Tables recipes
3295    /// are used to encode read and write keys; index recipes are used for index
3296    /// reads, and query recipes are used only for SQL queries.
3297    #[derive(Clone, Debug, PartialEq)]
3298    #[non_exhaustive]
3299    pub enum Target {
3300        /// A table name, matching the name from the database schema.
3301        TableName(std::string::String),
3302        /// An index name, matching the name from the database schema.
3303        IndexName(std::string::String),
3304        /// The UID of a query, matching the UID from `RoutingHint`.
3305        OperationUid(u64),
3306    }
3307
3308    impl Target {
3309        /// Initializes the enum to the [TableName](Self::TableName) branch.
3310        pub fn from_table_name(value: impl std::convert::Into<std::string::String>) -> Self {
3311            Self::TableName(value.into())
3312        }
3313        /// Initializes the enum to the [IndexName](Self::IndexName) branch.
3314        pub fn from_index_name(value: impl std::convert::Into<std::string::String>) -> Self {
3315            Self::IndexName(value.into())
3316        }
3317        /// Initializes the enum to the [OperationUid](Self::OperationUid) branch.
3318        pub fn from_operation_uid(value: impl std::convert::Into<u64>) -> Self {
3319            Self::OperationUid(value.into())
3320        }
3321    }
3322}
3323
3324/// A `RecipeList` contains a list of `KeyRecipe`s, which share the same
3325/// schema generation.
3326#[derive(Clone, Default, PartialEq)]
3327#[non_exhaustive]
3328pub struct RecipeList {
3329    /// The schema generation of the recipes. To be sent to the server in
3330    /// `RoutingHint.schema_generation` whenever one of the recipes is used.
3331    /// `schema_generation` values are comparable with each other; if generation A
3332    /// compares greater than generation B, then A is a more recent schema than B.
3333    /// Clients should in general aim to cache only the latest schema generation,
3334    /// and discard more stale recipes.
3335    pub schema_generation: ::bytes::Bytes,
3336
3337    /// A list of recipes to be cached.
3338    pub recipe: std::vec::Vec<crate::model::KeyRecipe>,
3339
3340    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3341}
3342
3343impl RecipeList {
3344    /// Creates a new default instance.
3345    pub fn new() -> Self {
3346        std::default::Default::default()
3347    }
3348
3349    /// Sets the value of [schema_generation][crate::model::RecipeList::schema_generation].
3350    pub fn set_schema_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3351        self.schema_generation = v.into();
3352        self
3353    }
3354
3355    /// Sets the value of [recipe][crate::model::RecipeList::recipe].
3356    pub fn set_recipe<T, V>(mut self, v: T) -> Self
3357    where
3358        T: std::iter::IntoIterator<Item = V>,
3359        V: std::convert::Into<crate::model::KeyRecipe>,
3360    {
3361        use std::iter::Iterator;
3362        self.recipe = v.into_iter().map(|i| i.into()).collect();
3363        self
3364    }
3365}
3366
3367impl wkt::message::Message for RecipeList {
3368    fn typename() -> &'static str {
3369        "type.googleapis.com/google.spanner.v1.RecipeList"
3370    }
3371}
3372
3373/// A `CacheUpdate` expresses a set of changes the client should incorporate into
3374/// its location cache. These changes may or may not be newer than what the
3375/// client has in its cache, and should be discarded if necessary. `CacheUpdate`s
3376/// can be obtained in response to requests that included a `RoutingHint`
3377/// field, but may also be obtained by explicit location-fetching RPCs which may
3378/// be added in the future.
3379#[derive(Clone, Default, PartialEq)]
3380#[non_exhaustive]
3381pub struct CacheUpdate {
3382    /// An internal ID for the database. Database names can be reused if a database
3383    /// is deleted and re-created. Each time the database is re-created, it will
3384    /// get a new database ID, which will never be re-used for any other database.
3385    pub database_id: u64,
3386
3387    /// A list of ranges to be cached.
3388    pub range: std::vec::Vec<crate::model::Range>,
3389
3390    /// A list of groups to be cached.
3391    pub group: std::vec::Vec<crate::model::Group>,
3392
3393    /// A list of recipes to be cached.
3394    pub key_recipes: std::option::Option<crate::model::RecipeList>,
3395
3396    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3397}
3398
3399impl CacheUpdate {
3400    /// Creates a new default instance.
3401    pub fn new() -> Self {
3402        std::default::Default::default()
3403    }
3404
3405    /// Sets the value of [database_id][crate::model::CacheUpdate::database_id].
3406    pub fn set_database_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3407        self.database_id = v.into();
3408        self
3409    }
3410
3411    /// Sets the value of [range][crate::model::CacheUpdate::range].
3412    pub fn set_range<T, V>(mut self, v: T) -> Self
3413    where
3414        T: std::iter::IntoIterator<Item = V>,
3415        V: std::convert::Into<crate::model::Range>,
3416    {
3417        use std::iter::Iterator;
3418        self.range = v.into_iter().map(|i| i.into()).collect();
3419        self
3420    }
3421
3422    /// Sets the value of [group][crate::model::CacheUpdate::group].
3423    pub fn set_group<T, V>(mut self, v: T) -> Self
3424    where
3425        T: std::iter::IntoIterator<Item = V>,
3426        V: std::convert::Into<crate::model::Group>,
3427    {
3428        use std::iter::Iterator;
3429        self.group = v.into_iter().map(|i| i.into()).collect();
3430        self
3431    }
3432
3433    /// Sets the value of [key_recipes][crate::model::CacheUpdate::key_recipes].
3434    pub fn set_key_recipes<T>(mut self, v: T) -> Self
3435    where
3436        T: std::convert::Into<crate::model::RecipeList>,
3437    {
3438        self.key_recipes = std::option::Option::Some(v.into());
3439        self
3440    }
3441
3442    /// Sets or clears the value of [key_recipes][crate::model::CacheUpdate::key_recipes].
3443    pub fn set_or_clear_key_recipes<T>(mut self, v: std::option::Option<T>) -> Self
3444    where
3445        T: std::convert::Into<crate::model::RecipeList>,
3446    {
3447        self.key_recipes = v.map(|x| x.into());
3448        self
3449    }
3450}
3451
3452impl wkt::message::Message for CacheUpdate {
3453    fn typename() -> &'static str {
3454        "type.googleapis.com/google.spanner.v1.CacheUpdate"
3455    }
3456}
3457
3458/// `RoutingHint` can be optionally added to location-aware Spanner
3459/// requests. It gives the server hints that can be used to route the request to
3460/// an appropriate server, potentially significantly decreasing latency and
3461/// improving throughput. To achieve improved performance, most fields must be
3462/// filled in with accurate values.
3463///
3464/// The presence of a valid `RoutingHint` tells the server that the client
3465/// is location-aware.
3466///
3467/// `RoutingHint` does not change the semantics of the request; it is
3468/// purely a performance hint; the request will perform the same actions on the
3469/// database's data as if `RoutingHint` were not present. However, if
3470/// the `RoutingHint` is incomplete or incorrect, the response may include
3471/// a `CacheUpdate` the client can use to correct its location cache.
3472#[derive(Clone, Default, PartialEq)]
3473#[non_exhaustive]
3474pub struct RoutingHint {
3475    /// A session-scoped unique ID for the operation, computed client-side.
3476    /// Requests with the same `operation_uid` should have a shared 'shape',
3477    /// meaning that some fields are expected to be the same, such as the SQL
3478    /// query, the target table/columns (for reads) etc. Requests with the same
3479    /// `operation_uid` are meant to differ only in fields like keys/key
3480    /// ranges/query parameters, transaction IDs, etc.
3481    ///
3482    /// `operation_uid` must be non-zero for `RoutingHint` to be valid.
3483    pub operation_uid: u64,
3484
3485    /// The database ID of the database being accessed, see
3486    /// `CacheUpdate.database_id`. Should match the cache entries that were used
3487    /// to generate the rest of the fields in this `RoutingHint`.
3488    pub database_id: u64,
3489
3490    /// The schema generation of the recipe that was used to generate `key` and
3491    /// `limit_key`. See also `RecipeList.schema_generation`.
3492    pub schema_generation: ::bytes::Bytes,
3493
3494    /// The key / key range that this request accesses. For operations that
3495    /// access a single key, `key` should be set and `limit_key` should be empty.
3496    /// For operations that access a key range, `key` and `limit_key` should both
3497    /// be set, to the inclusive start and exclusive end of the range respectively.
3498    ///
3499    /// The keys are encoded in "sortable string format" (ssformat), using a
3500    /// `KeyRecipe` that is appropriate for the request. See `KeyRecipe` for more
3501    /// details.
3502    pub key: ::bytes::Bytes,
3503
3504    /// If this request targets a key range, this is the exclusive end of the
3505    /// range. See `key` for more details.
3506    pub limit_key: ::bytes::Bytes,
3507
3508    /// The group UID of the group that the client believes serves the range
3509    /// defined by `key` and `limit_key`. See `Range.group_uid` for more details.
3510    pub group_uid: u64,
3511
3512    /// The split ID of the split that the client believes contains the range
3513    /// defined by `key` and `limit_key`. See `Range.split_id` for more details.
3514    pub split_id: u64,
3515
3516    /// The tablet UID of the tablet from group `group_uid` that the client
3517    /// believes is best to serve this request. See `Group.local_tablet_uids` and
3518    /// `Group.leader_tablet_uid`.
3519    pub tablet_uid: u64,
3520
3521    /// If the client had multiple options for tablet selection, and some of its
3522    /// first choices were unhealthy (e.g., the server is unreachable, or
3523    /// `Tablet.skip` is true), this field will contain the tablet UIDs of those
3524    /// tablets, with their incarnations. The server may include a `CacheUpdate`
3525    /// with new locations for those tablets.
3526    pub skipped_tablet_uid: std::vec::Vec<crate::model::routing_hint::SkippedTablet>,
3527
3528    /// If present, the client's current location. This should be the name of a
3529    /// Google Cloud zone or region, such as "us-central1".
3530    ///
3531    /// If absent, the client's location will be assumed to be the same as the
3532    /// location of the server the client ends up connected to.
3533    ///
3534    /// Locations are primarily valuable for clients that connect from regions
3535    /// other than the ones that contain the Spanner database.
3536    pub client_location: std::string::String,
3537
3538    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3539}
3540
3541impl RoutingHint {
3542    /// Creates a new default instance.
3543    pub fn new() -> Self {
3544        std::default::Default::default()
3545    }
3546
3547    /// Sets the value of [operation_uid][crate::model::RoutingHint::operation_uid].
3548    pub fn set_operation_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3549        self.operation_uid = v.into();
3550        self
3551    }
3552
3553    /// Sets the value of [database_id][crate::model::RoutingHint::database_id].
3554    pub fn set_database_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3555        self.database_id = v.into();
3556        self
3557    }
3558
3559    /// Sets the value of [schema_generation][crate::model::RoutingHint::schema_generation].
3560    pub fn set_schema_generation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3561        self.schema_generation = v.into();
3562        self
3563    }
3564
3565    /// Sets the value of [key][crate::model::RoutingHint::key].
3566    pub fn set_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3567        self.key = v.into();
3568        self
3569    }
3570
3571    /// Sets the value of [limit_key][crate::model::RoutingHint::limit_key].
3572    pub fn set_limit_key<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3573        self.limit_key = v.into();
3574        self
3575    }
3576
3577    /// Sets the value of [group_uid][crate::model::RoutingHint::group_uid].
3578    pub fn set_group_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3579        self.group_uid = v.into();
3580        self
3581    }
3582
3583    /// Sets the value of [split_id][crate::model::RoutingHint::split_id].
3584    pub fn set_split_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3585        self.split_id = v.into();
3586        self
3587    }
3588
3589    /// Sets the value of [tablet_uid][crate::model::RoutingHint::tablet_uid].
3590    pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3591        self.tablet_uid = v.into();
3592        self
3593    }
3594
3595    /// Sets the value of [skipped_tablet_uid][crate::model::RoutingHint::skipped_tablet_uid].
3596    pub fn set_skipped_tablet_uid<T, V>(mut self, v: T) -> Self
3597    where
3598        T: std::iter::IntoIterator<Item = V>,
3599        V: std::convert::Into<crate::model::routing_hint::SkippedTablet>,
3600    {
3601        use std::iter::Iterator;
3602        self.skipped_tablet_uid = v.into_iter().map(|i| i.into()).collect();
3603        self
3604    }
3605
3606    /// Sets the value of [client_location][crate::model::RoutingHint::client_location].
3607    pub fn set_client_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3608        self.client_location = v.into();
3609        self
3610    }
3611}
3612
3613impl wkt::message::Message for RoutingHint {
3614    fn typename() -> &'static str {
3615        "type.googleapis.com/google.spanner.v1.RoutingHint"
3616    }
3617}
3618
3619/// Defines additional types related to [RoutingHint].
3620pub mod routing_hint {
3621    #[allow(unused_imports)]
3622    use super::*;
3623
3624    /// A tablet that was skipped by the client. See `Tablet.tablet_uid` and
3625    /// `Tablet.incarnation`.
3626    #[derive(Clone, Default, PartialEq)]
3627    #[non_exhaustive]
3628    pub struct SkippedTablet {
3629        /// The tablet UID of the tablet that was skipped. See `Tablet.tablet_uid`.
3630        pub tablet_uid: u64,
3631
3632        /// The incarnation of the tablet that was skipped. See `Tablet.incarnation`.
3633        pub incarnation: ::bytes::Bytes,
3634
3635        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3636    }
3637
3638    impl SkippedTablet {
3639        /// Creates a new default instance.
3640        pub fn new() -> Self {
3641            std::default::Default::default()
3642        }
3643
3644        /// Sets the value of [tablet_uid][crate::model::routing_hint::SkippedTablet::tablet_uid].
3645        pub fn set_tablet_uid<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
3646            self.tablet_uid = v.into();
3647            self
3648        }
3649
3650        /// Sets the value of [incarnation][crate::model::routing_hint::SkippedTablet::incarnation].
3651        pub fn set_incarnation<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
3652            self.incarnation = v.into();
3653            self
3654        }
3655    }
3656
3657    impl wkt::message::Message for SkippedTablet {
3658        fn typename() -> &'static str {
3659            "type.googleapis.com/google.spanner.v1.RoutingHint.SkippedTablet"
3660        }
3661    }
3662}
3663
3664/// A modification to one or more Cloud Spanner rows.  Mutations can be
3665/// applied to a Cloud Spanner database by sending them in a
3666/// [Commit][google.spanner.v1.Spanner.Commit] call.
3667///
3668/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
3669#[derive(Clone, Default, PartialEq)]
3670#[non_exhaustive]
3671pub struct Mutation {
3672    /// Required. The operation to perform.
3673    pub operation: std::option::Option<crate::model::mutation::Operation>,
3674
3675    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3676}
3677
3678impl Mutation {
3679    /// Creates a new default instance.
3680    pub fn new() -> Self {
3681        std::default::Default::default()
3682    }
3683
3684    /// Sets the value of [operation][crate::model::Mutation::operation].
3685    ///
3686    /// Note that all the setters affecting `operation` are mutually
3687    /// exclusive.
3688    pub fn set_operation<
3689        T: std::convert::Into<std::option::Option<crate::model::mutation::Operation>>,
3690    >(
3691        mut self,
3692        v: T,
3693    ) -> Self {
3694        self.operation = v.into();
3695        self
3696    }
3697
3698    /// The value of [operation][crate::model::Mutation::operation]
3699    /// if it holds a `Insert`, `None` if the field is not set or
3700    /// holds a different branch.
3701    pub fn insert(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3702        #[allow(unreachable_patterns)]
3703        self.operation.as_ref().and_then(|v| match v {
3704            crate::model::mutation::Operation::Insert(v) => std::option::Option::Some(v),
3705            _ => std::option::Option::None,
3706        })
3707    }
3708
3709    /// Sets the value of [operation][crate::model::Mutation::operation]
3710    /// to hold a `Insert`.
3711    ///
3712    /// Note that all the setters affecting `operation` are
3713    /// mutually exclusive.
3714    pub fn set_insert<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3715        mut self,
3716        v: T,
3717    ) -> Self {
3718        self.operation =
3719            std::option::Option::Some(crate::model::mutation::Operation::Insert(v.into()));
3720        self
3721    }
3722
3723    /// The value of [operation][crate::model::Mutation::operation]
3724    /// if it holds a `Update`, `None` if the field is not set or
3725    /// holds a different branch.
3726    pub fn update(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3727        #[allow(unreachable_patterns)]
3728        self.operation.as_ref().and_then(|v| match v {
3729            crate::model::mutation::Operation::Update(v) => std::option::Option::Some(v),
3730            _ => std::option::Option::None,
3731        })
3732    }
3733
3734    /// Sets the value of [operation][crate::model::Mutation::operation]
3735    /// to hold a `Update`.
3736    ///
3737    /// Note that all the setters affecting `operation` are
3738    /// mutually exclusive.
3739    pub fn set_update<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3740        mut self,
3741        v: T,
3742    ) -> Self {
3743        self.operation =
3744            std::option::Option::Some(crate::model::mutation::Operation::Update(v.into()));
3745        self
3746    }
3747
3748    /// The value of [operation][crate::model::Mutation::operation]
3749    /// if it holds a `InsertOrUpdate`, `None` if the field is not set or
3750    /// holds a different branch.
3751    pub fn insert_or_update(
3752        &self,
3753    ) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3754        #[allow(unreachable_patterns)]
3755        self.operation.as_ref().and_then(|v| match v {
3756            crate::model::mutation::Operation::InsertOrUpdate(v) => std::option::Option::Some(v),
3757            _ => std::option::Option::None,
3758        })
3759    }
3760
3761    /// Sets the value of [operation][crate::model::Mutation::operation]
3762    /// to hold a `InsertOrUpdate`.
3763    ///
3764    /// Note that all the setters affecting `operation` are
3765    /// mutually exclusive.
3766    pub fn set_insert_or_update<
3767        T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
3768    >(
3769        mut self,
3770        v: T,
3771    ) -> Self {
3772        self.operation =
3773            std::option::Option::Some(crate::model::mutation::Operation::InsertOrUpdate(v.into()));
3774        self
3775    }
3776
3777    /// The value of [operation][crate::model::Mutation::operation]
3778    /// if it holds a `Replace`, `None` if the field is not set or
3779    /// holds a different branch.
3780    pub fn replace(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Write>> {
3781        #[allow(unreachable_patterns)]
3782        self.operation.as_ref().and_then(|v| match v {
3783            crate::model::mutation::Operation::Replace(v) => std::option::Option::Some(v),
3784            _ => std::option::Option::None,
3785        })
3786    }
3787
3788    /// Sets the value of [operation][crate::model::Mutation::operation]
3789    /// to hold a `Replace`.
3790    ///
3791    /// Note that all the setters affecting `operation` are
3792    /// mutually exclusive.
3793    pub fn set_replace<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>>(
3794        mut self,
3795        v: T,
3796    ) -> Self {
3797        self.operation =
3798            std::option::Option::Some(crate::model::mutation::Operation::Replace(v.into()));
3799        self
3800    }
3801
3802    /// The value of [operation][crate::model::Mutation::operation]
3803    /// if it holds a `Delete`, `None` if the field is not set or
3804    /// holds a different branch.
3805    pub fn delete(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Delete>> {
3806        #[allow(unreachable_patterns)]
3807        self.operation.as_ref().and_then(|v| match v {
3808            crate::model::mutation::Operation::Delete(v) => std::option::Option::Some(v),
3809            _ => std::option::Option::None,
3810        })
3811    }
3812
3813    /// Sets the value of [operation][crate::model::Mutation::operation]
3814    /// to hold a `Delete`.
3815    ///
3816    /// Note that all the setters affecting `operation` are
3817    /// mutually exclusive.
3818    pub fn set_delete<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Delete>>>(
3819        mut self,
3820        v: T,
3821    ) -> Self {
3822        self.operation =
3823            std::option::Option::Some(crate::model::mutation::Operation::Delete(v.into()));
3824        self
3825    }
3826
3827    /// The value of [operation][crate::model::Mutation::operation]
3828    /// if it holds a `Send`, `None` if the field is not set or
3829    /// holds a different branch.
3830    pub fn send(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Send>> {
3831        #[allow(unreachable_patterns)]
3832        self.operation.as_ref().and_then(|v| match v {
3833            crate::model::mutation::Operation::Send(v) => std::option::Option::Some(v),
3834            _ => std::option::Option::None,
3835        })
3836    }
3837
3838    /// Sets the value of [operation][crate::model::Mutation::operation]
3839    /// to hold a `Send`.
3840    ///
3841    /// Note that all the setters affecting `operation` are
3842    /// mutually exclusive.
3843    pub fn set_send<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Send>>>(
3844        mut self,
3845        v: T,
3846    ) -> Self {
3847        self.operation =
3848            std::option::Option::Some(crate::model::mutation::Operation::Send(v.into()));
3849        self
3850    }
3851
3852    /// The value of [operation][crate::model::Mutation::operation]
3853    /// if it holds a `Ack`, `None` if the field is not set or
3854    /// holds a different branch.
3855    pub fn ack(&self) -> std::option::Option<&std::boxed::Box<crate::model::mutation::Ack>> {
3856        #[allow(unreachable_patterns)]
3857        self.operation.as_ref().and_then(|v| match v {
3858            crate::model::mutation::Operation::Ack(v) => std::option::Option::Some(v),
3859            _ => std::option::Option::None,
3860        })
3861    }
3862
3863    /// Sets the value of [operation][crate::model::Mutation::operation]
3864    /// to hold a `Ack`.
3865    ///
3866    /// Note that all the setters affecting `operation` are
3867    /// mutually exclusive.
3868    pub fn set_ack<T: std::convert::Into<std::boxed::Box<crate::model::mutation::Ack>>>(
3869        mut self,
3870        v: T,
3871    ) -> Self {
3872        self.operation =
3873            std::option::Option::Some(crate::model::mutation::Operation::Ack(v.into()));
3874        self
3875    }
3876}
3877
3878impl wkt::message::Message for Mutation {
3879    fn typename() -> &'static str {
3880        "type.googleapis.com/google.spanner.v1.Mutation"
3881    }
3882}
3883
3884/// Defines additional types related to [Mutation].
3885pub mod mutation {
3886    #[allow(unused_imports)]
3887    use super::*;
3888
3889    /// Arguments to [insert][google.spanner.v1.Mutation.insert],
3890    /// [update][google.spanner.v1.Mutation.update],
3891    /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], and
3892    /// [replace][google.spanner.v1.Mutation.replace] operations.
3893    ///
3894    /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
3895    /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
3896    /// [google.spanner.v1.Mutation.replace]: crate::model::Mutation::operation
3897    /// [google.spanner.v1.Mutation.update]: crate::model::Mutation::operation
3898    #[derive(Clone, Default, PartialEq)]
3899    #[non_exhaustive]
3900    pub struct Write {
3901        /// Required. The table whose rows will be written.
3902        pub table: std::string::String,
3903
3904        /// The names of the columns in
3905        /// [table][google.spanner.v1.Mutation.Write.table] to be written.
3906        ///
3907        /// The list of columns must contain enough columns to allow
3908        /// Cloud Spanner to derive values for all primary key columns in the
3909        /// row(s) to be modified.
3910        ///
3911        /// [google.spanner.v1.Mutation.Write.table]: crate::model::mutation::Write::table
3912        pub columns: std::vec::Vec<std::string::String>,
3913
3914        /// The values to be written. `values` can contain more than one
3915        /// list of values. If it does, then multiple rows are written, one
3916        /// for each entry in `values`. Each list in `values` must have
3917        /// exactly as many entries as there are entries in
3918        /// [columns][google.spanner.v1.Mutation.Write.columns] above. Sending
3919        /// multiple lists is equivalent to sending multiple `Mutation`s, each
3920        /// containing one `values` entry and repeating
3921        /// [table][google.spanner.v1.Mutation.Write.table] and
3922        /// [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in
3923        /// each list are encoded as described [here][google.spanner.v1.TypeCode].
3924        ///
3925        /// [google.spanner.v1.Mutation.Write.columns]: crate::model::mutation::Write::columns
3926        /// [google.spanner.v1.Mutation.Write.table]: crate::model::mutation::Write::table
3927        /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
3928        pub values: std::vec::Vec<wkt::ListValue>,
3929
3930        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3931    }
3932
3933    impl Write {
3934        /// Creates a new default instance.
3935        pub fn new() -> Self {
3936            std::default::Default::default()
3937        }
3938
3939        /// Sets the value of [table][crate::model::mutation::Write::table].
3940        pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3941            self.table = v.into();
3942            self
3943        }
3944
3945        /// Sets the value of [columns][crate::model::mutation::Write::columns].
3946        pub fn set_columns<T, V>(mut self, v: T) -> Self
3947        where
3948            T: std::iter::IntoIterator<Item = V>,
3949            V: std::convert::Into<std::string::String>,
3950        {
3951            use std::iter::Iterator;
3952            self.columns = v.into_iter().map(|i| i.into()).collect();
3953            self
3954        }
3955
3956        /// Sets the value of [values][crate::model::mutation::Write::values].
3957        pub fn set_values<T, V>(mut self, v: T) -> Self
3958        where
3959            T: std::iter::IntoIterator<Item = V>,
3960            V: std::convert::Into<wkt::ListValue>,
3961        {
3962            use std::iter::Iterator;
3963            self.values = v.into_iter().map(|i| i.into()).collect();
3964            self
3965        }
3966    }
3967
3968    impl wkt::message::Message for Write {
3969        fn typename() -> &'static str {
3970            "type.googleapis.com/google.spanner.v1.Mutation.Write"
3971        }
3972    }
3973
3974    /// Arguments to [delete][google.spanner.v1.Mutation.delete] operations.
3975    ///
3976    /// [google.spanner.v1.Mutation.delete]: crate::model::Mutation::operation
3977    #[derive(Clone, Default, PartialEq)]
3978    #[non_exhaustive]
3979    pub struct Delete {
3980        /// Required. The table whose rows will be deleted.
3981        pub table: std::string::String,
3982
3983        /// Required. The primary keys of the rows within
3984        /// [table][google.spanner.v1.Mutation.Delete.table] to delete.  The primary
3985        /// keys must be specified in the order in which they appear in the `PRIMARY
3986        /// KEY()` clause of the table's equivalent DDL statement (the DDL statement
3987        /// used to create the table). Delete is idempotent. The transaction will
3988        /// succeed even if some or all rows do not exist.
3989        ///
3990        /// [google.spanner.v1.Mutation.Delete.table]: crate::model::mutation::Delete::table
3991        pub key_set: std::option::Option<crate::model::KeySet>,
3992
3993        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3994    }
3995
3996    impl Delete {
3997        /// Creates a new default instance.
3998        pub fn new() -> Self {
3999            std::default::Default::default()
4000        }
4001
4002        /// Sets the value of [table][crate::model::mutation::Delete::table].
4003        pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4004            self.table = v.into();
4005            self
4006        }
4007
4008        /// Sets the value of [key_set][crate::model::mutation::Delete::key_set].
4009        pub fn set_key_set<T>(mut self, v: T) -> Self
4010        where
4011            T: std::convert::Into<crate::model::KeySet>,
4012        {
4013            self.key_set = std::option::Option::Some(v.into());
4014            self
4015        }
4016
4017        /// Sets or clears the value of [key_set][crate::model::mutation::Delete::key_set].
4018        pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
4019        where
4020            T: std::convert::Into<crate::model::KeySet>,
4021        {
4022            self.key_set = v.map(|x| x.into());
4023            self
4024        }
4025    }
4026
4027    impl wkt::message::Message for Delete {
4028        fn typename() -> &'static str {
4029            "type.googleapis.com/google.spanner.v1.Mutation.Delete"
4030        }
4031    }
4032
4033    /// Arguments to [send][google.spanner.v1.Mutation.send] operations.
4034    ///
4035    /// [google.spanner.v1.Mutation.send]: crate::model::Mutation::operation
4036    #[derive(Clone, Default, PartialEq)]
4037    #[non_exhaustive]
4038    pub struct Send {
4039        /// Required. The queue to which the message will be sent.
4040        pub queue: std::string::String,
4041
4042        /// Required. The primary key of the message to be sent.
4043        pub key: std::option::Option<wkt::ListValue>,
4044
4045        /// The time at which Spanner will begin attempting to deliver the message.
4046        /// If `deliver_time` is not set, Spanner will deliver the message
4047        /// immediately. If `deliver_time` is in the past, Spanner will replace it
4048        /// with a value closer to the current time.
4049        pub deliver_time: std::option::Option<wkt::Timestamp>,
4050
4051        /// The payload of the message.
4052        pub payload: std::option::Option<wkt::Value>,
4053
4054        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4055    }
4056
4057    impl Send {
4058        /// Creates a new default instance.
4059        pub fn new() -> Self {
4060            std::default::Default::default()
4061        }
4062
4063        /// Sets the value of [queue][crate::model::mutation::Send::queue].
4064        pub fn set_queue<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4065            self.queue = v.into();
4066            self
4067        }
4068
4069        /// Sets the value of [key][crate::model::mutation::Send::key].
4070        pub fn set_key<T>(mut self, v: T) -> Self
4071        where
4072            T: std::convert::Into<wkt::ListValue>,
4073        {
4074            self.key = std::option::Option::Some(v.into());
4075            self
4076        }
4077
4078        /// Sets or clears the value of [key][crate::model::mutation::Send::key].
4079        pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
4080        where
4081            T: std::convert::Into<wkt::ListValue>,
4082        {
4083            self.key = v.map(|x| x.into());
4084            self
4085        }
4086
4087        /// Sets the value of [deliver_time][crate::model::mutation::Send::deliver_time].
4088        pub fn set_deliver_time<T>(mut self, v: T) -> Self
4089        where
4090            T: std::convert::Into<wkt::Timestamp>,
4091        {
4092            self.deliver_time = std::option::Option::Some(v.into());
4093            self
4094        }
4095
4096        /// Sets or clears the value of [deliver_time][crate::model::mutation::Send::deliver_time].
4097        pub fn set_or_clear_deliver_time<T>(mut self, v: std::option::Option<T>) -> Self
4098        where
4099            T: std::convert::Into<wkt::Timestamp>,
4100        {
4101            self.deliver_time = v.map(|x| x.into());
4102            self
4103        }
4104
4105        /// Sets the value of [payload][crate::model::mutation::Send::payload].
4106        pub fn set_payload<T>(mut self, v: T) -> Self
4107        where
4108            T: std::convert::Into<wkt::Value>,
4109        {
4110            self.payload = std::option::Option::Some(v.into());
4111            self
4112        }
4113
4114        /// Sets or clears the value of [payload][crate::model::mutation::Send::payload].
4115        pub fn set_or_clear_payload<T>(mut self, v: std::option::Option<T>) -> Self
4116        where
4117            T: std::convert::Into<wkt::Value>,
4118        {
4119            self.payload = v.map(|x| x.into());
4120            self
4121        }
4122    }
4123
4124    impl wkt::message::Message for Send {
4125        fn typename() -> &'static str {
4126            "type.googleapis.com/google.spanner.v1.Mutation.Send"
4127        }
4128    }
4129
4130    /// Arguments to [ack][google.spanner.v1.Mutation.ack] operations.
4131    ///
4132    /// [google.spanner.v1.Mutation.ack]: crate::model::Mutation::operation
4133    #[derive(Clone, Default, PartialEq)]
4134    #[non_exhaustive]
4135    pub struct Ack {
4136        /// Required. The queue where the message to be acked is stored.
4137        pub queue: std::string::String,
4138
4139        /// Required. The primary key of the message to be acked.
4140        pub key: std::option::Option<wkt::ListValue>,
4141
4142        /// By default, an attempt to ack a message that does not exist will fail
4143        /// with a `NOT_FOUND` error. With `ignore_not_found` set to true, the ack
4144        /// will succeed even if the message does not exist. This is useful for
4145        /// unconditionally acking a message, even if it is missing or has already
4146        /// been acked.
4147        pub ignore_not_found: bool,
4148
4149        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4150    }
4151
4152    impl Ack {
4153        /// Creates a new default instance.
4154        pub fn new() -> Self {
4155            std::default::Default::default()
4156        }
4157
4158        /// Sets the value of [queue][crate::model::mutation::Ack::queue].
4159        pub fn set_queue<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4160            self.queue = v.into();
4161            self
4162        }
4163
4164        /// Sets the value of [key][crate::model::mutation::Ack::key].
4165        pub fn set_key<T>(mut self, v: T) -> Self
4166        where
4167            T: std::convert::Into<wkt::ListValue>,
4168        {
4169            self.key = std::option::Option::Some(v.into());
4170            self
4171        }
4172
4173        /// Sets or clears the value of [key][crate::model::mutation::Ack::key].
4174        pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
4175        where
4176            T: std::convert::Into<wkt::ListValue>,
4177        {
4178            self.key = v.map(|x| x.into());
4179            self
4180        }
4181
4182        /// Sets the value of [ignore_not_found][crate::model::mutation::Ack::ignore_not_found].
4183        pub fn set_ignore_not_found<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4184            self.ignore_not_found = v.into();
4185            self
4186        }
4187    }
4188
4189    impl wkt::message::Message for Ack {
4190        fn typename() -> &'static str {
4191            "type.googleapis.com/google.spanner.v1.Mutation.Ack"
4192        }
4193    }
4194
4195    /// Required. The operation to perform.
4196    #[derive(Clone, Debug, PartialEq)]
4197    #[non_exhaustive]
4198    pub enum Operation {
4199        /// Insert new rows in a table. If any of the rows already exist,
4200        /// the write or transaction fails with error `ALREADY_EXISTS`.
4201        Insert(std::boxed::Box<crate::model::mutation::Write>),
4202        /// Update existing rows in a table. If any of the rows does not
4203        /// already exist, the transaction fails with error `NOT_FOUND`.
4204        Update(std::boxed::Box<crate::model::mutation::Write>),
4205        /// Like [insert][google.spanner.v1.Mutation.insert], except that if the row
4206        /// already exists, then its column values are overwritten with the ones
4207        /// provided. Any column values not explicitly written are preserved.
4208        ///
4209        /// When using
4210        /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as
4211        /// when using [insert][google.spanner.v1.Mutation.insert], all `NOT NULL`
4212        /// columns in the table must be given a value. This holds true even when the
4213        /// row already exists and will therefore actually be updated.
4214        ///
4215        /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
4216        /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
4217        InsertOrUpdate(std::boxed::Box<crate::model::mutation::Write>),
4218        /// Like [insert][google.spanner.v1.Mutation.insert], except that if the row
4219        /// already exists, it is deleted, and the column values provided are
4220        /// inserted instead. Unlike
4221        /// [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this
4222        /// means any values not explicitly written become `NULL`.
4223        ///
4224        /// In an interleaved table, if you create the child table with the
4225        /// `ON DELETE CASCADE` annotation, then replacing a parent row
4226        /// also deletes the child rows. Otherwise, you must delete the
4227        /// child rows before you replace the parent row.
4228        ///
4229        /// [google.spanner.v1.Mutation.insert]: crate::model::Mutation::operation
4230        /// [google.spanner.v1.Mutation.insert_or_update]: crate::model::Mutation::operation
4231        Replace(std::boxed::Box<crate::model::mutation::Write>),
4232        /// Delete rows from a table. Succeeds whether or not the named
4233        /// rows were present.
4234        Delete(std::boxed::Box<crate::model::mutation::Delete>),
4235        /// Send a message to a queue.
4236        Send(std::boxed::Box<crate::model::mutation::Send>),
4237        /// Ack a message from a queue.
4238        Ack(std::boxed::Box<crate::model::mutation::Ack>),
4239    }
4240
4241    impl Operation {
4242        /// Initializes the enum to the [Insert](Self::Insert) branch.
4243        pub fn from_insert(
4244            value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4245        ) -> Self {
4246            Self::Insert(value.into())
4247        }
4248        /// Initializes the enum to the [Update](Self::Update) branch.
4249        pub fn from_update(
4250            value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4251        ) -> Self {
4252            Self::Update(value.into())
4253        }
4254        /// Initializes the enum to the [InsertOrUpdate](Self::InsertOrUpdate) branch.
4255        pub fn from_insert_or_update(
4256            value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4257        ) -> Self {
4258            Self::InsertOrUpdate(value.into())
4259        }
4260        /// Initializes the enum to the [Replace](Self::Replace) branch.
4261        pub fn from_replace(
4262            value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Write>>,
4263        ) -> Self {
4264            Self::Replace(value.into())
4265        }
4266        /// Initializes the enum to the [Delete](Self::Delete) branch.
4267        pub fn from_delete(
4268            value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Delete>>,
4269        ) -> Self {
4270            Self::Delete(value.into())
4271        }
4272        /// Initializes the enum to the [Send](Self::Send) branch.
4273        pub fn from_send(
4274            value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Send>>,
4275        ) -> Self {
4276            Self::Send(value.into())
4277        }
4278        /// Initializes the enum to the [Ack](Self::Ack) branch.
4279        pub fn from_ack(
4280            value: impl std::convert::Into<std::boxed::Box<crate::model::mutation::Ack>>,
4281        ) -> Self {
4282            Self::Ack(value.into())
4283        }
4284    }
4285}
4286
4287/// Node information for nodes appearing in a
4288/// [QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes].
4289///
4290/// [google.spanner.v1.QueryPlan.plan_nodes]: crate::model::QueryPlan::plan_nodes
4291#[derive(Clone, Default, PartialEq)]
4292#[non_exhaustive]
4293pub struct PlanNode {
4294    /// The `PlanNode`'s index in [node
4295    /// list][google.spanner.v1.QueryPlan.plan_nodes].
4296    ///
4297    /// [google.spanner.v1.QueryPlan.plan_nodes]: crate::model::QueryPlan::plan_nodes
4298    pub index: i32,
4299
4300    /// Used to determine the type of node. May be needed for visualizing
4301    /// different kinds of nodes differently. For example, If the node is a
4302    /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a
4303    /// condensed representation which can be used to directly embed a description
4304    /// of the node in its parent.
4305    ///
4306    /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4307    pub kind: crate::model::plan_node::Kind,
4308
4309    /// The display name for the node.
4310    pub display_name: std::string::String,
4311
4312    /// List of child node `index`es and their relationship to this parent.
4313    pub child_links: std::vec::Vec<crate::model::plan_node::ChildLink>,
4314
4315    /// Condensed representation for
4316    /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes.
4317    ///
4318    /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4319    pub short_representation: std::option::Option<crate::model::plan_node::ShortRepresentation>,
4320
4321    /// Attributes relevant to the node contained in a group of key-value pairs.
4322    /// For example, a Parameter Reference node could have the following
4323    /// information in its metadata:
4324    ///
4325    /// ```norust
4326    /// {
4327    ///   "parameter_reference": "param1",
4328    ///   "parameter_type": "array"
4329    /// }
4330    /// ```
4331    pub metadata: std::option::Option<wkt::Struct>,
4332
4333    /// The execution statistics associated with the node, contained in a group of
4334    /// key-value pairs. Only present if the plan was returned as a result of a
4335    /// profile query. For example, number of executions, number of rows/time per
4336    /// execution etc.
4337    pub execution_stats: std::option::Option<wkt::Struct>,
4338
4339    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4340}
4341
4342impl PlanNode {
4343    /// Creates a new default instance.
4344    pub fn new() -> Self {
4345        std::default::Default::default()
4346    }
4347
4348    /// Sets the value of [index][crate::model::PlanNode::index].
4349    pub fn set_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4350        self.index = v.into();
4351        self
4352    }
4353
4354    /// Sets the value of [kind][crate::model::PlanNode::kind].
4355    pub fn set_kind<T: std::convert::Into<crate::model::plan_node::Kind>>(mut self, v: T) -> Self {
4356        self.kind = v.into();
4357        self
4358    }
4359
4360    /// Sets the value of [display_name][crate::model::PlanNode::display_name].
4361    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4362        self.display_name = v.into();
4363        self
4364    }
4365
4366    /// Sets the value of [child_links][crate::model::PlanNode::child_links].
4367    pub fn set_child_links<T, V>(mut self, v: T) -> Self
4368    where
4369        T: std::iter::IntoIterator<Item = V>,
4370        V: std::convert::Into<crate::model::plan_node::ChildLink>,
4371    {
4372        use std::iter::Iterator;
4373        self.child_links = v.into_iter().map(|i| i.into()).collect();
4374        self
4375    }
4376
4377    /// Sets the value of [short_representation][crate::model::PlanNode::short_representation].
4378    pub fn set_short_representation<T>(mut self, v: T) -> Self
4379    where
4380        T: std::convert::Into<crate::model::plan_node::ShortRepresentation>,
4381    {
4382        self.short_representation = std::option::Option::Some(v.into());
4383        self
4384    }
4385
4386    /// Sets or clears the value of [short_representation][crate::model::PlanNode::short_representation].
4387    pub fn set_or_clear_short_representation<T>(mut self, v: std::option::Option<T>) -> Self
4388    where
4389        T: std::convert::Into<crate::model::plan_node::ShortRepresentation>,
4390    {
4391        self.short_representation = v.map(|x| x.into());
4392        self
4393    }
4394
4395    /// Sets the value of [metadata][crate::model::PlanNode::metadata].
4396    pub fn set_metadata<T>(mut self, v: T) -> Self
4397    where
4398        T: std::convert::Into<wkt::Struct>,
4399    {
4400        self.metadata = std::option::Option::Some(v.into());
4401        self
4402    }
4403
4404    /// Sets or clears the value of [metadata][crate::model::PlanNode::metadata].
4405    pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
4406    where
4407        T: std::convert::Into<wkt::Struct>,
4408    {
4409        self.metadata = v.map(|x| x.into());
4410        self
4411    }
4412
4413    /// Sets the value of [execution_stats][crate::model::PlanNode::execution_stats].
4414    pub fn set_execution_stats<T>(mut self, v: T) -> Self
4415    where
4416        T: std::convert::Into<wkt::Struct>,
4417    {
4418        self.execution_stats = std::option::Option::Some(v.into());
4419        self
4420    }
4421
4422    /// Sets or clears the value of [execution_stats][crate::model::PlanNode::execution_stats].
4423    pub fn set_or_clear_execution_stats<T>(mut self, v: std::option::Option<T>) -> Self
4424    where
4425        T: std::convert::Into<wkt::Struct>,
4426    {
4427        self.execution_stats = v.map(|x| x.into());
4428        self
4429    }
4430}
4431
4432impl wkt::message::Message for PlanNode {
4433    fn typename() -> &'static str {
4434        "type.googleapis.com/google.spanner.v1.PlanNode"
4435    }
4436}
4437
4438/// Defines additional types related to [PlanNode].
4439pub mod plan_node {
4440    #[allow(unused_imports)]
4441    use super::*;
4442
4443    /// Metadata associated with a parent-child relationship appearing in a
4444    /// [PlanNode][google.spanner.v1.PlanNode].
4445    ///
4446    /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4447    #[derive(Clone, Default, PartialEq)]
4448    #[non_exhaustive]
4449    pub struct ChildLink {
4450        /// The node to which the link points.
4451        pub child_index: i32,
4452
4453        /// The type of the link. For example, in Hash Joins this could be used to
4454        /// distinguish between the build child and the probe child, or in the case
4455        /// of the child being an output variable, to represent the tag associated
4456        /// with the output variable.
4457        pub r#type: std::string::String,
4458
4459        /// Only present if the child node is
4460        /// [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds to an
4461        /// output variable of the parent node. The field carries the name of the
4462        /// output variable. For example, a `TableScan` operator that reads rows from
4463        /// a table will have child links to the `SCALAR` nodes representing the
4464        /// output variables created for each column that is read by the operator.
4465        /// The corresponding `variable` fields will be set to the variable names
4466        /// assigned to the columns.
4467        ///
4468        /// [google.spanner.v1.PlanNode.Kind.SCALAR]: crate::model::plan_node::Kind::Scalar
4469        pub variable: std::string::String,
4470
4471        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4472    }
4473
4474    impl ChildLink {
4475        /// Creates a new default instance.
4476        pub fn new() -> Self {
4477            std::default::Default::default()
4478        }
4479
4480        /// Sets the value of [child_index][crate::model::plan_node::ChildLink::child_index].
4481        pub fn set_child_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4482            self.child_index = v.into();
4483            self
4484        }
4485
4486        /// Sets the value of [r#type][crate::model::plan_node::ChildLink::type].
4487        pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4488            self.r#type = v.into();
4489            self
4490        }
4491
4492        /// Sets the value of [variable][crate::model::plan_node::ChildLink::variable].
4493        pub fn set_variable<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4494            self.variable = v.into();
4495            self
4496        }
4497    }
4498
4499    impl wkt::message::Message for ChildLink {
4500        fn typename() -> &'static str {
4501            "type.googleapis.com/google.spanner.v1.PlanNode.ChildLink"
4502        }
4503    }
4504
4505    /// Condensed representation of a node and its subtree. Only present for
4506    /// `SCALAR` [PlanNode(s)][google.spanner.v1.PlanNode].
4507    ///
4508    /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4509    #[derive(Clone, Default, PartialEq)]
4510    #[non_exhaustive]
4511    pub struct ShortRepresentation {
4512        /// A string representation of the expression subtree rooted at this node.
4513        pub description: std::string::String,
4514
4515        /// A mapping of (subquery variable name) -> (subquery node id) for cases
4516        /// where the `description` string of this node references a `SCALAR`
4517        /// subquery contained in the expression subtree rooted at this node. The
4518        /// referenced `SCALAR` subquery may not necessarily be a direct child of
4519        /// this node.
4520        pub subqueries: std::collections::HashMap<std::string::String, i32>,
4521
4522        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4523    }
4524
4525    impl ShortRepresentation {
4526        /// Creates a new default instance.
4527        pub fn new() -> Self {
4528            std::default::Default::default()
4529        }
4530
4531        /// Sets the value of [description][crate::model::plan_node::ShortRepresentation::description].
4532        pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4533            self.description = v.into();
4534            self
4535        }
4536
4537        /// Sets the value of [subqueries][crate::model::plan_node::ShortRepresentation::subqueries].
4538        pub fn set_subqueries<T, K, V>(mut self, v: T) -> Self
4539        where
4540            T: std::iter::IntoIterator<Item = (K, V)>,
4541            K: std::convert::Into<std::string::String>,
4542            V: std::convert::Into<i32>,
4543        {
4544            use std::iter::Iterator;
4545            self.subqueries = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4546            self
4547        }
4548    }
4549
4550    impl wkt::message::Message for ShortRepresentation {
4551        fn typename() -> &'static str {
4552            "type.googleapis.com/google.spanner.v1.PlanNode.ShortRepresentation"
4553        }
4554    }
4555
4556    /// The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between
4557    /// the two different kinds of nodes that can appear in a query plan.
4558    ///
4559    /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4560    ///
4561    /// # Working with unknown values
4562    ///
4563    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4564    /// additional enum variants at any time. Adding new variants is not considered
4565    /// a breaking change. Applications should write their code in anticipation of:
4566    ///
4567    /// - New values appearing in future releases of the client library, **and**
4568    /// - New values received dynamically, without application changes.
4569    ///
4570    /// Please consult the [Working with enums] section in the user guide for some
4571    /// guidelines.
4572    ///
4573    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4574    #[derive(Clone, Debug, PartialEq)]
4575    #[non_exhaustive]
4576    pub enum Kind {
4577        /// Not specified.
4578        Unspecified,
4579        /// Denotes a Relational operator node in the expression tree. Relational
4580        /// operators represent iterative processing of rows during query execution.
4581        /// For example, a `TableScan` operation that reads rows from a table.
4582        Relational,
4583        /// Denotes a Scalar node in the expression tree. Scalar nodes represent
4584        /// non-iterable entities in the query plan. For example, constants or
4585        /// arithmetic operators appearing inside predicate expressions or references
4586        /// to column names.
4587        Scalar,
4588        /// If set, the enum was initialized with an unknown value.
4589        ///
4590        /// Applications can examine the value using [Kind::value] or
4591        /// [Kind::name].
4592        UnknownValue(kind::UnknownValue),
4593    }
4594
4595    #[doc(hidden)]
4596    pub mod kind {
4597        #[allow(unused_imports)]
4598        use super::*;
4599        #[derive(Clone, Debug, PartialEq)]
4600        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4601    }
4602
4603    impl Kind {
4604        /// Gets the enum value.
4605        ///
4606        /// Returns `None` if the enum contains an unknown value deserialized from
4607        /// the string representation of enums.
4608        pub fn value(&self) -> std::option::Option<i32> {
4609            match self {
4610                Self::Unspecified => std::option::Option::Some(0),
4611                Self::Relational => std::option::Option::Some(1),
4612                Self::Scalar => std::option::Option::Some(2),
4613                Self::UnknownValue(u) => u.0.value(),
4614            }
4615        }
4616
4617        /// Gets the enum value as a string.
4618        ///
4619        /// Returns `None` if the enum contains an unknown value deserialized from
4620        /// the integer representation of enums.
4621        pub fn name(&self) -> std::option::Option<&str> {
4622            match self {
4623                Self::Unspecified => std::option::Option::Some("KIND_UNSPECIFIED"),
4624                Self::Relational => std::option::Option::Some("RELATIONAL"),
4625                Self::Scalar => std::option::Option::Some("SCALAR"),
4626                Self::UnknownValue(u) => u.0.name(),
4627            }
4628        }
4629    }
4630
4631    impl std::default::Default for Kind {
4632        fn default() -> Self {
4633            use std::convert::From;
4634            Self::from(0)
4635        }
4636    }
4637
4638    impl std::fmt::Display for Kind {
4639        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4640            wkt::internal::display_enum(f, self.name(), self.value())
4641        }
4642    }
4643
4644    impl std::convert::From<i32> for Kind {
4645        fn from(value: i32) -> Self {
4646            match value {
4647                0 => Self::Unspecified,
4648                1 => Self::Relational,
4649                2 => Self::Scalar,
4650                _ => Self::UnknownValue(kind::UnknownValue(
4651                    wkt::internal::UnknownEnumValue::Integer(value),
4652                )),
4653            }
4654        }
4655    }
4656
4657    impl std::convert::From<&str> for Kind {
4658        fn from(value: &str) -> Self {
4659            use std::string::ToString;
4660            match value {
4661                "KIND_UNSPECIFIED" => Self::Unspecified,
4662                "RELATIONAL" => Self::Relational,
4663                "SCALAR" => Self::Scalar,
4664                _ => Self::UnknownValue(kind::UnknownValue(
4665                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4666                )),
4667            }
4668        }
4669    }
4670
4671    impl serde::ser::Serialize for Kind {
4672        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4673        where
4674            S: serde::Serializer,
4675        {
4676            match self {
4677                Self::Unspecified => serializer.serialize_i32(0),
4678                Self::Relational => serializer.serialize_i32(1),
4679                Self::Scalar => serializer.serialize_i32(2),
4680                Self::UnknownValue(u) => u.0.serialize(serializer),
4681            }
4682        }
4683    }
4684
4685    impl<'de> serde::de::Deserialize<'de> for Kind {
4686        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4687        where
4688            D: serde::Deserializer<'de>,
4689        {
4690            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Kind>::new(
4691                ".google.spanner.v1.PlanNode.Kind",
4692            ))
4693        }
4694    }
4695}
4696
4697/// Output of query advisor analysis.
4698#[derive(Clone, Default, PartialEq)]
4699#[non_exhaustive]
4700pub struct QueryAdvisorResult {
4701    /// Optional. Index Recommendation for a query. This is an optional field and
4702    /// the recommendation will only be available when the recommendation
4703    /// guarantees significant improvement in query performance.
4704    pub index_advice: std::vec::Vec<crate::model::query_advisor_result::IndexAdvice>,
4705
4706    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4707}
4708
4709impl QueryAdvisorResult {
4710    /// Creates a new default instance.
4711    pub fn new() -> Self {
4712        std::default::Default::default()
4713    }
4714
4715    /// Sets the value of [index_advice][crate::model::QueryAdvisorResult::index_advice].
4716    pub fn set_index_advice<T, V>(mut self, v: T) -> Self
4717    where
4718        T: std::iter::IntoIterator<Item = V>,
4719        V: std::convert::Into<crate::model::query_advisor_result::IndexAdvice>,
4720    {
4721        use std::iter::Iterator;
4722        self.index_advice = v.into_iter().map(|i| i.into()).collect();
4723        self
4724    }
4725}
4726
4727impl wkt::message::Message for QueryAdvisorResult {
4728    fn typename() -> &'static str {
4729        "type.googleapis.com/google.spanner.v1.QueryAdvisorResult"
4730    }
4731}
4732
4733/// Defines additional types related to [QueryAdvisorResult].
4734pub mod query_advisor_result {
4735    #[allow(unused_imports)]
4736    use super::*;
4737
4738    /// Recommendation to add new indexes to run queries more efficiently.
4739    #[derive(Clone, Default, PartialEq)]
4740    #[non_exhaustive]
4741    pub struct IndexAdvice {
4742        /// Optional. DDL statements to add new indexes that will improve the query.
4743        pub ddl: std::vec::Vec<std::string::String>,
4744
4745        /// Optional. Estimated latency improvement factor. For example if the query
4746        /// currently takes 500 ms to run and the estimated latency with new indexes
4747        /// is 100 ms this field will be 5.
4748        pub improvement_factor: f64,
4749
4750        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4751    }
4752
4753    impl IndexAdvice {
4754        /// Creates a new default instance.
4755        pub fn new() -> Self {
4756            std::default::Default::default()
4757        }
4758
4759        /// Sets the value of [ddl][crate::model::query_advisor_result::IndexAdvice::ddl].
4760        pub fn set_ddl<T, V>(mut self, v: T) -> Self
4761        where
4762            T: std::iter::IntoIterator<Item = V>,
4763            V: std::convert::Into<std::string::String>,
4764        {
4765            use std::iter::Iterator;
4766            self.ddl = v.into_iter().map(|i| i.into()).collect();
4767            self
4768        }
4769
4770        /// Sets the value of [improvement_factor][crate::model::query_advisor_result::IndexAdvice::improvement_factor].
4771        pub fn set_improvement_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
4772            self.improvement_factor = v.into();
4773            self
4774        }
4775    }
4776
4777    impl wkt::message::Message for IndexAdvice {
4778        fn typename() -> &'static str {
4779            "type.googleapis.com/google.spanner.v1.QueryAdvisorResult.IndexAdvice"
4780        }
4781    }
4782}
4783
4784/// Contains an ordered list of nodes appearing in the query plan.
4785#[derive(Clone, Default, PartialEq)]
4786#[non_exhaustive]
4787pub struct QueryPlan {
4788    /// The nodes in the query plan. Plan nodes are returned in pre-order starting
4789    /// with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id`
4790    /// corresponds to its index in `plan_nodes`.
4791    ///
4792    /// [google.spanner.v1.PlanNode]: crate::model::PlanNode
4793    pub plan_nodes: std::vec::Vec<crate::model::PlanNode>,
4794
4795    /// Optional. The advise/recommendations for a query. Currently this field will
4796    /// be serving index recommendations for a query.
4797    pub query_advice: std::option::Option<crate::model::QueryAdvisorResult>,
4798
4799    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4800}
4801
4802impl QueryPlan {
4803    /// Creates a new default instance.
4804    pub fn new() -> Self {
4805        std::default::Default::default()
4806    }
4807
4808    /// Sets the value of [plan_nodes][crate::model::QueryPlan::plan_nodes].
4809    pub fn set_plan_nodes<T, V>(mut self, v: T) -> Self
4810    where
4811        T: std::iter::IntoIterator<Item = V>,
4812        V: std::convert::Into<crate::model::PlanNode>,
4813    {
4814        use std::iter::Iterator;
4815        self.plan_nodes = v.into_iter().map(|i| i.into()).collect();
4816        self
4817    }
4818
4819    /// Sets the value of [query_advice][crate::model::QueryPlan::query_advice].
4820    pub fn set_query_advice<T>(mut self, v: T) -> Self
4821    where
4822        T: std::convert::Into<crate::model::QueryAdvisorResult>,
4823    {
4824        self.query_advice = std::option::Option::Some(v.into());
4825        self
4826    }
4827
4828    /// Sets or clears the value of [query_advice][crate::model::QueryPlan::query_advice].
4829    pub fn set_or_clear_query_advice<T>(mut self, v: std::option::Option<T>) -> Self
4830    where
4831        T: std::convert::Into<crate::model::QueryAdvisorResult>,
4832    {
4833        self.query_advice = v.map(|x| x.into());
4834        self
4835    }
4836}
4837
4838impl wkt::message::Message for QueryPlan {
4839    fn typename() -> &'static str {
4840        "type.googleapis.com/google.spanner.v1.QueryPlan"
4841    }
4842}
4843
4844/// Results from [Read][google.spanner.v1.Spanner.Read] or
4845/// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql].
4846///
4847/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
4848/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
4849#[derive(Clone, Default, PartialEq)]
4850#[non_exhaustive]
4851pub struct ResultSet {
4852    /// Metadata about the result set, such as row type information.
4853    pub metadata: std::option::Option<crate::model::ResultSetMetadata>,
4854
4855    /// Each element in `rows` is a row whose format is defined by
4856    /// [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. The ith
4857    /// element in each row matches the ith field in
4858    /// [metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type]. Elements
4859    /// are encoded based on type as described [here][google.spanner.v1.TypeCode].
4860    ///
4861    /// [google.spanner.v1.ResultSetMetadata.row_type]: crate::model::ResultSetMetadata::row_type
4862    /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
4863    pub rows: std::vec::Vec<wkt::ListValue>,
4864
4865    /// Query plan and execution statistics for the SQL statement that
4866    /// produced this result set. These can be requested by setting
4867    /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4868    /// DML statements always produce stats containing the number of rows
4869    /// modified, unless executed using the
4870    /// [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]
4871    /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4872    /// Other fields might or might not be populated, based on the
4873    /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
4874    ///
4875    /// [google.spanner.v1.ExecuteSqlRequest.QueryMode.PLAN]: crate::model::execute_sql_request::QueryMode::Plan
4876    /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
4877    pub stats: std::option::Option<crate::model::ResultSetStats>,
4878
4879    /// Optional. A precommit token is included if the read-write transaction is on
4880    /// a multiplexed session. Pass the precommit token with the highest sequence
4881    /// number from this transaction attempt to the
4882    /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
4883    ///
4884    /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
4885    pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
4886
4887    /// Optional. A cache update expresses a set of changes the client should
4888    /// incorporate into its location cache. The client should discard the changes
4889    /// if they are older than the data it already has. This data can be obtained
4890    /// in response to requests that included a `RoutingHint` field, but may also
4891    /// be obtained by explicit location-fetching RPCs which may be added in the
4892    /// future.
4893    pub cache_update: std::option::Option<crate::model::CacheUpdate>,
4894
4895    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4896}
4897
4898impl ResultSet {
4899    /// Creates a new default instance.
4900    pub fn new() -> Self {
4901        std::default::Default::default()
4902    }
4903
4904    /// Sets the value of [metadata][crate::model::ResultSet::metadata].
4905    pub fn set_metadata<T>(mut self, v: T) -> Self
4906    where
4907        T: std::convert::Into<crate::model::ResultSetMetadata>,
4908    {
4909        self.metadata = std::option::Option::Some(v.into());
4910        self
4911    }
4912
4913    /// Sets or clears the value of [metadata][crate::model::ResultSet::metadata].
4914    pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
4915    where
4916        T: std::convert::Into<crate::model::ResultSetMetadata>,
4917    {
4918        self.metadata = v.map(|x| x.into());
4919        self
4920    }
4921
4922    /// Sets the value of [rows][crate::model::ResultSet::rows].
4923    pub fn set_rows<T, V>(mut self, v: T) -> Self
4924    where
4925        T: std::iter::IntoIterator<Item = V>,
4926        V: std::convert::Into<wkt::ListValue>,
4927    {
4928        use std::iter::Iterator;
4929        self.rows = v.into_iter().map(|i| i.into()).collect();
4930        self
4931    }
4932
4933    /// Sets the value of [stats][crate::model::ResultSet::stats].
4934    pub fn set_stats<T>(mut self, v: T) -> Self
4935    where
4936        T: std::convert::Into<crate::model::ResultSetStats>,
4937    {
4938        self.stats = std::option::Option::Some(v.into());
4939        self
4940    }
4941
4942    /// Sets or clears the value of [stats][crate::model::ResultSet::stats].
4943    pub fn set_or_clear_stats<T>(mut self, v: std::option::Option<T>) -> Self
4944    where
4945        T: std::convert::Into<crate::model::ResultSetStats>,
4946    {
4947        self.stats = v.map(|x| x.into());
4948        self
4949    }
4950
4951    /// Sets the value of [precommit_token][crate::model::ResultSet::precommit_token].
4952    pub fn set_precommit_token<T>(mut self, v: T) -> Self
4953    where
4954        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
4955    {
4956        self.precommit_token = std::option::Option::Some(v.into());
4957        self
4958    }
4959
4960    /// Sets or clears the value of [precommit_token][crate::model::ResultSet::precommit_token].
4961    pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
4962    where
4963        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
4964    {
4965        self.precommit_token = v.map(|x| x.into());
4966        self
4967    }
4968
4969    /// Sets the value of [cache_update][crate::model::ResultSet::cache_update].
4970    pub fn set_cache_update<T>(mut self, v: T) -> Self
4971    where
4972        T: std::convert::Into<crate::model::CacheUpdate>,
4973    {
4974        self.cache_update = std::option::Option::Some(v.into());
4975        self
4976    }
4977
4978    /// Sets or clears the value of [cache_update][crate::model::ResultSet::cache_update].
4979    pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
4980    where
4981        T: std::convert::Into<crate::model::CacheUpdate>,
4982    {
4983        self.cache_update = v.map(|x| x.into());
4984        self
4985    }
4986}
4987
4988impl wkt::message::Message for ResultSet {
4989    fn typename() -> &'static str {
4990        "type.googleapis.com/google.spanner.v1.ResultSet"
4991    }
4992}
4993
4994/// Partial results from a streaming read or SQL query. Streaming reads and
4995/// SQL queries better tolerate large result sets, large rows, and large
4996/// values, but are a little trickier to consume.
4997#[derive(Clone, Default, PartialEq)]
4998#[non_exhaustive]
4999pub struct PartialResultSet {
5000    /// Metadata about the result set, such as row type information.
5001    /// Only present in the first response.
5002    pub metadata: std::option::Option<crate::model::ResultSetMetadata>,
5003
5004    /// A streamed result set consists of a stream of values, which might
5005    /// be split into many `PartialResultSet` messages to accommodate
5006    /// large rows and/or large values. Every N complete values defines a
5007    /// row, where N is equal to the number of entries in
5008    /// [metadata.row_type.fields][google.spanner.v1.StructType.fields].
5009    ///
5010    /// Most values are encoded based on type as described
5011    /// [here][google.spanner.v1.TypeCode].
5012    ///
5013    /// It's possible that the last value in values is "chunked",
5014    /// meaning that the rest of the value is sent in subsequent
5015    /// `PartialResultSet`(s). This is denoted by the
5016    /// [chunked_value][google.spanner.v1.PartialResultSet.chunked_value] field.
5017    /// Two or more chunked values can be merged to form a complete value as
5018    /// follows:
5019    ///
5020    /// * `bool/number/null`: can't be chunked
5021    /// * `string`: concatenate the strings
5022    /// * `list`: concatenate the lists. If the last element in a list is a
5023    ///   `string`, `list`, or `object`, merge it with the first element in
5024    ///   the next list by applying these rules recursively.
5025    /// * `object`: concatenate the (field name, field value) pairs. If a
5026    ///   field name is duplicated, then apply these rules recursively
5027    ///   to merge the field values.
5028    ///
5029    /// Some examples of merging:
5030    ///
5031    /// ```norust
5032    /// Strings are concatenated.
5033    /// "foo", "bar" => "foobar"
5034    ///
5035    /// Lists of non-strings are concatenated.
5036    /// [2, 3], [4] => [2, 3, 4]
5037    ///
5038    /// Lists are concatenated, but the last and first elements are merged
5039    /// because they are strings.
5040    /// ["a", "b"], ["c", "d"] => ["a", "bc", "d"]
5041    ///
5042    /// Lists are concatenated, but the last and first elements are merged
5043    /// because they are lists. Recursively, the last and first elements
5044    /// of the inner lists are merged because they are strings.
5045    /// ["a", ["b", "c"]], [["d"], "e"] => ["a", ["b", "cd"], "e"]
5046    ///
5047    /// Non-overlapping object fields are combined.
5048    /// {"a": "1"}, {"b": "2"} => {"a": "1", "b": 2"}
5049    ///
5050    /// Overlapping object fields are merged.
5051    /// {"a": "1"}, {"a": "2"} => {"a": "12"}
5052    ///
5053    /// Examples of merging objects containing lists of strings.
5054    /// {"a": ["1"]}, {"a": ["2"]} => {"a": ["12"]}
5055    /// ```
5056    ///
5057    /// For a more complete example, suppose a streaming SQL query is
5058    /// yielding a result set whose rows contain a single string
5059    /// field. The following `PartialResultSet`s might be yielded:
5060    ///
5061    /// ```norust
5062    /// {
5063    ///   "metadata": { ... }
5064    ///   "values": ["Hello", "W"]
5065    ///   "chunked_value": true
5066    ///   "resume_token": "Af65..."
5067    /// }
5068    /// {
5069    ///   "values": ["orl"]
5070    ///   "chunked_value": true
5071    /// }
5072    /// {
5073    ///   "values": ["d"]
5074    ///   "resume_token": "Zx1B..."
5075    /// }
5076    /// ```
5077    ///
5078    /// This sequence of `PartialResultSet`s encodes two rows, one
5079    /// containing the field value `"Hello"`, and a second containing the
5080    /// field value `"World" = "W" + "orl" + "d"`.
5081    ///
5082    /// Not all `PartialResultSet`s contain a `resume_token`. Execution can only be
5083    /// resumed from a previously yielded `resume_token`. For the above sequence of
5084    /// `PartialResultSet`s, resuming the query with `"resume_token": "Af65..."`
5085    /// yields results from the `PartialResultSet` with value "orl".
5086    ///
5087    /// [google.spanner.v1.PartialResultSet.chunked_value]: crate::model::PartialResultSet::chunked_value
5088    /// [google.spanner.v1.StructType.fields]: crate::model::StructType::fields
5089    /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
5090    pub values: std::vec::Vec<wkt::Value>,
5091
5092    /// If true, then the final value in
5093    /// [values][google.spanner.v1.PartialResultSet.values] is chunked, and must be
5094    /// combined with more values from subsequent `PartialResultSet`s to obtain a
5095    /// complete field value.
5096    ///
5097    /// [google.spanner.v1.PartialResultSet.values]: crate::model::PartialResultSet::values
5098    pub chunked_value: bool,
5099
5100    /// Streaming calls might be interrupted for a variety of reasons, such
5101    /// as TCP connection loss. If this occurs, the stream of results can
5102    /// be resumed by re-sending the original request and including
5103    /// `resume_token`. Note that executing any other transaction in the
5104    /// same session invalidates the token.
5105    pub resume_token: ::bytes::Bytes,
5106
5107    /// Query plan and execution statistics for the statement that produced this
5108    /// streaming result set. These can be requested by setting
5109    /// [ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode]
5110    /// and are sent only once with the last response in the stream. This field is
5111    /// also present in the last response for DML statements.
5112    ///
5113    /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
5114    pub stats: std::option::Option<crate::model::ResultSetStats>,
5115
5116    /// Optional. A precommit token is included if the read-write transaction
5117    /// has multiplexed sessions enabled. Pass the precommit token with the highest
5118    /// sequence number from this transaction attempt to the
5119    /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
5120    ///
5121    /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
5122    pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
5123
5124    /// Optional. Indicates whether this is the last `PartialResultSet` in the
5125    /// stream. The server might optionally set this field. Clients shouldn't rely
5126    /// on this field being set in all cases.
5127    pub last: bool,
5128
5129    /// Optional. A cache update expresses a set of changes the client should
5130    /// incorporate into its location cache. The client should discard the changes
5131    /// if they are older than the data it already has. This data can be obtained
5132    /// in response to requests that included a `RoutingHint` field, but may also
5133    /// be obtained by explicit location-fetching RPCs which may be added in the
5134    /// future.
5135    pub cache_update: std::option::Option<crate::model::CacheUpdate>,
5136
5137    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5138}
5139
5140impl PartialResultSet {
5141    /// Creates a new default instance.
5142    pub fn new() -> Self {
5143        std::default::Default::default()
5144    }
5145
5146    /// Sets the value of [metadata][crate::model::PartialResultSet::metadata].
5147    pub fn set_metadata<T>(mut self, v: T) -> Self
5148    where
5149        T: std::convert::Into<crate::model::ResultSetMetadata>,
5150    {
5151        self.metadata = std::option::Option::Some(v.into());
5152        self
5153    }
5154
5155    /// Sets or clears the value of [metadata][crate::model::PartialResultSet::metadata].
5156    pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
5157    where
5158        T: std::convert::Into<crate::model::ResultSetMetadata>,
5159    {
5160        self.metadata = v.map(|x| x.into());
5161        self
5162    }
5163
5164    /// Sets the value of [values][crate::model::PartialResultSet::values].
5165    pub fn set_values<T, V>(mut self, v: T) -> Self
5166    where
5167        T: std::iter::IntoIterator<Item = V>,
5168        V: std::convert::Into<wkt::Value>,
5169    {
5170        use std::iter::Iterator;
5171        self.values = v.into_iter().map(|i| i.into()).collect();
5172        self
5173    }
5174
5175    /// Sets the value of [chunked_value][crate::model::PartialResultSet::chunked_value].
5176    pub fn set_chunked_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5177        self.chunked_value = v.into();
5178        self
5179    }
5180
5181    /// Sets the value of [resume_token][crate::model::PartialResultSet::resume_token].
5182    pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
5183        self.resume_token = v.into();
5184        self
5185    }
5186
5187    /// Sets the value of [stats][crate::model::PartialResultSet::stats].
5188    pub fn set_stats<T>(mut self, v: T) -> Self
5189    where
5190        T: std::convert::Into<crate::model::ResultSetStats>,
5191    {
5192        self.stats = std::option::Option::Some(v.into());
5193        self
5194    }
5195
5196    /// Sets or clears the value of [stats][crate::model::PartialResultSet::stats].
5197    pub fn set_or_clear_stats<T>(mut self, v: std::option::Option<T>) -> Self
5198    where
5199        T: std::convert::Into<crate::model::ResultSetStats>,
5200    {
5201        self.stats = v.map(|x| x.into());
5202        self
5203    }
5204
5205    /// Sets the value of [precommit_token][crate::model::PartialResultSet::precommit_token].
5206    pub fn set_precommit_token<T>(mut self, v: T) -> Self
5207    where
5208        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
5209    {
5210        self.precommit_token = std::option::Option::Some(v.into());
5211        self
5212    }
5213
5214    /// Sets or clears the value of [precommit_token][crate::model::PartialResultSet::precommit_token].
5215    pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
5216    where
5217        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
5218    {
5219        self.precommit_token = v.map(|x| x.into());
5220        self
5221    }
5222
5223    /// Sets the value of [last][crate::model::PartialResultSet::last].
5224    pub fn set_last<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5225        self.last = v.into();
5226        self
5227    }
5228
5229    /// Sets the value of [cache_update][crate::model::PartialResultSet::cache_update].
5230    pub fn set_cache_update<T>(mut self, v: T) -> Self
5231    where
5232        T: std::convert::Into<crate::model::CacheUpdate>,
5233    {
5234        self.cache_update = std::option::Option::Some(v.into());
5235        self
5236    }
5237
5238    /// Sets or clears the value of [cache_update][crate::model::PartialResultSet::cache_update].
5239    pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
5240    where
5241        T: std::convert::Into<crate::model::CacheUpdate>,
5242    {
5243        self.cache_update = v.map(|x| x.into());
5244        self
5245    }
5246}
5247
5248impl wkt::message::Message for PartialResultSet {
5249    fn typename() -> &'static str {
5250        "type.googleapis.com/google.spanner.v1.PartialResultSet"
5251    }
5252}
5253
5254/// Metadata about a [ResultSet][google.spanner.v1.ResultSet] or
5255/// [PartialResultSet][google.spanner.v1.PartialResultSet].
5256///
5257/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
5258/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
5259#[derive(Clone, Default, PartialEq)]
5260#[non_exhaustive]
5261pub struct ResultSetMetadata {
5262    /// Indicates the field names and types for the rows in the result
5263    /// set. For example, a SQL query like `"SELECT UserId, UserName FROM
5264    /// Users"` could return a `row_type` value like:
5265    ///
5266    /// ```norust
5267    /// "fields": [
5268    ///   { "name": "UserId", "type": { "code": "INT64" } },
5269    ///   { "name": "UserName", "type": { "code": "STRING" } },
5270    /// ]
5271    /// ```
5272    pub row_type: std::option::Option<crate::model::StructType>,
5273
5274    /// If the read or SQL query began a transaction as a side-effect, the
5275    /// information about the new transaction is yielded here.
5276    pub transaction: std::option::Option<crate::model::Transaction>,
5277
5278    /// A SQL query can be parameterized. In PLAN mode, these parameters can be
5279    /// undeclared. This indicates the field names and types for those undeclared
5280    /// parameters in the SQL query. For example, a SQL query like `"SELECT * FROM
5281    /// Users where UserId = @userId and UserName = @userName "` could return a
5282    /// `undeclared_parameters` value like:
5283    ///
5284    /// ```norust
5285    /// "fields": [
5286    ///   { "name": "UserId", "type": { "code": "INT64" } },
5287    ///   { "name": "UserName", "type": { "code": "STRING" } },
5288    /// ]
5289    /// ```
5290    pub undeclared_parameters: std::option::Option<crate::model::StructType>,
5291
5292    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5293}
5294
5295impl ResultSetMetadata {
5296    /// Creates a new default instance.
5297    pub fn new() -> Self {
5298        std::default::Default::default()
5299    }
5300
5301    /// Sets the value of [row_type][crate::model::ResultSetMetadata::row_type].
5302    pub fn set_row_type<T>(mut self, v: T) -> Self
5303    where
5304        T: std::convert::Into<crate::model::StructType>,
5305    {
5306        self.row_type = std::option::Option::Some(v.into());
5307        self
5308    }
5309
5310    /// Sets or clears the value of [row_type][crate::model::ResultSetMetadata::row_type].
5311    pub fn set_or_clear_row_type<T>(mut self, v: std::option::Option<T>) -> Self
5312    where
5313        T: std::convert::Into<crate::model::StructType>,
5314    {
5315        self.row_type = v.map(|x| x.into());
5316        self
5317    }
5318
5319    /// Sets the value of [transaction][crate::model::ResultSetMetadata::transaction].
5320    pub fn set_transaction<T>(mut self, v: T) -> Self
5321    where
5322        T: std::convert::Into<crate::model::Transaction>,
5323    {
5324        self.transaction = std::option::Option::Some(v.into());
5325        self
5326    }
5327
5328    /// Sets or clears the value of [transaction][crate::model::ResultSetMetadata::transaction].
5329    pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
5330    where
5331        T: std::convert::Into<crate::model::Transaction>,
5332    {
5333        self.transaction = v.map(|x| x.into());
5334        self
5335    }
5336
5337    /// Sets the value of [undeclared_parameters][crate::model::ResultSetMetadata::undeclared_parameters].
5338    pub fn set_undeclared_parameters<T>(mut self, v: T) -> Self
5339    where
5340        T: std::convert::Into<crate::model::StructType>,
5341    {
5342        self.undeclared_parameters = std::option::Option::Some(v.into());
5343        self
5344    }
5345
5346    /// Sets or clears the value of [undeclared_parameters][crate::model::ResultSetMetadata::undeclared_parameters].
5347    pub fn set_or_clear_undeclared_parameters<T>(mut self, v: std::option::Option<T>) -> Self
5348    where
5349        T: std::convert::Into<crate::model::StructType>,
5350    {
5351        self.undeclared_parameters = v.map(|x| x.into());
5352        self
5353    }
5354}
5355
5356impl wkt::message::Message for ResultSetMetadata {
5357    fn typename() -> &'static str {
5358        "type.googleapis.com/google.spanner.v1.ResultSetMetadata"
5359    }
5360}
5361
5362/// Additional statistics about a [ResultSet][google.spanner.v1.ResultSet] or
5363/// [PartialResultSet][google.spanner.v1.PartialResultSet].
5364///
5365/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
5366/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
5367#[derive(Clone, Default, PartialEq)]
5368#[non_exhaustive]
5369pub struct ResultSetStats {
5370    /// [QueryPlan][google.spanner.v1.QueryPlan] for the query associated with this
5371    /// result.
5372    ///
5373    /// [google.spanner.v1.QueryPlan]: crate::model::QueryPlan
5374    pub query_plan: std::option::Option<crate::model::QueryPlan>,
5375
5376    /// Aggregated statistics from the execution of the query. Only present when
5377    /// the query is profiled. For example, a query could return the statistics as
5378    /// follows:
5379    ///
5380    /// ```norust
5381    /// {
5382    ///   "rows_returned": "3",
5383    ///   "elapsed_time": "1.22 secs",
5384    ///   "cpu_time": "1.19 secs"
5385    /// }
5386    /// ```
5387    pub query_stats: std::option::Option<wkt::Struct>,
5388
5389    /// The number of rows modified by the DML statement.
5390    pub row_count: std::option::Option<crate::model::result_set_stats::RowCount>,
5391
5392    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5393}
5394
5395impl ResultSetStats {
5396    /// Creates a new default instance.
5397    pub fn new() -> Self {
5398        std::default::Default::default()
5399    }
5400
5401    /// Sets the value of [query_plan][crate::model::ResultSetStats::query_plan].
5402    pub fn set_query_plan<T>(mut self, v: T) -> Self
5403    where
5404        T: std::convert::Into<crate::model::QueryPlan>,
5405    {
5406        self.query_plan = std::option::Option::Some(v.into());
5407        self
5408    }
5409
5410    /// Sets or clears the value of [query_plan][crate::model::ResultSetStats::query_plan].
5411    pub fn set_or_clear_query_plan<T>(mut self, v: std::option::Option<T>) -> Self
5412    where
5413        T: std::convert::Into<crate::model::QueryPlan>,
5414    {
5415        self.query_plan = v.map(|x| x.into());
5416        self
5417    }
5418
5419    /// Sets the value of [query_stats][crate::model::ResultSetStats::query_stats].
5420    pub fn set_query_stats<T>(mut self, v: T) -> Self
5421    where
5422        T: std::convert::Into<wkt::Struct>,
5423    {
5424        self.query_stats = std::option::Option::Some(v.into());
5425        self
5426    }
5427
5428    /// Sets or clears the value of [query_stats][crate::model::ResultSetStats::query_stats].
5429    pub fn set_or_clear_query_stats<T>(mut self, v: std::option::Option<T>) -> Self
5430    where
5431        T: std::convert::Into<wkt::Struct>,
5432    {
5433        self.query_stats = v.map(|x| x.into());
5434        self
5435    }
5436
5437    /// Sets the value of [row_count][crate::model::ResultSetStats::row_count].
5438    ///
5439    /// Note that all the setters affecting `row_count` are mutually
5440    /// exclusive.
5441    pub fn set_row_count<
5442        T: std::convert::Into<std::option::Option<crate::model::result_set_stats::RowCount>>,
5443    >(
5444        mut self,
5445        v: T,
5446    ) -> Self {
5447        self.row_count = v.into();
5448        self
5449    }
5450
5451    /// The value of [row_count][crate::model::ResultSetStats::row_count]
5452    /// if it holds a `RowCountExact`, `None` if the field is not set or
5453    /// holds a different branch.
5454    pub fn row_count_exact(&self) -> std::option::Option<&i64> {
5455        #[allow(unreachable_patterns)]
5456        self.row_count.as_ref().and_then(|v| match v {
5457            crate::model::result_set_stats::RowCount::RowCountExact(v) => {
5458                std::option::Option::Some(v)
5459            }
5460            _ => std::option::Option::None,
5461        })
5462    }
5463
5464    /// Sets the value of [row_count][crate::model::ResultSetStats::row_count]
5465    /// to hold a `RowCountExact`.
5466    ///
5467    /// Note that all the setters affecting `row_count` are
5468    /// mutually exclusive.
5469    pub fn set_row_count_exact<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5470        self.row_count = std::option::Option::Some(
5471            crate::model::result_set_stats::RowCount::RowCountExact(v.into()),
5472        );
5473        self
5474    }
5475
5476    /// The value of [row_count][crate::model::ResultSetStats::row_count]
5477    /// if it holds a `RowCountLowerBound`, `None` if the field is not set or
5478    /// holds a different branch.
5479    pub fn row_count_lower_bound(&self) -> std::option::Option<&i64> {
5480        #[allow(unreachable_patterns)]
5481        self.row_count.as_ref().and_then(|v| match v {
5482            crate::model::result_set_stats::RowCount::RowCountLowerBound(v) => {
5483                std::option::Option::Some(v)
5484            }
5485            _ => std::option::Option::None,
5486        })
5487    }
5488
5489    /// Sets the value of [row_count][crate::model::ResultSetStats::row_count]
5490    /// to hold a `RowCountLowerBound`.
5491    ///
5492    /// Note that all the setters affecting `row_count` are
5493    /// mutually exclusive.
5494    pub fn set_row_count_lower_bound<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
5495        self.row_count = std::option::Option::Some(
5496            crate::model::result_set_stats::RowCount::RowCountLowerBound(v.into()),
5497        );
5498        self
5499    }
5500}
5501
5502impl wkt::message::Message for ResultSetStats {
5503    fn typename() -> &'static str {
5504        "type.googleapis.com/google.spanner.v1.ResultSetStats"
5505    }
5506}
5507
5508/// Defines additional types related to [ResultSetStats].
5509pub mod result_set_stats {
5510    #[allow(unused_imports)]
5511    use super::*;
5512
5513    /// The number of rows modified by the DML statement.
5514    #[derive(Clone, Debug, PartialEq)]
5515    #[non_exhaustive]
5516    pub enum RowCount {
5517        /// Standard DML returns an exact count of rows that were modified.
5518        RowCountExact(i64),
5519        /// Partitioned DML doesn't offer exactly-once semantics, so it
5520        /// returns a lower bound of the rows modified.
5521        RowCountLowerBound(i64),
5522    }
5523
5524    impl RowCount {
5525        /// Initializes the enum to the [RowCountExact](Self::RowCountExact) branch.
5526        pub fn from_row_count_exact(value: impl std::convert::Into<i64>) -> Self {
5527            Self::RowCountExact(value.into())
5528        }
5529        /// Initializes the enum to the [RowCountLowerBound](Self::RowCountLowerBound) branch.
5530        pub fn from_row_count_lower_bound(value: impl std::convert::Into<i64>) -> Self {
5531            Self::RowCountLowerBound(value.into())
5532        }
5533    }
5534}
5535
5536/// The request for [CreateSession][google.spanner.v1.Spanner.CreateSession].
5537///
5538/// [google.spanner.v1.Spanner.CreateSession]: crate::client::Spanner::create_session
5539#[derive(Clone, Default, PartialEq)]
5540#[non_exhaustive]
5541pub struct CreateSessionRequest {
5542    /// Required. The database in which the new session is created.
5543    pub database: std::string::String,
5544
5545    /// Required. The session to create.
5546    pub session: std::option::Option<crate::model::Session>,
5547
5548    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5549}
5550
5551impl CreateSessionRequest {
5552    /// Creates a new default instance.
5553    pub fn new() -> Self {
5554        std::default::Default::default()
5555    }
5556
5557    /// Sets the value of [database][crate::model::CreateSessionRequest::database].
5558    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5559        self.database = v.into();
5560        self
5561    }
5562
5563    /// Sets the value of [session][crate::model::CreateSessionRequest::session].
5564    pub fn set_session<T>(mut self, v: T) -> Self
5565    where
5566        T: std::convert::Into<crate::model::Session>,
5567    {
5568        self.session = std::option::Option::Some(v.into());
5569        self
5570    }
5571
5572    /// Sets or clears the value of [session][crate::model::CreateSessionRequest::session].
5573    pub fn set_or_clear_session<T>(mut self, v: std::option::Option<T>) -> Self
5574    where
5575        T: std::convert::Into<crate::model::Session>,
5576    {
5577        self.session = v.map(|x| x.into());
5578        self
5579    }
5580}
5581
5582impl wkt::message::Message for CreateSessionRequest {
5583    fn typename() -> &'static str {
5584        "type.googleapis.com/google.spanner.v1.CreateSessionRequest"
5585    }
5586}
5587
5588/// The request for
5589/// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
5590///
5591/// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5592#[derive(Clone, Default, PartialEq)]
5593#[non_exhaustive]
5594pub struct BatchCreateSessionsRequest {
5595    /// Required. The database in which the new sessions are created.
5596    pub database: std::string::String,
5597
5598    /// Parameters to apply to each created session.
5599    pub session_template: std::option::Option<crate::model::Session>,
5600
5601    /// Required. The number of sessions to be created in this batch call. At least
5602    /// one session is created. The API can return fewer than the requested number
5603    /// of sessions. If a specific number of sessions are desired, the client can
5604    /// make additional calls to `BatchCreateSessions` (adjusting
5605    /// [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count]
5606    /// as necessary).
5607    ///
5608    /// [google.spanner.v1.BatchCreateSessionsRequest.session_count]: crate::model::BatchCreateSessionsRequest::session_count
5609    pub session_count: i32,
5610
5611    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5612}
5613
5614impl BatchCreateSessionsRequest {
5615    /// Creates a new default instance.
5616    pub fn new() -> Self {
5617        std::default::Default::default()
5618    }
5619
5620    /// Sets the value of [database][crate::model::BatchCreateSessionsRequest::database].
5621    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5622        self.database = v.into();
5623        self
5624    }
5625
5626    /// Sets the value of [session_template][crate::model::BatchCreateSessionsRequest::session_template].
5627    pub fn set_session_template<T>(mut self, v: T) -> Self
5628    where
5629        T: std::convert::Into<crate::model::Session>,
5630    {
5631        self.session_template = std::option::Option::Some(v.into());
5632        self
5633    }
5634
5635    /// Sets or clears the value of [session_template][crate::model::BatchCreateSessionsRequest::session_template].
5636    pub fn set_or_clear_session_template<T>(mut self, v: std::option::Option<T>) -> Self
5637    where
5638        T: std::convert::Into<crate::model::Session>,
5639    {
5640        self.session_template = v.map(|x| x.into());
5641        self
5642    }
5643
5644    /// Sets the value of [session_count][crate::model::BatchCreateSessionsRequest::session_count].
5645    pub fn set_session_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5646        self.session_count = v.into();
5647        self
5648    }
5649}
5650
5651impl wkt::message::Message for BatchCreateSessionsRequest {
5652    fn typename() -> &'static str {
5653        "type.googleapis.com/google.spanner.v1.BatchCreateSessionsRequest"
5654    }
5655}
5656
5657/// The response for
5658/// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
5659///
5660/// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5661#[derive(Clone, Default, PartialEq)]
5662#[non_exhaustive]
5663pub struct BatchCreateSessionsResponse {
5664    /// The freshly created sessions.
5665    pub session: std::vec::Vec<crate::model::Session>,
5666
5667    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5668}
5669
5670impl BatchCreateSessionsResponse {
5671    /// Creates a new default instance.
5672    pub fn new() -> Self {
5673        std::default::Default::default()
5674    }
5675
5676    /// Sets the value of [session][crate::model::BatchCreateSessionsResponse::session].
5677    pub fn set_session<T, V>(mut self, v: T) -> Self
5678    where
5679        T: std::iter::IntoIterator<Item = V>,
5680        V: std::convert::Into<crate::model::Session>,
5681    {
5682        use std::iter::Iterator;
5683        self.session = v.into_iter().map(|i| i.into()).collect();
5684        self
5685    }
5686}
5687
5688impl wkt::message::Message for BatchCreateSessionsResponse {
5689    fn typename() -> &'static str {
5690        "type.googleapis.com/google.spanner.v1.BatchCreateSessionsResponse"
5691    }
5692}
5693
5694/// A session in the Cloud Spanner API.
5695#[derive(Clone, Default, PartialEq)]
5696#[non_exhaustive]
5697pub struct Session {
5698    /// Output only. The name of the session. This is always system-assigned.
5699    pub name: std::string::String,
5700
5701    /// The labels for the session.
5702    ///
5703    /// * Label keys must be between 1 and 63 characters long and must conform to
5704    ///   the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.
5705    /// * Label values must be between 0 and 63 characters long and must conform
5706    ///   to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
5707    /// * No more than 64 labels can be associated with a given session.
5708    ///
5709    /// See <https://goo.gl/xmQnxf> for more information on and examples of labels.
5710    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
5711
5712    /// Output only. The timestamp when the session is created.
5713    pub create_time: std::option::Option<wkt::Timestamp>,
5714
5715    /// Output only. The approximate timestamp when the session is last used. It's
5716    /// typically earlier than the actual last use time.
5717    pub approximate_last_use_time: std::option::Option<wkt::Timestamp>,
5718
5719    /// The database role which created this session.
5720    pub creator_role: std::string::String,
5721
5722    /// Optional. If `true`, specifies a multiplexed session. Use a multiplexed
5723    /// session for multiple, concurrent operations including any combination of
5724    /// read-only and read-write transactions. Use
5725    /// [`sessions.create`][google.spanner.v1.Spanner.CreateSession] to create
5726    /// multiplexed sessions. Don't use
5727    /// [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions] to
5728    /// create a multiplexed session. You can't delete or list multiplexed
5729    /// sessions.
5730    ///
5731    /// [google.spanner.v1.Spanner.BatchCreateSessions]: crate::client::Spanner::batch_create_sessions
5732    /// [google.spanner.v1.Spanner.CreateSession]: crate::client::Spanner::create_session
5733    pub multiplexed: bool,
5734
5735    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5736}
5737
5738impl Session {
5739    /// Creates a new default instance.
5740    pub fn new() -> Self {
5741        std::default::Default::default()
5742    }
5743
5744    /// Sets the value of [name][crate::model::Session::name].
5745    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5746        self.name = v.into();
5747        self
5748    }
5749
5750    /// Sets the value of [labels][crate::model::Session::labels].
5751    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
5752    where
5753        T: std::iter::IntoIterator<Item = (K, V)>,
5754        K: std::convert::Into<std::string::String>,
5755        V: std::convert::Into<std::string::String>,
5756    {
5757        use std::iter::Iterator;
5758        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5759        self
5760    }
5761
5762    /// Sets the value of [create_time][crate::model::Session::create_time].
5763    pub fn set_create_time<T>(mut self, v: T) -> Self
5764    where
5765        T: std::convert::Into<wkt::Timestamp>,
5766    {
5767        self.create_time = std::option::Option::Some(v.into());
5768        self
5769    }
5770
5771    /// Sets or clears the value of [create_time][crate::model::Session::create_time].
5772    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
5773    where
5774        T: std::convert::Into<wkt::Timestamp>,
5775    {
5776        self.create_time = v.map(|x| x.into());
5777        self
5778    }
5779
5780    /// Sets the value of [approximate_last_use_time][crate::model::Session::approximate_last_use_time].
5781    pub fn set_approximate_last_use_time<T>(mut self, v: T) -> Self
5782    where
5783        T: std::convert::Into<wkt::Timestamp>,
5784    {
5785        self.approximate_last_use_time = std::option::Option::Some(v.into());
5786        self
5787    }
5788
5789    /// Sets or clears the value of [approximate_last_use_time][crate::model::Session::approximate_last_use_time].
5790    pub fn set_or_clear_approximate_last_use_time<T>(mut self, v: std::option::Option<T>) -> Self
5791    where
5792        T: std::convert::Into<wkt::Timestamp>,
5793    {
5794        self.approximate_last_use_time = v.map(|x| x.into());
5795        self
5796    }
5797
5798    /// Sets the value of [creator_role][crate::model::Session::creator_role].
5799    pub fn set_creator_role<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5800        self.creator_role = v.into();
5801        self
5802    }
5803
5804    /// Sets the value of [multiplexed][crate::model::Session::multiplexed].
5805    pub fn set_multiplexed<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5806        self.multiplexed = v.into();
5807        self
5808    }
5809}
5810
5811impl wkt::message::Message for Session {
5812    fn typename() -> &'static str {
5813        "type.googleapis.com/google.spanner.v1.Session"
5814    }
5815}
5816
5817/// The request for [GetSession][google.spanner.v1.Spanner.GetSession].
5818///
5819/// [google.spanner.v1.Spanner.GetSession]: crate::client::Spanner::get_session
5820#[derive(Clone, Default, PartialEq)]
5821#[non_exhaustive]
5822pub struct GetSessionRequest {
5823    /// Required. The name of the session to retrieve.
5824    pub name: std::string::String,
5825
5826    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5827}
5828
5829impl GetSessionRequest {
5830    /// Creates a new default instance.
5831    pub fn new() -> Self {
5832        std::default::Default::default()
5833    }
5834
5835    /// Sets the value of [name][crate::model::GetSessionRequest::name].
5836    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5837        self.name = v.into();
5838        self
5839    }
5840}
5841
5842impl wkt::message::Message for GetSessionRequest {
5843    fn typename() -> &'static str {
5844        "type.googleapis.com/google.spanner.v1.GetSessionRequest"
5845    }
5846}
5847
5848/// The request for [ListSessions][google.spanner.v1.Spanner.ListSessions].
5849///
5850/// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5851#[derive(Clone, Default, PartialEq)]
5852#[non_exhaustive]
5853pub struct ListSessionsRequest {
5854    /// Required. The database in which to list sessions.
5855    pub database: std::string::String,
5856
5857    /// Number of sessions to be returned in the response. If 0 or less, defaults
5858    /// to the server's maximum allowed page size.
5859    pub page_size: i32,
5860
5861    /// If non-empty, `page_token` should contain a
5862    /// [next_page_token][google.spanner.v1.ListSessionsResponse.next_page_token]
5863    /// from a previous
5864    /// [ListSessionsResponse][google.spanner.v1.ListSessionsResponse].
5865    ///
5866    /// [google.spanner.v1.ListSessionsResponse]: crate::model::ListSessionsResponse
5867    /// [google.spanner.v1.ListSessionsResponse.next_page_token]: crate::model::ListSessionsResponse::next_page_token
5868    pub page_token: std::string::String,
5869
5870    /// An expression for filtering the results of the request. Filter rules are
5871    /// case insensitive. The fields eligible for filtering are:
5872    ///
5873    /// * `labels.key` where key is the name of a label
5874    ///
5875    /// Some examples of using filters are:
5876    ///
5877    /// * `labels.env:*` --> The session has the label "env".
5878    /// * `labels.env:dev` --> The session has the label "env" and the value of
5879    ///   the label contains the string "dev".
5880    pub filter: std::string::String,
5881
5882    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5883}
5884
5885impl ListSessionsRequest {
5886    /// Creates a new default instance.
5887    pub fn new() -> Self {
5888        std::default::Default::default()
5889    }
5890
5891    /// Sets the value of [database][crate::model::ListSessionsRequest::database].
5892    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5893        self.database = v.into();
5894        self
5895    }
5896
5897    /// Sets the value of [page_size][crate::model::ListSessionsRequest::page_size].
5898    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5899        self.page_size = v.into();
5900        self
5901    }
5902
5903    /// Sets the value of [page_token][crate::model::ListSessionsRequest::page_token].
5904    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5905        self.page_token = v.into();
5906        self
5907    }
5908
5909    /// Sets the value of [filter][crate::model::ListSessionsRequest::filter].
5910    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5911        self.filter = v.into();
5912        self
5913    }
5914}
5915
5916impl wkt::message::Message for ListSessionsRequest {
5917    fn typename() -> &'static str {
5918        "type.googleapis.com/google.spanner.v1.ListSessionsRequest"
5919    }
5920}
5921
5922/// The response for [ListSessions][google.spanner.v1.Spanner.ListSessions].
5923///
5924/// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5925#[derive(Clone, Default, PartialEq)]
5926#[non_exhaustive]
5927pub struct ListSessionsResponse {
5928    /// The list of requested sessions.
5929    pub sessions: std::vec::Vec<crate::model::Session>,
5930
5931    /// `next_page_token` can be sent in a subsequent
5932    /// [ListSessions][google.spanner.v1.Spanner.ListSessions] call to fetch more
5933    /// of the matching sessions.
5934    ///
5935    /// [google.spanner.v1.Spanner.ListSessions]: crate::client::Spanner::list_sessions
5936    pub next_page_token: std::string::String,
5937
5938    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5939}
5940
5941impl ListSessionsResponse {
5942    /// Creates a new default instance.
5943    pub fn new() -> Self {
5944        std::default::Default::default()
5945    }
5946
5947    /// Sets the value of [sessions][crate::model::ListSessionsResponse::sessions].
5948    pub fn set_sessions<T, V>(mut self, v: T) -> Self
5949    where
5950        T: std::iter::IntoIterator<Item = V>,
5951        V: std::convert::Into<crate::model::Session>,
5952    {
5953        use std::iter::Iterator;
5954        self.sessions = v.into_iter().map(|i| i.into()).collect();
5955        self
5956    }
5957
5958    /// Sets the value of [next_page_token][crate::model::ListSessionsResponse::next_page_token].
5959    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5960        self.next_page_token = v.into();
5961        self
5962    }
5963}
5964
5965impl wkt::message::Message for ListSessionsResponse {
5966    fn typename() -> &'static str {
5967        "type.googleapis.com/google.spanner.v1.ListSessionsResponse"
5968    }
5969}
5970
5971#[doc(hidden)]
5972impl google_cloud_gax::paginator::internal::PageableResponse for ListSessionsResponse {
5973    type PageItem = crate::model::Session;
5974
5975    fn items(self) -> std::vec::Vec<Self::PageItem> {
5976        self.sessions
5977    }
5978
5979    fn next_page_token(&self) -> std::string::String {
5980        use std::clone::Clone;
5981        self.next_page_token.clone()
5982    }
5983}
5984
5985/// The request for [DeleteSession][google.spanner.v1.Spanner.DeleteSession].
5986///
5987/// [google.spanner.v1.Spanner.DeleteSession]: crate::client::Spanner::delete_session
5988#[derive(Clone, Default, PartialEq)]
5989#[non_exhaustive]
5990pub struct DeleteSessionRequest {
5991    /// Required. The name of the session to delete.
5992    pub name: std::string::String,
5993
5994    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5995}
5996
5997impl DeleteSessionRequest {
5998    /// Creates a new default instance.
5999    pub fn new() -> Self {
6000        std::default::Default::default()
6001    }
6002
6003    /// Sets the value of [name][crate::model::DeleteSessionRequest::name].
6004    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6005        self.name = v.into();
6006        self
6007    }
6008}
6009
6010impl wkt::message::Message for DeleteSessionRequest {
6011    fn typename() -> &'static str {
6012        "type.googleapis.com/google.spanner.v1.DeleteSessionRequest"
6013    }
6014}
6015
6016/// Common request options for various APIs.
6017#[derive(Clone, Default, PartialEq)]
6018#[non_exhaustive]
6019pub struct RequestOptions {
6020    /// Priority for the request.
6021    pub priority: crate::model::request_options::Priority,
6022
6023    /// A per-request tag which can be applied to queries or reads, used for
6024    /// statistics collection.
6025    /// Both `request_tag` and `transaction_tag` can be specified for a read or
6026    /// query that belongs to a transaction.
6027    /// This field is ignored for requests where it's not applicable (for example,
6028    /// `CommitRequest`).
6029    /// Legal characters for `request_tag` values are all printable characters
6030    /// (ASCII 32 - 126) and the length of a request_tag is limited to 50
6031    /// characters. Values that exceed this limit are truncated.
6032    /// Any leading underscore (_) characters are removed from the string.
6033    pub request_tag: std::string::String,
6034
6035    /// A tag used for statistics collection about this transaction.
6036    /// Both `request_tag` and `transaction_tag` can be specified for a read or
6037    /// query that belongs to a transaction.
6038    /// To enable tagging on a transaction, `transaction_tag` must be set to the
6039    /// same value for all requests belonging to the same transaction, including
6040    /// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
6041    /// If this request doesn't belong to any transaction, `transaction_tag` is
6042    /// ignored.
6043    /// Legal characters for `transaction_tag` values are all printable characters
6044    /// (ASCII 32 - 126) and the length of a `transaction_tag` is limited to 50
6045    /// characters. Values that exceed this limit are truncated.
6046    /// Any leading underscore (_) characters are removed from the string.
6047    ///
6048    /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
6049    pub transaction_tag: std::string::String,
6050
6051    /// Optional. Optional context that may be needed for some requests.
6052    pub client_context: std::option::Option<crate::model::request_options::ClientContext>,
6053
6054    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6055}
6056
6057impl RequestOptions {
6058    /// Creates a new default instance.
6059    pub fn new() -> Self {
6060        std::default::Default::default()
6061    }
6062
6063    /// Sets the value of [priority][crate::model::RequestOptions::priority].
6064    pub fn set_priority<T: std::convert::Into<crate::model::request_options::Priority>>(
6065        mut self,
6066        v: T,
6067    ) -> Self {
6068        self.priority = v.into();
6069        self
6070    }
6071
6072    /// Sets the value of [request_tag][crate::model::RequestOptions::request_tag].
6073    pub fn set_request_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6074        self.request_tag = v.into();
6075        self
6076    }
6077
6078    /// Sets the value of [transaction_tag][crate::model::RequestOptions::transaction_tag].
6079    pub fn set_transaction_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6080        self.transaction_tag = v.into();
6081        self
6082    }
6083
6084    /// Sets the value of [client_context][crate::model::RequestOptions::client_context].
6085    pub fn set_client_context<T>(mut self, v: T) -> Self
6086    where
6087        T: std::convert::Into<crate::model::request_options::ClientContext>,
6088    {
6089        self.client_context = std::option::Option::Some(v.into());
6090        self
6091    }
6092
6093    /// Sets or clears the value of [client_context][crate::model::RequestOptions::client_context].
6094    pub fn set_or_clear_client_context<T>(mut self, v: std::option::Option<T>) -> Self
6095    where
6096        T: std::convert::Into<crate::model::request_options::ClientContext>,
6097    {
6098        self.client_context = v.map(|x| x.into());
6099        self
6100    }
6101}
6102
6103impl wkt::message::Message for RequestOptions {
6104    fn typename() -> &'static str {
6105        "type.googleapis.com/google.spanner.v1.RequestOptions"
6106    }
6107}
6108
6109/// Defines additional types related to [RequestOptions].
6110pub mod request_options {
6111    #[allow(unused_imports)]
6112    use super::*;
6113
6114    /// Container for various pieces of client-owned context attached to a request.
6115    #[derive(Clone, Default, PartialEq)]
6116    #[non_exhaustive]
6117    pub struct ClientContext {
6118        /// Optional. Map of parameter name to value for this request. These values
6119        /// will be returned by any SECURE_CONTEXT() calls invoked by this request
6120        /// (e.g., by queries against Parameterized Secure Views).
6121        pub secure_context: std::collections::HashMap<std::string::String, wkt::Value>,
6122
6123        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6124    }
6125
6126    impl ClientContext {
6127        /// Creates a new default instance.
6128        pub fn new() -> Self {
6129            std::default::Default::default()
6130        }
6131
6132        /// Sets the value of [secure_context][crate::model::request_options::ClientContext::secure_context].
6133        pub fn set_secure_context<T, K, V>(mut self, v: T) -> Self
6134        where
6135            T: std::iter::IntoIterator<Item = (K, V)>,
6136            K: std::convert::Into<std::string::String>,
6137            V: std::convert::Into<wkt::Value>,
6138        {
6139            use std::iter::Iterator;
6140            self.secure_context = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6141            self
6142        }
6143    }
6144
6145    impl wkt::message::Message for ClientContext {
6146        fn typename() -> &'static str {
6147            "type.googleapis.com/google.spanner.v1.RequestOptions.ClientContext"
6148        }
6149    }
6150
6151    /// The relative priority for requests. Note that priority isn't applicable
6152    /// for [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
6153    ///
6154    /// The priority acts as a hint to the Cloud Spanner scheduler and doesn't
6155    /// guarantee priority or order of execution. For example:
6156    ///
6157    /// * Some parts of a write operation always execute at `PRIORITY_HIGH`,
6158    ///   regardless of the specified priority. This can cause you to see an
6159    ///   increase in high priority workload even when executing a low priority
6160    ///   request. This can also potentially cause a priority inversion where a
6161    ///   lower priority request is fulfilled ahead of a higher priority
6162    ///   request.
6163    /// * If a transaction contains multiple operations with different priorities,
6164    ///   Cloud Spanner doesn't guarantee to process the higher priority
6165    ///   operations first. There might be other constraints to satisfy, such as
6166    ///   the order of operations.
6167    ///
6168    /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
6169    ///
6170    /// # Working with unknown values
6171    ///
6172    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6173    /// additional enum variants at any time. Adding new variants is not considered
6174    /// a breaking change. Applications should write their code in anticipation of:
6175    ///
6176    /// - New values appearing in future releases of the client library, **and**
6177    /// - New values received dynamically, without application changes.
6178    ///
6179    /// Please consult the [Working with enums] section in the user guide for some
6180    /// guidelines.
6181    ///
6182    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6183    #[derive(Clone, Debug, PartialEq)]
6184    #[non_exhaustive]
6185    pub enum Priority {
6186        /// `PRIORITY_UNSPECIFIED` is equivalent to `PRIORITY_HIGH`.
6187        Unspecified,
6188        /// This specifies that the request is low priority.
6189        Low,
6190        /// This specifies that the request is medium priority.
6191        Medium,
6192        /// This specifies that the request is high priority.
6193        High,
6194        /// If set, the enum was initialized with an unknown value.
6195        ///
6196        /// Applications can examine the value using [Priority::value] or
6197        /// [Priority::name].
6198        UnknownValue(priority::UnknownValue),
6199    }
6200
6201    #[doc(hidden)]
6202    pub mod priority {
6203        #[allow(unused_imports)]
6204        use super::*;
6205        #[derive(Clone, Debug, PartialEq)]
6206        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6207    }
6208
6209    impl Priority {
6210        /// Gets the enum value.
6211        ///
6212        /// Returns `None` if the enum contains an unknown value deserialized from
6213        /// the string representation of enums.
6214        pub fn value(&self) -> std::option::Option<i32> {
6215            match self {
6216                Self::Unspecified => std::option::Option::Some(0),
6217                Self::Low => std::option::Option::Some(1),
6218                Self::Medium => std::option::Option::Some(2),
6219                Self::High => std::option::Option::Some(3),
6220                Self::UnknownValue(u) => u.0.value(),
6221            }
6222        }
6223
6224        /// Gets the enum value as a string.
6225        ///
6226        /// Returns `None` if the enum contains an unknown value deserialized from
6227        /// the integer representation of enums.
6228        pub fn name(&self) -> std::option::Option<&str> {
6229            match self {
6230                Self::Unspecified => std::option::Option::Some("PRIORITY_UNSPECIFIED"),
6231                Self::Low => std::option::Option::Some("PRIORITY_LOW"),
6232                Self::Medium => std::option::Option::Some("PRIORITY_MEDIUM"),
6233                Self::High => std::option::Option::Some("PRIORITY_HIGH"),
6234                Self::UnknownValue(u) => u.0.name(),
6235            }
6236        }
6237    }
6238
6239    impl std::default::Default for Priority {
6240        fn default() -> Self {
6241            use std::convert::From;
6242            Self::from(0)
6243        }
6244    }
6245
6246    impl std::fmt::Display for Priority {
6247        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6248            wkt::internal::display_enum(f, self.name(), self.value())
6249        }
6250    }
6251
6252    impl std::convert::From<i32> for Priority {
6253        fn from(value: i32) -> Self {
6254            match value {
6255                0 => Self::Unspecified,
6256                1 => Self::Low,
6257                2 => Self::Medium,
6258                3 => Self::High,
6259                _ => Self::UnknownValue(priority::UnknownValue(
6260                    wkt::internal::UnknownEnumValue::Integer(value),
6261                )),
6262            }
6263        }
6264    }
6265
6266    impl std::convert::From<&str> for Priority {
6267        fn from(value: &str) -> Self {
6268            use std::string::ToString;
6269            match value {
6270                "PRIORITY_UNSPECIFIED" => Self::Unspecified,
6271                "PRIORITY_LOW" => Self::Low,
6272                "PRIORITY_MEDIUM" => Self::Medium,
6273                "PRIORITY_HIGH" => Self::High,
6274                _ => Self::UnknownValue(priority::UnknownValue(
6275                    wkt::internal::UnknownEnumValue::String(value.to_string()),
6276                )),
6277            }
6278        }
6279    }
6280
6281    impl serde::ser::Serialize for Priority {
6282        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6283        where
6284            S: serde::Serializer,
6285        {
6286            match self {
6287                Self::Unspecified => serializer.serialize_i32(0),
6288                Self::Low => serializer.serialize_i32(1),
6289                Self::Medium => serializer.serialize_i32(2),
6290                Self::High => serializer.serialize_i32(3),
6291                Self::UnknownValue(u) => u.0.serialize(serializer),
6292            }
6293        }
6294    }
6295
6296    impl<'de> serde::de::Deserialize<'de> for Priority {
6297        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6298        where
6299            D: serde::Deserializer<'de>,
6300        {
6301            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Priority>::new(
6302                ".google.spanner.v1.RequestOptions.Priority",
6303            ))
6304        }
6305    }
6306}
6307
6308/// The `DirectedReadOptions` can be used to indicate which replicas or regions
6309/// should be used for non-transactional reads or queries.
6310///
6311/// `DirectedReadOptions` can only be specified for a read-only transaction,
6312/// otherwise the API returns an `INVALID_ARGUMENT` error.
6313#[derive(Clone, Default, PartialEq)]
6314#[non_exhaustive]
6315pub struct DirectedReadOptions {
6316    /// Required. At most one of either `include_replicas` or `exclude_replicas`
6317    /// should be present in the message.
6318    pub replicas: std::option::Option<crate::model::directed_read_options::Replicas>,
6319
6320    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6321}
6322
6323impl DirectedReadOptions {
6324    /// Creates a new default instance.
6325    pub fn new() -> Self {
6326        std::default::Default::default()
6327    }
6328
6329    /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas].
6330    ///
6331    /// Note that all the setters affecting `replicas` are mutually
6332    /// exclusive.
6333    pub fn set_replicas<
6334        T: std::convert::Into<std::option::Option<crate::model::directed_read_options::Replicas>>,
6335    >(
6336        mut self,
6337        v: T,
6338    ) -> Self {
6339        self.replicas = v.into();
6340        self
6341    }
6342
6343    /// The value of [replicas][crate::model::DirectedReadOptions::replicas]
6344    /// if it holds a `IncludeReplicas`, `None` if the field is not set or
6345    /// holds a different branch.
6346    pub fn include_replicas(
6347        &self,
6348    ) -> std::option::Option<&std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>>
6349    {
6350        #[allow(unreachable_patterns)]
6351        self.replicas.as_ref().and_then(|v| match v {
6352            crate::model::directed_read_options::Replicas::IncludeReplicas(v) => {
6353                std::option::Option::Some(v)
6354            }
6355            _ => std::option::Option::None,
6356        })
6357    }
6358
6359    /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas]
6360    /// to hold a `IncludeReplicas`.
6361    ///
6362    /// Note that all the setters affecting `replicas` are
6363    /// mutually exclusive.
6364    pub fn set_include_replicas<
6365        T: std::convert::Into<std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>>,
6366    >(
6367        mut self,
6368        v: T,
6369    ) -> Self {
6370        self.replicas = std::option::Option::Some(
6371            crate::model::directed_read_options::Replicas::IncludeReplicas(v.into()),
6372        );
6373        self
6374    }
6375
6376    /// The value of [replicas][crate::model::DirectedReadOptions::replicas]
6377    /// if it holds a `ExcludeReplicas`, `None` if the field is not set or
6378    /// holds a different branch.
6379    pub fn exclude_replicas(
6380        &self,
6381    ) -> std::option::Option<&std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>>
6382    {
6383        #[allow(unreachable_patterns)]
6384        self.replicas.as_ref().and_then(|v| match v {
6385            crate::model::directed_read_options::Replicas::ExcludeReplicas(v) => {
6386                std::option::Option::Some(v)
6387            }
6388            _ => std::option::Option::None,
6389        })
6390    }
6391
6392    /// Sets the value of [replicas][crate::model::DirectedReadOptions::replicas]
6393    /// to hold a `ExcludeReplicas`.
6394    ///
6395    /// Note that all the setters affecting `replicas` are
6396    /// mutually exclusive.
6397    pub fn set_exclude_replicas<
6398        T: std::convert::Into<std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>>,
6399    >(
6400        mut self,
6401        v: T,
6402    ) -> Self {
6403        self.replicas = std::option::Option::Some(
6404            crate::model::directed_read_options::Replicas::ExcludeReplicas(v.into()),
6405        );
6406        self
6407    }
6408}
6409
6410impl wkt::message::Message for DirectedReadOptions {
6411    fn typename() -> &'static str {
6412        "type.googleapis.com/google.spanner.v1.DirectedReadOptions"
6413    }
6414}
6415
6416/// Defines additional types related to [DirectedReadOptions].
6417pub mod directed_read_options {
6418    #[allow(unused_imports)]
6419    use super::*;
6420
6421    /// The directed read replica selector.
6422    /// Callers must provide one or more of the following fields for replica
6423    /// selection:
6424    ///
6425    /// * `location` - The location must be one of the regions within the
6426    ///   multi-region configuration of your database.
6427    /// * `type` - The type of the replica.
6428    ///
6429    /// Some examples of using replica_selectors are:
6430    ///
6431    /// * `location:us-east1` --> The "us-east1" replica(s) of any available type
6432    ///   is used to process the request.
6433    /// * `type:READ_ONLY`    --> The "READ_ONLY" type replica(s) in the nearest
6434    ///   available location are used to process the
6435    ///   request.
6436    /// * `location:us-east1 type:READ_ONLY` --> The "READ_ONLY" type replica(s)
6437    ///   in location "us-east1" is used to process
6438    ///   the request.
6439    #[derive(Clone, Default, PartialEq)]
6440    #[non_exhaustive]
6441    pub struct ReplicaSelection {
6442        /// The location or region of the serving requests, for example, "us-east1".
6443        pub location: std::string::String,
6444
6445        /// The type of replica.
6446        pub r#type: crate::model::directed_read_options::replica_selection::Type,
6447
6448        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6449    }
6450
6451    impl ReplicaSelection {
6452        /// Creates a new default instance.
6453        pub fn new() -> Self {
6454            std::default::Default::default()
6455        }
6456
6457        /// Sets the value of [location][crate::model::directed_read_options::ReplicaSelection::location].
6458        pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6459            self.location = v.into();
6460            self
6461        }
6462
6463        /// Sets the value of [r#type][crate::model::directed_read_options::ReplicaSelection::type].
6464        pub fn set_type<
6465            T: std::convert::Into<crate::model::directed_read_options::replica_selection::Type>,
6466        >(
6467            mut self,
6468            v: T,
6469        ) -> Self {
6470            self.r#type = v.into();
6471            self
6472        }
6473    }
6474
6475    impl wkt::message::Message for ReplicaSelection {
6476        fn typename() -> &'static str {
6477            "type.googleapis.com/google.spanner.v1.DirectedReadOptions.ReplicaSelection"
6478        }
6479    }
6480
6481    /// Defines additional types related to [ReplicaSelection].
6482    pub mod replica_selection {
6483        #[allow(unused_imports)]
6484        use super::*;
6485
6486        /// Indicates the type of replica.
6487        ///
6488        /// # Working with unknown values
6489        ///
6490        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6491        /// additional enum variants at any time. Adding new variants is not considered
6492        /// a breaking change. Applications should write their code in anticipation of:
6493        ///
6494        /// - New values appearing in future releases of the client library, **and**
6495        /// - New values received dynamically, without application changes.
6496        ///
6497        /// Please consult the [Working with enums] section in the user guide for some
6498        /// guidelines.
6499        ///
6500        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6501        #[derive(Clone, Debug, PartialEq)]
6502        #[non_exhaustive]
6503        pub enum Type {
6504            /// Not specified.
6505            Unspecified,
6506            /// Read-write replicas support both reads and writes.
6507            ReadWrite,
6508            /// Read-only replicas only support reads (not writes).
6509            ReadOnly,
6510            /// If set, the enum was initialized with an unknown value.
6511            ///
6512            /// Applications can examine the value using [Type::value] or
6513            /// [Type::name].
6514            UnknownValue(r#type::UnknownValue),
6515        }
6516
6517        #[doc(hidden)]
6518        pub mod r#type {
6519            #[allow(unused_imports)]
6520            use super::*;
6521            #[derive(Clone, Debug, PartialEq)]
6522            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6523        }
6524
6525        impl Type {
6526            /// Gets the enum value.
6527            ///
6528            /// Returns `None` if the enum contains an unknown value deserialized from
6529            /// the string representation of enums.
6530            pub fn value(&self) -> std::option::Option<i32> {
6531                match self {
6532                    Self::Unspecified => std::option::Option::Some(0),
6533                    Self::ReadWrite => std::option::Option::Some(1),
6534                    Self::ReadOnly => std::option::Option::Some(2),
6535                    Self::UnknownValue(u) => u.0.value(),
6536                }
6537            }
6538
6539            /// Gets the enum value as a string.
6540            ///
6541            /// Returns `None` if the enum contains an unknown value deserialized from
6542            /// the integer representation of enums.
6543            pub fn name(&self) -> std::option::Option<&str> {
6544                match self {
6545                    Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
6546                    Self::ReadWrite => std::option::Option::Some("READ_WRITE"),
6547                    Self::ReadOnly => std::option::Option::Some("READ_ONLY"),
6548                    Self::UnknownValue(u) => u.0.name(),
6549                }
6550            }
6551        }
6552
6553        impl std::default::Default for Type {
6554            fn default() -> Self {
6555                use std::convert::From;
6556                Self::from(0)
6557            }
6558        }
6559
6560        impl std::fmt::Display for Type {
6561            fn fmt(
6562                &self,
6563                f: &mut std::fmt::Formatter<'_>,
6564            ) -> std::result::Result<(), std::fmt::Error> {
6565                wkt::internal::display_enum(f, self.name(), self.value())
6566            }
6567        }
6568
6569        impl std::convert::From<i32> for Type {
6570            fn from(value: i32) -> Self {
6571                match value {
6572                    0 => Self::Unspecified,
6573                    1 => Self::ReadWrite,
6574                    2 => Self::ReadOnly,
6575                    _ => Self::UnknownValue(r#type::UnknownValue(
6576                        wkt::internal::UnknownEnumValue::Integer(value),
6577                    )),
6578                }
6579            }
6580        }
6581
6582        impl std::convert::From<&str> for Type {
6583            fn from(value: &str) -> Self {
6584                use std::string::ToString;
6585                match value {
6586                    "TYPE_UNSPECIFIED" => Self::Unspecified,
6587                    "READ_WRITE" => Self::ReadWrite,
6588                    "READ_ONLY" => Self::ReadOnly,
6589                    _ => Self::UnknownValue(r#type::UnknownValue(
6590                        wkt::internal::UnknownEnumValue::String(value.to_string()),
6591                    )),
6592                }
6593            }
6594        }
6595
6596        impl serde::ser::Serialize for Type {
6597            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6598            where
6599                S: serde::Serializer,
6600            {
6601                match self {
6602                    Self::Unspecified => serializer.serialize_i32(0),
6603                    Self::ReadWrite => serializer.serialize_i32(1),
6604                    Self::ReadOnly => serializer.serialize_i32(2),
6605                    Self::UnknownValue(u) => u.0.serialize(serializer),
6606                }
6607            }
6608        }
6609
6610        impl<'de> serde::de::Deserialize<'de> for Type {
6611            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6612            where
6613                D: serde::Deserializer<'de>,
6614            {
6615                deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
6616                    ".google.spanner.v1.DirectedReadOptions.ReplicaSelection.Type",
6617                ))
6618            }
6619        }
6620    }
6621
6622    /// An `IncludeReplicas` contains a repeated set of `ReplicaSelection` which
6623    /// indicates the order in which replicas should be considered.
6624    #[derive(Clone, Default, PartialEq)]
6625    #[non_exhaustive]
6626    pub struct IncludeReplicas {
6627        /// The directed read replica selector.
6628        pub replica_selections:
6629            std::vec::Vec<crate::model::directed_read_options::ReplicaSelection>,
6630
6631        /// If `true`, Spanner doesn't route requests to a replica outside the
6632        /// <`include_replicas` list when all of the specified replicas are
6633        /// unavailable or unhealthy. Default value is `false`.
6634        pub auto_failover_disabled: bool,
6635
6636        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6637    }
6638
6639    impl IncludeReplicas {
6640        /// Creates a new default instance.
6641        pub fn new() -> Self {
6642            std::default::Default::default()
6643        }
6644
6645        /// Sets the value of [replica_selections][crate::model::directed_read_options::IncludeReplicas::replica_selections].
6646        pub fn set_replica_selections<T, V>(mut self, v: T) -> Self
6647        where
6648            T: std::iter::IntoIterator<Item = V>,
6649            V: std::convert::Into<crate::model::directed_read_options::ReplicaSelection>,
6650        {
6651            use std::iter::Iterator;
6652            self.replica_selections = v.into_iter().map(|i| i.into()).collect();
6653            self
6654        }
6655
6656        /// Sets the value of [auto_failover_disabled][crate::model::directed_read_options::IncludeReplicas::auto_failover_disabled].
6657        pub fn set_auto_failover_disabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6658            self.auto_failover_disabled = v.into();
6659            self
6660        }
6661    }
6662
6663    impl wkt::message::Message for IncludeReplicas {
6664        fn typename() -> &'static str {
6665            "type.googleapis.com/google.spanner.v1.DirectedReadOptions.IncludeReplicas"
6666        }
6667    }
6668
6669    /// An ExcludeReplicas contains a repeated set of ReplicaSelection that should
6670    /// be excluded from serving requests.
6671    #[derive(Clone, Default, PartialEq)]
6672    #[non_exhaustive]
6673    pub struct ExcludeReplicas {
6674        /// The directed read replica selector.
6675        pub replica_selections:
6676            std::vec::Vec<crate::model::directed_read_options::ReplicaSelection>,
6677
6678        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6679    }
6680
6681    impl ExcludeReplicas {
6682        /// Creates a new default instance.
6683        pub fn new() -> Self {
6684            std::default::Default::default()
6685        }
6686
6687        /// Sets the value of [replica_selections][crate::model::directed_read_options::ExcludeReplicas::replica_selections].
6688        pub fn set_replica_selections<T, V>(mut self, v: T) -> Self
6689        where
6690            T: std::iter::IntoIterator<Item = V>,
6691            V: std::convert::Into<crate::model::directed_read_options::ReplicaSelection>,
6692        {
6693            use std::iter::Iterator;
6694            self.replica_selections = v.into_iter().map(|i| i.into()).collect();
6695            self
6696        }
6697    }
6698
6699    impl wkt::message::Message for ExcludeReplicas {
6700        fn typename() -> &'static str {
6701            "type.googleapis.com/google.spanner.v1.DirectedReadOptions.ExcludeReplicas"
6702        }
6703    }
6704
6705    /// Required. At most one of either `include_replicas` or `exclude_replicas`
6706    /// should be present in the message.
6707    #[derive(Clone, Debug, PartialEq)]
6708    #[non_exhaustive]
6709    pub enum Replicas {
6710        /// `Include_replicas` indicates the order of replicas (as they appear in
6711        /// this list) to process the request. If `auto_failover_disabled` is set to
6712        /// `true` and all replicas are exhausted without finding a healthy replica,
6713        /// Spanner waits for a replica in the list to become available, requests
6714        /// might fail due to `DEADLINE_EXCEEDED` errors.
6715        IncludeReplicas(std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>),
6716        /// `Exclude_replicas` indicates that specified replicas should be excluded
6717        /// from serving requests. Spanner doesn't route requests to the replicas
6718        /// in this list.
6719        ExcludeReplicas(std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>),
6720    }
6721
6722    impl Replicas {
6723        /// Initializes the enum to the [IncludeReplicas](Self::IncludeReplicas) branch.
6724        pub fn from_include_replicas(
6725            value: impl std::convert::Into<
6726                std::boxed::Box<crate::model::directed_read_options::IncludeReplicas>,
6727            >,
6728        ) -> Self {
6729            Self::IncludeReplicas(value.into())
6730        }
6731        /// Initializes the enum to the [ExcludeReplicas](Self::ExcludeReplicas) branch.
6732        pub fn from_exclude_replicas(
6733            value: impl std::convert::Into<
6734                std::boxed::Box<crate::model::directed_read_options::ExcludeReplicas>,
6735            >,
6736        ) -> Self {
6737            Self::ExcludeReplicas(value.into())
6738        }
6739    }
6740}
6741
6742/// The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
6743/// [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
6744///
6745/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
6746/// [google.spanner.v1.Spanner.ExecuteStreamingSql]: crate::client::Spanner::execute_streaming_sql
6747#[derive(Clone, Default, PartialEq)]
6748#[non_exhaustive]
6749pub struct ExecuteSqlRequest {
6750    /// Required. The session in which the SQL query should be performed.
6751    pub session: std::string::String,
6752
6753    /// The transaction to use.
6754    ///
6755    /// For queries, if none is provided, the default is a temporary read-only
6756    /// transaction with strong concurrency.
6757    ///
6758    /// Standard DML statements require a read-write transaction. To protect
6759    /// against replays, single-use transactions are not supported. The caller
6760    /// must either supply an existing transaction ID or begin a new transaction.
6761    ///
6762    /// Partitioned DML requires an existing Partitioned DML transaction ID.
6763    pub transaction: std::option::Option<crate::model::TransactionSelector>,
6764
6765    /// Required. The SQL string.
6766    pub sql: std::string::String,
6767
6768    /// Parameter names and values that bind to placeholders in the SQL string.
6769    ///
6770    /// A parameter placeholder consists of the `@` character followed by the
6771    /// parameter name (for example, `@firstName`). Parameter names must conform
6772    /// to the naming requirements of identifiers as specified at
6773    /// <https://cloud.google.com/spanner/docs/lexical#identifiers>.
6774    ///
6775    /// Parameters can appear anywhere that a literal value is expected. The same
6776    /// parameter name can be used more than once, for example:
6777    ///
6778    /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
6779    ///
6780    /// It's an error to execute a SQL statement with unbound parameters.
6781    pub params: std::option::Option<wkt::Struct>,
6782
6783    /// It isn't always possible for Cloud Spanner to infer the right SQL type
6784    /// from a JSON value. For example, values of type `BYTES` and values
6785    /// of type `STRING` both appear in
6786    /// [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings.
6787    ///
6788    /// In these cases, you can use `param_types` to specify the exact
6789    /// SQL type for some or all of the SQL statement parameters. See the
6790    /// definition of [Type][google.spanner.v1.Type] for more information
6791    /// about SQL types.
6792    ///
6793    /// [google.spanner.v1.ExecuteSqlRequest.params]: crate::model::ExecuteSqlRequest::params
6794    /// [google.spanner.v1.Type]: crate::model::Type
6795    pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
6796
6797    /// If this request is resuming a previously interrupted SQL statement
6798    /// execution, `resume_token` should be copied from the last
6799    /// [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
6800    /// interruption. Doing this enables the new SQL statement execution to resume
6801    /// where the last one left off. The rest of the request parameters must
6802    /// exactly match the request that yielded this token.
6803    ///
6804    /// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
6805    pub resume_token: ::bytes::Bytes,
6806
6807    /// Used to control the amount of debugging information returned in
6808    /// [ResultSetStats][google.spanner.v1.ResultSetStats]. If
6809    /// [partition_token][google.spanner.v1.ExecuteSqlRequest.partition_token] is
6810    /// set, [query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode] can only
6811    /// be set to
6812    /// [QueryMode.NORMAL][google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL].
6813    ///
6814    /// [google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL]: crate::model::execute_sql_request::QueryMode::Normal
6815    /// [google.spanner.v1.ExecuteSqlRequest.partition_token]: crate::model::ExecuteSqlRequest::partition_token
6816    /// [google.spanner.v1.ExecuteSqlRequest.query_mode]: crate::model::ExecuteSqlRequest::query_mode
6817    /// [google.spanner.v1.ResultSetStats]: crate::model::ResultSetStats
6818    pub query_mode: crate::model::execute_sql_request::QueryMode,
6819
6820    /// If present, results are restricted to the specified partition
6821    /// previously created using `PartitionQuery`. There must be an exact
6822    /// match for the values of fields common to this message and the
6823    /// `PartitionQueryRequest` message used to create this `partition_token`.
6824    pub partition_token: ::bytes::Bytes,
6825
6826    /// A per-transaction sequence number used to identify this request. This field
6827    /// makes each request idempotent such that if the request is received multiple
6828    /// times, at most one succeeds.
6829    ///
6830    /// The sequence number must be monotonically increasing within the
6831    /// transaction. If a request arrives for the first time with an out-of-order
6832    /// sequence number, the transaction can be aborted. Replays of previously
6833    /// handled requests yield the same response as the first execution.
6834    ///
6835    /// Required for DML statements. Ignored for queries.
6836    pub seqno: i64,
6837
6838    /// Query optimizer configuration to use for the given query.
6839    pub query_options: std::option::Option<crate::model::execute_sql_request::QueryOptions>,
6840
6841    /// Common options for this request.
6842    pub request_options: std::option::Option<crate::model::RequestOptions>,
6843
6844    /// Directed read options for this request.
6845    pub directed_read_options: std::option::Option<crate::model::DirectedReadOptions>,
6846
6847    /// If this is for a partitioned query and this field is set to `true`, the
6848    /// request is executed with Spanner Data Boost independent compute resources.
6849    ///
6850    /// If the field is set to `true` but the request doesn't set
6851    /// `partition_token`, the API returns an `INVALID_ARGUMENT` error.
6852    pub data_boost_enabled: bool,
6853
6854    /// Optional. If set to `true`, this statement marks the end of the
6855    /// transaction. After this statement executes, you must commit or abort the
6856    /// transaction. Attempts to execute any other requests against this
6857    /// transaction (including reads and queries) are rejected.
6858    ///
6859    /// For DML statements, setting this option might cause some error reporting to
6860    /// be deferred until commit time (for example, validation of unique
6861    /// constraints). Given this, successful execution of a DML statement shouldn't
6862    /// be assumed until a subsequent `Commit` call completes successfully.
6863    pub last_statement: bool,
6864
6865    /// Optional. Makes the Spanner requests location-aware if present.
6866    ///
6867    /// It gives the server hints that can be used to route the request
6868    /// to an appropriate server, potentially significantly decreasing latency and
6869    /// improving throughput. To achieve improved performance, most fields must be
6870    /// filled in with accurate values.
6871    pub routing_hint: std::option::Option<crate::model::RoutingHint>,
6872
6873    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6874}
6875
6876impl ExecuteSqlRequest {
6877    /// Creates a new default instance.
6878    pub fn new() -> Self {
6879        std::default::Default::default()
6880    }
6881
6882    /// Sets the value of [session][crate::model::ExecuteSqlRequest::session].
6883    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6884        self.session = v.into();
6885        self
6886    }
6887
6888    /// Sets the value of [transaction][crate::model::ExecuteSqlRequest::transaction].
6889    pub fn set_transaction<T>(mut self, v: T) -> Self
6890    where
6891        T: std::convert::Into<crate::model::TransactionSelector>,
6892    {
6893        self.transaction = std::option::Option::Some(v.into());
6894        self
6895    }
6896
6897    /// Sets or clears the value of [transaction][crate::model::ExecuteSqlRequest::transaction].
6898    pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
6899    where
6900        T: std::convert::Into<crate::model::TransactionSelector>,
6901    {
6902        self.transaction = v.map(|x| x.into());
6903        self
6904    }
6905
6906    /// Sets the value of [sql][crate::model::ExecuteSqlRequest::sql].
6907    pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6908        self.sql = v.into();
6909        self
6910    }
6911
6912    /// Sets the value of [params][crate::model::ExecuteSqlRequest::params].
6913    pub fn set_params<T>(mut self, v: T) -> Self
6914    where
6915        T: std::convert::Into<wkt::Struct>,
6916    {
6917        self.params = std::option::Option::Some(v.into());
6918        self
6919    }
6920
6921    /// Sets or clears the value of [params][crate::model::ExecuteSqlRequest::params].
6922    pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
6923    where
6924        T: std::convert::Into<wkt::Struct>,
6925    {
6926        self.params = v.map(|x| x.into());
6927        self
6928    }
6929
6930    /// Sets the value of [param_types][crate::model::ExecuteSqlRequest::param_types].
6931    pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
6932    where
6933        T: std::iter::IntoIterator<Item = (K, V)>,
6934        K: std::convert::Into<std::string::String>,
6935        V: std::convert::Into<crate::model::Type>,
6936    {
6937        use std::iter::Iterator;
6938        self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
6939        self
6940    }
6941
6942    /// Sets the value of [resume_token][crate::model::ExecuteSqlRequest::resume_token].
6943    pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
6944        self.resume_token = v.into();
6945        self
6946    }
6947
6948    /// Sets the value of [query_mode][crate::model::ExecuteSqlRequest::query_mode].
6949    pub fn set_query_mode<T: std::convert::Into<crate::model::execute_sql_request::QueryMode>>(
6950        mut self,
6951        v: T,
6952    ) -> Self {
6953        self.query_mode = v.into();
6954        self
6955    }
6956
6957    /// Sets the value of [partition_token][crate::model::ExecuteSqlRequest::partition_token].
6958    pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
6959        self.partition_token = v.into();
6960        self
6961    }
6962
6963    /// Sets the value of [seqno][crate::model::ExecuteSqlRequest::seqno].
6964    pub fn set_seqno<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6965        self.seqno = v.into();
6966        self
6967    }
6968
6969    /// Sets the value of [query_options][crate::model::ExecuteSqlRequest::query_options].
6970    pub fn set_query_options<T>(mut self, v: T) -> Self
6971    where
6972        T: std::convert::Into<crate::model::execute_sql_request::QueryOptions>,
6973    {
6974        self.query_options = std::option::Option::Some(v.into());
6975        self
6976    }
6977
6978    /// Sets or clears the value of [query_options][crate::model::ExecuteSqlRequest::query_options].
6979    pub fn set_or_clear_query_options<T>(mut self, v: std::option::Option<T>) -> Self
6980    where
6981        T: std::convert::Into<crate::model::execute_sql_request::QueryOptions>,
6982    {
6983        self.query_options = v.map(|x| x.into());
6984        self
6985    }
6986
6987    /// Sets the value of [request_options][crate::model::ExecuteSqlRequest::request_options].
6988    pub fn set_request_options<T>(mut self, v: T) -> Self
6989    where
6990        T: std::convert::Into<crate::model::RequestOptions>,
6991    {
6992        self.request_options = std::option::Option::Some(v.into());
6993        self
6994    }
6995
6996    /// Sets or clears the value of [request_options][crate::model::ExecuteSqlRequest::request_options].
6997    pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
6998    where
6999        T: std::convert::Into<crate::model::RequestOptions>,
7000    {
7001        self.request_options = v.map(|x| x.into());
7002        self
7003    }
7004
7005    /// Sets the value of [directed_read_options][crate::model::ExecuteSqlRequest::directed_read_options].
7006    pub fn set_directed_read_options<T>(mut self, v: T) -> Self
7007    where
7008        T: std::convert::Into<crate::model::DirectedReadOptions>,
7009    {
7010        self.directed_read_options = std::option::Option::Some(v.into());
7011        self
7012    }
7013
7014    /// Sets or clears the value of [directed_read_options][crate::model::ExecuteSqlRequest::directed_read_options].
7015    pub fn set_or_clear_directed_read_options<T>(mut self, v: std::option::Option<T>) -> Self
7016    where
7017        T: std::convert::Into<crate::model::DirectedReadOptions>,
7018    {
7019        self.directed_read_options = v.map(|x| x.into());
7020        self
7021    }
7022
7023    /// Sets the value of [data_boost_enabled][crate::model::ExecuteSqlRequest::data_boost_enabled].
7024    pub fn set_data_boost_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7025        self.data_boost_enabled = v.into();
7026        self
7027    }
7028
7029    /// Sets the value of [last_statement][crate::model::ExecuteSqlRequest::last_statement].
7030    pub fn set_last_statement<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7031        self.last_statement = v.into();
7032        self
7033    }
7034
7035    /// Sets the value of [routing_hint][crate::model::ExecuteSqlRequest::routing_hint].
7036    pub fn set_routing_hint<T>(mut self, v: T) -> Self
7037    where
7038        T: std::convert::Into<crate::model::RoutingHint>,
7039    {
7040        self.routing_hint = std::option::Option::Some(v.into());
7041        self
7042    }
7043
7044    /// Sets or clears the value of [routing_hint][crate::model::ExecuteSqlRequest::routing_hint].
7045    pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
7046    where
7047        T: std::convert::Into<crate::model::RoutingHint>,
7048    {
7049        self.routing_hint = v.map(|x| x.into());
7050        self
7051    }
7052}
7053
7054impl wkt::message::Message for ExecuteSqlRequest {
7055    fn typename() -> &'static str {
7056        "type.googleapis.com/google.spanner.v1.ExecuteSqlRequest"
7057    }
7058}
7059
7060/// Defines additional types related to [ExecuteSqlRequest].
7061pub mod execute_sql_request {
7062    #[allow(unused_imports)]
7063    use super::*;
7064
7065    /// Query optimizer configuration.
7066    #[derive(Clone, Default, PartialEq)]
7067    #[non_exhaustive]
7068    pub struct QueryOptions {
7069        /// An option to control the selection of optimizer version.
7070        ///
7071        /// This parameter allows individual queries to pick different query
7072        /// optimizer versions.
7073        ///
7074        /// Specifying `latest` as a value instructs Cloud Spanner to use the
7075        /// latest supported query optimizer version. If not specified, Cloud Spanner
7076        /// uses the optimizer version set at the database level options. Any other
7077        /// positive integer (from the list of supported optimizer versions)
7078        /// overrides the default optimizer version for query execution.
7079        ///
7080        /// The list of supported optimizer versions can be queried from
7081        /// `SPANNER_SYS.SUPPORTED_OPTIMIZER_VERSIONS`.
7082        ///
7083        /// Executing a SQL statement with an invalid optimizer version fails with
7084        /// an `INVALID_ARGUMENT` error.
7085        ///
7086        /// See
7087        /// <https://cloud.google.com/spanner/docs/query-optimizer/manage-query-optimizer>
7088        /// for more information on managing the query optimizer.
7089        ///
7090        /// The `optimizer_version` statement hint has precedence over this setting.
7091        pub optimizer_version: std::string::String,
7092
7093        /// An option to control the selection of optimizer statistics package.
7094        ///
7095        /// This parameter allows individual queries to use a different query
7096        /// optimizer statistics package.
7097        ///
7098        /// Specifying `latest` as a value instructs Cloud Spanner to use the latest
7099        /// generated statistics package. If not specified, Cloud Spanner uses
7100        /// the statistics package set at the database level options, or the latest
7101        /// package if the database option isn't set.
7102        ///
7103        /// The statistics package requested by the query has to be exempt from
7104        /// garbage collection. This can be achieved with the following DDL
7105        /// statement:
7106        ///
7107        /// ```norust
7108        /// ALTER STATISTICS <package_name> SET OPTIONS (allow_gc=false)
7109        /// ```
7110        ///
7111        /// The list of available statistics packages can be queried from
7112        /// `INFORMATION_SCHEMA.SPANNER_STATISTICS`.
7113        ///
7114        /// Executing a SQL statement with an invalid optimizer statistics package
7115        /// or with a statistics package that allows garbage collection fails with
7116        /// an `INVALID_ARGUMENT` error.
7117        pub optimizer_statistics_package: std::string::String,
7118
7119        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7120    }
7121
7122    impl QueryOptions {
7123        /// Creates a new default instance.
7124        pub fn new() -> Self {
7125            std::default::Default::default()
7126        }
7127
7128        /// Sets the value of [optimizer_version][crate::model::execute_sql_request::QueryOptions::optimizer_version].
7129        pub fn set_optimizer_version<T: std::convert::Into<std::string::String>>(
7130            mut self,
7131            v: T,
7132        ) -> Self {
7133            self.optimizer_version = v.into();
7134            self
7135        }
7136
7137        /// Sets the value of [optimizer_statistics_package][crate::model::execute_sql_request::QueryOptions::optimizer_statistics_package].
7138        pub fn set_optimizer_statistics_package<T: std::convert::Into<std::string::String>>(
7139            mut self,
7140            v: T,
7141        ) -> Self {
7142            self.optimizer_statistics_package = v.into();
7143            self
7144        }
7145    }
7146
7147    impl wkt::message::Message for QueryOptions {
7148        fn typename() -> &'static str {
7149            "type.googleapis.com/google.spanner.v1.ExecuteSqlRequest.QueryOptions"
7150        }
7151    }
7152
7153    /// Mode in which the statement must be processed.
7154    ///
7155    /// # Working with unknown values
7156    ///
7157    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7158    /// additional enum variants at any time. Adding new variants is not considered
7159    /// a breaking change. Applications should write their code in anticipation of:
7160    ///
7161    /// - New values appearing in future releases of the client library, **and**
7162    /// - New values received dynamically, without application changes.
7163    ///
7164    /// Please consult the [Working with enums] section in the user guide for some
7165    /// guidelines.
7166    ///
7167    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
7168    #[derive(Clone, Debug, PartialEq)]
7169    #[non_exhaustive]
7170    pub enum QueryMode {
7171        /// The default mode. Only the statement results are returned.
7172        Normal,
7173        /// This mode returns only the query plan, without any results or
7174        /// execution statistics information.
7175        Plan,
7176        /// This mode returns the query plan, overall execution statistics,
7177        /// operator level execution statistics along with the results. This has a
7178        /// performance overhead compared to the other modes. It isn't recommended
7179        /// to use this mode for production traffic.
7180        Profile,
7181        /// This mode returns the overall (but not operator-level) execution
7182        /// statistics along with the results.
7183        WithStats,
7184        /// This mode returns the query plan, overall (but not operator-level)
7185        /// execution statistics along with the results.
7186        WithPlanAndStats,
7187        /// If set, the enum was initialized with an unknown value.
7188        ///
7189        /// Applications can examine the value using [QueryMode::value] or
7190        /// [QueryMode::name].
7191        UnknownValue(query_mode::UnknownValue),
7192    }
7193
7194    #[doc(hidden)]
7195    pub mod query_mode {
7196        #[allow(unused_imports)]
7197        use super::*;
7198        #[derive(Clone, Debug, PartialEq)]
7199        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7200    }
7201
7202    impl QueryMode {
7203        /// Gets the enum value.
7204        ///
7205        /// Returns `None` if the enum contains an unknown value deserialized from
7206        /// the string representation of enums.
7207        pub fn value(&self) -> std::option::Option<i32> {
7208            match self {
7209                Self::Normal => std::option::Option::Some(0),
7210                Self::Plan => std::option::Option::Some(1),
7211                Self::Profile => std::option::Option::Some(2),
7212                Self::WithStats => std::option::Option::Some(3),
7213                Self::WithPlanAndStats => std::option::Option::Some(4),
7214                Self::UnknownValue(u) => u.0.value(),
7215            }
7216        }
7217
7218        /// Gets the enum value as a string.
7219        ///
7220        /// Returns `None` if the enum contains an unknown value deserialized from
7221        /// the integer representation of enums.
7222        pub fn name(&self) -> std::option::Option<&str> {
7223            match self {
7224                Self::Normal => std::option::Option::Some("NORMAL"),
7225                Self::Plan => std::option::Option::Some("PLAN"),
7226                Self::Profile => std::option::Option::Some("PROFILE"),
7227                Self::WithStats => std::option::Option::Some("WITH_STATS"),
7228                Self::WithPlanAndStats => std::option::Option::Some("WITH_PLAN_AND_STATS"),
7229                Self::UnknownValue(u) => u.0.name(),
7230            }
7231        }
7232    }
7233
7234    impl std::default::Default for QueryMode {
7235        fn default() -> Self {
7236            use std::convert::From;
7237            Self::from(0)
7238        }
7239    }
7240
7241    impl std::fmt::Display for QueryMode {
7242        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7243            wkt::internal::display_enum(f, self.name(), self.value())
7244        }
7245    }
7246
7247    impl std::convert::From<i32> for QueryMode {
7248        fn from(value: i32) -> Self {
7249            match value {
7250                0 => Self::Normal,
7251                1 => Self::Plan,
7252                2 => Self::Profile,
7253                3 => Self::WithStats,
7254                4 => Self::WithPlanAndStats,
7255                _ => Self::UnknownValue(query_mode::UnknownValue(
7256                    wkt::internal::UnknownEnumValue::Integer(value),
7257                )),
7258            }
7259        }
7260    }
7261
7262    impl std::convert::From<&str> for QueryMode {
7263        fn from(value: &str) -> Self {
7264            use std::string::ToString;
7265            match value {
7266                "NORMAL" => Self::Normal,
7267                "PLAN" => Self::Plan,
7268                "PROFILE" => Self::Profile,
7269                "WITH_STATS" => Self::WithStats,
7270                "WITH_PLAN_AND_STATS" => Self::WithPlanAndStats,
7271                _ => Self::UnknownValue(query_mode::UnknownValue(
7272                    wkt::internal::UnknownEnumValue::String(value.to_string()),
7273                )),
7274            }
7275        }
7276    }
7277
7278    impl serde::ser::Serialize for QueryMode {
7279        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7280        where
7281            S: serde::Serializer,
7282        {
7283            match self {
7284                Self::Normal => serializer.serialize_i32(0),
7285                Self::Plan => serializer.serialize_i32(1),
7286                Self::Profile => serializer.serialize_i32(2),
7287                Self::WithStats => serializer.serialize_i32(3),
7288                Self::WithPlanAndStats => serializer.serialize_i32(4),
7289                Self::UnknownValue(u) => u.0.serialize(serializer),
7290            }
7291        }
7292    }
7293
7294    impl<'de> serde::de::Deserialize<'de> for QueryMode {
7295        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7296        where
7297            D: serde::Deserializer<'de>,
7298        {
7299            deserializer.deserialize_any(wkt::internal::EnumVisitor::<QueryMode>::new(
7300                ".google.spanner.v1.ExecuteSqlRequest.QueryMode",
7301            ))
7302        }
7303    }
7304}
7305
7306/// The request for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
7307///
7308/// [google.spanner.v1.Spanner.ExecuteBatchDml]: crate::client::Spanner::execute_batch_dml
7309#[derive(Clone, Default, PartialEq)]
7310#[non_exhaustive]
7311pub struct ExecuteBatchDmlRequest {
7312    /// Required. The session in which the DML statements should be performed.
7313    pub session: std::string::String,
7314
7315    /// Required. The transaction to use. Must be a read-write transaction.
7316    ///
7317    /// To protect against replays, single-use transactions are not supported. The
7318    /// caller must either supply an existing transaction ID or begin a new
7319    /// transaction.
7320    pub transaction: std::option::Option<crate::model::TransactionSelector>,
7321
7322    /// Required. The list of statements to execute in this batch. Statements are
7323    /// executed serially, such that the effects of statement `i` are visible to
7324    /// statement `i+1`. Each statement must be a DML statement. Execution stops at
7325    /// the first failed statement; the remaining statements are not executed.
7326    ///
7327    /// Callers must provide at least one statement.
7328    pub statements: std::vec::Vec<crate::model::execute_batch_dml_request::Statement>,
7329
7330    /// Required. A per-transaction sequence number used to identify this request.
7331    /// This field makes each request idempotent such that if the request is
7332    /// received multiple times, at most one succeeds.
7333    ///
7334    /// The sequence number must be monotonically increasing within the
7335    /// transaction. If a request arrives for the first time with an out-of-order
7336    /// sequence number, the transaction might be aborted. Replays of previously
7337    /// handled requests yield the same response as the first execution.
7338    pub seqno: i64,
7339
7340    /// Common options for this request.
7341    pub request_options: std::option::Option<crate::model::RequestOptions>,
7342
7343    /// Optional. If set to `true`, this request marks the end of the transaction.
7344    /// After these statements execute, you must commit or abort the transaction.
7345    /// Attempts to execute any other requests against this transaction
7346    /// (including reads and queries) are rejected.
7347    ///
7348    /// Setting this option might cause some error reporting to be deferred until
7349    /// commit time (for example, validation of unique constraints). Given this,
7350    /// successful execution of statements shouldn't be assumed until a subsequent
7351    /// `Commit` call completes successfully.
7352    pub last_statements: bool,
7353
7354    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7355}
7356
7357impl ExecuteBatchDmlRequest {
7358    /// Creates a new default instance.
7359    pub fn new() -> Self {
7360        std::default::Default::default()
7361    }
7362
7363    /// Sets the value of [session][crate::model::ExecuteBatchDmlRequest::session].
7364    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7365        self.session = v.into();
7366        self
7367    }
7368
7369    /// Sets the value of [transaction][crate::model::ExecuteBatchDmlRequest::transaction].
7370    pub fn set_transaction<T>(mut self, v: T) -> Self
7371    where
7372        T: std::convert::Into<crate::model::TransactionSelector>,
7373    {
7374        self.transaction = std::option::Option::Some(v.into());
7375        self
7376    }
7377
7378    /// Sets or clears the value of [transaction][crate::model::ExecuteBatchDmlRequest::transaction].
7379    pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7380    where
7381        T: std::convert::Into<crate::model::TransactionSelector>,
7382    {
7383        self.transaction = v.map(|x| x.into());
7384        self
7385    }
7386
7387    /// Sets the value of [statements][crate::model::ExecuteBatchDmlRequest::statements].
7388    pub fn set_statements<T, V>(mut self, v: T) -> Self
7389    where
7390        T: std::iter::IntoIterator<Item = V>,
7391        V: std::convert::Into<crate::model::execute_batch_dml_request::Statement>,
7392    {
7393        use std::iter::Iterator;
7394        self.statements = v.into_iter().map(|i| i.into()).collect();
7395        self
7396    }
7397
7398    /// Sets the value of [seqno][crate::model::ExecuteBatchDmlRequest::seqno].
7399    pub fn set_seqno<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7400        self.seqno = v.into();
7401        self
7402    }
7403
7404    /// Sets the value of [request_options][crate::model::ExecuteBatchDmlRequest::request_options].
7405    pub fn set_request_options<T>(mut self, v: T) -> Self
7406    where
7407        T: std::convert::Into<crate::model::RequestOptions>,
7408    {
7409        self.request_options = std::option::Option::Some(v.into());
7410        self
7411    }
7412
7413    /// Sets or clears the value of [request_options][crate::model::ExecuteBatchDmlRequest::request_options].
7414    pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
7415    where
7416        T: std::convert::Into<crate::model::RequestOptions>,
7417    {
7418        self.request_options = v.map(|x| x.into());
7419        self
7420    }
7421
7422    /// Sets the value of [last_statements][crate::model::ExecuteBatchDmlRequest::last_statements].
7423    pub fn set_last_statements<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7424        self.last_statements = v.into();
7425        self
7426    }
7427}
7428
7429impl wkt::message::Message for ExecuteBatchDmlRequest {
7430    fn typename() -> &'static str {
7431        "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlRequest"
7432    }
7433}
7434
7435/// Defines additional types related to [ExecuteBatchDmlRequest].
7436pub mod execute_batch_dml_request {
7437    #[allow(unused_imports)]
7438    use super::*;
7439
7440    /// A single DML statement.
7441    #[derive(Clone, Default, PartialEq)]
7442    #[non_exhaustive]
7443    pub struct Statement {
7444        /// Required. The DML string.
7445        pub sql: std::string::String,
7446
7447        /// Parameter names and values that bind to placeholders in the DML string.
7448        ///
7449        /// A parameter placeholder consists of the `@` character followed by the
7450        /// parameter name (for example, `@firstName`). Parameter names can contain
7451        /// letters, numbers, and underscores.
7452        ///
7453        /// Parameters can appear anywhere that a literal value is expected. The
7454        /// same parameter name can be used more than once, for example:
7455        ///
7456        /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
7457        ///
7458        /// It's an error to execute a SQL statement with unbound parameters.
7459        pub params: std::option::Option<wkt::Struct>,
7460
7461        /// It isn't always possible for Cloud Spanner to infer the right SQL type
7462        /// from a JSON value. For example, values of type `BYTES` and values
7463        /// of type `STRING` both appear in
7464        /// [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as
7465        /// JSON strings.
7466        ///
7467        /// In these cases, `param_types` can be used to specify the exact
7468        /// SQL type for some or all of the SQL statement parameters. See the
7469        /// definition of [Type][google.spanner.v1.Type] for more information
7470        /// about SQL types.
7471        ///
7472        /// [google.spanner.v1.ExecuteBatchDmlRequest.Statement.params]: crate::model::execute_batch_dml_request::Statement::params
7473        /// [google.spanner.v1.Type]: crate::model::Type
7474        pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
7475
7476        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7477    }
7478
7479    impl Statement {
7480        /// Creates a new default instance.
7481        pub fn new() -> Self {
7482            std::default::Default::default()
7483        }
7484
7485        /// Sets the value of [sql][crate::model::execute_batch_dml_request::Statement::sql].
7486        pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7487            self.sql = v.into();
7488            self
7489        }
7490
7491        /// Sets the value of [params][crate::model::execute_batch_dml_request::Statement::params].
7492        pub fn set_params<T>(mut self, v: T) -> Self
7493        where
7494            T: std::convert::Into<wkt::Struct>,
7495        {
7496            self.params = std::option::Option::Some(v.into());
7497            self
7498        }
7499
7500        /// Sets or clears the value of [params][crate::model::execute_batch_dml_request::Statement::params].
7501        pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
7502        where
7503            T: std::convert::Into<wkt::Struct>,
7504        {
7505            self.params = v.map(|x| x.into());
7506            self
7507        }
7508
7509        /// Sets the value of [param_types][crate::model::execute_batch_dml_request::Statement::param_types].
7510        pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
7511        where
7512            T: std::iter::IntoIterator<Item = (K, V)>,
7513            K: std::convert::Into<std::string::String>,
7514            V: std::convert::Into<crate::model::Type>,
7515        {
7516            use std::iter::Iterator;
7517            self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7518            self
7519        }
7520    }
7521
7522    impl wkt::message::Message for Statement {
7523        fn typename() -> &'static str {
7524            "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlRequest.Statement"
7525        }
7526    }
7527}
7528
7529/// The response for
7530/// [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
7531/// of [ResultSet][google.spanner.v1.ResultSet] messages, one for each DML
7532/// statement that has successfully executed, in the same order as the statements
7533/// in the request. If a statement fails, the status in the response body
7534/// identifies the cause of the failure.
7535///
7536/// To check for DML statements that failed, use the following approach:
7537///
7538/// 1. Check the status in the response message. The
7539///    [google.rpc.Code][google.rpc.Code] enum
7540///    value `OK` indicates that all statements were executed successfully.
7541/// 1. If the status was not `OK`, check the number of result sets in the
7542///    response. If the response contains `N`
7543///    [ResultSet][google.spanner.v1.ResultSet] messages, then statement `N+1` in
7544///    the request failed.
7545///
7546/// Example 1:
7547///
7548/// * Request: 5 DML statements, all executed successfully.
7549/// * Response: 5 [ResultSet][google.spanner.v1.ResultSet] messages, with the
7550///   status `OK`.
7551///
7552/// Example 2:
7553///
7554/// * Request: 5 DML statements. The third statement has a syntax error.
7555/// * Response: 2 [ResultSet][google.spanner.v1.ResultSet] messages, and a syntax
7556///   error (`INVALID_ARGUMENT`)
7557///   status. The number of [ResultSet][google.spanner.v1.ResultSet] messages
7558///   indicates that the third statement failed, and the fourth and fifth
7559///   statements were not executed.
7560///
7561/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
7562/// [google.spanner.v1.Spanner.ExecuteBatchDml]: crate::client::Spanner::execute_batch_dml
7563#[derive(Clone, Default, PartialEq)]
7564#[non_exhaustive]
7565pub struct ExecuteBatchDmlResponse {
7566    /// One [ResultSet][google.spanner.v1.ResultSet] for each statement in the
7567    /// request that ran successfully, in the same order as the statements in the
7568    /// request. Each [ResultSet][google.spanner.v1.ResultSet] does not contain any
7569    /// rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each
7570    /// [ResultSet][google.spanner.v1.ResultSet] contain the number of rows
7571    /// modified by the statement.
7572    ///
7573    /// Only the first [ResultSet][google.spanner.v1.ResultSet] in the response
7574    /// contains valid [ResultSetMetadata][google.spanner.v1.ResultSetMetadata].
7575    ///
7576    /// [google.spanner.v1.ResultSet]: crate::model::ResultSet
7577    /// [google.spanner.v1.ResultSetMetadata]: crate::model::ResultSetMetadata
7578    /// [google.spanner.v1.ResultSetStats]: crate::model::ResultSetStats
7579    pub result_sets: std::vec::Vec<crate::model::ResultSet>,
7580
7581    /// If all DML statements are executed successfully, the status is `OK`.
7582    /// Otherwise, the error status of the first failed statement.
7583    pub status: std::option::Option<google_cloud_rpc::model::Status>,
7584
7585    /// Optional. A precommit token is included if the read-write transaction
7586    /// is on a multiplexed session. Pass the precommit token with the highest
7587    /// sequence number from this transaction attempt should be passed to the
7588    /// [Commit][google.spanner.v1.Spanner.Commit] request for this transaction.
7589    ///
7590    /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
7591    pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
7592
7593    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7594}
7595
7596impl ExecuteBatchDmlResponse {
7597    /// Creates a new default instance.
7598    pub fn new() -> Self {
7599        std::default::Default::default()
7600    }
7601
7602    /// Sets the value of [result_sets][crate::model::ExecuteBatchDmlResponse::result_sets].
7603    pub fn set_result_sets<T, V>(mut self, v: T) -> Self
7604    where
7605        T: std::iter::IntoIterator<Item = V>,
7606        V: std::convert::Into<crate::model::ResultSet>,
7607    {
7608        use std::iter::Iterator;
7609        self.result_sets = v.into_iter().map(|i| i.into()).collect();
7610        self
7611    }
7612
7613    /// Sets the value of [status][crate::model::ExecuteBatchDmlResponse::status].
7614    pub fn set_status<T>(mut self, v: T) -> Self
7615    where
7616        T: std::convert::Into<google_cloud_rpc::model::Status>,
7617    {
7618        self.status = std::option::Option::Some(v.into());
7619        self
7620    }
7621
7622    /// Sets or clears the value of [status][crate::model::ExecuteBatchDmlResponse::status].
7623    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
7624    where
7625        T: std::convert::Into<google_cloud_rpc::model::Status>,
7626    {
7627        self.status = v.map(|x| x.into());
7628        self
7629    }
7630
7631    /// Sets the value of [precommit_token][crate::model::ExecuteBatchDmlResponse::precommit_token].
7632    pub fn set_precommit_token<T>(mut self, v: T) -> Self
7633    where
7634        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
7635    {
7636        self.precommit_token = std::option::Option::Some(v.into());
7637        self
7638    }
7639
7640    /// Sets or clears the value of [precommit_token][crate::model::ExecuteBatchDmlResponse::precommit_token].
7641    pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
7642    where
7643        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
7644    {
7645        self.precommit_token = v.map(|x| x.into());
7646        self
7647    }
7648}
7649
7650impl wkt::message::Message for ExecuteBatchDmlResponse {
7651    fn typename() -> &'static str {
7652        "type.googleapis.com/google.spanner.v1.ExecuteBatchDmlResponse"
7653    }
7654}
7655
7656/// Options for a `PartitionQueryRequest` and `PartitionReadRequest`.
7657#[derive(Clone, Default, PartialEq)]
7658#[non_exhaustive]
7659pub struct PartitionOptions {
7660    /// **Note:** This hint is currently ignored by `PartitionQuery` and
7661    /// `PartitionRead` requests.
7662    ///
7663    /// The desired data size for each partition generated. The default for this
7664    /// option is currently 1 GiB. This is only a hint. The actual size of each
7665    /// partition can be smaller or larger than this size request.
7666    pub partition_size_bytes: i64,
7667
7668    /// **Note:** This hint is currently ignored by `PartitionQuery` and
7669    /// `PartitionRead` requests.
7670    ///
7671    /// The desired maximum number of partitions to return. For example, this
7672    /// might be set to the number of workers available. The default for this
7673    /// option is currently 10,000. The maximum value is currently 200,000. This
7674    /// is only a hint. The actual number of partitions returned can be smaller or
7675    /// larger than this maximum count request.
7676    pub max_partitions: i64,
7677
7678    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7679}
7680
7681impl PartitionOptions {
7682    /// Creates a new default instance.
7683    pub fn new() -> Self {
7684        std::default::Default::default()
7685    }
7686
7687    /// Sets the value of [partition_size_bytes][crate::model::PartitionOptions::partition_size_bytes].
7688    pub fn set_partition_size_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7689        self.partition_size_bytes = v.into();
7690        self
7691    }
7692
7693    /// Sets the value of [max_partitions][crate::model::PartitionOptions::max_partitions].
7694    pub fn set_max_partitions<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
7695        self.max_partitions = v.into();
7696        self
7697    }
7698}
7699
7700impl wkt::message::Message for PartitionOptions {
7701    fn typename() -> &'static str {
7702        "type.googleapis.com/google.spanner.v1.PartitionOptions"
7703    }
7704}
7705
7706/// The request for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
7707///
7708/// [google.spanner.v1.Spanner.PartitionQuery]: crate::client::Spanner::partition_query
7709#[derive(Clone, Default, PartialEq)]
7710#[non_exhaustive]
7711pub struct PartitionQueryRequest {
7712    /// Required. The session used to create the partitions.
7713    pub session: std::string::String,
7714
7715    /// Read-only snapshot transactions are supported, read and write and
7716    /// single-use transactions are not.
7717    pub transaction: std::option::Option<crate::model::TransactionSelector>,
7718
7719    /// Required. The query request to generate partitions for. The request fails
7720    /// if the query isn't root partitionable. For a query to be root
7721    /// partitionable, it needs to satisfy a few conditions. For example, if the
7722    /// query execution plan contains a distributed union operator, then it must be
7723    /// the first operator in the plan. For more information about other
7724    /// conditions, see [Read data in
7725    /// parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel).
7726    ///
7727    /// The query request must not contain DML commands, such as `INSERT`,
7728    /// `UPDATE`, or `DELETE`. Use
7729    /// [`ExecuteStreamingSql`][google.spanner.v1.Spanner.ExecuteStreamingSql] with
7730    /// a `PartitionedDml` transaction for large, partition-friendly DML
7731    /// operations.
7732    ///
7733    /// [google.spanner.v1.Spanner.ExecuteStreamingSql]: crate::client::Spanner::execute_streaming_sql
7734    pub sql: std::string::String,
7735
7736    /// Optional. Parameter names and values that bind to placeholders in the SQL
7737    /// string.
7738    ///
7739    /// A parameter placeholder consists of the `@` character followed by the
7740    /// parameter name (for example, `@firstName`). Parameter names can contain
7741    /// letters, numbers, and underscores.
7742    ///
7743    /// Parameters can appear anywhere that a literal value is expected. The same
7744    /// parameter name can be used more than once, for example:
7745    ///
7746    /// `"WHERE id > @msg_id AND id < @msg_id + 100"`
7747    ///
7748    /// It's an error to execute a SQL statement with unbound parameters.
7749    pub params: std::option::Option<wkt::Struct>,
7750
7751    /// Optional. It isn't always possible for Cloud Spanner to infer the right SQL
7752    /// type from a JSON value. For example, values of type `BYTES` and values of
7753    /// type `STRING` both appear in
7754    /// [params][google.spanner.v1.PartitionQueryRequest.params] as JSON strings.
7755    ///
7756    /// In these cases, `param_types` can be used to specify the exact
7757    /// SQL type for some or all of the SQL query parameters. See the
7758    /// definition of [Type][google.spanner.v1.Type] for more information
7759    /// about SQL types.
7760    ///
7761    /// [google.spanner.v1.PartitionQueryRequest.params]: crate::model::PartitionQueryRequest::params
7762    /// [google.spanner.v1.Type]: crate::model::Type
7763    pub param_types: std::collections::HashMap<std::string::String, crate::model::Type>,
7764
7765    /// Additional options that affect how many partitions are created.
7766    pub partition_options: std::option::Option<crate::model::PartitionOptions>,
7767
7768    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7769}
7770
7771impl PartitionQueryRequest {
7772    /// Creates a new default instance.
7773    pub fn new() -> Self {
7774        std::default::Default::default()
7775    }
7776
7777    /// Sets the value of [session][crate::model::PartitionQueryRequest::session].
7778    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7779        self.session = v.into();
7780        self
7781    }
7782
7783    /// Sets the value of [transaction][crate::model::PartitionQueryRequest::transaction].
7784    pub fn set_transaction<T>(mut self, v: T) -> Self
7785    where
7786        T: std::convert::Into<crate::model::TransactionSelector>,
7787    {
7788        self.transaction = std::option::Option::Some(v.into());
7789        self
7790    }
7791
7792    /// Sets or clears the value of [transaction][crate::model::PartitionQueryRequest::transaction].
7793    pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7794    where
7795        T: std::convert::Into<crate::model::TransactionSelector>,
7796    {
7797        self.transaction = v.map(|x| x.into());
7798        self
7799    }
7800
7801    /// Sets the value of [sql][crate::model::PartitionQueryRequest::sql].
7802    pub fn set_sql<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7803        self.sql = v.into();
7804        self
7805    }
7806
7807    /// Sets the value of [params][crate::model::PartitionQueryRequest::params].
7808    pub fn set_params<T>(mut self, v: T) -> Self
7809    where
7810        T: std::convert::Into<wkt::Struct>,
7811    {
7812        self.params = std::option::Option::Some(v.into());
7813        self
7814    }
7815
7816    /// Sets or clears the value of [params][crate::model::PartitionQueryRequest::params].
7817    pub fn set_or_clear_params<T>(mut self, v: std::option::Option<T>) -> Self
7818    where
7819        T: std::convert::Into<wkt::Struct>,
7820    {
7821        self.params = v.map(|x| x.into());
7822        self
7823    }
7824
7825    /// Sets the value of [param_types][crate::model::PartitionQueryRequest::param_types].
7826    pub fn set_param_types<T, K, V>(mut self, v: T) -> Self
7827    where
7828        T: std::iter::IntoIterator<Item = (K, V)>,
7829        K: std::convert::Into<std::string::String>,
7830        V: std::convert::Into<crate::model::Type>,
7831    {
7832        use std::iter::Iterator;
7833        self.param_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7834        self
7835    }
7836
7837    /// Sets the value of [partition_options][crate::model::PartitionQueryRequest::partition_options].
7838    pub fn set_partition_options<T>(mut self, v: T) -> Self
7839    where
7840        T: std::convert::Into<crate::model::PartitionOptions>,
7841    {
7842        self.partition_options = std::option::Option::Some(v.into());
7843        self
7844    }
7845
7846    /// Sets or clears the value of [partition_options][crate::model::PartitionQueryRequest::partition_options].
7847    pub fn set_or_clear_partition_options<T>(mut self, v: std::option::Option<T>) -> Self
7848    where
7849        T: std::convert::Into<crate::model::PartitionOptions>,
7850    {
7851        self.partition_options = v.map(|x| x.into());
7852        self
7853    }
7854}
7855
7856impl wkt::message::Message for PartitionQueryRequest {
7857    fn typename() -> &'static str {
7858        "type.googleapis.com/google.spanner.v1.PartitionQueryRequest"
7859    }
7860}
7861
7862/// The request for [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
7863///
7864/// [google.spanner.v1.Spanner.PartitionRead]: crate::client::Spanner::partition_read
7865#[derive(Clone, Default, PartialEq)]
7866#[non_exhaustive]
7867pub struct PartitionReadRequest {
7868    /// Required. The session used to create the partitions.
7869    pub session: std::string::String,
7870
7871    /// Read only snapshot transactions are supported, read/write and single use
7872    /// transactions are not.
7873    pub transaction: std::option::Option<crate::model::TransactionSelector>,
7874
7875    /// Required. The name of the table in the database to be read.
7876    pub table: std::string::String,
7877
7878    /// If non-empty, the name of an index on
7879    /// [table][google.spanner.v1.PartitionReadRequest.table]. This index is used
7880    /// instead of the table primary key when interpreting
7881    /// [key_set][google.spanner.v1.PartitionReadRequest.key_set] and sorting
7882    /// result rows. See [key_set][google.spanner.v1.PartitionReadRequest.key_set]
7883    /// for further information.
7884    ///
7885    /// [google.spanner.v1.PartitionReadRequest.key_set]: crate::model::PartitionReadRequest::key_set
7886    /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7887    pub index: std::string::String,
7888
7889    /// The columns of [table][google.spanner.v1.PartitionReadRequest.table] to be
7890    /// returned for each row matching this request.
7891    ///
7892    /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7893    pub columns: std::vec::Vec<std::string::String>,
7894
7895    /// Required. `key_set` identifies the rows to be yielded. `key_set` names the
7896    /// primary keys of the rows in
7897    /// [table][google.spanner.v1.PartitionReadRequest.table] to be yielded, unless
7898    /// [index][google.spanner.v1.PartitionReadRequest.index] is present. If
7899    /// [index][google.spanner.v1.PartitionReadRequest.index] is present, then
7900    /// [key_set][google.spanner.v1.PartitionReadRequest.key_set] instead names
7901    /// index keys in [index][google.spanner.v1.PartitionReadRequest.index].
7902    ///
7903    /// It isn't an error for the `key_set` to name rows that don't
7904    /// exist in the database. Read yields nothing for nonexistent rows.
7905    ///
7906    /// [google.spanner.v1.PartitionReadRequest.index]: crate::model::PartitionReadRequest::index
7907    /// [google.spanner.v1.PartitionReadRequest.key_set]: crate::model::PartitionReadRequest::key_set
7908    /// [google.spanner.v1.PartitionReadRequest.table]: crate::model::PartitionReadRequest::table
7909    pub key_set: std::option::Option<crate::model::KeySet>,
7910
7911    /// Additional options that affect how many partitions are created.
7912    pub partition_options: std::option::Option<crate::model::PartitionOptions>,
7913
7914    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7915}
7916
7917impl PartitionReadRequest {
7918    /// Creates a new default instance.
7919    pub fn new() -> Self {
7920        std::default::Default::default()
7921    }
7922
7923    /// Sets the value of [session][crate::model::PartitionReadRequest::session].
7924    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7925        self.session = v.into();
7926        self
7927    }
7928
7929    /// Sets the value of [transaction][crate::model::PartitionReadRequest::transaction].
7930    pub fn set_transaction<T>(mut self, v: T) -> Self
7931    where
7932        T: std::convert::Into<crate::model::TransactionSelector>,
7933    {
7934        self.transaction = std::option::Option::Some(v.into());
7935        self
7936    }
7937
7938    /// Sets or clears the value of [transaction][crate::model::PartitionReadRequest::transaction].
7939    pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
7940    where
7941        T: std::convert::Into<crate::model::TransactionSelector>,
7942    {
7943        self.transaction = v.map(|x| x.into());
7944        self
7945    }
7946
7947    /// Sets the value of [table][crate::model::PartitionReadRequest::table].
7948    pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7949        self.table = v.into();
7950        self
7951    }
7952
7953    /// Sets the value of [index][crate::model::PartitionReadRequest::index].
7954    pub fn set_index<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7955        self.index = v.into();
7956        self
7957    }
7958
7959    /// Sets the value of [columns][crate::model::PartitionReadRequest::columns].
7960    pub fn set_columns<T, V>(mut self, v: T) -> Self
7961    where
7962        T: std::iter::IntoIterator<Item = V>,
7963        V: std::convert::Into<std::string::String>,
7964    {
7965        use std::iter::Iterator;
7966        self.columns = v.into_iter().map(|i| i.into()).collect();
7967        self
7968    }
7969
7970    /// Sets the value of [key_set][crate::model::PartitionReadRequest::key_set].
7971    pub fn set_key_set<T>(mut self, v: T) -> Self
7972    where
7973        T: std::convert::Into<crate::model::KeySet>,
7974    {
7975        self.key_set = std::option::Option::Some(v.into());
7976        self
7977    }
7978
7979    /// Sets or clears the value of [key_set][crate::model::PartitionReadRequest::key_set].
7980    pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
7981    where
7982        T: std::convert::Into<crate::model::KeySet>,
7983    {
7984        self.key_set = v.map(|x| x.into());
7985        self
7986    }
7987
7988    /// Sets the value of [partition_options][crate::model::PartitionReadRequest::partition_options].
7989    pub fn set_partition_options<T>(mut self, v: T) -> Self
7990    where
7991        T: std::convert::Into<crate::model::PartitionOptions>,
7992    {
7993        self.partition_options = std::option::Option::Some(v.into());
7994        self
7995    }
7996
7997    /// Sets or clears the value of [partition_options][crate::model::PartitionReadRequest::partition_options].
7998    pub fn set_or_clear_partition_options<T>(mut self, v: std::option::Option<T>) -> Self
7999    where
8000        T: std::convert::Into<crate::model::PartitionOptions>,
8001    {
8002        self.partition_options = v.map(|x| x.into());
8003        self
8004    }
8005}
8006
8007impl wkt::message::Message for PartitionReadRequest {
8008    fn typename() -> &'static str {
8009        "type.googleapis.com/google.spanner.v1.PartitionReadRequest"
8010    }
8011}
8012
8013/// Information returned for each partition returned in a
8014/// PartitionResponse.
8015#[derive(Clone, Default, PartialEq)]
8016#[non_exhaustive]
8017pub struct Partition {
8018    /// This token can be passed to `Read`, `StreamingRead`, `ExecuteSql`, or
8019    /// `ExecuteStreamingSql` requests to restrict the results to those identified
8020    /// by this partition token.
8021    pub partition_token: ::bytes::Bytes,
8022
8023    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8024}
8025
8026impl Partition {
8027    /// Creates a new default instance.
8028    pub fn new() -> Self {
8029        std::default::Default::default()
8030    }
8031
8032    /// Sets the value of [partition_token][crate::model::Partition::partition_token].
8033    pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8034        self.partition_token = v.into();
8035        self
8036    }
8037}
8038
8039impl wkt::message::Message for Partition {
8040    fn typename() -> &'static str {
8041        "type.googleapis.com/google.spanner.v1.Partition"
8042    }
8043}
8044
8045/// The response for [PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
8046/// or [PartitionRead][google.spanner.v1.Spanner.PartitionRead]
8047///
8048/// [google.spanner.v1.Spanner.PartitionQuery]: crate::client::Spanner::partition_query
8049/// [google.spanner.v1.Spanner.PartitionRead]: crate::client::Spanner::partition_read
8050#[derive(Clone, Default, PartialEq)]
8051#[non_exhaustive]
8052pub struct PartitionResponse {
8053    /// Partitions created by this request.
8054    pub partitions: std::vec::Vec<crate::model::Partition>,
8055
8056    /// Transaction created by this request.
8057    pub transaction: std::option::Option<crate::model::Transaction>,
8058
8059    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8060}
8061
8062impl PartitionResponse {
8063    /// Creates a new default instance.
8064    pub fn new() -> Self {
8065        std::default::Default::default()
8066    }
8067
8068    /// Sets the value of [partitions][crate::model::PartitionResponse::partitions].
8069    pub fn set_partitions<T, V>(mut self, v: T) -> Self
8070    where
8071        T: std::iter::IntoIterator<Item = V>,
8072        V: std::convert::Into<crate::model::Partition>,
8073    {
8074        use std::iter::Iterator;
8075        self.partitions = v.into_iter().map(|i| i.into()).collect();
8076        self
8077    }
8078
8079    /// Sets the value of [transaction][crate::model::PartitionResponse::transaction].
8080    pub fn set_transaction<T>(mut self, v: T) -> Self
8081    where
8082        T: std::convert::Into<crate::model::Transaction>,
8083    {
8084        self.transaction = std::option::Option::Some(v.into());
8085        self
8086    }
8087
8088    /// Sets or clears the value of [transaction][crate::model::PartitionResponse::transaction].
8089    pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
8090    where
8091        T: std::convert::Into<crate::model::Transaction>,
8092    {
8093        self.transaction = v.map(|x| x.into());
8094        self
8095    }
8096}
8097
8098impl wkt::message::Message for PartitionResponse {
8099    fn typename() -> &'static str {
8100        "type.googleapis.com/google.spanner.v1.PartitionResponse"
8101    }
8102}
8103
8104/// The request for [Read][google.spanner.v1.Spanner.Read] and
8105/// [StreamingRead][google.spanner.v1.Spanner.StreamingRead].
8106///
8107/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
8108/// [google.spanner.v1.Spanner.StreamingRead]: crate::client::Spanner::streaming_read
8109#[derive(Clone, Default, PartialEq)]
8110#[non_exhaustive]
8111pub struct ReadRequest {
8112    /// Required. The session in which the read should be performed.
8113    pub session: std::string::String,
8114
8115    /// The transaction to use. If none is provided, the default is a
8116    /// temporary read-only transaction with strong concurrency.
8117    pub transaction: std::option::Option<crate::model::TransactionSelector>,
8118
8119    /// Required. The name of the table in the database to be read.
8120    pub table: std::string::String,
8121
8122    /// If non-empty, the name of an index on
8123    /// [table][google.spanner.v1.ReadRequest.table]. This index is used instead of
8124    /// the table primary key when interpreting
8125    /// [key_set][google.spanner.v1.ReadRequest.key_set] and sorting result rows.
8126    /// See [key_set][google.spanner.v1.ReadRequest.key_set] for further
8127    /// information.
8128    ///
8129    /// [google.spanner.v1.ReadRequest.key_set]: crate::model::ReadRequest::key_set
8130    /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8131    pub index: std::string::String,
8132
8133    /// Required. The columns of [table][google.spanner.v1.ReadRequest.table] to be
8134    /// returned for each row matching this request.
8135    ///
8136    /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8137    pub columns: std::vec::Vec<std::string::String>,
8138
8139    /// Required. `key_set` identifies the rows to be yielded. `key_set` names the
8140    /// primary keys of the rows in [table][google.spanner.v1.ReadRequest.table] to
8141    /// be yielded, unless [index][google.spanner.v1.ReadRequest.index] is present.
8142    /// If [index][google.spanner.v1.ReadRequest.index] is present, then
8143    /// [key_set][google.spanner.v1.ReadRequest.key_set] instead names index keys
8144    /// in [index][google.spanner.v1.ReadRequest.index].
8145    ///
8146    /// If the [partition_token][google.spanner.v1.ReadRequest.partition_token]
8147    /// field is empty, rows are yielded in table primary key order (if
8148    /// [index][google.spanner.v1.ReadRequest.index] is empty) or index key order
8149    /// (if [index][google.spanner.v1.ReadRequest.index] is non-empty). If the
8150    /// [partition_token][google.spanner.v1.ReadRequest.partition_token] field
8151    /// isn't empty, rows are yielded in an unspecified order.
8152    ///
8153    /// It isn't an error for the `key_set` to name rows that don't
8154    /// exist in the database. Read yields nothing for nonexistent rows.
8155    ///
8156    /// [google.spanner.v1.ReadRequest.index]: crate::model::ReadRequest::index
8157    /// [google.spanner.v1.ReadRequest.key_set]: crate::model::ReadRequest::key_set
8158    /// [google.spanner.v1.ReadRequest.partition_token]: crate::model::ReadRequest::partition_token
8159    /// [google.spanner.v1.ReadRequest.table]: crate::model::ReadRequest::table
8160    pub key_set: std::option::Option<crate::model::KeySet>,
8161
8162    /// If greater than zero, only the first `limit` rows are yielded. If `limit`
8163    /// is zero, the default is no limit. A limit can't be specified if
8164    /// `partition_token` is set.
8165    pub limit: i64,
8166
8167    /// If this request is resuming a previously interrupted read,
8168    /// `resume_token` should be copied from the last
8169    /// [PartialResultSet][google.spanner.v1.PartialResultSet] yielded before the
8170    /// interruption. Doing this enables the new read to resume where the last read
8171    /// left off. The rest of the request parameters must exactly match the request
8172    /// that yielded this token.
8173    ///
8174    /// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
8175    pub resume_token: ::bytes::Bytes,
8176
8177    /// If present, results are restricted to the specified partition
8178    /// previously created using `PartitionRead`. There must be an exact
8179    /// match for the values of fields common to this message and the
8180    /// PartitionReadRequest message used to create this partition_token.
8181    pub partition_token: ::bytes::Bytes,
8182
8183    /// Common options for this request.
8184    pub request_options: std::option::Option<crate::model::RequestOptions>,
8185
8186    /// Directed read options for this request.
8187    pub directed_read_options: std::option::Option<crate::model::DirectedReadOptions>,
8188
8189    /// If this is for a partitioned read and this field is set to `true`, the
8190    /// request is executed with Spanner Data Boost independent compute resources.
8191    ///
8192    /// If the field is set to `true` but the request doesn't set
8193    /// `partition_token`, the API returns an `INVALID_ARGUMENT` error.
8194    pub data_boost_enabled: bool,
8195
8196    /// Optional. Order for the returned rows.
8197    ///
8198    /// By default, Spanner returns result rows in primary key order except for
8199    /// PartitionRead requests. For applications that don't require rows to be
8200    /// returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
8201    /// `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
8202    /// resulting in lower latencies in certain cases (for example, bulk point
8203    /// lookups).
8204    pub order_by: crate::model::read_request::OrderBy,
8205
8206    /// Optional. Lock Hint for the request, it can only be used with read-write
8207    /// transactions.
8208    pub lock_hint: crate::model::read_request::LockHint,
8209
8210    /// Optional. Makes the Spanner requests location-aware if present.
8211    ///
8212    /// It gives the server hints that can be used to route the request
8213    /// to an appropriate server, potentially significantly decreasing latency and
8214    /// improving throughput. To achieve improved performance, most fields must be
8215    /// filled in with accurate values.
8216    pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8217
8218    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8219}
8220
8221impl ReadRequest {
8222    /// Creates a new default instance.
8223    pub fn new() -> Self {
8224        std::default::Default::default()
8225    }
8226
8227    /// Sets the value of [session][crate::model::ReadRequest::session].
8228    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8229        self.session = v.into();
8230        self
8231    }
8232
8233    /// Sets the value of [transaction][crate::model::ReadRequest::transaction].
8234    pub fn set_transaction<T>(mut self, v: T) -> Self
8235    where
8236        T: std::convert::Into<crate::model::TransactionSelector>,
8237    {
8238        self.transaction = std::option::Option::Some(v.into());
8239        self
8240    }
8241
8242    /// Sets or clears the value of [transaction][crate::model::ReadRequest::transaction].
8243    pub fn set_or_clear_transaction<T>(mut self, v: std::option::Option<T>) -> Self
8244    where
8245        T: std::convert::Into<crate::model::TransactionSelector>,
8246    {
8247        self.transaction = v.map(|x| x.into());
8248        self
8249    }
8250
8251    /// Sets the value of [table][crate::model::ReadRequest::table].
8252    pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8253        self.table = v.into();
8254        self
8255    }
8256
8257    /// Sets the value of [index][crate::model::ReadRequest::index].
8258    pub fn set_index<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8259        self.index = v.into();
8260        self
8261    }
8262
8263    /// Sets the value of [columns][crate::model::ReadRequest::columns].
8264    pub fn set_columns<T, V>(mut self, v: T) -> Self
8265    where
8266        T: std::iter::IntoIterator<Item = V>,
8267        V: std::convert::Into<std::string::String>,
8268    {
8269        use std::iter::Iterator;
8270        self.columns = v.into_iter().map(|i| i.into()).collect();
8271        self
8272    }
8273
8274    /// Sets the value of [key_set][crate::model::ReadRequest::key_set].
8275    pub fn set_key_set<T>(mut self, v: T) -> Self
8276    where
8277        T: std::convert::Into<crate::model::KeySet>,
8278    {
8279        self.key_set = std::option::Option::Some(v.into());
8280        self
8281    }
8282
8283    /// Sets or clears the value of [key_set][crate::model::ReadRequest::key_set].
8284    pub fn set_or_clear_key_set<T>(mut self, v: std::option::Option<T>) -> Self
8285    where
8286        T: std::convert::Into<crate::model::KeySet>,
8287    {
8288        self.key_set = v.map(|x| x.into());
8289        self
8290    }
8291
8292    /// Sets the value of [limit][crate::model::ReadRequest::limit].
8293    pub fn set_limit<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
8294        self.limit = v.into();
8295        self
8296    }
8297
8298    /// Sets the value of [resume_token][crate::model::ReadRequest::resume_token].
8299    pub fn set_resume_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8300        self.resume_token = v.into();
8301        self
8302    }
8303
8304    /// Sets the value of [partition_token][crate::model::ReadRequest::partition_token].
8305    pub fn set_partition_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
8306        self.partition_token = v.into();
8307        self
8308    }
8309
8310    /// Sets the value of [request_options][crate::model::ReadRequest::request_options].
8311    pub fn set_request_options<T>(mut self, v: T) -> Self
8312    where
8313        T: std::convert::Into<crate::model::RequestOptions>,
8314    {
8315        self.request_options = std::option::Option::Some(v.into());
8316        self
8317    }
8318
8319    /// Sets or clears the value of [request_options][crate::model::ReadRequest::request_options].
8320    pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8321    where
8322        T: std::convert::Into<crate::model::RequestOptions>,
8323    {
8324        self.request_options = v.map(|x| x.into());
8325        self
8326    }
8327
8328    /// Sets the value of [directed_read_options][crate::model::ReadRequest::directed_read_options].
8329    pub fn set_directed_read_options<T>(mut self, v: T) -> Self
8330    where
8331        T: std::convert::Into<crate::model::DirectedReadOptions>,
8332    {
8333        self.directed_read_options = std::option::Option::Some(v.into());
8334        self
8335    }
8336
8337    /// Sets or clears the value of [directed_read_options][crate::model::ReadRequest::directed_read_options].
8338    pub fn set_or_clear_directed_read_options<T>(mut self, v: std::option::Option<T>) -> Self
8339    where
8340        T: std::convert::Into<crate::model::DirectedReadOptions>,
8341    {
8342        self.directed_read_options = v.map(|x| x.into());
8343        self
8344    }
8345
8346    /// Sets the value of [data_boost_enabled][crate::model::ReadRequest::data_boost_enabled].
8347    pub fn set_data_boost_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8348        self.data_boost_enabled = v.into();
8349        self
8350    }
8351
8352    /// Sets the value of [order_by][crate::model::ReadRequest::order_by].
8353    pub fn set_order_by<T: std::convert::Into<crate::model::read_request::OrderBy>>(
8354        mut self,
8355        v: T,
8356    ) -> Self {
8357        self.order_by = v.into();
8358        self
8359    }
8360
8361    /// Sets the value of [lock_hint][crate::model::ReadRequest::lock_hint].
8362    pub fn set_lock_hint<T: std::convert::Into<crate::model::read_request::LockHint>>(
8363        mut self,
8364        v: T,
8365    ) -> Self {
8366        self.lock_hint = v.into();
8367        self
8368    }
8369
8370    /// Sets the value of [routing_hint][crate::model::ReadRequest::routing_hint].
8371    pub fn set_routing_hint<T>(mut self, v: T) -> Self
8372    where
8373        T: std::convert::Into<crate::model::RoutingHint>,
8374    {
8375        self.routing_hint = std::option::Option::Some(v.into());
8376        self
8377    }
8378
8379    /// Sets or clears the value of [routing_hint][crate::model::ReadRequest::routing_hint].
8380    pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8381    where
8382        T: std::convert::Into<crate::model::RoutingHint>,
8383    {
8384        self.routing_hint = v.map(|x| x.into());
8385        self
8386    }
8387}
8388
8389impl wkt::message::Message for ReadRequest {
8390    fn typename() -> &'static str {
8391        "type.googleapis.com/google.spanner.v1.ReadRequest"
8392    }
8393}
8394
8395/// Defines additional types related to [ReadRequest].
8396pub mod read_request {
8397    #[allow(unused_imports)]
8398    use super::*;
8399
8400    /// An option to control the order in which rows are returned from a read.
8401    ///
8402    /// # Working with unknown values
8403    ///
8404    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8405    /// additional enum variants at any time. Adding new variants is not considered
8406    /// a breaking change. Applications should write their code in anticipation of:
8407    ///
8408    /// - New values appearing in future releases of the client library, **and**
8409    /// - New values received dynamically, without application changes.
8410    ///
8411    /// Please consult the [Working with enums] section in the user guide for some
8412    /// guidelines.
8413    ///
8414    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8415    #[derive(Clone, Debug, PartialEq)]
8416    #[non_exhaustive]
8417    pub enum OrderBy {
8418        /// Default value.
8419        ///
8420        /// `ORDER_BY_UNSPECIFIED` is equivalent to `ORDER_BY_PRIMARY_KEY`.
8421        Unspecified,
8422        /// Read rows are returned in primary key order.
8423        ///
8424        /// In the event that this option is used in conjunction with the
8425        /// `partition_token` field, the API returns an `INVALID_ARGUMENT` error.
8426        PrimaryKey,
8427        /// Read rows are returned in any order.
8428        NoOrder,
8429        /// If set, the enum was initialized with an unknown value.
8430        ///
8431        /// Applications can examine the value using [OrderBy::value] or
8432        /// [OrderBy::name].
8433        UnknownValue(order_by::UnknownValue),
8434    }
8435
8436    #[doc(hidden)]
8437    pub mod order_by {
8438        #[allow(unused_imports)]
8439        use super::*;
8440        #[derive(Clone, Debug, PartialEq)]
8441        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8442    }
8443
8444    impl OrderBy {
8445        /// Gets the enum value.
8446        ///
8447        /// Returns `None` if the enum contains an unknown value deserialized from
8448        /// the string representation of enums.
8449        pub fn value(&self) -> std::option::Option<i32> {
8450            match self {
8451                Self::Unspecified => std::option::Option::Some(0),
8452                Self::PrimaryKey => std::option::Option::Some(1),
8453                Self::NoOrder => std::option::Option::Some(2),
8454                Self::UnknownValue(u) => u.0.value(),
8455            }
8456        }
8457
8458        /// Gets the enum value as a string.
8459        ///
8460        /// Returns `None` if the enum contains an unknown value deserialized from
8461        /// the integer representation of enums.
8462        pub fn name(&self) -> std::option::Option<&str> {
8463            match self {
8464                Self::Unspecified => std::option::Option::Some("ORDER_BY_UNSPECIFIED"),
8465                Self::PrimaryKey => std::option::Option::Some("ORDER_BY_PRIMARY_KEY"),
8466                Self::NoOrder => std::option::Option::Some("ORDER_BY_NO_ORDER"),
8467                Self::UnknownValue(u) => u.0.name(),
8468            }
8469        }
8470    }
8471
8472    impl std::default::Default for OrderBy {
8473        fn default() -> Self {
8474            use std::convert::From;
8475            Self::from(0)
8476        }
8477    }
8478
8479    impl std::fmt::Display for OrderBy {
8480        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8481            wkt::internal::display_enum(f, self.name(), self.value())
8482        }
8483    }
8484
8485    impl std::convert::From<i32> for OrderBy {
8486        fn from(value: i32) -> Self {
8487            match value {
8488                0 => Self::Unspecified,
8489                1 => Self::PrimaryKey,
8490                2 => Self::NoOrder,
8491                _ => Self::UnknownValue(order_by::UnknownValue(
8492                    wkt::internal::UnknownEnumValue::Integer(value),
8493                )),
8494            }
8495        }
8496    }
8497
8498    impl std::convert::From<&str> for OrderBy {
8499        fn from(value: &str) -> Self {
8500            use std::string::ToString;
8501            match value {
8502                "ORDER_BY_UNSPECIFIED" => Self::Unspecified,
8503                "ORDER_BY_PRIMARY_KEY" => Self::PrimaryKey,
8504                "ORDER_BY_NO_ORDER" => Self::NoOrder,
8505                _ => Self::UnknownValue(order_by::UnknownValue(
8506                    wkt::internal::UnknownEnumValue::String(value.to_string()),
8507                )),
8508            }
8509        }
8510    }
8511
8512    impl serde::ser::Serialize for OrderBy {
8513        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8514        where
8515            S: serde::Serializer,
8516        {
8517            match self {
8518                Self::Unspecified => serializer.serialize_i32(0),
8519                Self::PrimaryKey => serializer.serialize_i32(1),
8520                Self::NoOrder => serializer.serialize_i32(2),
8521                Self::UnknownValue(u) => u.0.serialize(serializer),
8522            }
8523        }
8524    }
8525
8526    impl<'de> serde::de::Deserialize<'de> for OrderBy {
8527        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8528        where
8529            D: serde::Deserializer<'de>,
8530        {
8531            deserializer.deserialize_any(wkt::internal::EnumVisitor::<OrderBy>::new(
8532                ".google.spanner.v1.ReadRequest.OrderBy",
8533            ))
8534        }
8535    }
8536
8537    /// A lock hint mechanism for reads done within a transaction.
8538    ///
8539    /// # Working with unknown values
8540    ///
8541    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8542    /// additional enum variants at any time. Adding new variants is not considered
8543    /// a breaking change. Applications should write their code in anticipation of:
8544    ///
8545    /// - New values appearing in future releases of the client library, **and**
8546    /// - New values received dynamically, without application changes.
8547    ///
8548    /// Please consult the [Working with enums] section in the user guide for some
8549    /// guidelines.
8550    ///
8551    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8552    #[derive(Clone, Debug, PartialEq)]
8553    #[non_exhaustive]
8554    pub enum LockHint {
8555        /// Default value.
8556        ///
8557        /// `LOCK_HINT_UNSPECIFIED` is equivalent to `LOCK_HINT_SHARED`.
8558        Unspecified,
8559        /// Acquire shared locks.
8560        ///
8561        /// By default when you perform a read as part of a read-write transaction,
8562        /// Spanner acquires shared read locks, which allows other reads to still
8563        /// access the data until your transaction is ready to commit. When your
8564        /// transaction is committing and writes are being applied, the transaction
8565        /// attempts to upgrade to an exclusive lock for any data you are writing.
8566        /// For more information about locks, see [Lock
8567        /// modes](https://cloud.google.com/spanner/docs/introspection/lock-statistics#explain-lock-modes).
8568        Shared,
8569        /// Acquire exclusive locks.
8570        ///
8571        /// Requesting exclusive locks is beneficial if you observe high write
8572        /// contention, which means you notice that multiple transactions are
8573        /// concurrently trying to read and write to the same data, resulting in a
8574        /// large number of aborts. This problem occurs when two transactions
8575        /// initially acquire shared locks and then both try to upgrade to exclusive
8576        /// locks at the same time. In this situation both transactions are waiting
8577        /// for the other to give up their lock, resulting in a deadlocked situation.
8578        /// Spanner is able to detect this occurring and force one of the
8579        /// transactions to abort. However, this is a slow and expensive operation
8580        /// and results in lower performance. In this case it makes sense to acquire
8581        /// exclusive locks at the start of the transaction because then when
8582        /// multiple transactions try to act on the same data, they automatically get
8583        /// serialized. Each transaction waits its turn to acquire the lock and
8584        /// avoids getting into deadlock situations.
8585        ///
8586        /// Because the exclusive lock hint is just a hint, it shouldn't be
8587        /// considered equivalent to a mutex. In other words, you shouldn't use
8588        /// Spanner exclusive locks as a mutual exclusion mechanism for the execution
8589        /// of code outside of Spanner.
8590        ///
8591        /// **Note:** Request exclusive locks judiciously because they block others
8592        /// from reading that data for the entire transaction, rather than just when
8593        /// the writes are being performed. Unless you observe high write contention,
8594        /// you should use the default of shared read locks so you don't prematurely
8595        /// block other clients from reading the data that you're writing to.
8596        Exclusive,
8597        /// If set, the enum was initialized with an unknown value.
8598        ///
8599        /// Applications can examine the value using [LockHint::value] or
8600        /// [LockHint::name].
8601        UnknownValue(lock_hint::UnknownValue),
8602    }
8603
8604    #[doc(hidden)]
8605    pub mod lock_hint {
8606        #[allow(unused_imports)]
8607        use super::*;
8608        #[derive(Clone, Debug, PartialEq)]
8609        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8610    }
8611
8612    impl LockHint {
8613        /// Gets the enum value.
8614        ///
8615        /// Returns `None` if the enum contains an unknown value deserialized from
8616        /// the string representation of enums.
8617        pub fn value(&self) -> std::option::Option<i32> {
8618            match self {
8619                Self::Unspecified => std::option::Option::Some(0),
8620                Self::Shared => std::option::Option::Some(1),
8621                Self::Exclusive => std::option::Option::Some(2),
8622                Self::UnknownValue(u) => u.0.value(),
8623            }
8624        }
8625
8626        /// Gets the enum value as a string.
8627        ///
8628        /// Returns `None` if the enum contains an unknown value deserialized from
8629        /// the integer representation of enums.
8630        pub fn name(&self) -> std::option::Option<&str> {
8631            match self {
8632                Self::Unspecified => std::option::Option::Some("LOCK_HINT_UNSPECIFIED"),
8633                Self::Shared => std::option::Option::Some("LOCK_HINT_SHARED"),
8634                Self::Exclusive => std::option::Option::Some("LOCK_HINT_EXCLUSIVE"),
8635                Self::UnknownValue(u) => u.0.name(),
8636            }
8637        }
8638    }
8639
8640    impl std::default::Default for LockHint {
8641        fn default() -> Self {
8642            use std::convert::From;
8643            Self::from(0)
8644        }
8645    }
8646
8647    impl std::fmt::Display for LockHint {
8648        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8649            wkt::internal::display_enum(f, self.name(), self.value())
8650        }
8651    }
8652
8653    impl std::convert::From<i32> for LockHint {
8654        fn from(value: i32) -> Self {
8655            match value {
8656                0 => Self::Unspecified,
8657                1 => Self::Shared,
8658                2 => Self::Exclusive,
8659                _ => Self::UnknownValue(lock_hint::UnknownValue(
8660                    wkt::internal::UnknownEnumValue::Integer(value),
8661                )),
8662            }
8663        }
8664    }
8665
8666    impl std::convert::From<&str> for LockHint {
8667        fn from(value: &str) -> Self {
8668            use std::string::ToString;
8669            match value {
8670                "LOCK_HINT_UNSPECIFIED" => Self::Unspecified,
8671                "LOCK_HINT_SHARED" => Self::Shared,
8672                "LOCK_HINT_EXCLUSIVE" => Self::Exclusive,
8673                _ => Self::UnknownValue(lock_hint::UnknownValue(
8674                    wkt::internal::UnknownEnumValue::String(value.to_string()),
8675                )),
8676            }
8677        }
8678    }
8679
8680    impl serde::ser::Serialize for LockHint {
8681        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8682        where
8683            S: serde::Serializer,
8684        {
8685            match self {
8686                Self::Unspecified => serializer.serialize_i32(0),
8687                Self::Shared => serializer.serialize_i32(1),
8688                Self::Exclusive => serializer.serialize_i32(2),
8689                Self::UnknownValue(u) => u.0.serialize(serializer),
8690            }
8691        }
8692    }
8693
8694    impl<'de> serde::de::Deserialize<'de> for LockHint {
8695        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8696        where
8697            D: serde::Deserializer<'de>,
8698        {
8699            deserializer.deserialize_any(wkt::internal::EnumVisitor::<LockHint>::new(
8700                ".google.spanner.v1.ReadRequest.LockHint",
8701            ))
8702        }
8703    }
8704}
8705
8706/// The request for
8707/// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
8708///
8709/// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
8710#[derive(Clone, Default, PartialEq)]
8711#[non_exhaustive]
8712pub struct BeginTransactionRequest {
8713    /// Required. The session in which the transaction runs.
8714    pub session: std::string::String,
8715
8716    /// Required. Options for the new transaction.
8717    pub options: std::option::Option<crate::model::TransactionOptions>,
8718
8719    /// Common options for this request.
8720    /// Priority is ignored for this request. Setting the priority in this
8721    /// `request_options` struct doesn't do anything. To set the priority for a
8722    /// transaction, set it on the reads and writes that are part of this
8723    /// transaction instead.
8724    pub request_options: std::option::Option<crate::model::RequestOptions>,
8725
8726    /// Optional. Required for read-write transactions on a multiplexed session
8727    /// that commit mutations but don't perform any reads or queries. You must
8728    /// randomly select one of the mutations from the mutation set and send it as a
8729    /// part of this request.
8730    pub mutation_key: std::option::Option<crate::model::Mutation>,
8731
8732    /// Optional. Makes the Spanner requests location-aware if present.
8733    ///
8734    /// It gives the server hints that can be used to route the request
8735    /// to an appropriate server, potentially significantly decreasing latency and
8736    /// improving throughput. To achieve improved performance, most fields must be
8737    /// filled in with accurate values.
8738    pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8739
8740    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8741}
8742
8743impl BeginTransactionRequest {
8744    /// Creates a new default instance.
8745    pub fn new() -> Self {
8746        std::default::Default::default()
8747    }
8748
8749    /// Sets the value of [session][crate::model::BeginTransactionRequest::session].
8750    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8751        self.session = v.into();
8752        self
8753    }
8754
8755    /// Sets the value of [options][crate::model::BeginTransactionRequest::options].
8756    pub fn set_options<T>(mut self, v: T) -> Self
8757    where
8758        T: std::convert::Into<crate::model::TransactionOptions>,
8759    {
8760        self.options = std::option::Option::Some(v.into());
8761        self
8762    }
8763
8764    /// Sets or clears the value of [options][crate::model::BeginTransactionRequest::options].
8765    pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
8766    where
8767        T: std::convert::Into<crate::model::TransactionOptions>,
8768    {
8769        self.options = v.map(|x| x.into());
8770        self
8771    }
8772
8773    /// Sets the value of [request_options][crate::model::BeginTransactionRequest::request_options].
8774    pub fn set_request_options<T>(mut self, v: T) -> Self
8775    where
8776        T: std::convert::Into<crate::model::RequestOptions>,
8777    {
8778        self.request_options = std::option::Option::Some(v.into());
8779        self
8780    }
8781
8782    /// Sets or clears the value of [request_options][crate::model::BeginTransactionRequest::request_options].
8783    pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8784    where
8785        T: std::convert::Into<crate::model::RequestOptions>,
8786    {
8787        self.request_options = v.map(|x| x.into());
8788        self
8789    }
8790
8791    /// Sets the value of [mutation_key][crate::model::BeginTransactionRequest::mutation_key].
8792    pub fn set_mutation_key<T>(mut self, v: T) -> Self
8793    where
8794        T: std::convert::Into<crate::model::Mutation>,
8795    {
8796        self.mutation_key = std::option::Option::Some(v.into());
8797        self
8798    }
8799
8800    /// Sets or clears the value of [mutation_key][crate::model::BeginTransactionRequest::mutation_key].
8801    pub fn set_or_clear_mutation_key<T>(mut self, v: std::option::Option<T>) -> Self
8802    where
8803        T: std::convert::Into<crate::model::Mutation>,
8804    {
8805        self.mutation_key = v.map(|x| x.into());
8806        self
8807    }
8808
8809    /// Sets the value of [routing_hint][crate::model::BeginTransactionRequest::routing_hint].
8810    pub fn set_routing_hint<T>(mut self, v: T) -> Self
8811    where
8812        T: std::convert::Into<crate::model::RoutingHint>,
8813    {
8814        self.routing_hint = std::option::Option::Some(v.into());
8815        self
8816    }
8817
8818    /// Sets or clears the value of [routing_hint][crate::model::BeginTransactionRequest::routing_hint].
8819    pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8820    where
8821        T: std::convert::Into<crate::model::RoutingHint>,
8822    {
8823        self.routing_hint = v.map(|x| x.into());
8824        self
8825    }
8826}
8827
8828impl wkt::message::Message for BeginTransactionRequest {
8829    fn typename() -> &'static str {
8830        "type.googleapis.com/google.spanner.v1.BeginTransactionRequest"
8831    }
8832}
8833
8834/// The request for [Commit][google.spanner.v1.Spanner.Commit].
8835///
8836/// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
8837#[derive(Clone, Default, PartialEq)]
8838#[non_exhaustive]
8839pub struct CommitRequest {
8840    /// Required. The session in which the transaction to be committed is running.
8841    pub session: std::string::String,
8842
8843    /// The mutations to be executed when this transaction commits. All
8844    /// mutations are applied atomically, in the order they appear in
8845    /// this list.
8846    pub mutations: std::vec::Vec<crate::model::Mutation>,
8847
8848    /// If `true`, then statistics related to the transaction is included in
8849    /// the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats].
8850    /// Default value is `false`.
8851    ///
8852    /// [google.spanner.v1.CommitResponse.commit_stats]: crate::model::CommitResponse::commit_stats
8853    pub return_commit_stats: bool,
8854
8855    /// Optional. The amount of latency this request is configured to incur in
8856    /// order to improve throughput. If this field isn't set, Spanner assumes
8857    /// requests are relatively latency sensitive and automatically determines an
8858    /// appropriate delay time. You can specify a commit delay value between 0 and
8859    /// 500 ms.
8860    pub max_commit_delay: std::option::Option<wkt::Duration>,
8861
8862    /// Common options for this request.
8863    pub request_options: std::option::Option<crate::model::RequestOptions>,
8864
8865    /// Optional. If the read-write transaction was executed on a multiplexed
8866    /// session, then you must include the precommit token with the highest
8867    /// sequence number received in this transaction attempt. Failing to do so
8868    /// results in a `FailedPrecondition` error.
8869    pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
8870
8871    /// Optional. Makes the Spanner requests location-aware if present.
8872    ///
8873    /// It gives the server hints that can be used to route the request
8874    /// to an appropriate server, potentially significantly decreasing latency and
8875    /// improving throughput. To achieve improved performance, most fields must be
8876    /// filled in with accurate values.
8877    pub routing_hint: std::option::Option<crate::model::RoutingHint>,
8878
8879    /// Required. The transaction in which to commit.
8880    pub transaction: std::option::Option<crate::model::commit_request::Transaction>,
8881
8882    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8883}
8884
8885impl CommitRequest {
8886    /// Creates a new default instance.
8887    pub fn new() -> Self {
8888        std::default::Default::default()
8889    }
8890
8891    /// Sets the value of [session][crate::model::CommitRequest::session].
8892    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8893        self.session = v.into();
8894        self
8895    }
8896
8897    /// Sets the value of [mutations][crate::model::CommitRequest::mutations].
8898    pub fn set_mutations<T, V>(mut self, v: T) -> Self
8899    where
8900        T: std::iter::IntoIterator<Item = V>,
8901        V: std::convert::Into<crate::model::Mutation>,
8902    {
8903        use std::iter::Iterator;
8904        self.mutations = v.into_iter().map(|i| i.into()).collect();
8905        self
8906    }
8907
8908    /// Sets the value of [return_commit_stats][crate::model::CommitRequest::return_commit_stats].
8909    pub fn set_return_commit_stats<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
8910        self.return_commit_stats = v.into();
8911        self
8912    }
8913
8914    /// Sets the value of [max_commit_delay][crate::model::CommitRequest::max_commit_delay].
8915    pub fn set_max_commit_delay<T>(mut self, v: T) -> Self
8916    where
8917        T: std::convert::Into<wkt::Duration>,
8918    {
8919        self.max_commit_delay = std::option::Option::Some(v.into());
8920        self
8921    }
8922
8923    /// Sets or clears the value of [max_commit_delay][crate::model::CommitRequest::max_commit_delay].
8924    pub fn set_or_clear_max_commit_delay<T>(mut self, v: std::option::Option<T>) -> Self
8925    where
8926        T: std::convert::Into<wkt::Duration>,
8927    {
8928        self.max_commit_delay = v.map(|x| x.into());
8929        self
8930    }
8931
8932    /// Sets the value of [request_options][crate::model::CommitRequest::request_options].
8933    pub fn set_request_options<T>(mut self, v: T) -> Self
8934    where
8935        T: std::convert::Into<crate::model::RequestOptions>,
8936    {
8937        self.request_options = std::option::Option::Some(v.into());
8938        self
8939    }
8940
8941    /// Sets or clears the value of [request_options][crate::model::CommitRequest::request_options].
8942    pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
8943    where
8944        T: std::convert::Into<crate::model::RequestOptions>,
8945    {
8946        self.request_options = v.map(|x| x.into());
8947        self
8948    }
8949
8950    /// Sets the value of [precommit_token][crate::model::CommitRequest::precommit_token].
8951    pub fn set_precommit_token<T>(mut self, v: T) -> Self
8952    where
8953        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
8954    {
8955        self.precommit_token = std::option::Option::Some(v.into());
8956        self
8957    }
8958
8959    /// Sets or clears the value of [precommit_token][crate::model::CommitRequest::precommit_token].
8960    pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
8961    where
8962        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
8963    {
8964        self.precommit_token = v.map(|x| x.into());
8965        self
8966    }
8967
8968    /// Sets the value of [routing_hint][crate::model::CommitRequest::routing_hint].
8969    pub fn set_routing_hint<T>(mut self, v: T) -> Self
8970    where
8971        T: std::convert::Into<crate::model::RoutingHint>,
8972    {
8973        self.routing_hint = std::option::Option::Some(v.into());
8974        self
8975    }
8976
8977    /// Sets or clears the value of [routing_hint][crate::model::CommitRequest::routing_hint].
8978    pub fn set_or_clear_routing_hint<T>(mut self, v: std::option::Option<T>) -> Self
8979    where
8980        T: std::convert::Into<crate::model::RoutingHint>,
8981    {
8982        self.routing_hint = v.map(|x| x.into());
8983        self
8984    }
8985
8986    /// Sets the value of [transaction][crate::model::CommitRequest::transaction].
8987    ///
8988    /// Note that all the setters affecting `transaction` are mutually
8989    /// exclusive.
8990    pub fn set_transaction<
8991        T: std::convert::Into<std::option::Option<crate::model::commit_request::Transaction>>,
8992    >(
8993        mut self,
8994        v: T,
8995    ) -> Self {
8996        self.transaction = v.into();
8997        self
8998    }
8999
9000    /// The value of [transaction][crate::model::CommitRequest::transaction]
9001    /// if it holds a `TransactionId`, `None` if the field is not set or
9002    /// holds a different branch.
9003    pub fn transaction_id(&self) -> std::option::Option<&::bytes::Bytes> {
9004        #[allow(unreachable_patterns)]
9005        self.transaction.as_ref().and_then(|v| match v {
9006            crate::model::commit_request::Transaction::TransactionId(v) => {
9007                std::option::Option::Some(v)
9008            }
9009            _ => std::option::Option::None,
9010        })
9011    }
9012
9013    /// Sets the value of [transaction][crate::model::CommitRequest::transaction]
9014    /// to hold a `TransactionId`.
9015    ///
9016    /// Note that all the setters affecting `transaction` are
9017    /// mutually exclusive.
9018    pub fn set_transaction_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9019        self.transaction = std::option::Option::Some(
9020            crate::model::commit_request::Transaction::TransactionId(v.into()),
9021        );
9022        self
9023    }
9024
9025    /// The value of [transaction][crate::model::CommitRequest::transaction]
9026    /// if it holds a `SingleUseTransaction`, `None` if the field is not set or
9027    /// holds a different branch.
9028    pub fn single_use_transaction(
9029        &self,
9030    ) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
9031        #[allow(unreachable_patterns)]
9032        self.transaction.as_ref().and_then(|v| match v {
9033            crate::model::commit_request::Transaction::SingleUseTransaction(v) => {
9034                std::option::Option::Some(v)
9035            }
9036            _ => std::option::Option::None,
9037        })
9038    }
9039
9040    /// Sets the value of [transaction][crate::model::CommitRequest::transaction]
9041    /// to hold a `SingleUseTransaction`.
9042    ///
9043    /// Note that all the setters affecting `transaction` are
9044    /// mutually exclusive.
9045    pub fn set_single_use_transaction<
9046        T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
9047    >(
9048        mut self,
9049        v: T,
9050    ) -> Self {
9051        self.transaction = std::option::Option::Some(
9052            crate::model::commit_request::Transaction::SingleUseTransaction(v.into()),
9053        );
9054        self
9055    }
9056}
9057
9058impl wkt::message::Message for CommitRequest {
9059    fn typename() -> &'static str {
9060        "type.googleapis.com/google.spanner.v1.CommitRequest"
9061    }
9062}
9063
9064/// Defines additional types related to [CommitRequest].
9065pub mod commit_request {
9066    #[allow(unused_imports)]
9067    use super::*;
9068
9069    /// Required. The transaction in which to commit.
9070    #[derive(Clone, Debug, PartialEq)]
9071    #[non_exhaustive]
9072    pub enum Transaction {
9073        /// Commit a previously-started transaction.
9074        TransactionId(::bytes::Bytes),
9075        /// Execute mutations in a temporary transaction. Note that unlike
9076        /// commit of a previously-started transaction, commit with a
9077        /// temporary transaction is non-idempotent. That is, if the
9078        /// `CommitRequest` is sent to Cloud Spanner more than once (for
9079        /// instance, due to retries in the application, or in the
9080        /// transport library), it's possible that the mutations are
9081        /// executed more than once. If this is undesirable, use
9082        /// [BeginTransaction][google.spanner.v1.Spanner.BeginTransaction] and
9083        /// [Commit][google.spanner.v1.Spanner.Commit] instead.
9084        ///
9085        /// [google.spanner.v1.Spanner.BeginTransaction]: crate::client::Spanner::begin_transaction
9086        /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
9087        SingleUseTransaction(std::boxed::Box<crate::model::TransactionOptions>),
9088    }
9089
9090    impl Transaction {
9091        /// Initializes the enum to the [TransactionId](Self::TransactionId) branch.
9092        pub fn from_transaction_id(value: impl std::convert::Into<::bytes::Bytes>) -> Self {
9093            Self::TransactionId(value.into())
9094        }
9095        /// Initializes the enum to the [SingleUseTransaction](Self::SingleUseTransaction) branch.
9096        pub fn from_single_use_transaction(
9097            value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
9098        ) -> Self {
9099            Self::SingleUseTransaction(value.into())
9100        }
9101    }
9102}
9103
9104/// The request for [Rollback][google.spanner.v1.Spanner.Rollback].
9105///
9106/// [google.spanner.v1.Spanner.Rollback]: crate::client::Spanner::rollback
9107#[derive(Clone, Default, PartialEq)]
9108#[non_exhaustive]
9109pub struct RollbackRequest {
9110    /// Required. The session in which the transaction to roll back is running.
9111    pub session: std::string::String,
9112
9113    /// Required. The transaction to roll back.
9114    pub transaction_id: ::bytes::Bytes,
9115
9116    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9117}
9118
9119impl RollbackRequest {
9120    /// Creates a new default instance.
9121    pub fn new() -> Self {
9122        std::default::Default::default()
9123    }
9124
9125    /// Sets the value of [session][crate::model::RollbackRequest::session].
9126    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9127        self.session = v.into();
9128        self
9129    }
9130
9131    /// Sets the value of [transaction_id][crate::model::RollbackRequest::transaction_id].
9132    pub fn set_transaction_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9133        self.transaction_id = v.into();
9134        self
9135    }
9136}
9137
9138impl wkt::message::Message for RollbackRequest {
9139    fn typename() -> &'static str {
9140        "type.googleapis.com/google.spanner.v1.RollbackRequest"
9141    }
9142}
9143
9144/// The request for [BatchWrite][google.spanner.v1.Spanner.BatchWrite].
9145///
9146/// [google.spanner.v1.Spanner.BatchWrite]: crate::client::Spanner::batch_write
9147#[derive(Clone, Default, PartialEq)]
9148#[non_exhaustive]
9149pub struct BatchWriteRequest {
9150    /// Required. The session in which the batch request is to be run.
9151    pub session: std::string::String,
9152
9153    /// Common options for this request.
9154    pub request_options: std::option::Option<crate::model::RequestOptions>,
9155
9156    /// Required. The groups of mutations to be applied.
9157    pub mutation_groups: std::vec::Vec<crate::model::batch_write_request::MutationGroup>,
9158
9159    /// Optional. If you don't set the `exclude_txn_from_change_streams` option or
9160    /// if it's set to `false`, then any change streams monitoring columns modified
9161    /// by transactions will capture the updates made within that transaction.
9162    pub exclude_txn_from_change_streams: bool,
9163
9164    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9165}
9166
9167impl BatchWriteRequest {
9168    /// Creates a new default instance.
9169    pub fn new() -> Self {
9170        std::default::Default::default()
9171    }
9172
9173    /// Sets the value of [session][crate::model::BatchWriteRequest::session].
9174    pub fn set_session<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9175        self.session = v.into();
9176        self
9177    }
9178
9179    /// Sets the value of [request_options][crate::model::BatchWriteRequest::request_options].
9180    pub fn set_request_options<T>(mut self, v: T) -> Self
9181    where
9182        T: std::convert::Into<crate::model::RequestOptions>,
9183    {
9184        self.request_options = std::option::Option::Some(v.into());
9185        self
9186    }
9187
9188    /// Sets or clears the value of [request_options][crate::model::BatchWriteRequest::request_options].
9189    pub fn set_or_clear_request_options<T>(mut self, v: std::option::Option<T>) -> Self
9190    where
9191        T: std::convert::Into<crate::model::RequestOptions>,
9192    {
9193        self.request_options = v.map(|x| x.into());
9194        self
9195    }
9196
9197    /// Sets the value of [mutation_groups][crate::model::BatchWriteRequest::mutation_groups].
9198    pub fn set_mutation_groups<T, V>(mut self, v: T) -> Self
9199    where
9200        T: std::iter::IntoIterator<Item = V>,
9201        V: std::convert::Into<crate::model::batch_write_request::MutationGroup>,
9202    {
9203        use std::iter::Iterator;
9204        self.mutation_groups = v.into_iter().map(|i| i.into()).collect();
9205        self
9206    }
9207
9208    /// Sets the value of [exclude_txn_from_change_streams][crate::model::BatchWriteRequest::exclude_txn_from_change_streams].
9209    pub fn set_exclude_txn_from_change_streams<T: std::convert::Into<bool>>(
9210        mut self,
9211        v: T,
9212    ) -> Self {
9213        self.exclude_txn_from_change_streams = v.into();
9214        self
9215    }
9216}
9217
9218impl wkt::message::Message for BatchWriteRequest {
9219    fn typename() -> &'static str {
9220        "type.googleapis.com/google.spanner.v1.BatchWriteRequest"
9221    }
9222}
9223
9224/// Defines additional types related to [BatchWriteRequest].
9225pub mod batch_write_request {
9226    #[allow(unused_imports)]
9227    use super::*;
9228
9229    /// A group of mutations to be committed together. Related mutations should be
9230    /// placed in a group. For example, two mutations inserting rows with the same
9231    /// primary key prefix in both parent and child tables are related.
9232    #[derive(Clone, Default, PartialEq)]
9233    #[non_exhaustive]
9234    pub struct MutationGroup {
9235        /// Required. The mutations in this group.
9236        pub mutations: std::vec::Vec<crate::model::Mutation>,
9237
9238        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9239    }
9240
9241    impl MutationGroup {
9242        /// Creates a new default instance.
9243        pub fn new() -> Self {
9244            std::default::Default::default()
9245        }
9246
9247        /// Sets the value of [mutations][crate::model::batch_write_request::MutationGroup::mutations].
9248        pub fn set_mutations<T, V>(mut self, v: T) -> Self
9249        where
9250            T: std::iter::IntoIterator<Item = V>,
9251            V: std::convert::Into<crate::model::Mutation>,
9252        {
9253            use std::iter::Iterator;
9254            self.mutations = v.into_iter().map(|i| i.into()).collect();
9255            self
9256        }
9257    }
9258
9259    impl wkt::message::Message for MutationGroup {
9260        fn typename() -> &'static str {
9261            "type.googleapis.com/google.spanner.v1.BatchWriteRequest.MutationGroup"
9262        }
9263    }
9264}
9265
9266/// The result of applying a batch of mutations.
9267#[derive(Clone, Default, PartialEq)]
9268#[non_exhaustive]
9269pub struct BatchWriteResponse {
9270    /// The mutation groups applied in this batch. The values index into the
9271    /// `mutation_groups` field in the corresponding `BatchWriteRequest`.
9272    pub indexes: std::vec::Vec<i32>,
9273
9274    /// An `OK` status indicates success. Any other status indicates a failure.
9275    pub status: std::option::Option<google_cloud_rpc::model::Status>,
9276
9277    /// The commit timestamp of the transaction that applied this batch.
9278    /// Present if status is OK and the mutation groups were applied, absent
9279    /// otherwise.
9280    ///
9281    /// For mutation groups with conditions, a status=OK and missing
9282    /// commit_timestamp means that the mutation groups were not applied due to the
9283    /// condition not being satisfied after evaluation.
9284    pub commit_timestamp: std::option::Option<wkt::Timestamp>,
9285
9286    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9287}
9288
9289impl BatchWriteResponse {
9290    /// Creates a new default instance.
9291    pub fn new() -> Self {
9292        std::default::Default::default()
9293    }
9294
9295    /// Sets the value of [indexes][crate::model::BatchWriteResponse::indexes].
9296    pub fn set_indexes<T, V>(mut self, v: T) -> Self
9297    where
9298        T: std::iter::IntoIterator<Item = V>,
9299        V: std::convert::Into<i32>,
9300    {
9301        use std::iter::Iterator;
9302        self.indexes = v.into_iter().map(|i| i.into()).collect();
9303        self
9304    }
9305
9306    /// Sets the value of [status][crate::model::BatchWriteResponse::status].
9307    pub fn set_status<T>(mut self, v: T) -> Self
9308    where
9309        T: std::convert::Into<google_cloud_rpc::model::Status>,
9310    {
9311        self.status = std::option::Option::Some(v.into());
9312        self
9313    }
9314
9315    /// Sets or clears the value of [status][crate::model::BatchWriteResponse::status].
9316    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
9317    where
9318        T: std::convert::Into<google_cloud_rpc::model::Status>,
9319    {
9320        self.status = v.map(|x| x.into());
9321        self
9322    }
9323
9324    /// Sets the value of [commit_timestamp][crate::model::BatchWriteResponse::commit_timestamp].
9325    pub fn set_commit_timestamp<T>(mut self, v: T) -> Self
9326    where
9327        T: std::convert::Into<wkt::Timestamp>,
9328    {
9329        self.commit_timestamp = std::option::Option::Some(v.into());
9330        self
9331    }
9332
9333    /// Sets or clears the value of [commit_timestamp][crate::model::BatchWriteResponse::commit_timestamp].
9334    pub fn set_or_clear_commit_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
9335    where
9336        T: std::convert::Into<wkt::Timestamp>,
9337    {
9338        self.commit_timestamp = v.map(|x| x.into());
9339        self
9340    }
9341}
9342
9343impl wkt::message::Message for BatchWriteResponse {
9344    fn typename() -> &'static str {
9345        "type.googleapis.com/google.spanner.v1.BatchWriteResponse"
9346    }
9347}
9348
9349/// The request for
9350/// [FetchCacheUpdate][google.spanner.v1.Spanner.FetchCacheUpdate].
9351///
9352/// [google.spanner.v1.Spanner.FetchCacheUpdate]: crate::client::Spanner::fetch_cache_update
9353#[derive(Clone, Default, PartialEq)]
9354#[non_exhaustive]
9355pub struct FetchCacheUpdateRequest {
9356    /// Required. The database for which to retrieve the cache update.
9357    pub database: std::string::String,
9358
9359    /// Optional. The maximum number of key recipes to return in the response.
9360    /// If not set, a default limit of 100 will be used.
9361    pub max_recipe_count: i32,
9362
9363    /// Optional. The maximum number of ranges to return in the response.
9364    /// If not set, a default limit of 10000 will be used.
9365    pub max_range_count: i32,
9366
9367    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9368}
9369
9370impl FetchCacheUpdateRequest {
9371    /// Creates a new default instance.
9372    pub fn new() -> Self {
9373        std::default::Default::default()
9374    }
9375
9376    /// Sets the value of [database][crate::model::FetchCacheUpdateRequest::database].
9377    pub fn set_database<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9378        self.database = v.into();
9379        self
9380    }
9381
9382    /// Sets the value of [max_recipe_count][crate::model::FetchCacheUpdateRequest::max_recipe_count].
9383    pub fn set_max_recipe_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9384        self.max_recipe_count = v.into();
9385        self
9386    }
9387
9388    /// Sets the value of [max_range_count][crate::model::FetchCacheUpdateRequest::max_range_count].
9389    pub fn set_max_range_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9390        self.max_range_count = v.into();
9391        self
9392    }
9393}
9394
9395impl wkt::message::Message for FetchCacheUpdateRequest {
9396    fn typename() -> &'static str {
9397        "type.googleapis.com/google.spanner.v1.FetchCacheUpdateRequest"
9398    }
9399}
9400
9401/// Options to use for transactions.
9402#[derive(Clone, Default, PartialEq)]
9403#[non_exhaustive]
9404pub struct TransactionOptions {
9405    /// When `exclude_txn_from_change_streams` is set to `true`, it prevents read
9406    /// or write transactions from being tracked in change streams.
9407    ///
9408    /// * If the DDL option `allow_txn_exclusion` is set to `true`, then the
9409    ///   updates
9410    ///   made within this transaction aren't recorded in the change stream.
9411    ///
9412    /// * If you don't set the DDL option `allow_txn_exclusion` or if it's
9413    ///   set to `false`, then the updates made within this transaction are
9414    ///   recorded in the change stream.
9415    ///
9416    ///
9417    /// When `exclude_txn_from_change_streams` is set to `false` or not set,
9418    /// modifications from this transaction are recorded in all change streams
9419    /// that are tracking columns modified by these transactions.
9420    ///
9421    /// The `exclude_txn_from_change_streams` option can only be specified
9422    /// for read-write or partitioned DML transactions, otherwise the API returns
9423    /// an `INVALID_ARGUMENT` error.
9424    pub exclude_txn_from_change_streams: bool,
9425
9426    /// Isolation level for the transaction.
9427    pub isolation_level: crate::model::transaction_options::IsolationLevel,
9428
9429    /// Required. The type of transaction.
9430    pub mode: std::option::Option<crate::model::transaction_options::Mode>,
9431
9432    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9433}
9434
9435impl TransactionOptions {
9436    /// Creates a new default instance.
9437    pub fn new() -> Self {
9438        std::default::Default::default()
9439    }
9440
9441    /// Sets the value of [exclude_txn_from_change_streams][crate::model::TransactionOptions::exclude_txn_from_change_streams].
9442    pub fn set_exclude_txn_from_change_streams<T: std::convert::Into<bool>>(
9443        mut self,
9444        v: T,
9445    ) -> Self {
9446        self.exclude_txn_from_change_streams = v.into();
9447        self
9448    }
9449
9450    /// Sets the value of [isolation_level][crate::model::TransactionOptions::isolation_level].
9451    pub fn set_isolation_level<
9452        T: std::convert::Into<crate::model::transaction_options::IsolationLevel>,
9453    >(
9454        mut self,
9455        v: T,
9456    ) -> Self {
9457        self.isolation_level = v.into();
9458        self
9459    }
9460
9461    /// Sets the value of [mode][crate::model::TransactionOptions::mode].
9462    ///
9463    /// Note that all the setters affecting `mode` are mutually
9464    /// exclusive.
9465    pub fn set_mode<
9466        T: std::convert::Into<std::option::Option<crate::model::transaction_options::Mode>>,
9467    >(
9468        mut self,
9469        v: T,
9470    ) -> Self {
9471        self.mode = v.into();
9472        self
9473    }
9474
9475    /// The value of [mode][crate::model::TransactionOptions::mode]
9476    /// if it holds a `ReadWrite`, `None` if the field is not set or
9477    /// holds a different branch.
9478    pub fn read_write(
9479        &self,
9480    ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::ReadWrite>> {
9481        #[allow(unreachable_patterns)]
9482        self.mode.as_ref().and_then(|v| match v {
9483            crate::model::transaction_options::Mode::ReadWrite(v) => std::option::Option::Some(v),
9484            _ => std::option::Option::None,
9485        })
9486    }
9487
9488    /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9489    /// to hold a `ReadWrite`.
9490    ///
9491    /// Note that all the setters affecting `mode` are
9492    /// mutually exclusive.
9493    pub fn set_read_write<
9494        T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadWrite>>,
9495    >(
9496        mut self,
9497        v: T,
9498    ) -> Self {
9499        self.mode =
9500            std::option::Option::Some(crate::model::transaction_options::Mode::ReadWrite(v.into()));
9501        self
9502    }
9503
9504    /// The value of [mode][crate::model::TransactionOptions::mode]
9505    /// if it holds a `PartitionedDml`, `None` if the field is not set or
9506    /// holds a different branch.
9507    pub fn partitioned_dml(
9508        &self,
9509    ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::PartitionedDml>>
9510    {
9511        #[allow(unreachable_patterns)]
9512        self.mode.as_ref().and_then(|v| match v {
9513            crate::model::transaction_options::Mode::PartitionedDml(v) => {
9514                std::option::Option::Some(v)
9515            }
9516            _ => std::option::Option::None,
9517        })
9518    }
9519
9520    /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9521    /// to hold a `PartitionedDml`.
9522    ///
9523    /// Note that all the setters affecting `mode` are
9524    /// mutually exclusive.
9525    pub fn set_partitioned_dml<
9526        T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::PartitionedDml>>,
9527    >(
9528        mut self,
9529        v: T,
9530    ) -> Self {
9531        self.mode = std::option::Option::Some(
9532            crate::model::transaction_options::Mode::PartitionedDml(v.into()),
9533        );
9534        self
9535    }
9536
9537    /// The value of [mode][crate::model::TransactionOptions::mode]
9538    /// if it holds a `ReadOnly`, `None` if the field is not set or
9539    /// holds a different branch.
9540    pub fn read_only(
9541        &self,
9542    ) -> std::option::Option<&std::boxed::Box<crate::model::transaction_options::ReadOnly>> {
9543        #[allow(unreachable_patterns)]
9544        self.mode.as_ref().and_then(|v| match v {
9545            crate::model::transaction_options::Mode::ReadOnly(v) => std::option::Option::Some(v),
9546            _ => std::option::Option::None,
9547        })
9548    }
9549
9550    /// Sets the value of [mode][crate::model::TransactionOptions::mode]
9551    /// to hold a `ReadOnly`.
9552    ///
9553    /// Note that all the setters affecting `mode` are
9554    /// mutually exclusive.
9555    pub fn set_read_only<
9556        T: std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadOnly>>,
9557    >(
9558        mut self,
9559        v: T,
9560    ) -> Self {
9561        self.mode =
9562            std::option::Option::Some(crate::model::transaction_options::Mode::ReadOnly(v.into()));
9563        self
9564    }
9565}
9566
9567impl wkt::message::Message for TransactionOptions {
9568    fn typename() -> &'static str {
9569        "type.googleapis.com/google.spanner.v1.TransactionOptions"
9570    }
9571}
9572
9573/// Defines additional types related to [TransactionOptions].
9574pub mod transaction_options {
9575    #[allow(unused_imports)]
9576    use super::*;
9577
9578    /// Message type to initiate a read-write transaction. Currently this
9579    /// transaction type has no options.
9580    #[derive(Clone, Default, PartialEq)]
9581    #[non_exhaustive]
9582    pub struct ReadWrite {
9583        /// Read lock mode for the transaction.
9584        pub read_lock_mode: crate::model::transaction_options::read_write::ReadLockMode,
9585
9586        /// Optional. Clients should pass the transaction ID of the previous
9587        /// transaction attempt that was aborted if this transaction is being
9588        /// executed on a multiplexed session.
9589        pub multiplexed_session_previous_transaction_id: ::bytes::Bytes,
9590
9591        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9592    }
9593
9594    impl ReadWrite {
9595        /// Creates a new default instance.
9596        pub fn new() -> Self {
9597            std::default::Default::default()
9598        }
9599
9600        /// Sets the value of [read_lock_mode][crate::model::transaction_options::ReadWrite::read_lock_mode].
9601        pub fn set_read_lock_mode<
9602            T: std::convert::Into<crate::model::transaction_options::read_write::ReadLockMode>,
9603        >(
9604            mut self,
9605            v: T,
9606        ) -> Self {
9607            self.read_lock_mode = v.into();
9608            self
9609        }
9610
9611        /// Sets the value of [multiplexed_session_previous_transaction_id][crate::model::transaction_options::ReadWrite::multiplexed_session_previous_transaction_id].
9612        pub fn set_multiplexed_session_previous_transaction_id<
9613            T: std::convert::Into<::bytes::Bytes>,
9614        >(
9615            mut self,
9616            v: T,
9617        ) -> Self {
9618            self.multiplexed_session_previous_transaction_id = v.into();
9619            self
9620        }
9621    }
9622
9623    impl wkt::message::Message for ReadWrite {
9624        fn typename() -> &'static str {
9625            "type.googleapis.com/google.spanner.v1.TransactionOptions.ReadWrite"
9626        }
9627    }
9628
9629    /// Defines additional types related to [ReadWrite].
9630    pub mod read_write {
9631        #[allow(unused_imports)]
9632        use super::*;
9633
9634        /// `ReadLockMode` is used to set the read lock mode for read-write
9635        /// transactions.
9636        ///
9637        /// # Working with unknown values
9638        ///
9639        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9640        /// additional enum variants at any time. Adding new variants is not considered
9641        /// a breaking change. Applications should write their code in anticipation of:
9642        ///
9643        /// - New values appearing in future releases of the client library, **and**
9644        /// - New values received dynamically, without application changes.
9645        ///
9646        /// Please consult the [Working with enums] section in the user guide for some
9647        /// guidelines.
9648        ///
9649        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9650        #[derive(Clone, Debug, PartialEq)]
9651        #[non_exhaustive]
9652        pub enum ReadLockMode {
9653            /// Default value.
9654            ///
9655            /// * If isolation level is
9656            ///   [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE],
9657            ///   locking semantics default to `PESSIMISTIC`.
9658            /// * If isolation level is
9659            ///   [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ],
9660            ///   locking semantics default to `OPTIMISTIC`.
9661            /// * See
9662            ///   [Concurrency
9663            ///   control](https://cloud.google.com/spanner/docs/concurrency-control)
9664            ///   for more details.
9665            ///
9666            /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9667            /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9668            Unspecified,
9669            /// Pessimistic lock mode.
9670            ///
9671            /// Lock acquisition behavior depends on the isolation level in use. In
9672            /// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]
9673            /// isolation, reads and writes acquire necessary locks during transaction
9674            /// statement execution. In
9675            /// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]
9676            /// isolation, reads that explicitly request to be locked and writes
9677            /// acquire locks.
9678            /// See
9679            /// [Concurrency
9680            /// control](https://cloud.google.com/spanner/docs/concurrency-control) for
9681            /// details on the types of locks acquired at each transaction step.
9682            ///
9683            /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9684            /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9685            Pessimistic,
9686            /// Optimistic lock mode.
9687            ///
9688            /// Lock acquisition behavior depends on the isolation level in use. In
9689            /// both
9690            /// [SERIALIZABLE][google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]
9691            /// and
9692            /// [REPEATABLE_READ][google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]
9693            /// isolation, reads and writes do not acquire locks during transaction
9694            /// statement execution.
9695            /// See
9696            /// [Concurrency
9697            /// control](https://cloud.google.com/spanner/docs/concurrency-control) for
9698            /// details on how the guarantees of each isolation level are provided at
9699            /// commit time.
9700            ///
9701            /// [google.spanner.v1.TransactionOptions.IsolationLevel.REPEATABLE_READ]: crate::model::transaction_options::IsolationLevel::RepeatableRead
9702            /// [google.spanner.v1.TransactionOptions.IsolationLevel.SERIALIZABLE]: crate::model::transaction_options::IsolationLevel::Serializable
9703            Optimistic,
9704            /// If set, the enum was initialized with an unknown value.
9705            ///
9706            /// Applications can examine the value using [ReadLockMode::value] or
9707            /// [ReadLockMode::name].
9708            UnknownValue(read_lock_mode::UnknownValue),
9709        }
9710
9711        #[doc(hidden)]
9712        pub mod read_lock_mode {
9713            #[allow(unused_imports)]
9714            use super::*;
9715            #[derive(Clone, Debug, PartialEq)]
9716            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9717        }
9718
9719        impl ReadLockMode {
9720            /// Gets the enum value.
9721            ///
9722            /// Returns `None` if the enum contains an unknown value deserialized from
9723            /// the string representation of enums.
9724            pub fn value(&self) -> std::option::Option<i32> {
9725                match self {
9726                    Self::Unspecified => std::option::Option::Some(0),
9727                    Self::Pessimistic => std::option::Option::Some(1),
9728                    Self::Optimistic => std::option::Option::Some(2),
9729                    Self::UnknownValue(u) => u.0.value(),
9730                }
9731            }
9732
9733            /// Gets the enum value as a string.
9734            ///
9735            /// Returns `None` if the enum contains an unknown value deserialized from
9736            /// the integer representation of enums.
9737            pub fn name(&self) -> std::option::Option<&str> {
9738                match self {
9739                    Self::Unspecified => std::option::Option::Some("READ_LOCK_MODE_UNSPECIFIED"),
9740                    Self::Pessimistic => std::option::Option::Some("PESSIMISTIC"),
9741                    Self::Optimistic => std::option::Option::Some("OPTIMISTIC"),
9742                    Self::UnknownValue(u) => u.0.name(),
9743                }
9744            }
9745        }
9746
9747        impl std::default::Default for ReadLockMode {
9748            fn default() -> Self {
9749                use std::convert::From;
9750                Self::from(0)
9751            }
9752        }
9753
9754        impl std::fmt::Display for ReadLockMode {
9755            fn fmt(
9756                &self,
9757                f: &mut std::fmt::Formatter<'_>,
9758            ) -> std::result::Result<(), std::fmt::Error> {
9759                wkt::internal::display_enum(f, self.name(), self.value())
9760            }
9761        }
9762
9763        impl std::convert::From<i32> for ReadLockMode {
9764            fn from(value: i32) -> Self {
9765                match value {
9766                    0 => Self::Unspecified,
9767                    1 => Self::Pessimistic,
9768                    2 => Self::Optimistic,
9769                    _ => Self::UnknownValue(read_lock_mode::UnknownValue(
9770                        wkt::internal::UnknownEnumValue::Integer(value),
9771                    )),
9772                }
9773            }
9774        }
9775
9776        impl std::convert::From<&str> for ReadLockMode {
9777            fn from(value: &str) -> Self {
9778                use std::string::ToString;
9779                match value {
9780                    "READ_LOCK_MODE_UNSPECIFIED" => Self::Unspecified,
9781                    "PESSIMISTIC" => Self::Pessimistic,
9782                    "OPTIMISTIC" => Self::Optimistic,
9783                    _ => Self::UnknownValue(read_lock_mode::UnknownValue(
9784                        wkt::internal::UnknownEnumValue::String(value.to_string()),
9785                    )),
9786                }
9787            }
9788        }
9789
9790        impl serde::ser::Serialize for ReadLockMode {
9791            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9792            where
9793                S: serde::Serializer,
9794            {
9795                match self {
9796                    Self::Unspecified => serializer.serialize_i32(0),
9797                    Self::Pessimistic => serializer.serialize_i32(1),
9798                    Self::Optimistic => serializer.serialize_i32(2),
9799                    Self::UnknownValue(u) => u.0.serialize(serializer),
9800                }
9801            }
9802        }
9803
9804        impl<'de> serde::de::Deserialize<'de> for ReadLockMode {
9805            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9806            where
9807                D: serde::Deserializer<'de>,
9808            {
9809                deserializer.deserialize_any(wkt::internal::EnumVisitor::<ReadLockMode>::new(
9810                    ".google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode",
9811                ))
9812            }
9813        }
9814    }
9815
9816    /// Message type to initiate a Partitioned DML transaction.
9817    #[derive(Clone, Default, PartialEq)]
9818    #[non_exhaustive]
9819    pub struct PartitionedDml {
9820        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9821    }
9822
9823    impl PartitionedDml {
9824        /// Creates a new default instance.
9825        pub fn new() -> Self {
9826            std::default::Default::default()
9827        }
9828    }
9829
9830    impl wkt::message::Message for PartitionedDml {
9831        fn typename() -> &'static str {
9832            "type.googleapis.com/google.spanner.v1.TransactionOptions.PartitionedDml"
9833        }
9834    }
9835
9836    /// Message type to initiate a read-only transaction.
9837    #[derive(Clone, Default, PartialEq)]
9838    #[non_exhaustive]
9839    pub struct ReadOnly {
9840        /// If true, the Cloud Spanner-selected read timestamp is included in
9841        /// the [Transaction][google.spanner.v1.Transaction] message that describes
9842        /// the transaction.
9843        ///
9844        /// [google.spanner.v1.Transaction]: crate::model::Transaction
9845        pub return_read_timestamp: bool,
9846
9847        /// How to choose the timestamp for the read-only transaction.
9848        pub timestamp_bound:
9849            std::option::Option<crate::model::transaction_options::read_only::TimestampBound>,
9850
9851        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9852    }
9853
9854    impl ReadOnly {
9855        /// Creates a new default instance.
9856        pub fn new() -> Self {
9857            std::default::Default::default()
9858        }
9859
9860        /// Sets the value of [return_read_timestamp][crate::model::transaction_options::ReadOnly::return_read_timestamp].
9861        pub fn set_return_read_timestamp<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9862            self.return_read_timestamp = v.into();
9863            self
9864        }
9865
9866        /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound].
9867        ///
9868        /// Note that all the setters affecting `timestamp_bound` are mutually
9869        /// exclusive.
9870        pub fn set_timestamp_bound<
9871            T: std::convert::Into<
9872                    std::option::Option<
9873                        crate::model::transaction_options::read_only::TimestampBound,
9874                    >,
9875                >,
9876        >(
9877            mut self,
9878            v: T,
9879        ) -> Self {
9880            self.timestamp_bound = v.into();
9881            self
9882        }
9883
9884        /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9885        /// if it holds a `Strong`, `None` if the field is not set or
9886        /// holds a different branch.
9887        pub fn strong(&self) -> std::option::Option<&bool> {
9888            #[allow(unreachable_patterns)]
9889            self.timestamp_bound.as_ref().and_then(|v| match v {
9890                crate::model::transaction_options::read_only::TimestampBound::Strong(v) => {
9891                    std::option::Option::Some(v)
9892                }
9893                _ => std::option::Option::None,
9894            })
9895        }
9896
9897        /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9898        /// to hold a `Strong`.
9899        ///
9900        /// Note that all the setters affecting `timestamp_bound` are
9901        /// mutually exclusive.
9902        pub fn set_strong<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
9903            self.timestamp_bound = std::option::Option::Some(
9904                crate::model::transaction_options::read_only::TimestampBound::Strong(v.into()),
9905            );
9906            self
9907        }
9908
9909        /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9910        /// if it holds a `MinReadTimestamp`, `None` if the field is not set or
9911        /// holds a different branch.
9912        pub fn min_read_timestamp(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
9913            #[allow(unreachable_patterns)]
9914            self.timestamp_bound.as_ref().and_then(|v| match v {
9915                crate::model::transaction_options::read_only::TimestampBound::MinReadTimestamp(
9916                    v,
9917                ) => std::option::Option::Some(v),
9918                _ => std::option::Option::None,
9919            })
9920        }
9921
9922        /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9923        /// to hold a `MinReadTimestamp`.
9924        ///
9925        /// Note that all the setters affecting `timestamp_bound` are
9926        /// mutually exclusive.
9927        pub fn set_min_read_timestamp<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
9928            mut self,
9929            v: T,
9930        ) -> Self {
9931            self.timestamp_bound = std::option::Option::Some(
9932                crate::model::transaction_options::read_only::TimestampBound::MinReadTimestamp(
9933                    v.into(),
9934                ),
9935            );
9936            self
9937        }
9938
9939        /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9940        /// if it holds a `MaxStaleness`, `None` if the field is not set or
9941        /// holds a different branch.
9942        pub fn max_staleness(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
9943            #[allow(unreachable_patterns)]
9944            self.timestamp_bound.as_ref().and_then(|v| match v {
9945                crate::model::transaction_options::read_only::TimestampBound::MaxStaleness(v) => {
9946                    std::option::Option::Some(v)
9947                }
9948                _ => std::option::Option::None,
9949            })
9950        }
9951
9952        /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9953        /// to hold a `MaxStaleness`.
9954        ///
9955        /// Note that all the setters affecting `timestamp_bound` are
9956        /// mutually exclusive.
9957        pub fn set_max_staleness<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
9958            mut self,
9959            v: T,
9960        ) -> Self {
9961            self.timestamp_bound = std::option::Option::Some(
9962                crate::model::transaction_options::read_only::TimestampBound::MaxStaleness(
9963                    v.into(),
9964                ),
9965            );
9966            self
9967        }
9968
9969        /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9970        /// if it holds a `ReadTimestamp`, `None` if the field is not set or
9971        /// holds a different branch.
9972        pub fn read_timestamp(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
9973            #[allow(unreachable_patterns)]
9974            self.timestamp_bound.as_ref().and_then(|v| match v {
9975                crate::model::transaction_options::read_only::TimestampBound::ReadTimestamp(v) => {
9976                    std::option::Option::Some(v)
9977                }
9978                _ => std::option::Option::None,
9979            })
9980        }
9981
9982        /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
9983        /// to hold a `ReadTimestamp`.
9984        ///
9985        /// Note that all the setters affecting `timestamp_bound` are
9986        /// mutually exclusive.
9987        pub fn set_read_timestamp<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
9988            mut self,
9989            v: T,
9990        ) -> Self {
9991            self.timestamp_bound = std::option::Option::Some(
9992                crate::model::transaction_options::read_only::TimestampBound::ReadTimestamp(
9993                    v.into(),
9994                ),
9995            );
9996            self
9997        }
9998
9999        /// The value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
10000        /// if it holds a `ExactStaleness`, `None` if the field is not set or
10001        /// holds a different branch.
10002        pub fn exact_staleness(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
10003            #[allow(unreachable_patterns)]
10004            self.timestamp_bound.as_ref().and_then(|v| match v {
10005                crate::model::transaction_options::read_only::TimestampBound::ExactStaleness(v) => {
10006                    std::option::Option::Some(v)
10007                }
10008                _ => std::option::Option::None,
10009            })
10010        }
10011
10012        /// Sets the value of [timestamp_bound][crate::model::transaction_options::ReadOnly::timestamp_bound]
10013        /// to hold a `ExactStaleness`.
10014        ///
10015        /// Note that all the setters affecting `timestamp_bound` are
10016        /// mutually exclusive.
10017        pub fn set_exact_staleness<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
10018            mut self,
10019            v: T,
10020        ) -> Self {
10021            self.timestamp_bound = std::option::Option::Some(
10022                crate::model::transaction_options::read_only::TimestampBound::ExactStaleness(
10023                    v.into(),
10024                ),
10025            );
10026            self
10027        }
10028    }
10029
10030    impl wkt::message::Message for ReadOnly {
10031        fn typename() -> &'static str {
10032            "type.googleapis.com/google.spanner.v1.TransactionOptions.ReadOnly"
10033        }
10034    }
10035
10036    /// Defines additional types related to [ReadOnly].
10037    pub mod read_only {
10038        #[allow(unused_imports)]
10039        use super::*;
10040
10041        /// How to choose the timestamp for the read-only transaction.
10042        #[derive(Clone, Debug, PartialEq)]
10043        #[non_exhaustive]
10044        pub enum TimestampBound {
10045            /// Read at a timestamp where all previously committed transactions
10046            /// are visible.
10047            Strong(bool),
10048            /// Executes all reads at a timestamp >= `min_read_timestamp`.
10049            ///
10050            /// This is useful for requesting fresher data than some previous
10051            /// read, or data that is fresh enough to observe the effects of some
10052            /// previously committed transaction whose timestamp is known.
10053            ///
10054            /// Note that this option can only be used in single-use transactions.
10055            ///
10056            /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10057            /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10058            MinReadTimestamp(std::boxed::Box<wkt::Timestamp>),
10059            /// Read data at a timestamp >= `NOW - max_staleness`
10060            /// seconds. Guarantees that all writes that have committed more
10061            /// than the specified number of seconds ago are visible. Because
10062            /// Cloud Spanner chooses the exact timestamp, this mode works even if
10063            /// the client's local clock is substantially skewed from Cloud Spanner
10064            /// commit timestamps.
10065            ///
10066            /// Useful for reading the freshest data available at a nearby
10067            /// replica, while bounding the possible staleness if the local
10068            /// replica has fallen behind.
10069            ///
10070            /// Note that this option can only be used in single-use
10071            /// transactions.
10072            MaxStaleness(std::boxed::Box<wkt::Duration>),
10073            /// Executes all reads at the given timestamp. Unlike other modes,
10074            /// reads at a specific timestamp are repeatable; the same read at
10075            /// the same timestamp always returns the same data. If the
10076            /// timestamp is in the future, the read is blocked until the
10077            /// specified timestamp, modulo the read's deadline.
10078            ///
10079            /// Useful for large scale consistent reads such as mapreduces, or
10080            /// for coordinating many reads against a consistent snapshot of the
10081            /// data.
10082            ///
10083            /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10084            /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10085            ReadTimestamp(std::boxed::Box<wkt::Timestamp>),
10086            /// Executes all reads at a timestamp that is `exact_staleness`
10087            /// old. The timestamp is chosen soon after the read is started.
10088            ///
10089            /// Guarantees that all writes that have committed more than the
10090            /// specified number of seconds ago are visible. Because Cloud Spanner
10091            /// chooses the exact timestamp, this mode works even if the client's
10092            /// local clock is substantially skewed from Cloud Spanner commit
10093            /// timestamps.
10094            ///
10095            /// Useful for reading at nearby replicas without the distributed
10096            /// timestamp negotiation overhead of `max_staleness`.
10097            ExactStaleness(std::boxed::Box<wkt::Duration>),
10098        }
10099
10100        impl TimestampBound {
10101            /// Initializes the enum to the [Strong](Self::Strong) branch.
10102            pub fn from_strong(value: impl std::convert::Into<bool>) -> Self {
10103                Self::Strong(value.into())
10104            }
10105            /// Initializes the enum to the [MinReadTimestamp](Self::MinReadTimestamp) branch.
10106            pub fn from_min_read_timestamp(
10107                value: impl std::convert::Into<std::boxed::Box<wkt::Timestamp>>,
10108            ) -> Self {
10109                Self::MinReadTimestamp(value.into())
10110            }
10111            /// Initializes the enum to the [MaxStaleness](Self::MaxStaleness) branch.
10112            pub fn from_max_staleness(
10113                value: impl std::convert::Into<std::boxed::Box<wkt::Duration>>,
10114            ) -> Self {
10115                Self::MaxStaleness(value.into())
10116            }
10117            /// Initializes the enum to the [ReadTimestamp](Self::ReadTimestamp) branch.
10118            pub fn from_read_timestamp(
10119                value: impl std::convert::Into<std::boxed::Box<wkt::Timestamp>>,
10120            ) -> Self {
10121                Self::ReadTimestamp(value.into())
10122            }
10123            /// Initializes the enum to the [ExactStaleness](Self::ExactStaleness) branch.
10124            pub fn from_exact_staleness(
10125                value: impl std::convert::Into<std::boxed::Box<wkt::Duration>>,
10126            ) -> Self {
10127                Self::ExactStaleness(value.into())
10128            }
10129        }
10130    }
10131
10132    /// `IsolationLevel` is used when setting the [isolation
10133    /// level](https://cloud.google.com/spanner/docs/isolation-levels) for a
10134    /// transaction.
10135    ///
10136    /// # Working with unknown values
10137    ///
10138    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10139    /// additional enum variants at any time. Adding new variants is not considered
10140    /// a breaking change. Applications should write their code in anticipation of:
10141    ///
10142    /// - New values appearing in future releases of the client library, **and**
10143    /// - New values received dynamically, without application changes.
10144    ///
10145    /// Please consult the [Working with enums] section in the user guide for some
10146    /// guidelines.
10147    ///
10148    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10149    #[derive(Clone, Debug, PartialEq)]
10150    #[non_exhaustive]
10151    pub enum IsolationLevel {
10152        /// Default value.
10153        ///
10154        /// If the value is not specified, the `SERIALIZABLE` isolation level is
10155        /// used.
10156        Unspecified,
10157        /// All transactions appear as if they executed in a serial order, even if
10158        /// some of the reads, writes, and other operations of distinct transactions
10159        /// actually occurred in parallel. Spanner assigns commit timestamps that
10160        /// reflect the order of committed transactions to implement this property.
10161        /// Spanner offers a stronger guarantee than serializability called external
10162        /// consistency. For more information, see
10163        /// [TrueTime and external
10164        /// consistency](https://cloud.google.com/spanner/docs/true-time-external-consistency#serializability).
10165        Serializable,
10166        /// All reads performed during the transaction observe a consistent snapshot
10167        /// of the database, and the transaction is only successfully committed in
10168        /// the absence of conflicts between its updates and any concurrent updates
10169        /// that have occurred since that snapshot. Consequently, in contrast to
10170        /// `SERIALIZABLE` transactions, only write-write conflicts are detected in
10171        /// snapshot transactions.
10172        ///
10173        /// This isolation level does not support read-only and partitioned DML
10174        /// transactions.
10175        ///
10176        /// When `REPEATABLE_READ` is specified on a read-write transaction, the
10177        /// locking semantics default to `OPTIMISTIC`.
10178        RepeatableRead,
10179        /// If set, the enum was initialized with an unknown value.
10180        ///
10181        /// Applications can examine the value using [IsolationLevel::value] or
10182        /// [IsolationLevel::name].
10183        UnknownValue(isolation_level::UnknownValue),
10184    }
10185
10186    #[doc(hidden)]
10187    pub mod isolation_level {
10188        #[allow(unused_imports)]
10189        use super::*;
10190        #[derive(Clone, Debug, PartialEq)]
10191        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10192    }
10193
10194    impl IsolationLevel {
10195        /// Gets the enum value.
10196        ///
10197        /// Returns `None` if the enum contains an unknown value deserialized from
10198        /// the string representation of enums.
10199        pub fn value(&self) -> std::option::Option<i32> {
10200            match self {
10201                Self::Unspecified => std::option::Option::Some(0),
10202                Self::Serializable => std::option::Option::Some(1),
10203                Self::RepeatableRead => std::option::Option::Some(2),
10204                Self::UnknownValue(u) => u.0.value(),
10205            }
10206        }
10207
10208        /// Gets the enum value as a string.
10209        ///
10210        /// Returns `None` if the enum contains an unknown value deserialized from
10211        /// the integer representation of enums.
10212        pub fn name(&self) -> std::option::Option<&str> {
10213            match self {
10214                Self::Unspecified => std::option::Option::Some("ISOLATION_LEVEL_UNSPECIFIED"),
10215                Self::Serializable => std::option::Option::Some("SERIALIZABLE"),
10216                Self::RepeatableRead => std::option::Option::Some("REPEATABLE_READ"),
10217                Self::UnknownValue(u) => u.0.name(),
10218            }
10219        }
10220    }
10221
10222    impl std::default::Default for IsolationLevel {
10223        fn default() -> Self {
10224            use std::convert::From;
10225            Self::from(0)
10226        }
10227    }
10228
10229    impl std::fmt::Display for IsolationLevel {
10230        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10231            wkt::internal::display_enum(f, self.name(), self.value())
10232        }
10233    }
10234
10235    impl std::convert::From<i32> for IsolationLevel {
10236        fn from(value: i32) -> Self {
10237            match value {
10238                0 => Self::Unspecified,
10239                1 => Self::Serializable,
10240                2 => Self::RepeatableRead,
10241                _ => Self::UnknownValue(isolation_level::UnknownValue(
10242                    wkt::internal::UnknownEnumValue::Integer(value),
10243                )),
10244            }
10245        }
10246    }
10247
10248    impl std::convert::From<&str> for IsolationLevel {
10249        fn from(value: &str) -> Self {
10250            use std::string::ToString;
10251            match value {
10252                "ISOLATION_LEVEL_UNSPECIFIED" => Self::Unspecified,
10253                "SERIALIZABLE" => Self::Serializable,
10254                "REPEATABLE_READ" => Self::RepeatableRead,
10255                _ => Self::UnknownValue(isolation_level::UnknownValue(
10256                    wkt::internal::UnknownEnumValue::String(value.to_string()),
10257                )),
10258            }
10259        }
10260    }
10261
10262    impl serde::ser::Serialize for IsolationLevel {
10263        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10264        where
10265            S: serde::Serializer,
10266        {
10267            match self {
10268                Self::Unspecified => serializer.serialize_i32(0),
10269                Self::Serializable => serializer.serialize_i32(1),
10270                Self::RepeatableRead => serializer.serialize_i32(2),
10271                Self::UnknownValue(u) => u.0.serialize(serializer),
10272            }
10273        }
10274    }
10275
10276    impl<'de> serde::de::Deserialize<'de> for IsolationLevel {
10277        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10278        where
10279            D: serde::Deserializer<'de>,
10280        {
10281            deserializer.deserialize_any(wkt::internal::EnumVisitor::<IsolationLevel>::new(
10282                ".google.spanner.v1.TransactionOptions.IsolationLevel",
10283            ))
10284        }
10285    }
10286
10287    /// Required. The type of transaction.
10288    #[derive(Clone, Debug, PartialEq)]
10289    #[non_exhaustive]
10290    pub enum Mode {
10291        /// Transaction may write.
10292        ///
10293        /// Authorization to begin a read-write transaction requires
10294        /// `spanner.databases.beginOrRollbackReadWriteTransaction` permission
10295        /// on the `session` resource.
10296        ReadWrite(std::boxed::Box<crate::model::transaction_options::ReadWrite>),
10297        /// Partitioned DML transaction.
10298        ///
10299        /// Authorization to begin a Partitioned DML transaction requires
10300        /// `spanner.databases.beginPartitionedDmlTransaction` permission
10301        /// on the `session` resource.
10302        PartitionedDml(std::boxed::Box<crate::model::transaction_options::PartitionedDml>),
10303        /// Transaction does not write.
10304        ///
10305        /// Authorization to begin a read-only transaction requires
10306        /// `spanner.databases.beginReadOnlyTransaction` permission
10307        /// on the `session` resource.
10308        ReadOnly(std::boxed::Box<crate::model::transaction_options::ReadOnly>),
10309    }
10310
10311    impl Mode {
10312        /// Initializes the enum to the [ReadWrite](Self::ReadWrite) branch.
10313        pub fn from_read_write(
10314            value: impl std::convert::Into<
10315                std::boxed::Box<crate::model::transaction_options::ReadWrite>,
10316            >,
10317        ) -> Self {
10318            Self::ReadWrite(value.into())
10319        }
10320        /// Initializes the enum to the [PartitionedDml](Self::PartitionedDml) branch.
10321        pub fn from_partitioned_dml(
10322            value: impl std::convert::Into<
10323                std::boxed::Box<crate::model::transaction_options::PartitionedDml>,
10324            >,
10325        ) -> Self {
10326            Self::PartitionedDml(value.into())
10327        }
10328        /// Initializes the enum to the [ReadOnly](Self::ReadOnly) branch.
10329        pub fn from_read_only(
10330            value: impl std::convert::Into<std::boxed::Box<crate::model::transaction_options::ReadOnly>>,
10331        ) -> Self {
10332            Self::ReadOnly(value.into())
10333        }
10334    }
10335}
10336
10337/// A transaction.
10338#[derive(Clone, Default, PartialEq)]
10339#[non_exhaustive]
10340pub struct Transaction {
10341    /// `id` may be used to identify the transaction in subsequent
10342    /// [Read][google.spanner.v1.Spanner.Read],
10343    /// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql],
10344    /// [Commit][google.spanner.v1.Spanner.Commit], or
10345    /// [Rollback][google.spanner.v1.Spanner.Rollback] calls.
10346    ///
10347    /// Single-use read-only transactions do not have IDs, because
10348    /// single-use transactions do not support multiple requests.
10349    ///
10350    /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
10351    /// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
10352    /// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
10353    /// [google.spanner.v1.Spanner.Rollback]: crate::client::Spanner::rollback
10354    pub id: ::bytes::Bytes,
10355
10356    /// For snapshot read-only transactions, the read timestamp chosen
10357    /// for the transaction. Not returned by default: see
10358    /// [TransactionOptions.ReadOnly.return_read_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp].
10359    ///
10360    /// A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
10361    /// Example: `"2014-10-02T15:01:23.045123456Z"`.
10362    ///
10363    /// [google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp]: crate::model::transaction_options::ReadOnly::return_read_timestamp
10364    pub read_timestamp: std::option::Option<wkt::Timestamp>,
10365
10366    /// A precommit token is included in the response of a BeginTransaction
10367    /// request if the read-write transaction is on a multiplexed session and
10368    /// a mutation_key was specified in the
10369    /// [BeginTransaction][google.spanner.v1.BeginTransactionRequest].
10370    /// The precommit token with the highest sequence number from this transaction
10371    /// attempt should be passed to the [Commit][google.spanner.v1.Spanner.Commit]
10372    /// request for this transaction.
10373    ///
10374    /// [google.spanner.v1.BeginTransactionRequest]: crate::model::BeginTransactionRequest
10375    /// [google.spanner.v1.Spanner.Commit]: crate::client::Spanner::commit
10376    pub precommit_token: std::option::Option<crate::model::MultiplexedSessionPrecommitToken>,
10377
10378    /// Optional. A cache update expresses a set of changes the client should
10379    /// incorporate into its location cache. The client should discard the changes
10380    /// if they are older than the data it already has. This data can be obtained
10381    /// in response to requests that included a `RoutingHint` field, but may also
10382    /// be obtained by explicit location-fetching RPCs which may be added in the
10383    /// future.
10384    pub cache_update: std::option::Option<crate::model::CacheUpdate>,
10385
10386    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10387}
10388
10389impl Transaction {
10390    /// Creates a new default instance.
10391    pub fn new() -> Self {
10392        std::default::Default::default()
10393    }
10394
10395    /// Sets the value of [id][crate::model::Transaction::id].
10396    pub fn set_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10397        self.id = v.into();
10398        self
10399    }
10400
10401    /// Sets the value of [read_timestamp][crate::model::Transaction::read_timestamp].
10402    pub fn set_read_timestamp<T>(mut self, v: T) -> Self
10403    where
10404        T: std::convert::Into<wkt::Timestamp>,
10405    {
10406        self.read_timestamp = std::option::Option::Some(v.into());
10407        self
10408    }
10409
10410    /// Sets or clears the value of [read_timestamp][crate::model::Transaction::read_timestamp].
10411    pub fn set_or_clear_read_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
10412    where
10413        T: std::convert::Into<wkt::Timestamp>,
10414    {
10415        self.read_timestamp = v.map(|x| x.into());
10416        self
10417    }
10418
10419    /// Sets the value of [precommit_token][crate::model::Transaction::precommit_token].
10420    pub fn set_precommit_token<T>(mut self, v: T) -> Self
10421    where
10422        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
10423    {
10424        self.precommit_token = std::option::Option::Some(v.into());
10425        self
10426    }
10427
10428    /// Sets or clears the value of [precommit_token][crate::model::Transaction::precommit_token].
10429    pub fn set_or_clear_precommit_token<T>(mut self, v: std::option::Option<T>) -> Self
10430    where
10431        T: std::convert::Into<crate::model::MultiplexedSessionPrecommitToken>,
10432    {
10433        self.precommit_token = v.map(|x| x.into());
10434        self
10435    }
10436
10437    /// Sets the value of [cache_update][crate::model::Transaction::cache_update].
10438    pub fn set_cache_update<T>(mut self, v: T) -> Self
10439    where
10440        T: std::convert::Into<crate::model::CacheUpdate>,
10441    {
10442        self.cache_update = std::option::Option::Some(v.into());
10443        self
10444    }
10445
10446    /// Sets or clears the value of [cache_update][crate::model::Transaction::cache_update].
10447    pub fn set_or_clear_cache_update<T>(mut self, v: std::option::Option<T>) -> Self
10448    where
10449        T: std::convert::Into<crate::model::CacheUpdate>,
10450    {
10451        self.cache_update = v.map(|x| x.into());
10452        self
10453    }
10454}
10455
10456impl wkt::message::Message for Transaction {
10457    fn typename() -> &'static str {
10458        "type.googleapis.com/google.spanner.v1.Transaction"
10459    }
10460}
10461
10462/// This message is used to select the transaction in which a
10463/// [Read][google.spanner.v1.Spanner.Read] or
10464/// [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.
10465///
10466/// See [TransactionOptions][google.spanner.v1.TransactionOptions] for more
10467/// information about transactions.
10468///
10469/// [google.spanner.v1.Spanner.ExecuteSql]: crate::client::Spanner::execute_sql
10470/// [google.spanner.v1.Spanner.Read]: crate::client::Spanner::read
10471/// [google.spanner.v1.TransactionOptions]: crate::model::TransactionOptions
10472#[derive(Clone, Default, PartialEq)]
10473#[non_exhaustive]
10474pub struct TransactionSelector {
10475    /// If no fields are set, the default is a single use transaction
10476    /// with strong concurrency.
10477    pub selector: std::option::Option<crate::model::transaction_selector::Selector>,
10478
10479    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10480}
10481
10482impl TransactionSelector {
10483    /// Creates a new default instance.
10484    pub fn new() -> Self {
10485        std::default::Default::default()
10486    }
10487
10488    /// Sets the value of [selector][crate::model::TransactionSelector::selector].
10489    ///
10490    /// Note that all the setters affecting `selector` are mutually
10491    /// exclusive.
10492    pub fn set_selector<
10493        T: std::convert::Into<std::option::Option<crate::model::transaction_selector::Selector>>,
10494    >(
10495        mut self,
10496        v: T,
10497    ) -> Self {
10498        self.selector = v.into();
10499        self
10500    }
10501
10502    /// The value of [selector][crate::model::TransactionSelector::selector]
10503    /// if it holds a `SingleUse`, `None` if the field is not set or
10504    /// holds a different branch.
10505    pub fn single_use(
10506        &self,
10507    ) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
10508        #[allow(unreachable_patterns)]
10509        self.selector.as_ref().and_then(|v| match v {
10510            crate::model::transaction_selector::Selector::SingleUse(v) => {
10511                std::option::Option::Some(v)
10512            }
10513            _ => std::option::Option::None,
10514        })
10515    }
10516
10517    /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10518    /// to hold a `SingleUse`.
10519    ///
10520    /// Note that all the setters affecting `selector` are
10521    /// mutually exclusive.
10522    pub fn set_single_use<
10523        T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10524    >(
10525        mut self,
10526        v: T,
10527    ) -> Self {
10528        self.selector = std::option::Option::Some(
10529            crate::model::transaction_selector::Selector::SingleUse(v.into()),
10530        );
10531        self
10532    }
10533
10534    /// The value of [selector][crate::model::TransactionSelector::selector]
10535    /// if it holds a `Id`, `None` if the field is not set or
10536    /// holds a different branch.
10537    pub fn id(&self) -> std::option::Option<&::bytes::Bytes> {
10538        #[allow(unreachable_patterns)]
10539        self.selector.as_ref().and_then(|v| match v {
10540            crate::model::transaction_selector::Selector::Id(v) => std::option::Option::Some(v),
10541            _ => std::option::Option::None,
10542        })
10543    }
10544
10545    /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10546    /// to hold a `Id`.
10547    ///
10548    /// Note that all the setters affecting `selector` are
10549    /// mutually exclusive.
10550    pub fn set_id<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10551        self.selector =
10552            std::option::Option::Some(crate::model::transaction_selector::Selector::Id(v.into()));
10553        self
10554    }
10555
10556    /// The value of [selector][crate::model::TransactionSelector::selector]
10557    /// if it holds a `Begin`, `None` if the field is not set or
10558    /// holds a different branch.
10559    pub fn begin(&self) -> std::option::Option<&std::boxed::Box<crate::model::TransactionOptions>> {
10560        #[allow(unreachable_patterns)]
10561        self.selector.as_ref().and_then(|v| match v {
10562            crate::model::transaction_selector::Selector::Begin(v) => std::option::Option::Some(v),
10563            _ => std::option::Option::None,
10564        })
10565    }
10566
10567    /// Sets the value of [selector][crate::model::TransactionSelector::selector]
10568    /// to hold a `Begin`.
10569    ///
10570    /// Note that all the setters affecting `selector` are
10571    /// mutually exclusive.
10572    pub fn set_begin<T: std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>>(
10573        mut self,
10574        v: T,
10575    ) -> Self {
10576        self.selector = std::option::Option::Some(
10577            crate::model::transaction_selector::Selector::Begin(v.into()),
10578        );
10579        self
10580    }
10581}
10582
10583impl wkt::message::Message for TransactionSelector {
10584    fn typename() -> &'static str {
10585        "type.googleapis.com/google.spanner.v1.TransactionSelector"
10586    }
10587}
10588
10589/// Defines additional types related to [TransactionSelector].
10590pub mod transaction_selector {
10591    #[allow(unused_imports)]
10592    use super::*;
10593
10594    /// If no fields are set, the default is a single use transaction
10595    /// with strong concurrency.
10596    #[derive(Clone, Debug, PartialEq)]
10597    #[non_exhaustive]
10598    pub enum Selector {
10599        /// Execute the read or SQL query in a temporary transaction.
10600        /// This is the most efficient way to execute a transaction that
10601        /// consists of a single SQL query.
10602        SingleUse(std::boxed::Box<crate::model::TransactionOptions>),
10603        /// Execute the read or SQL query in a previously-started transaction.
10604        Id(::bytes::Bytes),
10605        /// Begin a new transaction and execute this read or SQL query in
10606        /// it. The transaction ID of the new transaction is returned in
10607        /// [ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction],
10608        /// which is a [Transaction][google.spanner.v1.Transaction].
10609        ///
10610        /// [google.spanner.v1.ResultSetMetadata.transaction]: crate::model::ResultSetMetadata::transaction
10611        /// [google.spanner.v1.Transaction]: crate::model::Transaction
10612        Begin(std::boxed::Box<crate::model::TransactionOptions>),
10613    }
10614
10615    impl Selector {
10616        /// Initializes the enum to the [SingleUse](Self::SingleUse) branch.
10617        pub fn from_single_use(
10618            value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10619        ) -> Self {
10620            Self::SingleUse(value.into())
10621        }
10622        /// Initializes the enum to the [Id](Self::Id) branch.
10623        pub fn from_id(value: impl std::convert::Into<::bytes::Bytes>) -> Self {
10624            Self::Id(value.into())
10625        }
10626        /// Initializes the enum to the [Begin](Self::Begin) branch.
10627        pub fn from_begin(
10628            value: impl std::convert::Into<std::boxed::Box<crate::model::TransactionOptions>>,
10629        ) -> Self {
10630            Self::Begin(value.into())
10631        }
10632    }
10633}
10634
10635/// When a read-write transaction is executed on a multiplexed session,
10636/// this precommit token is sent back to the client
10637/// as a part of the [Transaction][google.spanner.v1.Transaction] message in the
10638/// [BeginTransaction][google.spanner.v1.BeginTransactionRequest] response and
10639/// also as a part of the [ResultSet][google.spanner.v1.ResultSet] and
10640/// [PartialResultSet][google.spanner.v1.PartialResultSet] responses.
10641///
10642/// [google.spanner.v1.BeginTransactionRequest]: crate::model::BeginTransactionRequest
10643/// [google.spanner.v1.PartialResultSet]: crate::model::PartialResultSet
10644/// [google.spanner.v1.ResultSet]: crate::model::ResultSet
10645/// [google.spanner.v1.Transaction]: crate::model::Transaction
10646#[derive(Clone, Default, PartialEq)]
10647#[non_exhaustive]
10648pub struct MultiplexedSessionPrecommitToken {
10649    /// Opaque precommit token.
10650    pub precommit_token: ::bytes::Bytes,
10651
10652    /// An incrementing seq number is generated on every precommit token
10653    /// that is returned. Clients should remember the precommit token with the
10654    /// highest sequence number from the current transaction attempt.
10655    pub seq_num: i32,
10656
10657    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10658}
10659
10660impl MultiplexedSessionPrecommitToken {
10661    /// Creates a new default instance.
10662    pub fn new() -> Self {
10663        std::default::Default::default()
10664    }
10665
10666    /// Sets the value of [precommit_token][crate::model::MultiplexedSessionPrecommitToken::precommit_token].
10667    pub fn set_precommit_token<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
10668        self.precommit_token = v.into();
10669        self
10670    }
10671
10672    /// Sets the value of [seq_num][crate::model::MultiplexedSessionPrecommitToken::seq_num].
10673    pub fn set_seq_num<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
10674        self.seq_num = v.into();
10675        self
10676    }
10677}
10678
10679impl wkt::message::Message for MultiplexedSessionPrecommitToken {
10680    fn typename() -> &'static str {
10681        "type.googleapis.com/google.spanner.v1.MultiplexedSessionPrecommitToken"
10682    }
10683}
10684
10685/// `Type` indicates the type of a Cloud Spanner value, as might be stored in a
10686/// table cell or returned from an SQL query.
10687#[derive(Clone, Default, PartialEq)]
10688#[non_exhaustive]
10689pub struct Type {
10690    /// Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
10691    ///
10692    /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
10693    pub code: crate::model::TypeCode,
10694
10695    /// If [code][google.spanner.v1.Type.code] ==
10696    /// [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type` is the
10697    /// type of the array elements.
10698    ///
10699    /// [google.spanner.v1.Type.code]: crate::model::Type::code
10700    /// [google.spanner.v1.TypeCode.ARRAY]: crate::model::TypeCode::Array
10701    pub array_element_type: std::option::Option<std::boxed::Box<crate::model::Type>>,
10702
10703    /// If [code][google.spanner.v1.Type.code] ==
10704    /// [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type` provides
10705    /// type information for the struct's fields.
10706    ///
10707    /// [google.spanner.v1.Type.code]: crate::model::Type::code
10708    /// [google.spanner.v1.TypeCode.STRUCT]: crate::model::TypeCode::Struct
10709    pub struct_type: std::option::Option<std::boxed::Box<crate::model::StructType>>,
10710
10711    /// The [TypeAnnotationCode][google.spanner.v1.TypeAnnotationCode] that
10712    /// disambiguates SQL type that Spanner will use to represent values of this
10713    /// type during query processing. This is necessary for some type codes because
10714    /// a single [TypeCode][google.spanner.v1.TypeCode] can be mapped to different
10715    /// SQL types depending on the SQL dialect.
10716    /// [type_annotation][google.spanner.v1.Type.type_annotation] typically is not
10717    /// needed to process the content of a value (it doesn't affect serialization)
10718    /// and clients can ignore it on the read path.
10719    ///
10720    /// [google.spanner.v1.Type.type_annotation]: crate::model::Type::type_annotation
10721    /// [google.spanner.v1.TypeAnnotationCode]: crate::model::TypeAnnotationCode
10722    /// [google.spanner.v1.TypeCode]: crate::model::TypeCode
10723    pub type_annotation: crate::model::TypeAnnotationCode,
10724
10725    /// If [code][google.spanner.v1.Type.code] ==
10726    /// [PROTO][google.spanner.v1.TypeCode.PROTO] or
10727    /// [code][google.spanner.v1.Type.code] ==
10728    /// [ENUM][google.spanner.v1.TypeCode.ENUM], then `proto_type_fqn` is the fully
10729    /// qualified name of the proto type representing the proto/enum definition.
10730    ///
10731    /// [google.spanner.v1.Type.code]: crate::model::Type::code
10732    /// [google.spanner.v1.TypeCode.ENUM]: crate::model::TypeCode::Enum
10733    /// [google.spanner.v1.TypeCode.PROTO]: crate::model::TypeCode::Proto
10734    pub proto_type_fqn: std::string::String,
10735
10736    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10737}
10738
10739impl Type {
10740    /// Creates a new default instance.
10741    pub fn new() -> Self {
10742        std::default::Default::default()
10743    }
10744
10745    /// Sets the value of [code][crate::model::Type::code].
10746    pub fn set_code<T: std::convert::Into<crate::model::TypeCode>>(mut self, v: T) -> Self {
10747        self.code = v.into();
10748        self
10749    }
10750
10751    /// Sets the value of [array_element_type][crate::model::Type::array_element_type].
10752    pub fn set_array_element_type<T>(mut self, v: T) -> Self
10753    where
10754        T: std::convert::Into<crate::model::Type>,
10755    {
10756        self.array_element_type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10757        self
10758    }
10759
10760    /// Sets or clears the value of [array_element_type][crate::model::Type::array_element_type].
10761    pub fn set_or_clear_array_element_type<T>(mut self, v: std::option::Option<T>) -> Self
10762    where
10763        T: std::convert::Into<crate::model::Type>,
10764    {
10765        self.array_element_type = v.map(|x| std::boxed::Box::new(x.into()));
10766        self
10767    }
10768
10769    /// Sets the value of [struct_type][crate::model::Type::struct_type].
10770    pub fn set_struct_type<T>(mut self, v: T) -> Self
10771    where
10772        T: std::convert::Into<crate::model::StructType>,
10773    {
10774        self.struct_type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10775        self
10776    }
10777
10778    /// Sets or clears the value of [struct_type][crate::model::Type::struct_type].
10779    pub fn set_or_clear_struct_type<T>(mut self, v: std::option::Option<T>) -> Self
10780    where
10781        T: std::convert::Into<crate::model::StructType>,
10782    {
10783        self.struct_type = v.map(|x| std::boxed::Box::new(x.into()));
10784        self
10785    }
10786
10787    /// Sets the value of [type_annotation][crate::model::Type::type_annotation].
10788    pub fn set_type_annotation<T: std::convert::Into<crate::model::TypeAnnotationCode>>(
10789        mut self,
10790        v: T,
10791    ) -> Self {
10792        self.type_annotation = v.into();
10793        self
10794    }
10795
10796    /// Sets the value of [proto_type_fqn][crate::model::Type::proto_type_fqn].
10797    pub fn set_proto_type_fqn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10798        self.proto_type_fqn = v.into();
10799        self
10800    }
10801}
10802
10803impl wkt::message::Message for Type {
10804    fn typename() -> &'static str {
10805        "type.googleapis.com/google.spanner.v1.Type"
10806    }
10807}
10808
10809/// `StructType` defines the fields of a
10810/// [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
10811///
10812/// [google.spanner.v1.TypeCode.STRUCT]: crate::model::TypeCode::Struct
10813#[derive(Clone, Default, PartialEq)]
10814#[non_exhaustive]
10815pub struct StructType {
10816    /// The list of fields that make up this struct. Order is
10817    /// significant, because values of this struct type are represented as
10818    /// lists, where the order of field values matches the order of
10819    /// fields in the [StructType][google.spanner.v1.StructType]. In turn, the
10820    /// order of fields matches the order of columns in a read request, or the
10821    /// order of fields in the `SELECT` clause of a query.
10822    ///
10823    /// [google.spanner.v1.StructType]: crate::model::StructType
10824    pub fields: std::vec::Vec<crate::model::struct_type::Field>,
10825
10826    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10827}
10828
10829impl StructType {
10830    /// Creates a new default instance.
10831    pub fn new() -> Self {
10832        std::default::Default::default()
10833    }
10834
10835    /// Sets the value of [fields][crate::model::StructType::fields].
10836    pub fn set_fields<T, V>(mut self, v: T) -> Self
10837    where
10838        T: std::iter::IntoIterator<Item = V>,
10839        V: std::convert::Into<crate::model::struct_type::Field>,
10840    {
10841        use std::iter::Iterator;
10842        self.fields = v.into_iter().map(|i| i.into()).collect();
10843        self
10844    }
10845}
10846
10847impl wkt::message::Message for StructType {
10848    fn typename() -> &'static str {
10849        "type.googleapis.com/google.spanner.v1.StructType"
10850    }
10851}
10852
10853/// Defines additional types related to [StructType].
10854pub mod struct_type {
10855    #[allow(unused_imports)]
10856    use super::*;
10857
10858    /// Message representing a single field of a struct.
10859    #[derive(Clone, Default, PartialEq)]
10860    #[non_exhaustive]
10861    pub struct Field {
10862        /// The name of the field. For reads, this is the column name. For
10863        /// SQL queries, it is the column alias (e.g., `"Word"` in the
10864        /// query `"SELECT 'hello' AS Word"`), or the column name (e.g.,
10865        /// `"ColName"` in the query `"SELECT ColName FROM Table"`). Some
10866        /// columns might have an empty name (e.g., `"SELECT
10867        /// UPPER(ColName)"`). Note that a query result can contain
10868        /// multiple fields with the same name.
10869        pub name: std::string::String,
10870
10871        /// The type of the field.
10872        pub r#type: std::option::Option<std::boxed::Box<crate::model::Type>>,
10873
10874        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
10875    }
10876
10877    impl Field {
10878        /// Creates a new default instance.
10879        pub fn new() -> Self {
10880            std::default::Default::default()
10881        }
10882
10883        /// Sets the value of [name][crate::model::struct_type::Field::name].
10884        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
10885            self.name = v.into();
10886            self
10887        }
10888
10889        /// Sets the value of [r#type][crate::model::struct_type::Field::type].
10890        pub fn set_type<T>(mut self, v: T) -> Self
10891        where
10892            T: std::convert::Into<crate::model::Type>,
10893        {
10894            self.r#type = std::option::Option::Some(std::boxed::Box::new(v.into()));
10895            self
10896        }
10897
10898        /// Sets or clears the value of [r#type][crate::model::struct_type::Field::type].
10899        pub fn set_or_clear_type<T>(mut self, v: std::option::Option<T>) -> Self
10900        where
10901            T: std::convert::Into<crate::model::Type>,
10902        {
10903            self.r#type = v.map(|x| std::boxed::Box::new(x.into()));
10904            self
10905        }
10906    }
10907
10908    impl wkt::message::Message for Field {
10909        fn typename() -> &'static str {
10910            "type.googleapis.com/google.spanner.v1.StructType.Field"
10911        }
10912    }
10913}
10914
10915/// `TypeCode` is used as part of [Type][google.spanner.v1.Type] to
10916/// indicate the type of a Cloud Spanner value.
10917///
10918/// Each legal value of a type can be encoded to or decoded from a JSON
10919/// value, using the encodings described below. All Cloud Spanner values can
10920/// be `null`, regardless of type; `null`s are always encoded as a JSON
10921/// `null`.
10922///
10923/// [google.spanner.v1.Type]: crate::model::Type
10924///
10925/// # Working with unknown values
10926///
10927/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10928/// additional enum variants at any time. Adding new variants is not considered
10929/// a breaking change. Applications should write their code in anticipation of:
10930///
10931/// - New values appearing in future releases of the client library, **and**
10932/// - New values received dynamically, without application changes.
10933///
10934/// Please consult the [Working with enums] section in the user guide for some
10935/// guidelines.
10936///
10937/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10938#[derive(Clone, Debug, PartialEq)]
10939#[non_exhaustive]
10940pub enum TypeCode {
10941    /// Not specified.
10942    Unspecified,
10943    /// Encoded as JSON `true` or `false`.
10944    Bool,
10945    /// Encoded as `string`, in decimal format.
10946    Int64,
10947    /// Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or
10948    /// `"-Infinity"`.
10949    Float64,
10950    /// Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or
10951    /// `"-Infinity"`.
10952    Float32,
10953    /// Encoded as `string` in RFC 3339 timestamp format. The time zone
10954    /// must be present, and must be `"Z"`.
10955    ///
10956    /// If the schema has the column option
10957    /// `allow_commit_timestamp=true`, the placeholder string
10958    /// `"spanner.commit_timestamp()"` can be used to instruct the system
10959    /// to insert the commit timestamp associated with the transaction
10960    /// commit.
10961    Timestamp,
10962    /// Encoded as `string` in RFC 3339 date format.
10963    Date,
10964    /// Encoded as `string`.
10965    String,
10966    /// Encoded as a base64-encoded `string`, as described in RFC 4648,
10967    /// section 4.
10968    Bytes,
10969    /// Encoded as `list`, where the list elements are represented
10970    /// according to
10971    /// [array_element_type][google.spanner.v1.Type.array_element_type].
10972    ///
10973    /// [google.spanner.v1.Type.array_element_type]: crate::model::Type::array_element_type
10974    Array,
10975    /// Encoded as `list`, where list element `i` is represented according
10976    /// to [struct_type.fields[i]][google.spanner.v1.StructType.fields].
10977    ///
10978    /// [google.spanner.v1.StructType.fields]: crate::model::StructType::fields
10979    Struct,
10980    /// Encoded as `string`, in decimal format or scientific notation format.
10981    /// Decimal format:
10982    /// `[+-]Digits[.[Digits]]` or
10983    /// `[+-][Digits].Digits`
10984    ///
10985    /// Scientific notation:
10986    /// `[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
10987    /// `[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
10988    /// (ExponentIndicator is `"e"` or `"E"`)
10989    Numeric,
10990    /// Encoded as a JSON-formatted `string` as described in RFC 7159. The
10991    /// following rules are applied when parsing JSON input:
10992    ///
10993    /// - Whitespace characters are not preserved.
10994    /// - If a JSON object has duplicate keys, only the first key is preserved.
10995    /// - Members of a JSON object are not guaranteed to have their order
10996    ///   preserved.
10997    /// - JSON array elements will have their order preserved.
10998    Json,
10999    /// Encoded as a base64-encoded `string`, as described in RFC 4648,
11000    /// section 4.
11001    Proto,
11002    /// Encoded as `string`, in decimal format.
11003    Enum,
11004    /// Encoded as `string`, in `ISO8601` duration format -
11005    /// `P[n]Y[n]M[n]DT[n]H[n]M[n[.fraction]]S`
11006    /// where `n` is an integer.
11007    /// For example, `P1Y2M3DT4H5M6.5S` represents time duration of 1 year, 2
11008    /// months, 3 days, 4 hours, 5 minutes, and 6.5 seconds.
11009    Interval,
11010    /// Encoded as `string`, in lower-case hexa-decimal format, as described
11011    /// in RFC 9562, section 4.
11012    Uuid,
11013    /// If set, the enum was initialized with an unknown value.
11014    ///
11015    /// Applications can examine the value using [TypeCode::value] or
11016    /// [TypeCode::name].
11017    UnknownValue(type_code::UnknownValue),
11018}
11019
11020#[doc(hidden)]
11021pub mod type_code {
11022    #[allow(unused_imports)]
11023    use super::*;
11024    #[derive(Clone, Debug, PartialEq)]
11025    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11026}
11027
11028impl TypeCode {
11029    /// Gets the enum value.
11030    ///
11031    /// Returns `None` if the enum contains an unknown value deserialized from
11032    /// the string representation of enums.
11033    pub fn value(&self) -> std::option::Option<i32> {
11034        match self {
11035            Self::Unspecified => std::option::Option::Some(0),
11036            Self::Bool => std::option::Option::Some(1),
11037            Self::Int64 => std::option::Option::Some(2),
11038            Self::Float64 => std::option::Option::Some(3),
11039            Self::Float32 => std::option::Option::Some(15),
11040            Self::Timestamp => std::option::Option::Some(4),
11041            Self::Date => std::option::Option::Some(5),
11042            Self::String => std::option::Option::Some(6),
11043            Self::Bytes => std::option::Option::Some(7),
11044            Self::Array => std::option::Option::Some(8),
11045            Self::Struct => std::option::Option::Some(9),
11046            Self::Numeric => std::option::Option::Some(10),
11047            Self::Json => std::option::Option::Some(11),
11048            Self::Proto => std::option::Option::Some(13),
11049            Self::Enum => std::option::Option::Some(14),
11050            Self::Interval => std::option::Option::Some(16),
11051            Self::Uuid => std::option::Option::Some(17),
11052            Self::UnknownValue(u) => u.0.value(),
11053        }
11054    }
11055
11056    /// Gets the enum value as a string.
11057    ///
11058    /// Returns `None` if the enum contains an unknown value deserialized from
11059    /// the integer representation of enums.
11060    pub fn name(&self) -> std::option::Option<&str> {
11061        match self {
11062            Self::Unspecified => std::option::Option::Some("TYPE_CODE_UNSPECIFIED"),
11063            Self::Bool => std::option::Option::Some("BOOL"),
11064            Self::Int64 => std::option::Option::Some("INT64"),
11065            Self::Float64 => std::option::Option::Some("FLOAT64"),
11066            Self::Float32 => std::option::Option::Some("FLOAT32"),
11067            Self::Timestamp => std::option::Option::Some("TIMESTAMP"),
11068            Self::Date => std::option::Option::Some("DATE"),
11069            Self::String => std::option::Option::Some("STRING"),
11070            Self::Bytes => std::option::Option::Some("BYTES"),
11071            Self::Array => std::option::Option::Some("ARRAY"),
11072            Self::Struct => std::option::Option::Some("STRUCT"),
11073            Self::Numeric => std::option::Option::Some("NUMERIC"),
11074            Self::Json => std::option::Option::Some("JSON"),
11075            Self::Proto => std::option::Option::Some("PROTO"),
11076            Self::Enum => std::option::Option::Some("ENUM"),
11077            Self::Interval => std::option::Option::Some("INTERVAL"),
11078            Self::Uuid => std::option::Option::Some("UUID"),
11079            Self::UnknownValue(u) => u.0.name(),
11080        }
11081    }
11082}
11083
11084impl std::default::Default for TypeCode {
11085    fn default() -> Self {
11086        use std::convert::From;
11087        Self::from(0)
11088    }
11089}
11090
11091impl std::fmt::Display for TypeCode {
11092    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11093        wkt::internal::display_enum(f, self.name(), self.value())
11094    }
11095}
11096
11097impl std::convert::From<i32> for TypeCode {
11098    fn from(value: i32) -> Self {
11099        match value {
11100            0 => Self::Unspecified,
11101            1 => Self::Bool,
11102            2 => Self::Int64,
11103            3 => Self::Float64,
11104            4 => Self::Timestamp,
11105            5 => Self::Date,
11106            6 => Self::String,
11107            7 => Self::Bytes,
11108            8 => Self::Array,
11109            9 => Self::Struct,
11110            10 => Self::Numeric,
11111            11 => Self::Json,
11112            13 => Self::Proto,
11113            14 => Self::Enum,
11114            15 => Self::Float32,
11115            16 => Self::Interval,
11116            17 => Self::Uuid,
11117            _ => Self::UnknownValue(type_code::UnknownValue(
11118                wkt::internal::UnknownEnumValue::Integer(value),
11119            )),
11120        }
11121    }
11122}
11123
11124impl std::convert::From<&str> for TypeCode {
11125    fn from(value: &str) -> Self {
11126        use std::string::ToString;
11127        match value {
11128            "TYPE_CODE_UNSPECIFIED" => Self::Unspecified,
11129            "BOOL" => Self::Bool,
11130            "INT64" => Self::Int64,
11131            "FLOAT64" => Self::Float64,
11132            "FLOAT32" => Self::Float32,
11133            "TIMESTAMP" => Self::Timestamp,
11134            "DATE" => Self::Date,
11135            "STRING" => Self::String,
11136            "BYTES" => Self::Bytes,
11137            "ARRAY" => Self::Array,
11138            "STRUCT" => Self::Struct,
11139            "NUMERIC" => Self::Numeric,
11140            "JSON" => Self::Json,
11141            "PROTO" => Self::Proto,
11142            "ENUM" => Self::Enum,
11143            "INTERVAL" => Self::Interval,
11144            "UUID" => Self::Uuid,
11145            _ => Self::UnknownValue(type_code::UnknownValue(
11146                wkt::internal::UnknownEnumValue::String(value.to_string()),
11147            )),
11148        }
11149    }
11150}
11151
11152impl serde::ser::Serialize for TypeCode {
11153    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11154    where
11155        S: serde::Serializer,
11156    {
11157        match self {
11158            Self::Unspecified => serializer.serialize_i32(0),
11159            Self::Bool => serializer.serialize_i32(1),
11160            Self::Int64 => serializer.serialize_i32(2),
11161            Self::Float64 => serializer.serialize_i32(3),
11162            Self::Float32 => serializer.serialize_i32(15),
11163            Self::Timestamp => serializer.serialize_i32(4),
11164            Self::Date => serializer.serialize_i32(5),
11165            Self::String => serializer.serialize_i32(6),
11166            Self::Bytes => serializer.serialize_i32(7),
11167            Self::Array => serializer.serialize_i32(8),
11168            Self::Struct => serializer.serialize_i32(9),
11169            Self::Numeric => serializer.serialize_i32(10),
11170            Self::Json => serializer.serialize_i32(11),
11171            Self::Proto => serializer.serialize_i32(13),
11172            Self::Enum => serializer.serialize_i32(14),
11173            Self::Interval => serializer.serialize_i32(16),
11174            Self::Uuid => serializer.serialize_i32(17),
11175            Self::UnknownValue(u) => u.0.serialize(serializer),
11176        }
11177    }
11178}
11179
11180impl<'de> serde::de::Deserialize<'de> for TypeCode {
11181    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11182    where
11183        D: serde::Deserializer<'de>,
11184    {
11185        deserializer.deserialize_any(wkt::internal::EnumVisitor::<TypeCode>::new(
11186            ".google.spanner.v1.TypeCode",
11187        ))
11188    }
11189}
11190
11191/// `TypeAnnotationCode` is used as a part of [Type][google.spanner.v1.Type] to
11192/// disambiguate SQL types that should be used for a given Cloud Spanner value.
11193/// Disambiguation is needed because the same Cloud Spanner type can be mapped to
11194/// different SQL types depending on SQL dialect. TypeAnnotationCode doesn't
11195/// affect the way value is serialized.
11196///
11197/// [google.spanner.v1.Type]: crate::model::Type
11198///
11199/// # Working with unknown values
11200///
11201/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
11202/// additional enum variants at any time. Adding new variants is not considered
11203/// a breaking change. Applications should write their code in anticipation of:
11204///
11205/// - New values appearing in future releases of the client library, **and**
11206/// - New values received dynamically, without application changes.
11207///
11208/// Please consult the [Working with enums] section in the user guide for some
11209/// guidelines.
11210///
11211/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
11212#[derive(Clone, Debug, PartialEq)]
11213#[non_exhaustive]
11214pub enum TypeAnnotationCode {
11215    /// Not specified.
11216    Unspecified,
11217    /// PostgreSQL compatible NUMERIC type. This annotation needs to be applied to
11218    /// [Type][google.spanner.v1.Type] instances having
11219    /// [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] type code to specify that
11220    /// values of this type should be treated as PostgreSQL NUMERIC values.
11221    /// Currently this annotation is always needed for
11222    /// [NUMERIC][google.spanner.v1.TypeCode.NUMERIC] when a client interacts with
11223    /// PostgreSQL-enabled Spanner databases.
11224    ///
11225    /// [google.spanner.v1.Type]: crate::model::Type
11226    /// [google.spanner.v1.TypeCode.NUMERIC]: crate::model::TypeCode::Numeric
11227    PgNumeric,
11228    /// PostgreSQL compatible JSONB type. This annotation needs to be applied to
11229    /// [Type][google.spanner.v1.Type] instances having
11230    /// [JSON][google.spanner.v1.TypeCode.JSON] type code to specify that values of
11231    /// this type should be treated as PostgreSQL JSONB values. Currently this
11232    /// annotation is always needed for [JSON][google.spanner.v1.TypeCode.JSON]
11233    /// when a client interacts with PostgreSQL-enabled Spanner databases.
11234    ///
11235    /// [google.spanner.v1.Type]: crate::model::Type
11236    /// [google.spanner.v1.TypeCode.JSON]: crate::model::TypeCode::Json
11237    PgJsonb,
11238    /// PostgreSQL compatible OID type. This annotation can be used by a client
11239    /// interacting with PostgreSQL-enabled Spanner database to specify that a
11240    /// value should be treated using the semantics of the OID type.
11241    PgOid,
11242    /// If set, the enum was initialized with an unknown value.
11243    ///
11244    /// Applications can examine the value using [TypeAnnotationCode::value] or
11245    /// [TypeAnnotationCode::name].
11246    UnknownValue(type_annotation_code::UnknownValue),
11247}
11248
11249#[doc(hidden)]
11250pub mod type_annotation_code {
11251    #[allow(unused_imports)]
11252    use super::*;
11253    #[derive(Clone, Debug, PartialEq)]
11254    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
11255}
11256
11257impl TypeAnnotationCode {
11258    /// Gets the enum value.
11259    ///
11260    /// Returns `None` if the enum contains an unknown value deserialized from
11261    /// the string representation of enums.
11262    pub fn value(&self) -> std::option::Option<i32> {
11263        match self {
11264            Self::Unspecified => std::option::Option::Some(0),
11265            Self::PgNumeric => std::option::Option::Some(2),
11266            Self::PgJsonb => std::option::Option::Some(3),
11267            Self::PgOid => std::option::Option::Some(4),
11268            Self::UnknownValue(u) => u.0.value(),
11269        }
11270    }
11271
11272    /// Gets the enum value as a string.
11273    ///
11274    /// Returns `None` if the enum contains an unknown value deserialized from
11275    /// the integer representation of enums.
11276    pub fn name(&self) -> std::option::Option<&str> {
11277        match self {
11278            Self::Unspecified => std::option::Option::Some("TYPE_ANNOTATION_CODE_UNSPECIFIED"),
11279            Self::PgNumeric => std::option::Option::Some("PG_NUMERIC"),
11280            Self::PgJsonb => std::option::Option::Some("PG_JSONB"),
11281            Self::PgOid => std::option::Option::Some("PG_OID"),
11282            Self::UnknownValue(u) => u.0.name(),
11283        }
11284    }
11285}
11286
11287impl std::default::Default for TypeAnnotationCode {
11288    fn default() -> Self {
11289        use std::convert::From;
11290        Self::from(0)
11291    }
11292}
11293
11294impl std::fmt::Display for TypeAnnotationCode {
11295    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
11296        wkt::internal::display_enum(f, self.name(), self.value())
11297    }
11298}
11299
11300impl std::convert::From<i32> for TypeAnnotationCode {
11301    fn from(value: i32) -> Self {
11302        match value {
11303            0 => Self::Unspecified,
11304            2 => Self::PgNumeric,
11305            3 => Self::PgJsonb,
11306            4 => Self::PgOid,
11307            _ => Self::UnknownValue(type_annotation_code::UnknownValue(
11308                wkt::internal::UnknownEnumValue::Integer(value),
11309            )),
11310        }
11311    }
11312}
11313
11314impl std::convert::From<&str> for TypeAnnotationCode {
11315    fn from(value: &str) -> Self {
11316        use std::string::ToString;
11317        match value {
11318            "TYPE_ANNOTATION_CODE_UNSPECIFIED" => Self::Unspecified,
11319            "PG_NUMERIC" => Self::PgNumeric,
11320            "PG_JSONB" => Self::PgJsonb,
11321            "PG_OID" => Self::PgOid,
11322            _ => Self::UnknownValue(type_annotation_code::UnknownValue(
11323                wkt::internal::UnknownEnumValue::String(value.to_string()),
11324            )),
11325        }
11326    }
11327}
11328
11329impl serde::ser::Serialize for TypeAnnotationCode {
11330    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
11331    where
11332        S: serde::Serializer,
11333    {
11334        match self {
11335            Self::Unspecified => serializer.serialize_i32(0),
11336            Self::PgNumeric => serializer.serialize_i32(2),
11337            Self::PgJsonb => serializer.serialize_i32(3),
11338            Self::PgOid => serializer.serialize_i32(4),
11339            Self::UnknownValue(u) => u.0.serialize(serializer),
11340        }
11341    }
11342}
11343
11344impl<'de> serde::de::Deserialize<'de> for TypeAnnotationCode {
11345    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
11346    where
11347        D: serde::Deserializer<'de>,
11348    {
11349        deserializer.deserialize_any(wkt::internal::EnumVisitor::<TypeAnnotationCode>::new(
11350            ".google.spanner.v1.TypeAnnotationCode",
11351        ))
11352    }
11353}