istio-api-rs 0.12.0

A collection of CRDs for api used in Istio.
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
// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium -Af resources/istio/v1_13_0/networking/v1alpha3/DestinationRule.yaml --api-version v1alpha3
// kopium version: 0.22.5

#[allow(unused_imports)]
mod prelude {
    pub use kube::CustomResource;
    pub use schemars::JsonSchema;
    pub use serde::{Serialize, Deserialize};
    pub use std::collections::BTreeMap;
}
use self::prelude::*;

/// Configuration affecting load balancing, outlier detection, etc. See more details at: <https://istio.io/docs/reference/config/networking/destination-rule.html>
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[kube(group = "networking.istio.io", version = "v1alpha3", kind = "DestinationRule", plural = "destinationrules")]
#[kube(namespaced)]
pub struct DestinationRuleSpec {
    /// A list of namespaces to which this destination rule is exported.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "exportTo")]
    pub export_to: Option<Vec<String>>,
    /// The name of a service from the service registry.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub host: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subsets: Option<Vec<DestinationRuleSubsets>>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "trafficPolicy")]
    pub traffic_policy: Option<DestinationRuleTrafficPolicy>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsets {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels: Option<BTreeMap<String, String>>,
    /// Name of the subset.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Traffic policies that apply to this subset.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "trafficPolicy")]
    pub traffic_policy: Option<DestinationRuleSubsetsTrafficPolicy>,
}

/// Traffic policies that apply to this subset.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicy {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionPool")]
    pub connection_pool: Option<DestinationRuleSubsetsTrafficPolicyConnectionPool>,
    /// Settings controlling the load balancer algorithms.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "loadBalancer")]
    pub load_balancer: Option<DestinationRuleSubsetsTrafficPolicyLoadBalancer>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "outlierDetection")]
    pub outlier_detection: Option<DestinationRuleSubsetsTrafficPolicyOutlierDetection>,
    /// Traffic policies specific to individual ports.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portLevelSettings")]
    pub port_level_settings: Option<Vec<DestinationRuleSubsetsTrafficPolicyPortLevelSettings>>,
    /// TLS related settings for connections to the upstream service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tls: Option<DestinationRuleSubsetsTrafficPolicyTls>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyConnectionPool {
    /// HTTP connection pool settings.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub http: Option<DestinationRuleSubsetsTrafficPolicyConnectionPoolHttp>,
    /// Settings common to both HTTP and TCP upstream connections.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tcp: Option<DestinationRuleSubsetsTrafficPolicyConnectionPoolTcp>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyConnectionPoolHttp {
    /// Specify if http1.1 connection should be upgraded to http2 for the associated destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "h2UpgradePolicy")]
    pub h2_upgrade_policy: Option<DestinationRuleSubsetsTrafficPolicyConnectionPoolHttpH2UpgradePolicy>,
    /// Maximum number of pending HTTP requests to a destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http1MaxPendingRequests")]
    pub http1_max_pending_requests: Option<i32>,
    /// Maximum number of requests to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http2MaxRequests")]
    pub http2_max_requests: Option<i32>,
    /// The idle timeout for upstream connection pool connections.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "idleTimeout")]
    pub idle_timeout: Option<String>,
    /// Maximum number of requests per connection to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRequestsPerConnection")]
    pub max_requests_per_connection: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRetries")]
    pub max_retries: Option<i32>,
    /// If set to true, client protocol will be preserved while initiating connection to backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useClientProtocol")]
    pub use_client_protocol: Option<bool>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleSubsetsTrafficPolicyConnectionPoolHttpH2UpgradePolicy {
    #[serde(rename = "DEFAULT")]
    Default,
    #[serde(rename = "DO_NOT_UPGRADE")]
    DoNotUpgrade,
    #[serde(rename = "UPGRADE")]
    Upgrade,
}

/// Settings common to both HTTP and TCP upstream connections.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyConnectionPoolTcp {
    /// TCP connection timeout.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectTimeout")]
    pub connect_timeout: Option<String>,
    /// Maximum number of HTTP1 /TCP connections to a destination host.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxConnections")]
    pub max_connections: Option<i32>,
    /// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "tcpKeepalive")]
    pub tcp_keepalive: Option<DestinationRuleSubsetsTrafficPolicyConnectionPoolTcpTcpKeepalive>,
}

/// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyConnectionPoolTcpTcpKeepalive {
    /// The time duration between keep-alive probes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub probes: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub time: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyLoadBalancer {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consistentHash")]
    pub consistent_hash: Option<DestinationRuleSubsetsTrafficPolicyLoadBalancerConsistentHash>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "localityLbSetting")]
    pub locality_lb_setting: Option<DestinationRuleSubsetsTrafficPolicyLoadBalancerLocalityLbSetting>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub simple: Option<DestinationRuleSubsetsTrafficPolicyLoadBalancerSimple>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyLoadBalancerConsistentHash {
    /// Hash based on HTTP cookie.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpCookie")]
    pub http_cookie: Option<DestinationRuleSubsetsTrafficPolicyLoadBalancerConsistentHashHttpCookie>,
    /// Hash based on a specific HTTP header.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpHeaderName")]
    pub http_header_name: Option<String>,
    /// Hash based on a specific HTTP query parameter.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpQueryParameterName")]
    pub http_query_parameter_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minimumRingSize")]
    pub minimum_ring_size: Option<i64>,
    /// Hash based on the source IP address.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useSourceIp")]
    pub use_source_ip: Option<bool>,
}

/// Hash based on HTTP cookie.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyLoadBalancerConsistentHashHttpCookie {
    /// Name of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Path to set for the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// Lifetime of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyLoadBalancerLocalityLbSetting {
    /// Optional: only one of distribute, failover or failoverPriority can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub distribute: Option<Vec<DestinationRuleSubsetsTrafficPolicyLoadBalancerLocalityLbSettingDistribute>>,
    /// enable locality load balancing, this is DestinationRule-level and will override mesh wide settings in entirety.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
    /// Optional: only one of distribute, failover or failoverPriority can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub failover: Option<Vec<DestinationRuleSubsetsTrafficPolicyLoadBalancerLocalityLbSettingFailover>>,
    /// failoverPriority is an ordered list of labels used to sort endpoints to do priority based load balancing.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "failoverPriority")]
    pub failover_priority: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyLoadBalancerLocalityLbSettingDistribute {
    /// Originating locality, '/' separated, e.g.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    /// Map of upstream localities to traffic distribution weights.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<BTreeMap<String, i64>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyLoadBalancerLocalityLbSettingFailover {
    /// Originating region.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleSubsetsTrafficPolicyLoadBalancerSimple {
    #[serde(rename = "ROUND_ROBIN")]
    RoundRobin,
    #[serde(rename = "LEAST_CONN")]
    LeastConn,
    #[serde(rename = "RANDOM")]
    Random,
    #[serde(rename = "PASSTHROUGH")]
    Passthrough,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyOutlierDetection {
    /// Minimum ejection duration.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "baseEjectionTime")]
    pub base_ejection_time: Option<String>,
    /// Number of 5xx errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutive5xxErrors")]
    pub consecutive5xx_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveErrors")]
    pub consecutive_errors: Option<i32>,
    /// Number of gateway errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveGatewayErrors")]
    pub consecutive_gateway_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveLocalOriginFailures")]
    pub consecutive_local_origin_failures: Option<i64>,
    /// Time interval between ejection sweep analysis.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxEjectionPercent")]
    pub max_ejection_percent: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minHealthPercent")]
    pub min_health_percent: Option<i32>,
    /// Determines whether to distinguish local origin failures from external errors.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "splitExternalLocalOriginErrors")]
    pub split_external_local_origin_errors: Option<bool>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettings {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionPool")]
    pub connection_pool: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPool>,
    /// Settings controlling the load balancer algorithms.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "loadBalancer")]
    pub load_balancer: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancer>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "outlierDetection")]
    pub outlier_detection: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsOutlierDetection>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsPort>,
    /// TLS related settings for connections to the upstream service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tls: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsTls>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPool {
    /// HTTP connection pool settings.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub http: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPoolHttp>,
    /// Settings common to both HTTP and TCP upstream connections.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tcp: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPoolTcp>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPoolHttp {
    /// Specify if http1.1 connection should be upgraded to http2 for the associated destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "h2UpgradePolicy")]
    pub h2_upgrade_policy: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPoolHttpH2UpgradePolicy>,
    /// Maximum number of pending HTTP requests to a destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http1MaxPendingRequests")]
    pub http1_max_pending_requests: Option<i32>,
    /// Maximum number of requests to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http2MaxRequests")]
    pub http2_max_requests: Option<i32>,
    /// The idle timeout for upstream connection pool connections.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "idleTimeout")]
    pub idle_timeout: Option<String>,
    /// Maximum number of requests per connection to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRequestsPerConnection")]
    pub max_requests_per_connection: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRetries")]
    pub max_retries: Option<i32>,
    /// If set to true, client protocol will be preserved while initiating connection to backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useClientProtocol")]
    pub use_client_protocol: Option<bool>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPoolHttpH2UpgradePolicy {
    #[serde(rename = "DEFAULT")]
    Default,
    #[serde(rename = "DO_NOT_UPGRADE")]
    DoNotUpgrade,
    #[serde(rename = "UPGRADE")]
    Upgrade,
}

/// Settings common to both HTTP and TCP upstream connections.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPoolTcp {
    /// TCP connection timeout.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectTimeout")]
    pub connect_timeout: Option<String>,
    /// Maximum number of HTTP1 /TCP connections to a destination host.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxConnections")]
    pub max_connections: Option<i32>,
    /// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "tcpKeepalive")]
    pub tcp_keepalive: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPoolTcpTcpKeepalive>,
}

/// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsConnectionPoolTcpTcpKeepalive {
    /// The time duration between keep-alive probes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub probes: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub time: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancer {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consistentHash")]
    pub consistent_hash: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerConsistentHash>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "localityLbSetting")]
    pub locality_lb_setting: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSetting>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub simple: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerSimple>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerConsistentHash {
    /// Hash based on HTTP cookie.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpCookie")]
    pub http_cookie: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerConsistentHashHttpCookie>,
    /// Hash based on a specific HTTP header.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpHeaderName")]
    pub http_header_name: Option<String>,
    /// Hash based on a specific HTTP query parameter.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpQueryParameterName")]
    pub http_query_parameter_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minimumRingSize")]
    pub minimum_ring_size: Option<i64>,
    /// Hash based on the source IP address.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useSourceIp")]
    pub use_source_ip: Option<bool>,
}

/// Hash based on HTTP cookie.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerConsistentHashHttpCookie {
    /// Name of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Path to set for the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// Lifetime of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSetting {
    /// Optional: only one of distribute, failover or failoverPriority can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub distribute: Option<Vec<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSettingDistribute>>,
    /// enable locality load balancing, this is DestinationRule-level and will override mesh wide settings in entirety.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
    /// Optional: only one of distribute, failover or failoverPriority can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub failover: Option<Vec<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSettingFailover>>,
    /// failoverPriority is an ordered list of labels used to sort endpoints to do priority based load balancing.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "failoverPriority")]
    pub failover_priority: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSettingDistribute {
    /// Originating locality, '/' separated, e.g.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    /// Map of upstream localities to traffic distribution weights.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<BTreeMap<String, i64>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSettingFailover {
    /// Originating region.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleSubsetsTrafficPolicyPortLevelSettingsLoadBalancerSimple {
    #[serde(rename = "ROUND_ROBIN")]
    RoundRobin,
    #[serde(rename = "LEAST_CONN")]
    LeastConn,
    #[serde(rename = "RANDOM")]
    Random,
    #[serde(rename = "PASSTHROUGH")]
    Passthrough,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsOutlierDetection {
    /// Minimum ejection duration.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "baseEjectionTime")]
    pub base_ejection_time: Option<String>,
    /// Number of 5xx errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutive5xxErrors")]
    pub consecutive5xx_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveErrors")]
    pub consecutive_errors: Option<i32>,
    /// Number of gateway errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveGatewayErrors")]
    pub consecutive_gateway_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveLocalOriginFailures")]
    pub consecutive_local_origin_failures: Option<i64>,
    /// Time interval between ejection sweep analysis.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxEjectionPercent")]
    pub max_ejection_percent: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minHealthPercent")]
    pub min_health_percent: Option<i32>,
    /// Determines whether to distinguish local origin failures from external errors.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "splitExternalLocalOriginErrors")]
    pub split_external_local_origin_errors: Option<bool>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsPort {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub number: Option<i64>,
}

/// TLS related settings for connections to the upstream service.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyPortLevelSettingsTls {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "caCertificates")]
    pub ca_certificates: Option<String>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "clientCertificate")]
    pub client_certificate: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "credentialName")]
    pub credential_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "insecureSkipVerify")]
    pub insecure_skip_verify: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mode: Option<DestinationRuleSubsetsTrafficPolicyPortLevelSettingsTlsMode>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "privateKey")]
    pub private_key: Option<String>,
    /// SNI string to present to the server during TLS handshake.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sni: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "subjectAltNames")]
    pub subject_alt_names: Option<Vec<String>>,
}

/// TLS related settings for connections to the upstream service.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleSubsetsTrafficPolicyPortLevelSettingsTlsMode {
    #[serde(rename = "DISABLE")]
    Disable,
    #[serde(rename = "SIMPLE")]
    Simple,
    #[serde(rename = "MUTUAL")]
    Mutual,
    #[serde(rename = "ISTIO_MUTUAL")]
    IstioMutual,
}

/// TLS related settings for connections to the upstream service.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleSubsetsTrafficPolicyTls {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "caCertificates")]
    pub ca_certificates: Option<String>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "clientCertificate")]
    pub client_certificate: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "credentialName")]
    pub credential_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "insecureSkipVerify")]
    pub insecure_skip_verify: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mode: Option<DestinationRuleSubsetsTrafficPolicyTlsMode>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "privateKey")]
    pub private_key: Option<String>,
    /// SNI string to present to the server during TLS handshake.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sni: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "subjectAltNames")]
    pub subject_alt_names: Option<Vec<String>>,
}

/// TLS related settings for connections to the upstream service.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleSubsetsTrafficPolicyTlsMode {
    #[serde(rename = "DISABLE")]
    Disable,
    #[serde(rename = "SIMPLE")]
    Simple,
    #[serde(rename = "MUTUAL")]
    Mutual,
    #[serde(rename = "ISTIO_MUTUAL")]
    IstioMutual,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicy {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionPool")]
    pub connection_pool: Option<DestinationRuleTrafficPolicyConnectionPool>,
    /// Settings controlling the load balancer algorithms.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "loadBalancer")]
    pub load_balancer: Option<DestinationRuleTrafficPolicyLoadBalancer>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "outlierDetection")]
    pub outlier_detection: Option<DestinationRuleTrafficPolicyOutlierDetection>,
    /// Traffic policies specific to individual ports.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portLevelSettings")]
    pub port_level_settings: Option<Vec<DestinationRuleTrafficPolicyPortLevelSettings>>,
    /// TLS related settings for connections to the upstream service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tls: Option<DestinationRuleTrafficPolicyTls>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyConnectionPool {
    /// HTTP connection pool settings.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub http: Option<DestinationRuleTrafficPolicyConnectionPoolHttp>,
    /// Settings common to both HTTP and TCP upstream connections.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tcp: Option<DestinationRuleTrafficPolicyConnectionPoolTcp>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyConnectionPoolHttp {
    /// Specify if http1.1 connection should be upgraded to http2 for the associated destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "h2UpgradePolicy")]
    pub h2_upgrade_policy: Option<DestinationRuleTrafficPolicyConnectionPoolHttpH2UpgradePolicy>,
    /// Maximum number of pending HTTP requests to a destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http1MaxPendingRequests")]
    pub http1_max_pending_requests: Option<i32>,
    /// Maximum number of requests to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http2MaxRequests")]
    pub http2_max_requests: Option<i32>,
    /// The idle timeout for upstream connection pool connections.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "idleTimeout")]
    pub idle_timeout: Option<String>,
    /// Maximum number of requests per connection to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRequestsPerConnection")]
    pub max_requests_per_connection: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRetries")]
    pub max_retries: Option<i32>,
    /// If set to true, client protocol will be preserved while initiating connection to backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useClientProtocol")]
    pub use_client_protocol: Option<bool>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleTrafficPolicyConnectionPoolHttpH2UpgradePolicy {
    #[serde(rename = "DEFAULT")]
    Default,
    #[serde(rename = "DO_NOT_UPGRADE")]
    DoNotUpgrade,
    #[serde(rename = "UPGRADE")]
    Upgrade,
}

/// Settings common to both HTTP and TCP upstream connections.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyConnectionPoolTcp {
    /// TCP connection timeout.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectTimeout")]
    pub connect_timeout: Option<String>,
    /// Maximum number of HTTP1 /TCP connections to a destination host.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxConnections")]
    pub max_connections: Option<i32>,
    /// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "tcpKeepalive")]
    pub tcp_keepalive: Option<DestinationRuleTrafficPolicyConnectionPoolTcpTcpKeepalive>,
}

/// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyConnectionPoolTcpTcpKeepalive {
    /// The time duration between keep-alive probes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub probes: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub time: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyLoadBalancer {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consistentHash")]
    pub consistent_hash: Option<DestinationRuleTrafficPolicyLoadBalancerConsistentHash>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "localityLbSetting")]
    pub locality_lb_setting: Option<DestinationRuleTrafficPolicyLoadBalancerLocalityLbSetting>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub simple: Option<DestinationRuleTrafficPolicyLoadBalancerSimple>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyLoadBalancerConsistentHash {
    /// Hash based on HTTP cookie.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpCookie")]
    pub http_cookie: Option<DestinationRuleTrafficPolicyLoadBalancerConsistentHashHttpCookie>,
    /// Hash based on a specific HTTP header.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpHeaderName")]
    pub http_header_name: Option<String>,
    /// Hash based on a specific HTTP query parameter.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpQueryParameterName")]
    pub http_query_parameter_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minimumRingSize")]
    pub minimum_ring_size: Option<i64>,
    /// Hash based on the source IP address.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useSourceIp")]
    pub use_source_ip: Option<bool>,
}

/// Hash based on HTTP cookie.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyLoadBalancerConsistentHashHttpCookie {
    /// Name of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Path to set for the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// Lifetime of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyLoadBalancerLocalityLbSetting {
    /// Optional: only one of distribute, failover or failoverPriority can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub distribute: Option<Vec<DestinationRuleTrafficPolicyLoadBalancerLocalityLbSettingDistribute>>,
    /// enable locality load balancing, this is DestinationRule-level and will override mesh wide settings in entirety.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
    /// Optional: only one of distribute, failover or failoverPriority can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub failover: Option<Vec<DestinationRuleTrafficPolicyLoadBalancerLocalityLbSettingFailover>>,
    /// failoverPriority is an ordered list of labels used to sort endpoints to do priority based load balancing.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "failoverPriority")]
    pub failover_priority: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyLoadBalancerLocalityLbSettingDistribute {
    /// Originating locality, '/' separated, e.g.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    /// Map of upstream localities to traffic distribution weights.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<BTreeMap<String, i64>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyLoadBalancerLocalityLbSettingFailover {
    /// Originating region.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleTrafficPolicyLoadBalancerSimple {
    #[serde(rename = "ROUND_ROBIN")]
    RoundRobin,
    #[serde(rename = "LEAST_CONN")]
    LeastConn,
    #[serde(rename = "RANDOM")]
    Random,
    #[serde(rename = "PASSTHROUGH")]
    Passthrough,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyOutlierDetection {
    /// Minimum ejection duration.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "baseEjectionTime")]
    pub base_ejection_time: Option<String>,
    /// Number of 5xx errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutive5xxErrors")]
    pub consecutive5xx_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveErrors")]
    pub consecutive_errors: Option<i32>,
    /// Number of gateway errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveGatewayErrors")]
    pub consecutive_gateway_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveLocalOriginFailures")]
    pub consecutive_local_origin_failures: Option<i64>,
    /// Time interval between ejection sweep analysis.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxEjectionPercent")]
    pub max_ejection_percent: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minHealthPercent")]
    pub min_health_percent: Option<i32>,
    /// Determines whether to distinguish local origin failures from external errors.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "splitExternalLocalOriginErrors")]
    pub split_external_local_origin_errors: Option<bool>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettings {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionPool")]
    pub connection_pool: Option<DestinationRuleTrafficPolicyPortLevelSettingsConnectionPool>,
    /// Settings controlling the load balancer algorithms.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "loadBalancer")]
    pub load_balancer: Option<DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancer>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "outlierDetection")]
    pub outlier_detection: Option<DestinationRuleTrafficPolicyPortLevelSettingsOutlierDetection>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<DestinationRuleTrafficPolicyPortLevelSettingsPort>,
    /// TLS related settings for connections to the upstream service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tls: Option<DestinationRuleTrafficPolicyPortLevelSettingsTls>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsConnectionPool {
    /// HTTP connection pool settings.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub http: Option<DestinationRuleTrafficPolicyPortLevelSettingsConnectionPoolHttp>,
    /// Settings common to both HTTP and TCP upstream connections.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tcp: Option<DestinationRuleTrafficPolicyPortLevelSettingsConnectionPoolTcp>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsConnectionPoolHttp {
    /// Specify if http1.1 connection should be upgraded to http2 for the associated destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "h2UpgradePolicy")]
    pub h2_upgrade_policy: Option<DestinationRuleTrafficPolicyPortLevelSettingsConnectionPoolHttpH2UpgradePolicy>,
    /// Maximum number of pending HTTP requests to a destination.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http1MaxPendingRequests")]
    pub http1_max_pending_requests: Option<i32>,
    /// Maximum number of requests to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http2MaxRequests")]
    pub http2_max_requests: Option<i32>,
    /// The idle timeout for upstream connection pool connections.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "idleTimeout")]
    pub idle_timeout: Option<String>,
    /// Maximum number of requests per connection to a backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRequestsPerConnection")]
    pub max_requests_per_connection: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxRetries")]
    pub max_retries: Option<i32>,
    /// If set to true, client protocol will be preserved while initiating connection to backend.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useClientProtocol")]
    pub use_client_protocol: Option<bool>,
}

/// HTTP connection pool settings.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleTrafficPolicyPortLevelSettingsConnectionPoolHttpH2UpgradePolicy {
    #[serde(rename = "DEFAULT")]
    Default,
    #[serde(rename = "DO_NOT_UPGRADE")]
    DoNotUpgrade,
    #[serde(rename = "UPGRADE")]
    Upgrade,
}

/// Settings common to both HTTP and TCP upstream connections.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsConnectionPoolTcp {
    /// TCP connection timeout.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectTimeout")]
    pub connect_timeout: Option<String>,
    /// Maximum number of HTTP1 /TCP connections to a destination host.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxConnections")]
    pub max_connections: Option<i32>,
    /// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "tcpKeepalive")]
    pub tcp_keepalive: Option<DestinationRuleTrafficPolicyPortLevelSettingsConnectionPoolTcpTcpKeepalive>,
}

/// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsConnectionPoolTcpTcpKeepalive {
    /// The time duration between keep-alive probes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub probes: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub time: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancer {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consistentHash")]
    pub consistent_hash: Option<DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerConsistentHash>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "localityLbSetting")]
    pub locality_lb_setting: Option<DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSetting>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub simple: Option<DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerSimple>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerConsistentHash {
    /// Hash based on HTTP cookie.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpCookie")]
    pub http_cookie: Option<DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerConsistentHashHttpCookie>,
    /// Hash based on a specific HTTP header.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpHeaderName")]
    pub http_header_name: Option<String>,
    /// Hash based on a specific HTTP query parameter.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpQueryParameterName")]
    pub http_query_parameter_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minimumRingSize")]
    pub minimum_ring_size: Option<i64>,
    /// Hash based on the source IP address.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useSourceIp")]
    pub use_source_ip: Option<bool>,
}

/// Hash based on HTTP cookie.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerConsistentHashHttpCookie {
    /// Name of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Path to set for the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// Lifetime of the cookie.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ttl: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSetting {
    /// Optional: only one of distribute, failover or failoverPriority can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub distribute: Option<Vec<DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSettingDistribute>>,
    /// enable locality load balancing, this is DestinationRule-level and will override mesh wide settings in entirety.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
    /// Optional: only one of distribute, failover or failoverPriority can be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub failover: Option<Vec<DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSettingFailover>>,
    /// failoverPriority is an ordered list of labels used to sort endpoints to do priority based load balancing.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "failoverPriority")]
    pub failover_priority: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSettingDistribute {
    /// Originating locality, '/' separated, e.g.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    /// Map of upstream localities to traffic distribution weights.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<BTreeMap<String, i64>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerLocalityLbSettingFailover {
    /// Originating region.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub to: Option<String>,
}

/// Settings controlling the load balancer algorithms.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleTrafficPolicyPortLevelSettingsLoadBalancerSimple {
    #[serde(rename = "ROUND_ROBIN")]
    RoundRobin,
    #[serde(rename = "LEAST_CONN")]
    LeastConn,
    #[serde(rename = "RANDOM")]
    Random,
    #[serde(rename = "PASSTHROUGH")]
    Passthrough,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsOutlierDetection {
    /// Minimum ejection duration.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "baseEjectionTime")]
    pub base_ejection_time: Option<String>,
    /// Number of 5xx errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutive5xxErrors")]
    pub consecutive5xx_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveErrors")]
    pub consecutive_errors: Option<i32>,
    /// Number of gateway errors before a host is ejected from the connection pool.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveGatewayErrors")]
    pub consecutive_gateway_errors: Option<i64>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "consecutiveLocalOriginFailures")]
    pub consecutive_local_origin_failures: Option<i64>,
    /// Time interval between ejection sweep analysis.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxEjectionPercent")]
    pub max_ejection_percent: Option<i32>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "minHealthPercent")]
    pub min_health_percent: Option<i32>,
    /// Determines whether to distinguish local origin failures from external errors.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "splitExternalLocalOriginErrors")]
    pub split_external_local_origin_errors: Option<bool>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsPort {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub number: Option<i64>,
}

/// TLS related settings for connections to the upstream service.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyPortLevelSettingsTls {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "caCertificates")]
    pub ca_certificates: Option<String>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "clientCertificate")]
    pub client_certificate: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "credentialName")]
    pub credential_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "insecureSkipVerify")]
    pub insecure_skip_verify: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mode: Option<DestinationRuleTrafficPolicyPortLevelSettingsTlsMode>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "privateKey")]
    pub private_key: Option<String>,
    /// SNI string to present to the server during TLS handshake.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sni: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "subjectAltNames")]
    pub subject_alt_names: Option<Vec<String>>,
}

/// TLS related settings for connections to the upstream service.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleTrafficPolicyPortLevelSettingsTlsMode {
    #[serde(rename = "DISABLE")]
    Disable,
    #[serde(rename = "SIMPLE")]
    Simple,
    #[serde(rename = "MUTUAL")]
    Mutual,
    #[serde(rename = "ISTIO_MUTUAL")]
    IstioMutual,
}

/// TLS related settings for connections to the upstream service.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct DestinationRuleTrafficPolicyTls {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "caCertificates")]
    pub ca_certificates: Option<String>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "clientCertificate")]
    pub client_certificate: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "credentialName")]
    pub credential_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "insecureSkipVerify")]
    pub insecure_skip_verify: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mode: Option<DestinationRuleTrafficPolicyTlsMode>,
    /// REQUIRED if mode is `MUTUAL`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "privateKey")]
    pub private_key: Option<String>,
    /// SNI string to present to the server during TLS handshake.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sni: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "subjectAltNames")]
    pub subject_alt_names: Option<Vec<String>>,
}

/// TLS related settings for connections to the upstream service.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum DestinationRuleTrafficPolicyTlsMode {
    #[serde(rename = "DISABLE")]
    Disable,
    #[serde(rename = "SIMPLE")]
    Simple,
    #[serde(rename = "MUTUAL")]
    Mutual,
    #[serde(rename = "ISTIO_MUTUAL")]
    IstioMutual,
}