gcp_sdk_type/
model.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate bytes;
extern crate serde;
extern crate serde_with;
extern crate std;
extern crate wkt;

/// Represents a color in the RGBA color space. This representation is designed
/// for simplicity of conversion to/from color representations in various
/// languages over compactness. For example, the fields of this representation
/// can be trivially provided to the constructor of `java.awt.Color` in Java; it
/// can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha`
/// method in iOS; and, with just a little work, it can be easily formatted into
/// a CSS `rgba()` string in JavaScript.
///
/// This reference page doesn't carry information about the absolute color
/// space
/// that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB,
/// DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color
/// space.
///
/// When color equality needs to be decided, implementations, unless
/// documented otherwise, treat two colors as equal if all their red,
/// green, blue, and alpha values each differ by at most 1e-5.
///
/// Example (Java):
///
/// ```norust
///  import com.google.type.Color;
///
///  // ...
///  public static java.awt.Color fromProto(Color protocolor) {
///    float alpha = protocolor.hasAlpha()
///        ? protocolor.getAlpha().getValue()
///        : 1.0;
///
///    return new java.awt.Color(
///        protocolor.getRed(),
///        protocolor.getGreen(),
///        protocolor.getBlue(),
///        alpha);
///  }
///
///  public static Color toProto(java.awt.Color color) {
///    float red = (float) color.getRed();
///    float green = (float) color.getGreen();
///    float blue = (float) color.getBlue();
///    float denominator = 255.0;
///    Color.Builder resultBuilder =
///        Color
///            .newBuilder()
///            .setRed(red / denominator)
///            .setGreen(green / denominator)
///            .setBlue(blue / denominator);
///    int alpha = color.getAlpha();
///    if (alpha != 255) {
///      result.setAlpha(
///          FloatValue
///              .newBuilder()
///              .setValue(((float) alpha) / denominator)
///              .build());
///    }
///    return resultBuilder.build();
///  }
///  // ...
/// ```
///
/// Example (iOS / Obj-C):
///
/// ```norust
///  // ...
///  static UIColor* fromProto(Color* protocolor) {
///     float red = [protocolor red];
///     float green = [protocolor green];
///     float blue = [protocolor blue];
///     FloatValue* alpha_wrapper = [protocolor alpha];
///     float alpha = 1.0;
///     if (alpha_wrapper != nil) {
///       alpha = [alpha_wrapper value];
///     }
///     return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
///  }
///
///  static Color* toProto(UIColor* color) {
///      CGFloat red, green, blue, alpha;
///      if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
///        return nil;
///      }
///      Color* result = [[Color alloc] init];
///      [result setRed:red];
///      [result setGreen:green];
///      [result setBlue:blue];
///      if (alpha <= 0.9999) {
///        [result setAlpha:floatWrapperWithValue(alpha)];
///      }
///      [result autorelease];
///      return result;
/// }
/// // ...
/// ```
///
/// Example (JavaScript):
///
/// ```norust
/// // ...
///
/// var protoToCssColor = function(rgb_color) {
///    var redFrac = rgb_color.red || 0.0;
///    var greenFrac = rgb_color.green || 0.0;
///    var blueFrac = rgb_color.blue || 0.0;
///    var red = Math.floor(redFrac * 255);
///    var green = Math.floor(greenFrac * 255);
///    var blue = Math.floor(blueFrac * 255);
///
///    if (!('alpha' in rgb_color)) {
///       return rgbToCssColor(red, green, blue);
///    }
///
///    var alphaFrac = rgb_color.alpha.value || 0.0;
///    var rgbParams = [red, green, blue].join(',');
///    return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
/// };
///
/// var rgbToCssColor = function(red, green, blue) {
///   var rgbNumber = new Number((red << 16) | (green << 8) | blue);
///   var hexString = rgbNumber.toString(16);
///   var missingZeros = 6 - hexString.length;
///   var resultBuilder = ['#'];
///   for (var i = 0; i < missingZeros; i++) {
///      resultBuilder.push('0');
///   }
///   resultBuilder.push(hexString);
///   return resultBuilder.join('');
/// };
///
/// // ...
/// ```
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct Color {
    /// The amount of red in the color as a value in the interval [0, 1].
    pub red: f32,

    /// The amount of green in the color as a value in the interval [0, 1].
    pub green: f32,

    /// The amount of blue in the color as a value in the interval [0, 1].
    pub blue: f32,

    /// The fraction of this color that should be applied to the pixel. That is,
    /// the final pixel color is defined by the equation:
    ///
    /// `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)`
    ///
    /// This means that a value of 1.0 corresponds to a solid color, whereas
    /// a value of 0.0 corresponds to a completely transparent color. This
    /// uses a wrapper message rather than a simple float scalar so that it is
    /// possible to distinguish between a default value and the value being unset.
    /// If omitted, this color object is rendered as a solid color
    /// (as if the alpha value had been explicitly given a value of 1.0).
    #[serde(skip_serializing_if = "std::option::Option::is_none")]
    pub alpha: std::option::Option<wkt::FloatValue>,
}

impl Color {
    /// Sets the value of [red][crate::model::Color::red].
    pub fn set_red<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
        self.red = v.into();
        self
    }

    /// Sets the value of [green][crate::model::Color::green].
    pub fn set_green<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
        self.green = v.into();
        self
    }

    /// Sets the value of [blue][crate::model::Color::blue].
    pub fn set_blue<T: std::convert::Into<f32>>(mut self, v: T) -> Self {
        self.blue = v.into();
        self
    }

    /// Sets the value of [alpha][crate::model::Color::alpha].
    pub fn set_alpha<T: std::convert::Into<std::option::Option<wkt::FloatValue>>>(
        mut self,
        v: T,
    ) -> Self {
        self.alpha = v.into();
        self
    }
}

impl wkt::message::Message for Color {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.Color"
    }
}

/// Represents a whole or partial calendar date, such as a birthday. The time of
/// day and time zone are either specified elsewhere or are insignificant. The
/// date is relative to the Gregorian Calendar. This can represent one of the
/// following:
///
/// * A full date, with non-zero year, month, and day values
/// * A month and day value, with a zero year, such as an anniversary
/// * A year on its own, with zero month and day values
/// * A year and month value, with a zero day, such as a credit card expiration
///   date
///
/// Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and
/// `google.protobuf.Timestamp`.
///
/// [google.type.TimeOfDay]: crate::model::TimeOfDay
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct Date {
    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without
    /// a year.
    pub year: i32,

    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a
    /// month and day.
    pub month: i32,

    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0
    /// to specify a year by itself or a year and month where the day isn't
    /// significant.
    pub day: i32,
}

impl Date {
    /// Sets the value of [year][crate::model::Date::year].
    pub fn set_year<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.year = v.into();
        self
    }

    /// Sets the value of [month][crate::model::Date::month].
    pub fn set_month<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.month = v.into();
        self
    }

    /// Sets the value of [day][crate::model::Date::day].
    pub fn set_day<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.day = v.into();
        self
    }
}

impl wkt::message::Message for Date {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.Date"
    }
}

/// Represents civil time (or occasionally physical time).
///
/// This type can represent a civil time in one of a few possible ways:
///
/// * When utc_offset is set and time_zone is unset: a civil time on a calendar
///   day with a particular offset from UTC.
/// * When time_zone is set and utc_offset is unset: a civil time on a calendar
///   day in a particular time zone.
/// * When neither time_zone nor utc_offset is set: a civil time on a calendar
///   day in local time.
///
/// The date is relative to the Proleptic Gregorian Calendar.
///
/// If year is 0, the DateTime is considered not to have a specific year. month
/// and day must have valid, non-zero values.
///
/// This type may also be used to represent a physical time if all the date and
/// time fields are set and either case of the `time_offset` oneof is set.
/// Consider using `Timestamp` message for physical time instead. If your use
/// case also would like to store the user's timezone, that can be done in
/// another field.
///
/// This type is more flexible than some applications may want. Make sure to
/// document and validate your application's limitations.
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct DateTime {
    /// Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a
    /// datetime without a year.
    pub year: i32,

    /// Required. Month of year. Must be from 1 to 12.
    pub month: i32,

    /// Required. Day of month. Must be from 1 to 31 and valid for the year and
    /// month.
    pub day: i32,

    /// Required. Hours of day in 24 hour format. Should be from 0 to 23. An API
    /// may choose to allow the value "24:00:00" for scenarios like business
    /// closing time.
    pub hours: i32,

    /// Required. Minutes of hour of day. Must be from 0 to 59.
    pub minutes: i32,

    /// Required. Seconds of minutes of the time. Must normally be from 0 to 59. An
    /// API may allow the value 60 if it allows leap-seconds.
    pub seconds: i32,

    /// Required. Fractions of seconds in nanoseconds. Must be from 0 to
    /// 999,999,999.
    pub nanos: i32,

    /// Optional. Specifies either the UTC offset or the time zone of the DateTime.
    /// Choose carefully between them, considering that time zone data may change
    /// in the future (for example, a country modifies their DST start/end dates,
    /// and future DateTimes in the affected range had already been stored).
    /// If omitted, the DateTime is considered to be in local time.
    #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
    pub time_offset: std::option::Option<crate::model::date_time::TimeOffset>,
}

impl DateTime {
    /// Sets the value of [year][crate::model::DateTime::year].
    pub fn set_year<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.year = v.into();
        self
    }

    /// Sets the value of [month][crate::model::DateTime::month].
    pub fn set_month<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.month = v.into();
        self
    }

    /// Sets the value of [day][crate::model::DateTime::day].
    pub fn set_day<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.day = v.into();
        self
    }

    /// Sets the value of [hours][crate::model::DateTime::hours].
    pub fn set_hours<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.hours = v.into();
        self
    }

    /// Sets the value of [minutes][crate::model::DateTime::minutes].
    pub fn set_minutes<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.minutes = v.into();
        self
    }

    /// Sets the value of [seconds][crate::model::DateTime::seconds].
    pub fn set_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.seconds = v.into();
        self
    }

    /// Sets the value of [nanos][crate::model::DateTime::nanos].
    pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.nanos = v.into();
        self
    }

    /// Sets the value of `time_offset`.
    pub fn set_time_offset<
        T: std::convert::Into<std::option::Option<crate::model::date_time::TimeOffset>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.time_offset = v.into();
        self
    }

    /// The value of [time_offset][crate::model::DateTime::time_offset]
    /// if it holds a `UtcOffset`, `None` if the field is not set or
    /// holds a different branch.
    pub fn get_utc_offset(&self) -> std::option::Option<&std::boxed::Box<wkt::Duration>> {
        #[allow(unreachable_patterns)]
        self.time_offset.as_ref().and_then(|v| match v {
            crate::model::date_time::TimeOffset::UtcOffset(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// The value of [time_offset][crate::model::DateTime::time_offset]
    /// if it holds a `TimeZone`, `None` if the field is not set or
    /// holds a different branch.
    pub fn get_time_zone(&self) -> std::option::Option<&std::boxed::Box<crate::model::TimeZone>> {
        #[allow(unreachable_patterns)]
        self.time_offset.as_ref().and_then(|v| match v {
            crate::model::date_time::TimeOffset::TimeZone(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [time_offset][crate::model::DateTime::time_offset]
    /// to hold a `UtcOffset`.
    ///
    /// Note that all the setters affecting `time_offset` are
    /// mutually exclusive.
    pub fn set_utc_offset<T: std::convert::Into<std::boxed::Box<wkt::Duration>>>(
        mut self,
        v: T,
    ) -> Self {
        self.time_offset =
            std::option::Option::Some(crate::model::date_time::TimeOffset::UtcOffset(v.into()));
        self
    }

    /// Sets the value of [time_offset][crate::model::DateTime::time_offset]
    /// to hold a `TimeZone`.
    ///
    /// Note that all the setters affecting `time_offset` are
    /// mutually exclusive.
    pub fn set_time_zone<T: std::convert::Into<std::boxed::Box<crate::model::TimeZone>>>(
        mut self,
        v: T,
    ) -> Self {
        self.time_offset =
            std::option::Option::Some(crate::model::date_time::TimeOffset::TimeZone(v.into()));
        self
    }
}

impl wkt::message::Message for DateTime {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.DateTime"
    }
}

/// Defines additional types related to DateTime
pub mod date_time {
    #[allow(unused_imports)]
    use super::*;

    /// Optional. Specifies either the UTC offset or the time zone of the DateTime.
    /// Choose carefully between them, considering that time zone data may change
    /// in the future (for example, a country modifies their DST start/end dates,
    /// and future DateTimes in the affected range had already been stored).
    /// If omitted, the DateTime is considered to be in local time.
    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
    #[serde(rename_all = "camelCase")]
    #[non_exhaustive]
    pub enum TimeOffset {
        /// UTC offset. Must be whole seconds, between -18 hours and +18 hours.
        /// For example, a UTC offset of -4:00 would be represented as
        /// { seconds: -14400 }.
        UtcOffset(std::boxed::Box<wkt::Duration>),
        /// Time zone.
        TimeZone(std::boxed::Box<crate::model::TimeZone>),
    }
}

/// Represents a time zone from the
/// [IANA Time Zone Database](https://www.iana.org/time-zones).
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct TimeZone {
    /// IANA Time Zone Database time zone, e.g. "America/New_York".
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub id: std::string::String,

    /// Optional. IANA Time Zone Database version number, e.g. "2019a".
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub version: std::string::String,
}

impl TimeZone {
    /// Sets the value of [id][crate::model::TimeZone::id].
    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.id = v.into();
        self
    }

    /// Sets the value of [version][crate::model::TimeZone::version].
    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.version = v.into();
        self
    }
}

impl wkt::message::Message for TimeZone {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.TimeZone"
    }
}

/// A representation of a decimal value, such as 2.5. Clients may convert values
/// into language-native decimal formats, such as Java's [BigDecimal][] or
/// Python's [decimal.Decimal][].
///
/// [BigDecimal]:
///  https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html
/// [decimal.Decimal]:
///  https://docs.python.org/3/library/decimal.html
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct Decimal {
    /// The decimal value, as a string.
    ///
    /// The string representation consists of an optional sign, `+` (`U+002B`)
    /// or `-` (`U+002D`), followed by a sequence of zero or more decimal digits
    /// ("the integer"), optionally followed by a fraction, optionally followed
    /// by an exponent.
    ///
    /// The fraction consists of a decimal point followed by zero or more decimal
    /// digits. The string must contain at least one digit in either the integer
    /// or the fraction. The number formed by the sign, the integer and the
    /// fraction is referred to as the significand.
    ///
    /// The exponent consists of the character `e` (`U+0065`) or `E` (`U+0045`)
    /// followed by one or more decimal digits.
    ///
    /// Services **should** normalize decimal values before storing them by:
    ///
    /// - Removing an explicitly-provided `+` sign (`+2.5` -> `2.5`).
    /// - Replacing a zero-length integer value with `0` (`.5` -> `0.5`).
    /// - Coercing the exponent character to lower-case (`2.5E8` -> `2.5e8`).
    /// - Removing an explicitly-provided zero exponent (`2.5e0` -> `2.5`).
    ///
    /// Services **may** perform additional normalization based on its own needs
    /// and the internal decimal implementation selected, such as shifting the
    /// decimal point and exponent value together (example: `2.5e-1` <-> `0.25`).
    /// Additionally, services **may** preserve trailing zeroes in the fraction
    /// to indicate increased precision, but are not required to do so.
    ///
    /// Note that only the `.` character is supported to divide the integer
    /// and the fraction; `,` **should not** be supported regardless of locale.
    /// Additionally, thousand separators **should not** be supported. If a
    /// service does support them, values **must** be normalized.
    ///
    /// The ENBF grammar is:
    ///
    /// ```norust
    /// DecimalString =
    ///   [Sign] Significand [Exponent];
    ///
    /// Sign = '+' | '-';
    ///
    /// Significand =
    ///   Digits ['.'] [Digits] | [Digits] '.' Digits;
    ///
    /// Exponent = ('e' | 'E') [Sign] Digits;
    ///
    /// Digits = { '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' };
    /// ```
    ///
    /// Services **should** clearly document the range of supported values, the
    /// maximum supported precision (total number of digits), and, if applicable,
    /// the scale (number of digits after the decimal point), as well as how it
    /// behaves when receiving out-of-bounds values.
    ///
    /// Services **may** choose to accept values passed as input even when the
    /// value has a higher precision or scale than the service supports, and
    /// **should** round the value to fit the supported scale. Alternatively, the
    /// service **may** error with `400 Bad Request` (`INVALID_ARGUMENT` in gRPC)
    /// if precision would be lost.
    ///
    /// Services **should** error with `400 Bad Request` (`INVALID_ARGUMENT` in
    /// gRPC) if the service receives a value outside of the supported range.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub value: std::string::String,
}

impl Decimal {
    /// Sets the value of [value][crate::model::Decimal::value].
    pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.value = v.into();
        self
    }
}

impl wkt::message::Message for Decimal {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.Decimal"
    }
}

/// Represents a textual expression in the Common Expression Language (CEL)
/// syntax. CEL is a C-like expression language. The syntax and semantics of CEL
/// are documented at <https://github.com/google/cel-spec>.
///
/// Example (Comparison):
///
/// ```norust
/// title: "Summary size limit"
/// description: "Determines if a summary is less than 100 chars"
/// expression: "document.summary.size() < 100"
/// ```
///
/// Example (Equality):
///
/// ```norust
/// title: "Requestor is owner"
/// description: "Determines if requestor is the document owner"
/// expression: "document.owner == request.auth.claims.email"
/// ```
///
/// Example (Logic):
///
/// ```norust
/// title: "Public documents"
/// description: "Determine whether the document should be publicly visible"
/// expression: "document.type != 'private' && document.type != 'internal'"
/// ```
///
/// Example (Data Manipulation):
///
/// ```norust
/// title: "Notification string"
/// description: "Create a notification string with a timestamp."
/// expression: "'New message received at ' + string(document.create_time)"
/// ```
///
/// The exact variables and functions that may be referenced within an expression
/// are determined by the service that evaluates it. See the service
/// documentation for additional information.
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct Expr {
    /// Textual representation of an expression in Common Expression Language
    /// syntax.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub expression: std::string::String,

    /// Optional. Title for the expression, i.e. a short string describing
    /// its purpose. This can be used e.g. in UIs which allow to enter the
    /// expression.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub title: std::string::String,

    /// Optional. Description of the expression. This is a longer text which
    /// describes the expression, e.g. when hovered over it in a UI.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub description: std::string::String,

    /// Optional. String indicating the location of the expression for error
    /// reporting, e.g. a file name and a position in the file.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub location: std::string::String,
}

impl Expr {
    /// Sets the value of [expression][crate::model::Expr::expression].
    pub fn set_expression<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.expression = v.into();
        self
    }

    /// Sets the value of [title][crate::model::Expr::title].
    pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.title = v.into();
        self
    }

    /// Sets the value of [description][crate::model::Expr::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [location][crate::model::Expr::location].
    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.location = v.into();
        self
    }
}

impl wkt::message::Message for Expr {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.Expr"
    }
}

/// Represents a fraction in terms of a numerator divided by a denominator.
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct Fraction {
    /// The numerator in the fraction, e.g. 2 in 2/3.
    #[serde_as(as = "serde_with::DisplayFromStr")]
    pub numerator: i64,

    /// The value by which the numerator is divided, e.g. 3 in 2/3. Must be
    /// positive.
    #[serde_as(as = "serde_with::DisplayFromStr")]
    pub denominator: i64,
}

impl Fraction {
    /// Sets the value of [numerator][crate::model::Fraction::numerator].
    pub fn set_numerator<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.numerator = v.into();
        self
    }

    /// Sets the value of [denominator][crate::model::Fraction::denominator].
    pub fn set_denominator<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.denominator = v.into();
        self
    }
}

impl wkt::message::Message for Fraction {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.Fraction"
    }
}

/// Represents a time interval, encoded as a Timestamp start (inclusive) and a
/// Timestamp end (exclusive).
///
/// The start must be less than or equal to the end.
/// When the start equals the end, the interval is empty (matches no time).
/// When both start and end are unspecified, the interval matches any time.
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct Interval {
    /// Optional. Inclusive start of the interval.
    ///
    /// If specified, a Timestamp matching this interval will have to be the same
    /// or after the start.
    #[serde(skip_serializing_if = "std::option::Option::is_none")]
    pub start_time: std::option::Option<wkt::Timestamp>,

    /// Optional. Exclusive end of the interval.
    ///
    /// If specified, a Timestamp matching this interval will have to be before the
    /// end.
    #[serde(skip_serializing_if = "std::option::Option::is_none")]
    pub end_time: std::option::Option<wkt::Timestamp>,
}

impl Interval {
    /// Sets the value of [start_time][crate::model::Interval::start_time].
    pub fn set_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
        mut self,
        v: T,
    ) -> Self {
        self.start_time = v.into();
        self
    }

    /// Sets the value of [end_time][crate::model::Interval::end_time].
    pub fn set_end_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
        mut self,
        v: T,
    ) -> Self {
        self.end_time = v.into();
        self
    }
}

impl wkt::message::Message for Interval {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.Interval"
    }
}

/// An object that represents a latitude/longitude pair. This is expressed as a
/// pair of doubles to represent degrees latitude and degrees longitude. Unless
/// specified otherwise, this must conform to the
/// <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
/// standard</a>. Values must be within normalized ranges.
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct LatLng {
    /// The latitude in degrees. It must be in the range [-90.0, +90.0].
    pub latitude: f64,

    /// The longitude in degrees. It must be in the range [-180.0, +180.0].
    pub longitude: f64,
}

impl LatLng {
    /// Sets the value of [latitude][crate::model::LatLng::latitude].
    pub fn set_latitude<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.latitude = v.into();
        self
    }

    /// Sets the value of [longitude][crate::model::LatLng::longitude].
    pub fn set_longitude<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.longitude = v.into();
        self
    }
}

impl wkt::message::Message for LatLng {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.LatLng"
    }
}

/// Localized variant of a text in a particular language.
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct LocalizedText {
    /// Localized string in the language corresponding to `language_code' below.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub text: std::string::String,

    /// The text's BCP-47 language code, such as "en-US" or "sr-Latn".
    ///
    /// For more information, see
    /// <http://www.unicode.org/reports/tr35/#Unicode_locale_identifier>.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub language_code: std::string::String,
}

impl LocalizedText {
    /// Sets the value of [text][crate::model::LocalizedText::text].
    pub fn set_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.text = v.into();
        self
    }

    /// Sets the value of [language_code][crate::model::LocalizedText::language_code].
    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.language_code = v.into();
        self
    }
}

impl wkt::message::Message for LocalizedText {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.LocalizedText"
    }
}

/// Represents an amount of money with its currency type.
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct Money {
    /// The three-letter currency code defined in ISO 4217.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub currency_code: std::string::String,

    /// The whole units of the amount.
    /// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
    #[serde_as(as = "serde_with::DisplayFromStr")]
    pub units: i64,

    /// Number of nano (10^-9) units of the amount.
    /// The value must be between -999,999,999 and +999,999,999 inclusive.
    /// If `units` is positive, `nanos` must be positive or zero.
    /// If `units` is zero, `nanos` can be positive, zero, or negative.
    /// If `units` is negative, `nanos` must be negative or zero.
    /// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
    pub nanos: i32,
}

impl Money {
    /// Sets the value of [currency_code][crate::model::Money::currency_code].
    pub fn set_currency_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.currency_code = v.into();
        self
    }

    /// Sets the value of [units][crate::model::Money::units].
    pub fn set_units<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.units = v.into();
        self
    }

    /// Sets the value of [nanos][crate::model::Money::nanos].
    pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.nanos = v.into();
        self
    }
}

impl wkt::message::Message for Money {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.Money"
    }
}

/// An object representing a phone number, suitable as an API wire format.
///
/// This representation:
///
/// - should not be used for locale-specific formatting of a phone number, such
///   as "+1 (650) 253-0000 ext. 123"
///
/// - is not designed for efficient storage
///
/// - may not be suitable for dialing - specialized libraries (see references)
///   should be used to parse the number for that purpose
///
///
/// To do something meaningful with this number, such as format it for various
/// use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first.
///
/// For instance, in Java this would be:
///
/// com.google.type.PhoneNumber wireProto =
/// com.google.type.PhoneNumber.newBuilder().build();
/// com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber =
/// PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ");
/// if (!wireProto.getExtension().isEmpty()) {
/// phoneNumber.setExtension(wireProto.getExtension());
/// }
///
/// Reference(s):
///
/// - <https://github.com/google/libphonenumber>
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct PhoneNumber {
    /// The phone number's extension. The extension is not standardized in ITU
    /// recommendations, except for being defined as a series of numbers with a
    /// maximum length of 40 digits. Other than digits, some other dialing
    /// characters such as ',' (indicating a wait) or '#' may be stored here.
    ///
    /// Note that no regions currently use extensions with short codes, so this
    /// field is normally only set in conjunction with an E.164 number. It is held
    /// separately from the E.164 number to allow for short code extensions in the
    /// future.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub extension: std::string::String,

    /// Required.  Either a regular number, or a short code.  New fields may be
    /// added to the oneof below in the future, so clients should ignore phone
    /// numbers for which none of the fields they coded against are set.
    #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
    pub kind: std::option::Option<crate::model::phone_number::Kind>,
}

impl PhoneNumber {
    /// Sets the value of [extension][crate::model::PhoneNumber::extension].
    pub fn set_extension<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.extension = v.into();
        self
    }

    /// Sets the value of `kind`.
    pub fn set_kind<
        T: std::convert::Into<std::option::Option<crate::model::phone_number::Kind>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.kind = v.into();
        self
    }

    /// The value of [kind][crate::model::PhoneNumber::kind]
    /// if it holds a `E164Number`, `None` if the field is not set or
    /// holds a different branch.
    pub fn get_e164_number(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.kind.as_ref().and_then(|v| match v {
            crate::model::phone_number::Kind::E164Number(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// The value of [kind][crate::model::PhoneNumber::kind]
    /// if it holds a `ShortCode`, `None` if the field is not set or
    /// holds a different branch.
    pub fn get_short_code(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::phone_number::ShortCode>> {
        #[allow(unreachable_patterns)]
        self.kind.as_ref().and_then(|v| match v {
            crate::model::phone_number::Kind::ShortCode(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [kind][crate::model::PhoneNumber::kind]
    /// to hold a `E164Number`.
    ///
    /// Note that all the setters affecting `kind` are
    /// mutually exclusive.
    pub fn set_e164_number<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.kind =
            std::option::Option::Some(crate::model::phone_number::Kind::E164Number(v.into()));
        self
    }

    /// Sets the value of [kind][crate::model::PhoneNumber::kind]
    /// to hold a `ShortCode`.
    ///
    /// Note that all the setters affecting `kind` are
    /// mutually exclusive.
    pub fn set_short_code<
        T: std::convert::Into<std::boxed::Box<crate::model::phone_number::ShortCode>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.kind =
            std::option::Option::Some(crate::model::phone_number::Kind::ShortCode(v.into()));
        self
    }
}

impl wkt::message::Message for PhoneNumber {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.PhoneNumber"
    }
}

/// Defines additional types related to PhoneNumber
pub mod phone_number {
    #[allow(unused_imports)]
    use super::*;

    /// An object representing a short code, which is a phone number that is
    /// typically much shorter than regular phone numbers and can be used to
    /// address messages in MMS and SMS systems, as well as for abbreviated dialing
    /// (e.g. "Text 611 to see how many minutes you have remaining on your plan.").
    ///
    /// Short codes are restricted to a region and are not internationally
    /// dialable, which means the same short code can exist in different regions,
    /// with different usage and pricing, even if those regions share the same
    /// country calling code (e.g. US and CA).
    #[serde_with::serde_as]
    #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
    #[serde(default, rename_all = "camelCase")]
    #[non_exhaustive]
    pub struct ShortCode {
        /// Required. The BCP-47 region code of the location where calls to this
        /// short code can be made, such as "US" and "BB".
        ///
        /// Reference(s):
        ///
        /// - <http://www.unicode.org/reports/tr35/#unicode_region_subtag>
        #[serde(skip_serializing_if = "std::string::String::is_empty")]
        pub region_code: std::string::String,

        /// Required. The short code digits, without a leading plus ('+') or country
        /// calling code, e.g. "611".
        #[serde(skip_serializing_if = "std::string::String::is_empty")]
        pub number: std::string::String,
    }

    impl ShortCode {
        /// Sets the value of [region_code][crate::model::phone_number::ShortCode::region_code].
        pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.region_code = v.into();
            self
        }

        /// Sets the value of [number][crate::model::phone_number::ShortCode::number].
        pub fn set_number<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.number = v.into();
            self
        }
    }

    impl wkt::message::Message for ShortCode {
        fn typename() -> &'static str {
            "type.googleapis.com/google.type.PhoneNumber.ShortCode"
        }
    }

    /// Required.  Either a regular number, or a short code.  New fields may be
    /// added to the oneof below in the future, so clients should ignore phone
    /// numbers for which none of the fields they coded against are set.
    #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
    #[serde(rename_all = "camelCase")]
    #[non_exhaustive]
    pub enum Kind {
        /// The phone number, represented as a leading plus sign ('+'), followed by a
        /// phone number that uses a relaxed ITU E.164 format consisting of the
        /// country calling code (1 to 3 digits) and the subscriber number, with no
        /// additional spaces or formatting, e.g.:
        ///
        /// - correct: "+15552220123"
        /// - incorrect: "+1 (555) 222-01234 x123".
        ///
        /// The ITU E.164 format limits the latter to 12 digits, but in practice not
        /// all countries respect that, so we relax that restriction here.
        /// National-only numbers are not allowed.
        ///
        /// References:
        ///
        /// - <https://www.itu.int/rec/T-REC-E.164-201011-I>
        /// - <https://en.wikipedia.org/wiki/E.164>.
        /// - <https://en.wikipedia.org/wiki/List_of_country_calling_codes>
        E164Number(std::string::String),
        /// A short code.
        ///
        /// Reference(s):
        ///
        /// - <https://en.wikipedia.org/wiki/Short_code>
        ShortCode(std::boxed::Box<crate::model::phone_number::ShortCode>),
    }
}

/// Represents a postal address, e.g. for postal delivery or payments addresses.
/// Given a postal address, a postal service can deliver items to a premise, P.O.
/// Box or similar.
/// It is not intended to model geographical locations (roads, towns,
/// mountains).
///
/// In typical usage an address would be created via user input or from importing
/// existing data, depending on the type of process.
///
/// Advice on address input / editing:
///
/// - Use an i18n-ready address widget such as
///   <https://github.com/google/libaddressinput>)
/// - Users should not be presented with UI elements for input or editing of
///   fields outside countries where that field is used.
///
/// For more guidance on how to use this schema, please see:
/// <https://support.google.com/business/answer/6397478>
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct PostalAddress {
    /// The schema revision of the `PostalAddress`. This must be set to 0, which is
    /// the latest revision.
    ///
    /// All new revisions **must** be backward compatible with old revisions.
    pub revision: i32,

    /// Required. CLDR region code of the country/region of the address. This
    /// is never inferred and it is up to the user to ensure the value is
    /// correct. See <http://cldr.unicode.org/> and
    /// <http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html>
    /// for details. Example: "CH" for Switzerland.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub region_code: std::string::String,

    /// Optional. BCP-47 language code of the contents of this address (if
    /// known). This is often the UI language of the input form or is expected
    /// to match one of the languages used in the address' country/region, or their
    /// transliterated equivalents.
    /// This can affect formatting in certain countries, but is not critical
    /// to the correctness of the data and will never affect any validation or
    /// other non-formatting related operations.
    ///
    /// If this value is not known, it should be omitted (rather than specifying a
    /// possibly incorrect default).
    ///
    /// Examples: "zh-Hant", "ja", "ja-Latn", "en".
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub language_code: std::string::String,

    /// Optional. Postal code of the address. Not all countries use or require
    /// postal codes to be present, but where they are used, they may trigger
    /// additional validation with other parts of the address (e.g. state/zip
    /// validation in the U.S.A.).
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub postal_code: std::string::String,

    /// Optional. Additional, country-specific, sorting code. This is not used
    /// in most regions. Where it is used, the value is either a string like
    /// "CEDEX", optionally followed by a number (e.g. "CEDEX 7"), or just a number
    /// alone, representing the "sector code" (Jamaica), "delivery area indicator"
    /// (Malawi) or "post office indicator" (e.g. Côte d'Ivoire).
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub sorting_code: std::string::String,

    /// Optional. Highest administrative subdivision which is used for postal
    /// addresses of a country or region.
    /// For example, this can be a state, a province, an oblast, or a prefecture.
    /// Specifically, for Spain this is the province and not the autonomous
    /// community (e.g. "Barcelona" and not "Catalonia").
    /// Many countries don't use an administrative area in postal addresses. E.g.
    /// in Switzerland this should be left unpopulated.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub administrative_area: std::string::String,

    /// Optional. Generally refers to the city/town portion of the address.
    /// Examples: US city, IT comune, UK post town.
    /// In regions of the world where localities are not well defined or do not fit
    /// into this structure well, leave locality empty and use address_lines.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub locality: std::string::String,

    /// Optional. Sublocality of the address.
    /// For example, this can be neighborhoods, boroughs, districts.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub sublocality: std::string::String,

    /// Unstructured address lines describing the lower levels of an address.
    ///
    /// Because values in address_lines do not have type information and may
    /// sometimes contain multiple values in a single field (e.g.
    /// "Austin, TX"), it is important that the line order is clear. The order of
    /// address lines should be "envelope order" for the country/region of the
    /// address. In places where this can vary (e.g. Japan), address_language is
    /// used to make it explicit (e.g. "ja" for large-to-small ordering and
    /// "ja-Latn" or "en" for small-to-large). This way, the most specific line of
    /// an address can be selected based on the language.
    ///
    /// The minimum permitted structural representation of an address consists
    /// of a region_code with all remaining information placed in the
    /// address_lines. It would be possible to format such an address very
    /// approximately without geocoding, but no semantic reasoning could be
    /// made about any of the address components until it was at least
    /// partially resolved.
    ///
    /// Creating an address only containing a region_code and address_lines, and
    /// then geocoding is the recommended way to handle completely unstructured
    /// addresses (as opposed to guessing which parts of the address should be
    /// localities or administrative areas).
    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
    pub address_lines: std::vec::Vec<std::string::String>,

    /// Optional. The recipient at the address.
    /// This field may, under certain circumstances, contain multiline information.
    /// For example, it might contain "care of" information.
    #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
    pub recipients: std::vec::Vec<std::string::String>,

    /// Optional. The name of the organization at the address.
    #[serde(skip_serializing_if = "std::string::String::is_empty")]
    pub organization: std::string::String,
}

impl PostalAddress {
    /// Sets the value of [revision][crate::model::PostalAddress::revision].
    pub fn set_revision<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.revision = v.into();
        self
    }

    /// Sets the value of [region_code][crate::model::PostalAddress::region_code].
    pub fn set_region_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.region_code = v.into();
        self
    }

    /// Sets the value of [language_code][crate::model::PostalAddress::language_code].
    pub fn set_language_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.language_code = v.into();
        self
    }

    /// Sets the value of [postal_code][crate::model::PostalAddress::postal_code].
    pub fn set_postal_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.postal_code = v.into();
        self
    }

    /// Sets the value of [sorting_code][crate::model::PostalAddress::sorting_code].
    pub fn set_sorting_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.sorting_code = v.into();
        self
    }

    /// Sets the value of [administrative_area][crate::model::PostalAddress::administrative_area].
    pub fn set_administrative_area<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.administrative_area = v.into();
        self
    }

    /// Sets the value of [locality][crate::model::PostalAddress::locality].
    pub fn set_locality<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.locality = v.into();
        self
    }

    /// Sets the value of [sublocality][crate::model::PostalAddress::sublocality].
    pub fn set_sublocality<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.sublocality = v.into();
        self
    }

    /// Sets the value of [organization][crate::model::PostalAddress::organization].
    pub fn set_organization<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.organization = v.into();
        self
    }

    /// Sets the value of [address_lines][crate::model::PostalAddress::address_lines].
    pub fn set_address_lines<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.address_lines = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [recipients][crate::model::PostalAddress::recipients].
    pub fn set_recipients<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.recipients = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for PostalAddress {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.PostalAddress"
    }
}

/// A quaternion is defined as the quotient of two directed lines in a
/// three-dimensional space or equivalently as the quotient of two Euclidean
/// vectors (<https://en.wikipedia.org/wiki/Quaternion>).
///
/// Quaternions are often used in calculations involving three-dimensional
/// rotations (<https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation>),
/// as they provide greater mathematical robustness by avoiding the gimbal lock
/// problems that can be encountered when using Euler angles
/// (<https://en.wikipedia.org/wiki/Gimbal_lock>).
///
/// Quaternions are generally represented in this form:
///
/// ```norust
/// w + xi + yj + zk
/// ```
///
/// where x, y, z, and w are real numbers, and i, j, and k are three imaginary
/// numbers.
///
/// Our naming choice `(x, y, z, w)` comes from the desire to avoid confusion for
/// those interested in the geometric properties of the quaternion in the 3D
/// Cartesian space. Other texts often use alternative names or subscripts, such
/// as `(a, b, c, d)`, `(1, i, j, k)`, or `(0, 1, 2, 3)`, which are perhaps
/// better suited for mathematical interpretations.
///
/// To avoid any confusion, as well as to maintain compatibility with a large
/// number of software libraries, the quaternions represented using the protocol
/// buffer below *must* follow the Hamilton convention, which defines `ij = k`
/// (i.e. a right-handed algebra), and therefore:
///
/// ```norust
/// i^2 = j^2 = k^2 = ijk = −1
/// ij = −ji = k
/// jk = −kj = i
/// ki = −ik = j
/// ```
///
/// Please DO NOT use this to represent quaternions that follow the JPL
/// convention, or any of the other quaternion flavors out there.
///
/// Definitions:
///
/// - Quaternion norm (or magnitude): `sqrt(x^2 + y^2 + z^2 + w^2)`.
/// - Unit (or normalized) quaternion: a quaternion whose norm is 1.
/// - Pure quaternion: a quaternion whose scalar component (`w`) is 0.
/// - Rotation quaternion: a unit quaternion used to represent rotation.
/// - Orientation quaternion: a unit quaternion used to represent orientation.
///
/// A quaternion can be normalized by dividing it by its norm. The resulting
/// quaternion maintains the same direction, but has a norm of 1, i.e. it moves
/// on the unit sphere. This is generally necessary for rotation and orientation
/// quaternions, to avoid rounding errors:
/// <https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions>
///
/// Note that `(x, y, z, w)` and `(-x, -y, -z, -w)` represent the same rotation,
/// but normalization would be even more useful, e.g. for comparison purposes, if
/// it would produce a unique representation. It is thus recommended that `w` be
/// kept positive, which can be achieved by changing all the signs when `w` is
/// negative.
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct Quaternion {
    /// The x component.
    pub x: f64,

    /// The y component.
    pub y: f64,

    /// The z component.
    pub z: f64,

    /// The scalar component.
    pub w: f64,
}

impl Quaternion {
    /// Sets the value of [x][crate::model::Quaternion::x].
    pub fn set_x<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.x = v.into();
        self
    }

    /// Sets the value of [y][crate::model::Quaternion::y].
    pub fn set_y<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.y = v.into();
        self
    }

    /// Sets the value of [z][crate::model::Quaternion::z].
    pub fn set_z<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.z = v.into();
        self
    }

    /// Sets the value of [w][crate::model::Quaternion::w].
    pub fn set_w<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
        self.w = v.into();
        self
    }
}

impl wkt::message::Message for Quaternion {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.Quaternion"
    }
}

/// Represents a time of day. The date and time zone are either not significant
/// or are specified elsewhere. An API may choose to allow leap seconds. Related
/// types are [google.type.Date][google.type.Date] and
/// `google.protobuf.Timestamp`.
///
/// [google.type.Date]: crate::model::Date
#[serde_with::serde_as]
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(default, rename_all = "camelCase")]
#[non_exhaustive]
pub struct TimeOfDay {
    /// Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
    /// to allow the value "24:00:00" for scenarios like business closing time.
    pub hours: i32,

    /// Minutes of hour of day. Must be from 0 to 59.
    pub minutes: i32,

    /// Seconds of minutes of the time. Must normally be from 0 to 59. An API may
    /// allow the value 60 if it allows leap-seconds.
    pub seconds: i32,

    /// Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
    pub nanos: i32,
}

impl TimeOfDay {
    /// Sets the value of [hours][crate::model::TimeOfDay::hours].
    pub fn set_hours<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.hours = v.into();
        self
    }

    /// Sets the value of [minutes][crate::model::TimeOfDay::minutes].
    pub fn set_minutes<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.minutes = v.into();
        self
    }

    /// Sets the value of [seconds][crate::model::TimeOfDay::seconds].
    pub fn set_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.seconds = v.into();
        self
    }

    /// Sets the value of [nanos][crate::model::TimeOfDay::nanos].
    pub fn set_nanos<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.nanos = v.into();
        self
    }
}

impl wkt::message::Message for TimeOfDay {
    fn typename() -> &'static str {
        "type.googleapis.com/google.type.TimeOfDay"
    }
}

/// A `CalendarPeriod` represents the abstract concept of a time period that has
/// a canonical start. Grammatically, "the start of the current
/// `CalendarPeriod`." All calendar times begin at midnight UTC.
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct CalendarPeriod(std::borrow::Cow<'static, str>);

impl CalendarPeriod {
    /// Creates a new CalendarPeriod instance.
    pub const fn new(v: &'static str) -> Self {
        Self(std::borrow::Cow::Borrowed(v))
    }

    /// Gets the enum value.
    pub fn value(&self) -> &str {
        &self.0
    }
}

/// Useful constants to work with [CalendarPeriod](CalendarPeriod)
pub mod calendar_period {
    use super::CalendarPeriod;

    /// Undefined period, raises an error.
    pub const CALENDAR_PERIOD_UNSPECIFIED: CalendarPeriod =
        CalendarPeriod::new("CALENDAR_PERIOD_UNSPECIFIED");

    /// A day.
    pub const DAY: CalendarPeriod = CalendarPeriod::new("DAY");

    /// A week. Weeks begin on Monday, following
    /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
    pub const WEEK: CalendarPeriod = CalendarPeriod::new("WEEK");

    /// A fortnight. The first calendar fortnight of the year begins at the start
    /// of week 1 according to
    /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date).
    pub const FORTNIGHT: CalendarPeriod = CalendarPeriod::new("FORTNIGHT");

    /// A month.
    pub const MONTH: CalendarPeriod = CalendarPeriod::new("MONTH");

    /// A quarter. Quarters start on dates 1-Jan, 1-Apr, 1-Jul, and 1-Oct of each
    /// year.
    pub const QUARTER: CalendarPeriod = CalendarPeriod::new("QUARTER");

    /// A half-year. Half-years start on dates 1-Jan and 1-Jul.
    pub const HALF: CalendarPeriod = CalendarPeriod::new("HALF");

    /// A year.
    pub const YEAR: CalendarPeriod = CalendarPeriod::new("YEAR");
}

impl std::convert::From<std::string::String> for CalendarPeriod {
    fn from(value: std::string::String) -> Self {
        Self(std::borrow::Cow::Owned(value))
    }
}

/// Represents a day of the week.
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct DayOfWeek(std::borrow::Cow<'static, str>);

impl DayOfWeek {
    /// Creates a new DayOfWeek instance.
    pub const fn new(v: &'static str) -> Self {
        Self(std::borrow::Cow::Borrowed(v))
    }

    /// Gets the enum value.
    pub fn value(&self) -> &str {
        &self.0
    }
}

/// Useful constants to work with [DayOfWeek](DayOfWeek)
pub mod day_of_week {
    use super::DayOfWeek;

    /// The day of the week is unspecified.
    pub const DAY_OF_WEEK_UNSPECIFIED: DayOfWeek = DayOfWeek::new("DAY_OF_WEEK_UNSPECIFIED");

    /// Monday
    pub const MONDAY: DayOfWeek = DayOfWeek::new("MONDAY");

    /// Tuesday
    pub const TUESDAY: DayOfWeek = DayOfWeek::new("TUESDAY");

    /// Wednesday
    pub const WEDNESDAY: DayOfWeek = DayOfWeek::new("WEDNESDAY");

    /// Thursday
    pub const THURSDAY: DayOfWeek = DayOfWeek::new("THURSDAY");

    /// Friday
    pub const FRIDAY: DayOfWeek = DayOfWeek::new("FRIDAY");

    /// Saturday
    pub const SATURDAY: DayOfWeek = DayOfWeek::new("SATURDAY");

    /// Sunday
    pub const SUNDAY: DayOfWeek = DayOfWeek::new("SUNDAY");
}

impl std::convert::From<std::string::String> for DayOfWeek {
    fn from(value: std::string::String) -> Self {
        Self(std::borrow::Cow::Owned(value))
    }
}

/// Represents a month in the Gregorian calendar.
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct Month(std::borrow::Cow<'static, str>);

impl Month {
    /// Creates a new Month instance.
    pub const fn new(v: &'static str) -> Self {
        Self(std::borrow::Cow::Borrowed(v))
    }

    /// Gets the enum value.
    pub fn value(&self) -> &str {
        &self.0
    }
}

/// Useful constants to work with [Month](Month)
pub mod month {
    use super::Month;

    /// The unspecified month.
    pub const MONTH_UNSPECIFIED: Month = Month::new("MONTH_UNSPECIFIED");

    /// The month of January.
    pub const JANUARY: Month = Month::new("JANUARY");

    /// The month of February.
    pub const FEBRUARY: Month = Month::new("FEBRUARY");

    /// The month of March.
    pub const MARCH: Month = Month::new("MARCH");

    /// The month of April.
    pub const APRIL: Month = Month::new("APRIL");

    /// The month of May.
    pub const MAY: Month = Month::new("MAY");

    /// The month of June.
    pub const JUNE: Month = Month::new("JUNE");

    /// The month of July.
    pub const JULY: Month = Month::new("JULY");

    /// The month of August.
    pub const AUGUST: Month = Month::new("AUGUST");

    /// The month of September.
    pub const SEPTEMBER: Month = Month::new("SEPTEMBER");

    /// The month of October.
    pub const OCTOBER: Month = Month::new("OCTOBER");

    /// The month of November.
    pub const NOVEMBER: Month = Month::new("NOVEMBER");

    /// The month of December.
    pub const DECEMBER: Month = Month::new("DECEMBER");
}

impl std::convert::From<std::string::String> for Month {
    fn from(value: std::string::String) -> Self {
        Self(std::borrow::Cow::Owned(value))
    }
}