consul_api/
structs_1_20_1.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
// The content of this file is generated by 'scanner/main.go'.
// Do not modify it manually.
// Manual changes may cause issues with the program's operation.
// If modifications are needed, please do so through the program's logic.

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
pub enum MeshGatewayMode {
    /// MeshGatewayModeDefault represents no specific mode and should
    /// be used to indicate that a different layer of the configuration
    /// chain should take precedence
    #[serde(rename = "")]
    Default,

    /// MeshGatewayModeNone represents that the Upstream Connect connections
    /// should be direct and not flow through a mesh gateway.
    #[serde(rename = "none")]
    None,

    /// MeshGatewayModeLocal represents that the Upstream Connect connections
    /// should be made to a mesh gateway in the local datacenter.
    #[serde(rename = "local")]
    Local,

    /// MeshGatewayModeRemote represents that the Upstream Connect connections
    /// should be made to a mesh gateway in a remote datacenter.
    #[serde(rename = "remote")]
    Remote,
}

impl Default for MeshGatewayMode {
    fn default() -> Self {
        Self::Default
    }
}

impl ::core::fmt::Display for MeshGatewayMode {
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Default => write!(f, ""),
            Self::None => write!(f, "none"),
            Self::Local => write!(f, "local"),
            Self::Remote => write!(f, "remote"),
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
pub enum ProxyMode {
    /// ProxyModeDefault represents no specific mode and should
    /// be used to indicate that a different layer of the configuration
    /// chain should take precedence
    #[serde(rename = "")]
    Default,

    /// ProxyModeTransparent represents that inbound and outbound application
    /// traffic is being captured and redirected through the proxy.
    #[serde(rename = "transparent")]
    Transparent,

    /// ProxyModeDirect represents that the proxy's listeners must be dialed directly
    /// by the local application and other proxies.
    #[serde(rename = "direct")]
    Direct,
}

impl Default for ProxyMode {
    fn default() -> Self {
        Self::Default
    }
}

impl ::core::fmt::Display for ProxyMode {
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Default => write!(f, ""),
            Self::Transparent => write!(f, "transparent"),
            Self::Direct => write!(f, "direct"),
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
pub enum LogSinkType {
    #[serde(rename = "")]
    Default,
    #[serde(rename = "file")]
    File,
    #[serde(rename = "stderr")]
    StdErr,
    #[serde(rename = "stdout")]
    StdOut,
}

impl Default for LogSinkType {
    fn default() -> Self {
        Self::Default
    }
}

impl ::core::fmt::Display for LogSinkType {
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Default => write!(f, ""),
            Self::File => write!(f, "file"),
            Self::StdErr => write!(f, "stderr"),
            Self::StdOut => write!(f, "stdout"),
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
pub enum Health {
    /// HealthAny is special, and is used as a wild card,
    /// not as a specific state.
    #[serde(rename = "any")]
    Any,
    #[serde(rename = "passing")]
    Passing,
    #[serde(rename = "warning")]
    Warning,
    #[serde(rename = "critical")]
    Critical,
    #[serde(rename = "maintenance")]
    Maintenance,
}

impl Default for Health {
    fn default() -> Self {
        Self::Any
    }
}

impl ::core::fmt::Display for Health {
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Any => write!(f, "any"),
            Self::Passing => write!(f, "passing"),
            Self::Warning => write!(f, "warning"),
            Self::Critical => write!(f, "critical"),
            Self::Maintenance => write!(f, "maintenance"),
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
pub enum MutualTLSMode {
    #[serde(rename = "")]
    Default,
    #[serde(rename = "strict")]
    Strict,
    #[serde(rename = "permissive")]
    Permissive,
}

impl Default for MutualTLSMode {
    fn default() -> Self {
        Self::Default
    }
}

impl ::core::fmt::Display for MutualTLSMode {
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Default => write!(f, ""),
            Self::Strict => write!(f, "strict"),
            Self::Permissive => write!(f, "permissive"),
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
pub enum UpstreamDestType {
    #[serde(rename = "")]
    None,
    #[serde(rename = "service")]
    Service,
    #[serde(rename = "prepared_query")]
    PreparedQuery,
}

impl Default for UpstreamDestType {
    fn default() -> Self {
        Self::None
    }
}

impl ::core::fmt::Display for UpstreamDestType {
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::None => write!(f, ""),
            Self::Service => write!(f, "service"),
            Self::PreparedQuery => write!(f, "prepared_query"),
        }
    }
}

/// AgentWeights represent optional weights for a service
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AgentWeights {
    #[serde(rename = "Passing")]
    pub passing: isize,

    #[serde(rename = "Warning")]
    pub warning: isize,

}

/// AgentService represents a service known to the agent
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AgentService {
    #[serde(rename = "ID")]
    pub id: String,

    #[serde(rename = "Service")]
    pub service: String,

    #[serde(rename = "Tags")]
    pub tags: Vec<String>,

    #[serde(rename = "Meta")]
    pub meta: ::std::collections::HashMap<String, String>,

    #[serde(rename = "Port")]
    pub port: u16,

    #[serde(rename = "Address")]
    pub address: String,

    #[serde(rename = "SocketPath")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub socket_path: Option<String>,

    #[serde(rename = "TaggedAddresses")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tagged_addresses: Option<::std::collections::HashMap<String, ServiceAddress>>,

    #[serde(rename = "Weights")]
    pub weights: AgentWeights,

    #[serde(rename = "EnableTagOverride")]
    pub enable_tag_override: bool,

    #[serde(rename = "CreateIndex")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub create_index: Option<u64>,

    #[serde(rename = "ModifyIndex")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub modify_index: Option<u64>,

    #[serde(rename = "ContentHash")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub content_hash: Option<String>,

    #[serde(rename = "Proxy")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxy: Option<AgentServiceConnectProxyConfig>,

    #[serde(rename = "Connect")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub connect: Option<AgentServiceConnect>,

    #[serde(rename = "PeerName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub peer_name: Option<String>,

    /// NOTE: If we ever set the ContentHash outside of singular service lookup then we may need
    /// to include the Namespace in the hash. When we do, then we are in for lots of fun with tests.
    /// For now though, ignoring it works well enough.
    #[serde(rename = "Namespace")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,

    #[serde(rename = "Partition")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub partition: Option<String>,

    /// Datacenter is only ever returned and is ignored if presented.
    #[serde(rename = "Datacenter")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub datacenter: Option<String>,

    #[serde(rename = "Locality")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub locality: Option<Locality>,

}

/// AgentServiceChecksInfo returns information about a Service and its checks
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AgentServiceChecksInfo {
    #[serde(rename = "AggregatedStatus")]
    pub aggregated_status: Health,

    #[serde(rename = "Service")]
    pub service: AgentService,

    #[serde(rename = "Checks")]
    pub checks: HealthChecks,

}

/// AgentServiceConnect represents the Connect configuration of a service.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AgentServiceConnect {
    #[serde(rename = "Native")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub native: Option<bool>,

    #[serde(rename = "SidecarService")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sidecar_service: Option<Box<AgentServiceRegistration>>,

}

/// AgentServiceConnectProxyConfig is the proxy configuration in a connect-proxy
/// ServiceDefinition or response.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AgentServiceConnectProxyConfig {
    #[serde(rename = "EnvoyExtensions")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub envoy_extensions: Option<Vec<EnvoyExtension>>,

    #[serde(rename = "DestinationServiceName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub destination_service_name: Option<String>,

    #[serde(rename = "DestinationServiceID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub destination_service_id: Option<String>,

    #[serde(rename = "LocalServiceAddress")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_service_address: Option<String>,

    #[serde(rename = "LocalServicePort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_service_port: Option<u16>,

    #[serde(rename = "LocalServiceSocketPath")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_service_socket_path: Option<String>,

    #[serde(rename = "Mode")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mode: Option<ProxyMode>,

    #[serde(rename = "TransparentProxy")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transparent_proxy: Option<TransparentProxyConfig>,

    #[serde(rename = "Upstreams")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub upstreams: Option<Vec<Upstream>>,

    #[serde(rename = "MeshGateway")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mesh_gateway: Option<MeshGatewayConfig>,

    #[serde(rename = "Expose")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expose: Option<ExposeConfig>,

    #[serde(rename = "AccessLogs")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub access_logs: Option<AccessLogsConfig>,

}

/// AgentServiceRegistration is used to register a new service
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AgentServiceRegistration {
    #[serde(rename = "Kind")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub kind: Option<String>,

    #[serde(rename = "ID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,

    #[serde(rename = "Name")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,

    #[serde(rename = "Tags")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<String>>,

    #[serde(rename = "Port")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub port: Option<u16>,

    #[serde(rename = "Address")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address: Option<String>,

    #[serde(rename = "SocketPath")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub socket_path: Option<String>,

    #[serde(rename = "TaggedAddresses")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tagged_addresses: Option<::std::collections::HashMap<String, ServiceAddress>>,

    #[serde(rename = "EnableTagOverride")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub enable_tag_override: Option<bool>,

    #[serde(rename = "Meta")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub meta: Option<::std::collections::HashMap<String, String>>,

    #[serde(rename = "Weights")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weights: Option<AgentWeights>,

    #[serde(rename = "Check")]
    pub check: AgentServiceCheck,

    #[serde(rename = "Checks")]
    pub checks: AgentServiceChecks,

    #[serde(rename = "Proxy")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxy: Option<AgentServiceConnectProxyConfig>,

    #[serde(rename = "Connect")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub connect: Option<AgentServiceConnect>,

    #[serde(rename = "Namespace")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,

    #[serde(rename = "Partition")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub partition: Option<String>,

    #[serde(rename = "Locality")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub locality: Option<Locality>,

}

/// AgentServiceCheck is used to define a node or service level check
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AgentServiceCheck {
    #[serde(rename = "CheckID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub check_id: Option<String>,

    #[serde(rename = "Name")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,

    #[serde(rename = "Args")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub args: Option<Vec<String>>,

    #[serde(rename = "DockerContainerID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub docker_container_id: Option<String>,

    #[serde(rename = "Shell")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shell: Option<String>,

    #[serde(rename = "Interval")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,

    #[serde(rename = "Timeout")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timeout: Option<String>,

    #[serde(rename = "TTL")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,

    #[serde(rename = "HTTP")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub http: Option<String>,

    #[serde(rename = "Header")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub header: Option<::std::collections::HashMap<String, Vec<String>>>,

    #[serde(rename = "Method")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub method: Option<String>,

    #[serde(rename = "Body")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub body: Option<String>,

    #[serde(rename = "TCP")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tcp: Option<String>,

    #[serde(rename = "TCPUseTLS")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tcp_use_tls: Option<bool>,

    #[serde(rename = "UDP")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub udp: Option<String>,

    #[serde(rename = "Status")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,

    #[serde(rename = "Notes")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub notes: Option<String>,

    #[serde(rename = "TLSServerName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tls_server_name: Option<String>,

    #[serde(rename = "TLSSkipVerify")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tls_skip_verify: Option<bool>,

    #[serde(rename = "GRPC")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grpc: Option<String>,

    #[serde(rename = "GRPCUseTLS")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grpc_use_tls: Option<bool>,

    #[serde(rename = "H2PING")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub h2_ping: Option<String>,

    #[serde(rename = "H2PingUseTLS")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub h2_ping_use_tls: Option<bool>,

    #[serde(rename = "AliasNode")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alias_node: Option<String>,

    #[serde(rename = "AliasService")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alias_service: Option<String>,

    #[serde(rename = "SuccessBeforePassing")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub success_before_passing: Option<isize>,

    #[serde(rename = "FailuresBeforeWarning")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub failures_before_warning: Option<isize>,

    #[serde(rename = "FailuresBeforeCritical")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub failures_before_critical: Option<isize>,

    /// In Consul 0.7 and later, checks that are associated with a service
    /// may also contain this optional DeregisterCriticalServiceAfter field,
    /// which is a timeout in the same Go time format as Interval and TTL. If
    /// a check is in the critical state for more than this configured value,
    /// then its associated service (and all of its associated checks) will
    /// automatically be deregistered.
    #[serde(rename = "DeregisterCriticalServiceAfter")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub deregister_critical_service_after: Option<String>,

}

pub type AgentServiceChecks = Vec<AgentServiceCheck>;


/// QueryOptions are used to parameterize a query
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct QueryOptions {
    /// Namespace overrides the `default` namespace
    /// Note: Namespaces are available only in Consul Enterprise
    #[serde(rename = "Namespace")]
    pub namespace: String,

    /// Partition overrides the `default` partition
    /// Note: Partitions are available only in Consul Enterprise
    #[serde(rename = "Partition")]
    pub partition: String,

    /// SamenessGroup is used find the SamenessGroup in the given
    /// Partition and will find the failover order for the Service
    /// from the SamenessGroup Members, with the given Partition being
    /// the first member.
    /// Note: SamenessGroups are available only in Consul Enterprise
    #[serde(rename = "SamenessGroup")]
    pub sameness_group: String,

    /// Providing a datacenter overwrites the DC provided
    /// by the Config
    #[serde(rename = "Datacenter")]
    pub datacenter: String,

    /// Providing a peer name in the query option
    #[serde(rename = "Peer")]
    pub peer: String,

    /// AllowStale allows any Consul server (non-leader) to service
    /// a read. This allows for lower latency and higher throughput
    #[serde(rename = "AllowStale")]
    pub allow_stale: bool,

    /// RequireConsistent forces the read to be fully consistent.
    /// This is more expensive but prevents ever performing a stale
    /// read.
    #[serde(rename = "RequireConsistent")]
    pub require_consistent: bool,

    /// UseCache requests that the agent cache results locally. See
    /// https://www.consul.io/api/features/caching.html for more details on the
    /// semantics.
    #[serde(rename = "UseCache")]
    pub use_cache: bool,

    /// MaxAge limits how old a cached value will be returned if UseCache is true.
    /// If there is a cached response that is older than the MaxAge, it is treated
    /// as a cache miss and a new fetch invoked. If the fetch fails, the error is
    /// returned. Clients that wish to allow for stale results on error can set
    /// StaleIfError to a longer duration to change this behavior. It is ignored
    /// if the endpoint supports background refresh caching. See
    /// https://www.consul.io/api/features/caching.html for more details.
    #[serde(rename = "MaxAge")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_age: Option<String>,

    /// StaleIfError specifies how stale the client will accept a cached response
    /// if the servers are unavailable to fetch a fresh one. Only makes sense when
    /// UseCache is true and MaxAge is set to a lower, non-zero value. It is
    /// ignored if the endpoint supports background refresh caching. See
    /// https://www.consul.io/api/features/caching.html for more details.
    #[serde(rename = "StaleIfError")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stale_if_error: Option<String>,

    /// WaitIndex is used to enable a blocking query. Waits
    /// until the timeout or the next index is reached
    #[serde(rename = "WaitIndex")]
    pub wait_index: u64,

    /// WaitHash is used by some endpoints instead of WaitIndex to perform blocking
    /// on state based on a hash of the response rather than a monotonic index.
    /// This is required when the state being blocked on is not stored in Raft, for
    /// example agent-local proxy configuration.
    #[serde(rename = "WaitHash")]
    pub wait_hash: String,

    /// WaitTime is used to bound the duration of a wait.
    /// Defaults to that of the Config, but can be overridden.
    #[serde(rename = "WaitTime")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wait_time: Option<String>,

    /// Token is used to provide a per-request ACL token
    /// which overrides the agent's default token.
    #[serde(rename = "Token")]
    pub token: String,

    /// Near is used to provide a node name that will sort the results
    /// in ascending order based on the estimated round trip time from
    /// that node. Setting this to "_agent" will use the agent's node
    /// for the sort.
    #[serde(rename = "Near")]
    pub near: String,

    /// NodeMeta is used to filter results by nodes with the given
    /// metadata key/value pairs. Currently, only one key/value pair can
    /// be provided for filtering.
    #[serde(rename = "NodeMeta")]
    pub node_meta: ::std::collections::HashMap<String, String>,

    /// RelayFactor is used in keyring operations to cause responses to be
    /// relayed back to the sender through N other random nodes. Must be
    /// a value from 0 to 5 (inclusive).
    #[serde(rename = "RelayFactor")]
    pub relay_factor: u8,

    /// LocalOnly is used in keyring list operation to force the keyring
    /// query to only hit local servers (no WAN traffic).
    #[serde(rename = "LocalOnly")]
    pub local_only: bool,

    /// Connect filters prepared query execution to only include Connect-capable
    /// services. This currently affects prepared query execution.
    #[serde(rename = "Connect")]
    pub connect: bool,

    /// Filter requests filtering data prior to it being returned. The string
    /// is a go-bexpr compatible expression.
    #[serde(rename = "Filter")]
    pub filter: String,

    /// MergeCentralConfig returns a service definition merged with the
    /// proxy-defaults/global and service-defaults/:service config entries.
    /// This can be used to ensure a full service definition is returned in the response
    /// especially when the service might not be written into the catalog that way.
    #[serde(rename = "MergeCentralConfig")]
    pub merge_central_config: bool,

    /// Global is used to request information from all datacenters. Currently only
    /// used for operator usage requests.
    #[serde(rename = "Global")]
    pub global: bool,

}

/// HealthCheck is used to represent a single check
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct HealthCheck {
    #[serde(rename = "Node")]
    pub node: String,

    #[serde(rename = "CheckID")]
    pub check_id: String,

    #[serde(rename = "Name")]
    pub name: String,

    #[serde(rename = "Status")]
    pub status: String,

    #[serde(rename = "Notes")]
    pub notes: String,

    #[serde(rename = "Output")]
    pub output: String,

    #[serde(rename = "ServiceID")]
    pub service_id: String,

    #[serde(rename = "ServiceName")]
    pub service_name: String,

    #[serde(rename = "ServiceTags")]
    pub service_tags: Vec<String>,

    #[serde(rename = "Type")]
    pub r#type: String,

    #[serde(rename = "Namespace")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,

    #[serde(rename = "Partition")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub partition: Option<String>,

    #[serde(rename = "ExposedPort")]
    pub exposed_port: u16,

    #[serde(rename = "PeerName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub peer_name: Option<String>,

    #[serde(rename = "Definition")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub definition: Option<HealthCheckDefinition>,

    #[serde(rename = "CreateIndex")]
    pub create_index: u64,

    #[serde(rename = "ModifyIndex")]
    pub modify_index: u64,

}

pub type HealthChecks = Vec<HealthCheck>;


/// CheckDefinition is used to JSON decode the Check definitions
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct CheckDefinition {
    #[serde(rename = "ID")]
    pub id: String,

    #[serde(rename = "Name")]
    pub name: String,

    #[serde(rename = "Notes")]
    pub notes: String,

    #[serde(rename = "ServiceID")]
    pub service_id: String,

    #[serde(rename = "Token")]
    pub token: String,

    #[serde(rename = "Status")]
    pub status: String,

    /// Copied fields from CheckType without the fields
    /// already present in CheckDefinition:
    ///
    ///   ID (CheckID), Name, Status, Notes
    #[serde(rename = "ScriptArgs")]
    pub script_args: Vec<String>,

    #[serde(rename = "HTTP")]
    pub http: String,

    #[serde(rename = "H2PING")]
    pub h2_ping: String,

    #[serde(rename = "H2PingUseTLS")]
    pub h2_ping_use_tls: bool,

    #[serde(rename = "Header")]
    pub header: ::std::collections::HashMap<String, Vec<String>>,

    #[serde(rename = "Method")]
    pub method: String,

    #[serde(rename = "Body")]
    pub body: String,

    #[serde(rename = "DisableRedirects")]
    pub disable_redirects: bool,

    #[serde(rename = "TCP")]
    pub tcp: String,

    #[serde(rename = "TCPUseTLS")]
    pub tcp_use_tls: bool,

    #[serde(rename = "UDP")]
    pub udp: String,

    #[serde(rename = "Interval")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,

    #[serde(rename = "DockerContainerID")]
    pub docker_container_id: String,

    #[serde(rename = "Shell")]
    pub shell: String,

    #[serde(rename = "GRPC")]
    pub grpc: String,

    #[serde(rename = "GRPCUseTLS")]
    pub grpc_use_tls: bool,

    #[serde(rename = "OSService")]
    pub os_service: String,

    #[serde(rename = "TLSServerName")]
    pub tls_server_name: String,

    #[serde(rename = "TLSSkipVerify")]
    pub tls_skip_verify: bool,

    #[serde(rename = "AliasNode")]
    pub alias_node: String,

    #[serde(rename = "AliasService")]
    pub alias_service: String,

    #[serde(rename = "Timeout")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timeout: Option<String>,

    #[serde(rename = "TTL")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,

    #[serde(rename = "SuccessBeforePassing")]
    pub success_before_passing: isize,

    #[serde(rename = "FailuresBeforeWarning")]
    pub failures_before_warning: isize,

    #[serde(rename = "FailuresBeforeCritical")]
    pub failures_before_critical: isize,

    #[serde(rename = "DeregisterCriticalServiceAfter")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub deregister_critical_service_after: Option<String>,

    #[serde(rename = "OutputMaxSize")]
    pub output_max_size: isize,

}

/// CheckType is used to create either the CheckMonitor or the CheckTTL.
/// The following types are supported: Script, HTTP, TCP, Docker, TTL, GRPC, Alias, H2PING. Script,
/// HTTP, Docker, TCP, GRPC, and H2PING all require Interval. Only one of the types may
/// to be provided: TTL or Script/Interval or HTTP/Interval or TCP/Interval or
/// Docker/Interval or GRPC/Interval or AliasService or H2PING/Interval.
/// Since types like CheckHTTP and CheckGRPC derive from CheckType, there are
/// helper conversion methods that do the reverse conversion. ie. checkHTTP.CheckType()
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct CheckType {
    #[serde(rename = "CheckID")]
    pub check_id: String,

    #[serde(rename = "Name")]
    pub name: String,

    #[serde(rename = "Status")]
    pub status: String,

    #[serde(rename = "Notes")]
    pub notes: String,

    #[serde(rename = "ScriptArgs")]
    pub script_args: Vec<String>,

    #[serde(rename = "HTTP")]
    pub http: String,

    #[serde(rename = "H2PING")]
    pub h2_ping: String,

    #[serde(rename = "H2PingUseTLS")]
    pub h2_ping_use_tls: bool,

    #[serde(rename = "Header")]
    pub header: ::std::collections::HashMap<String, Vec<String>>,

    #[serde(rename = "Method")]
    pub method: String,

    #[serde(rename = "Body")]
    pub body: String,

    #[serde(rename = "DisableRedirects")]
    pub disable_redirects: bool,

    #[serde(rename = "TCP")]
    pub tcp: String,

    #[serde(rename = "TCPUseTLS")]
    pub tcp_use_tls: bool,

    #[serde(rename = "UDP")]
    pub udp: String,

    #[serde(rename = "Interval")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,

    #[serde(rename = "AliasNode")]
    pub alias_node: String,

    #[serde(rename = "AliasService")]
    pub alias_service: String,

    #[serde(rename = "DockerContainerID")]
    pub docker_container_id: String,

    #[serde(rename = "Shell")]
    pub shell: String,

    #[serde(rename = "GRPC")]
    pub grpc: String,

    #[serde(rename = "GRPCUseTLS")]
    pub grpc_use_tls: bool,

    #[serde(rename = "OSService")]
    pub os_service: String,

    #[serde(rename = "TLSServerName")]
    pub tls_server_name: String,

    #[serde(rename = "TLSSkipVerify")]
    pub tls_skip_verify: bool,

    #[serde(rename = "Timeout")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timeout: Option<String>,

    #[serde(rename = "TTL")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,

    #[serde(rename = "SuccessBeforePassing")]
    pub success_before_passing: isize,

    #[serde(rename = "FailuresBeforeWarning")]
    pub failures_before_warning: isize,

    #[serde(rename = "FailuresBeforeCritical")]
    pub failures_before_critical: isize,

    /// Definition fields used when exposing checks through a proxy
    #[serde(rename = "ProxyHTTP")]
    pub proxy_http: String,

    #[serde(rename = "ProxyGRPC")]
    pub proxy_grpc: String,

    /// DeregisterCriticalServiceAfter, if >0, will cause the associated
    /// service, if any, to be deregistered if this check is critical for
    /// longer than this duration.
    #[serde(rename = "DeregisterCriticalServiceAfter")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub deregister_critical_service_after: Option<String>,

    #[serde(rename = "OutputMaxSize")]
    pub output_max_size: isize,

}

pub type CheckTypes = Vec<CheckType>;


/// ConnectAuthorizeRequest is the structure of a request to authorize
/// a connection.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ConnectAuthorizeRequest {
    /// Target is the name of the service that is being requested.
    #[serde(rename = "Target")]
    pub target: String,

    /// ClientCertURI is a unique identifier for the requesting client. This
    /// is currently the URI SAN from the TLS client certificate.
    ///
    /// ClientCertSerial is a colon-hex-encoded of the serial number for
    /// the requesting client cert. This is used to check against revocation
    /// lists.
    #[serde(rename = "ClientCertURI")]
    pub client_cert_uri: String,

    #[serde(rename = "ClientCertSerial")]
    pub client_cert_serial: String,

}

/// MeshGatewayConfig controls how Mesh Gateways are configured and used
/// This is a struct to allow for future additions without having more free-hanging
/// configuration items all over the place
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct MeshGatewayConfig {
    /// The Mesh Gateway routing mode
    #[serde(rename = "Mode")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mode: Option<MeshGatewayMode>,

}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct TransparentProxyConfig {
    /// The port of the listener where outbound application traffic is being redirected to.
    #[serde(rename = "OutboundListenerPort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub outbound_listener_port: Option<u16>,

    /// DialedDirectly indicates whether transparent proxies can dial this proxy instance directly.
    /// The discovery chain is not considered when dialing a service instance directly.
    /// This setting is useful when addressing stateful services, such as a database cluster with a leader node.
    #[serde(rename = "DialedDirectly")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub dialed_directly: Option<bool>,

}

/// AccessLogsConfig contains the associated default settings for all Envoy instances within the datacenter or partition
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct AccessLogsConfig {
    /// Enabled turns off all access logging
    #[serde(rename = "Enabled")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,

    /// DisableListenerLogs turns off just listener logs for connections rejected by Envoy because they don't
    /// have a matching listener filter.
    #[serde(rename = "DisableListenerLogs")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub disable_listener_logs: Option<bool>,

    /// Type selects the output for logs: "file", "stderr". "stdout"
    #[serde(rename = "Type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#type: Option<LogSinkType>,

    /// Path is the output file to write logs
    #[serde(rename = "Path")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,

    /// The presence of one format string or the other implies the access log string encoding.
    /// Defining Both is invalid.
    #[serde(rename = "JSONFormat")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub json_format: Option<String>,

    #[serde(rename = "TextFormat")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub text_format: Option<String>,

}

/// ConnectProxyConfig describes the configuration needed for any proxy managed
/// or unmanaged. It describes a single logical service's listener and optionally
/// upstreams and sidecar-related config for a single instance. To describe a
/// centralized proxy that routed traffic for multiple services, a different one
/// of these would be needed for each, sharing the same LogicalProxyID.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ConnectProxyConfig {
    /// EnvoyExtensions are the list of Envoy extensions configured for the local service.
    #[serde(rename = "EnvoyExtensions")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub envoy_extensions: Option<Vec<EnvoyExtension>>,

    /// DestinationServiceName is required and is the name of the service to accept
    /// traffic for.
    #[serde(rename = "DestinationServiceName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub destination_service_name: Option<String>,

    /// DestinationServiceID is optional and should only be specified for
    /// "side-car" style proxies where the proxy is in front of just a single
    /// instance of the service. It should be set to the service ID of the instance
    /// being represented which must be registered to the same agent. It's valid to
    /// provide a service ID that does not yet exist to avoid timing issues when
    /// bootstrapping a service with a proxy.
    #[serde(rename = "DestinationServiceID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub destination_service_id: Option<String>,

    /// LocalServiceAddress is the address of the local service instance. It is
    /// optional and should only be specified for "side-car" style proxies. It will
    /// default to 127.0.0.1 if the proxy is a "side-car" (DestinationServiceID is
    /// set) but otherwise will be ignored.
    #[serde(rename = "LocalServiceAddress")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_service_address: Option<String>,

    /// LocalServicePort is the port of the local service instance. It is optional
    /// and should only be specified for "side-car" style proxies. It will default
    /// to the registered port for the instance if the proxy is a "side-car"
    /// (DestinationServiceID is set) but otherwise will be ignored.
    #[serde(rename = "LocalServicePort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_service_port: Option<u16>,

    /// LocalServiceSocketPath is the socket of the local service instance. It is optional
    /// and should only be specified for "side-car" style proxies.
    #[serde(rename = "LocalServiceSocketPath")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_service_socket_path: Option<String>,

    /// Mode represents how the proxy's inbound and upstream listeners are dialed.
    #[serde(rename = "Mode")]
    pub mode: ProxyMode,

    /// Upstreams describes any upstream dependencies the proxy instance should
    /// setup.
    #[serde(rename = "Upstreams")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub upstreams: Option<Upstreams>,

    /// MeshGateway defines the mesh gateway configuration for this upstream
    #[serde(rename = "MeshGateway")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mesh_gateway: Option<MeshGatewayConfig>,

    /// Expose defines whether checks or paths are exposed through the proxy
    #[serde(rename = "Expose")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expose: Option<ExposeConfig>,

    /// TransparentProxy defines configuration for when the proxy is in
    /// transparent mode.
    #[serde(rename = "TransparentProxy")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transparent_proxy: Option<TransparentProxyConfig>,

    /// AccessLogs configures the output and format of Envoy access logs
    #[serde(rename = "AccessLogs")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub access_logs: Option<AccessLogsConfig>,

}

/// Upstream represents a single upstream dependency for a service or proxy. It
/// describes the mechanism used to discover instances to communicate with (the
/// Target) as well as any potential client configuration that may be useful such
/// as load balancer options, timeouts etc.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Upstream {
    /// Destination fields are the required ones for determining what this upstream
    /// points to. Depending on DestinationType some other fields below might
    /// further restrict the set of instances allowable.
    ///
    /// DestinationType would be better as an int constant but even with custom
    /// JSON marshallers it causes havoc with all the mapstructure mangling we do
    /// on service definitions in various places.
    #[serde(rename = "DestinationType")]
    pub destination_type: String,

    #[serde(rename = "DestinationNamespace")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub destination_namespace: Option<String>,

    #[serde(rename = "DestinationPartition")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub destination_partition: Option<String>,

    #[serde(rename = "DestinationPeer")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub destination_peer: Option<String>,

    #[serde(rename = "DestinationName")]
    pub destination_name: String,

    /// Datacenter that the service discovery request should be run against. Note
    /// for prepared queries, the actual results might be from a different
    /// datacenter.
    #[serde(rename = "Datacenter")]
    pub datacenter: String,

    /// LocalBindAddress is the ip address a side-car proxy should listen on for
    /// traffic destined for this upstream service. Default if empty is 127.0.0.1.
    #[serde(rename = "LocalBindAddress")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_bind_address: Option<String>,

    /// LocalBindPort is the ip address a side-car proxy should listen on for traffic
    /// destined for this upstream service. Required.
    #[serde(rename = "LocalBindPort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_bind_port: Option<u16>,

    /// These are exclusive with LocalBindAddress/LocalBindPort
    #[serde(rename = "LocalBindSocketPath")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_bind_socket_path: Option<String>,

    /// This might be represented as an int, but because it's octal outputs can be a bit strange.
    #[serde(rename = "LocalBindSocketMode")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_bind_socket_mode: Option<String>,

    /// MeshGateway is the configuration for mesh gateway usage of this upstream
    #[serde(rename = "MeshGateway")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mesh_gateway: Option<MeshGatewayConfig>,

    /// CentrallyConfigured indicates whether the upstream was defined in a proxy
    /// instance registration or whether it was generated from a config entry.
    #[serde(rename = "CentrallyConfigured")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub centrally_configured: Option<bool>,

}

pub type Upstreams = Vec<Upstream>;


/// ExposeConfig describes HTTP paths to expose through Envoy outside of Connect.
/// Users can expose individual paths and/or all HTTP/GRPC paths for checks.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ExposeConfig {
    /// Checks defines whether paths associated with Consul checks will be exposed.
    /// This flag triggers exposing all HTTP and GRPC check paths registered for the service.
    #[serde(rename = "Checks")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checks: Option<bool>,

    /// Paths is the list of paths exposed through the proxy.
    #[serde(rename = "Paths")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub paths: Option<Vec<ExposePath>>,

}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ExposePath {
    /// ListenerPort defines the port of the proxy's listener for exposed paths.
    #[serde(rename = "ListenerPort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub listener_port: Option<u16>,

    /// Path is the path to expose through the proxy, ie. "/metrics."
    #[serde(rename = "Path")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,

    /// LocalPathPort is the port that the service is listening on for the given path.
    #[serde(rename = "LocalPathPort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub local_path_port: Option<u16>,

    /// Protocol describes the upstream's service protocol.
    /// Valid values are "http" and "http2", defaults to "http"
    #[serde(rename = "Protocol")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub protocol: Option<String>,

    /// ParsedFromCheck is set if this path was parsed from a registered check
    #[serde(rename = "ParsedFromCheck")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parsed_from_check: Option<bool>,

}

/// EnvoyExtension has configuration for an extension that patches Envoy resources.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct EnvoyExtension {
    #[serde(rename = "Name")]
    pub name: String,

    #[serde(rename = "Required")]
    pub required: bool,

    #[serde(rename = "ConsulVersion")]
    pub consul_version: String,

    #[serde(rename = "EnvoyVersion")]
    pub envoy_version: String,

}

/// ServiceDefinition is used to JSON decode the Service definitions. For
/// documentation on specific fields see NodeService which is better documented.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ServiceDefinition {
    #[serde(rename = "ID")]
    pub id: String,

    #[serde(rename = "Name")]
    pub name: String,

    #[serde(rename = "Tags")]
    pub tags: Vec<String>,

    #[serde(rename = "Address")]
    pub address: String,

    #[serde(rename = "TaggedAddresses")]
    pub tagged_addresses: ::std::collections::HashMap<String, ServiceAddress>,

    #[serde(rename = "Meta")]
    pub meta: ::std::collections::HashMap<String, String>,

    #[serde(rename = "Port")]
    pub port: u16,

    #[serde(rename = "SocketPath")]
    pub socket_path: String,

    #[serde(rename = "Check")]
    pub check: CheckType,

    #[serde(rename = "Checks")]
    pub checks: CheckTypes,

    #[serde(rename = "Weights")]
    pub weights: Weights,

    #[serde(rename = "Token")]
    pub token: String,

    #[serde(rename = "EnableTagOverride")]
    pub enable_tag_override: bool,

    #[serde(rename = "Locality")]
    pub locality: Locality,

    /// Proxy is the configuration set for Kind = connect-proxy. It is mandatory in
    /// that case and an error to be set for any other kind. This config is part of
    /// a proxy service definition. ProxyConfig may be a more natural name here, but
    /// it's confusing for the UX because one of the fields in ConnectProxyConfig is
    /// also called just "Config"
    #[serde(rename = "Proxy")]
    pub proxy: ConnectProxyConfig,

    #[serde(rename = "Connect")]
    pub connect: Box<ServiceConnect>,

}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct WriteRequest {
    /// Token is the ACL token ID. If not provided, the 'anonymous'
    /// token is assumed for backwards compatibility.
    #[serde(rename = "Token")]
    pub token: String,

}

/// Weights represent the weight used by DNS for a given status
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Weights {
    #[serde(rename = "Passing")]
    pub passing: isize,

    #[serde(rename = "Warning")]
    pub warning: isize,

}

/// Specifies weights for the service.
/// Default is {"Passing": 1, "Warning": 1}.
/// Learn more: https://developer.hashicorp.com/consul/api-docs/agent/service#weights
impl Default for Weights {
    fn default() -> Self {
        Self {
            passing: 1,
            warning: 1,
        }
    }
}


/// Type to hold a address and port of a service
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ServiceAddress {
    #[serde(rename = "Address")]
    pub address: String,

    #[serde(rename = "Port")]
    pub port: u16,

}

/// PeeringServiceMeta is read-only information provided from an exported peer.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct PeeringServiceMeta {
    #[serde(rename = "SNI")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sni: Option<Vec<String>>,

    #[serde(rename = "SpiffeID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spiffe_id: Option<Vec<String>>,

    #[serde(rename = "Protocol")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub protocol: Option<String>,

}

/// ServiceConnect are the shared Connect settings between all service
/// definitions from the agent to the state store.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ServiceConnect {
    /// Native is true when this service can natively understand Connect.
    #[serde(rename = "Native")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub native: Option<bool>,

    /// SidecarService is a nested Service Definition to register at the same time.
    /// It's purely a convenience mechanism to allow specifying a sidecar service
    /// along with the application service definition. It's nested nature allows
    /// all of the fields to be defaulted which can reduce the amount of
    /// boilerplate needed to register a sidecar service separately, but the end
    /// result is identical to just making a second service registration via any
    /// other means.
    #[serde(rename = "SidecarService")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sidecar_service: Option<Box<ServiceDefinition>>,

    #[serde(rename = "PeerMeta")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub peer_meta: Option<PeeringServiceMeta>,

}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct HealthCheckDefinition {
    #[serde(rename = "HTTP")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub http: Option<String>,

    #[serde(rename = "TLSServerName")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tls_server_name: Option<String>,

    #[serde(rename = "TLSSkipVerify")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tls_skip_verify: Option<bool>,

    #[serde(rename = "Header")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub header: Option<::std::collections::HashMap<String, Vec<String>>>,

    #[serde(rename = "Method")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub method: Option<String>,

    #[serde(rename = "Body")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub body: Option<String>,

    #[serde(rename = "DisableRedirects")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub disable_redirects: Option<bool>,

    #[serde(rename = "TCP")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tcp: Option<String>,

    #[serde(rename = "TCPUseTLS")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tcp_use_tls: Option<bool>,

    #[serde(rename = "UDP")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub udp: Option<String>,

    #[serde(rename = "H2PING")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub h2_ping: Option<String>,

    #[serde(rename = "OSService")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub os_service: Option<String>,

    #[serde(rename = "H2PingUseTLS")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub h2_ping_use_tls: Option<bool>,

    #[serde(rename = "Interval")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,

    #[serde(rename = "OutputMaxSize")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output_max_size: Option<usize>,

    #[serde(rename = "Timeout")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timeout: Option<String>,

    #[serde(rename = "DeregisterCriticalServiceAfter")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub deregister_critical_service_after: Option<String>,

    #[serde(rename = "ScriptArgs")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub script_args: Option<Vec<String>>,

    #[serde(rename = "DockerContainerID")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub docker_container_id: Option<String>,

    #[serde(rename = "Shell")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shell: Option<String>,

    #[serde(rename = "GRPC")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grpc: Option<String>,

    #[serde(rename = "GRPCUseTLS")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grpc_use_tls: Option<bool>,

    #[serde(rename = "AliasNode")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alias_node: Option<String>,

    #[serde(rename = "AliasService")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alias_service: Option<String>,

    #[serde(rename = "TTL")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,

}

/// Locality identifies where a given entity is running.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Locality {
    /// Region is region the zone belongs to.
    #[serde(rename = "Region")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub region: Option<String>,

    /// Zone is the zone the entity is running in.
    #[serde(rename = "Zone")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zone: Option<String>,

}