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
// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium -Af resources/istio/v1_23_0/networking/v1beta1/VirtualService.yaml --api-version v1beta1
// 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 label/content routing, sni routing, etc. See more details at: <https://istio.io/docs/reference/config/networking/virtual-service.html>
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[kube(group = "networking.istio.io", version = "v1beta1", kind = "VirtualService", plural = "virtualservices")]
#[kube(namespaced)]
pub struct VirtualServiceSpec {
    /// A list of namespaces to which this virtual service is exported.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "exportTo")]
    pub export_to: Option<Vec<String>>,
    /// The names of gateways and sidecars that should apply these routes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub gateways: Option<Vec<String>>,
    /// The destination hosts to which traffic is being sent.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub hosts: Option<Vec<String>>,
    /// An ordered list of route rules for HTTP traffic.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub http: Option<Vec<VirtualServiceHttp>>,
    /// An ordered list of route rules for opaque TCP traffic.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tcp: Option<Vec<VirtualServiceTcp>>,
    /// An ordered list of route rule for non-terminated TLS & HTTPS traffic.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tls: Option<Vec<VirtualServiceTls>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttp {
    /// Cross-Origin Resource Sharing policy (CORS).
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "corsPolicy")]
    pub cors_policy: Option<VirtualServiceHttpCorsPolicy>,
    /// Delegate is used to specify the particular VirtualService which can be used to define delegate HTTPRoute.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub delegate: Option<VirtualServiceHttpDelegate>,
    /// A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "directResponse")]
    pub direct_response: Option<VirtualServiceHttpDirectResponse>,
    /// Fault injection policy to apply on HTTP traffic at the client side.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub fault: Option<VirtualServiceHttpFault>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headers: Option<VirtualServiceHttpHeaders>,
    /// Match conditions to be satisfied for the rule to be activated.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "match")]
    pub r#match: Option<Vec<VirtualServiceHttpMatch>>,
    /// Mirror HTTP traffic to a another destination in addition to forwarding the requests to the intended destination.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mirror: Option<VirtualServiceHttpMirror>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "mirrorPercent")]
    pub mirror_percent: Option<i64>,
    /// Percentage of the traffic to be mirrored by the `mirror` field.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "mirrorPercentage")]
    pub mirror_percentage: Option<VirtualServiceHttpMirrorPercentage>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "mirror_percent")]
    pub mirror_percent_x: Option<i64>,
    /// Specifies the destinations to mirror HTTP traffic in addition to the original destination.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub mirrors: Option<Vec<VirtualServiceHttpMirrors>>,
    /// The name assigned to the route for debugging purposes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub redirect: Option<VirtualServiceHttpRedirect>,
    /// Retry policy for HTTP requests.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub retries: Option<VirtualServiceHttpRetries>,
    /// Rewrite HTTP URIs and Authority headers.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub rewrite: Option<VirtualServiceHttpRewrite>,
    /// A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub route: Option<Vec<VirtualServiceHttpRoute>>,
    /// Timeout for HTTP requests, default is disabled.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timeout: Option<String>,
}

/// Cross-Origin Resource Sharing policy (CORS).
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpCorsPolicy {
    /// Indicates whether the caller is allowed to send the actual request (not the preflight) using credentials.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowCredentials")]
    pub allow_credentials: Option<bool>,
    /// List of HTTP headers that can be used when requesting the resource.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowHeaders")]
    pub allow_headers: Option<Vec<String>>,
    /// List of HTTP methods allowed to access the resource.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowMethods")]
    pub allow_methods: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowOrigin")]
    pub allow_origin: Option<Vec<String>>,
    /// String patterns that match allowed origins.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allowOrigins")]
    pub allow_origins: Option<Vec<VirtualServiceHttpCorsPolicyAllowOrigins>>,
    /// A list of HTTP headers that the browsers are allowed to access.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "exposeHeaders")]
    pub expose_headers: Option<Vec<String>>,
    /// Specifies how long the results of a preflight request can be cached.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
    pub max_age: Option<String>,
    /// Indicates whether preflight requests not matching the configured allowed origin shouldn't be forwarded to the upstream.
    /// 
    /// Valid Options: FORWARD, IGNORE
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "unmatchedPreflights")]
    pub unmatched_preflights: Option<VirtualServiceHttpCorsPolicyUnmatchedPreflights>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpCorsPolicyAllowOrigins {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// Cross-Origin Resource Sharing policy (CORS).
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum VirtualServiceHttpCorsPolicyUnmatchedPreflights {
    #[serde(rename = "UNSPECIFIED")]
    Unspecified,
    #[serde(rename = "FORWARD")]
    Forward,
    #[serde(rename = "IGNORE")]
    Ignore,
}

/// Delegate is used to specify the particular VirtualService which can be used to define delegate HTTPRoute.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpDelegate {
    /// Name specifies the name of the delegate VirtualService.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Namespace specifies the namespace where the delegate VirtualService resides.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
}

/// A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpDirectResponse {
    /// Specifies the content of the response body.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub body: Option<VirtualServiceHttpDirectResponseBody>,
    /// Specifies the HTTP response status to be returned.
    pub status: i64,
}

/// Specifies the content of the response body.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpDirectResponseBody {
    /// response body as base64 encoded bytes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub bytes: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub string: Option<String>,
}

/// Fault injection policy to apply on HTTP traffic at the client side.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpFault {
    /// Abort Http request attempts and return error codes back to downstream service, giving the impression that the upstream service is faulty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub abort: Option<VirtualServiceHttpFaultAbort>,
    /// Delay requests before forwarding, emulating various failures such as network issues, overloaded upstream service, etc.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub delay: Option<VirtualServiceHttpFaultDelay>,
}

/// Abort Http request attempts and return error codes back to downstream service, giving the impression that the upstream service is faulty.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpFaultAbort {
    /// GRPC status code to use to abort the request.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "grpcStatus")]
    pub grpc_status: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "http2Error")]
    pub http2_error: Option<String>,
    /// HTTP status code to use to abort the Http request.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpStatus")]
    pub http_status: Option<i32>,
    /// Percentage of requests to be aborted with the error code provided.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub percentage: Option<VirtualServiceHttpFaultAbortPercentage>,
}

/// Percentage of requests to be aborted with the error code provided.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpFaultAbortPercentage {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<f64>,
}

/// Delay requests before forwarding, emulating various failures such as network issues, overloaded upstream service, etc.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpFaultDelay {
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "exponentialDelay")]
    pub exponential_delay: Option<String>,
    /// Add a fixed delay before forwarding the request.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "fixedDelay")]
    pub fixed_delay: Option<String>,
    /// Percentage of requests on which the delay will be injected (0-100).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub percent: Option<i32>,
    /// Percentage of requests on which the delay will be injected.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub percentage: Option<VirtualServiceHttpFaultDelayPercentage>,
}

/// Percentage of requests on which the delay will be injected.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpFaultDelayPercentage {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<f64>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpHeaders {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub request: Option<VirtualServiceHttpHeadersRequest>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub response: Option<VirtualServiceHttpHeadersResponse>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpHeadersRequest {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub add: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub remove: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub set: Option<BTreeMap<String, String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpHeadersResponse {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub add: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub remove: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub set: Option<BTreeMap<String, String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMatch {
    /// HTTP Authority values are case-sensitive and formatted as follows: - `exact: "value"` for exact string match - `prefix: "value"` for prefix-based match - `regex: "value"` for [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub authority: Option<VirtualServiceHttpMatchAuthority>,
    /// Names of gateways where the rule should be applied.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub gateways: Option<Vec<String>>,
    /// The header keys must be lowercase and use hyphen as the separator, e.g.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headers: Option<BTreeMap<String, VirtualServiceHttpMatchHeaders>>,
    /// Flag to specify whether the URI matching should be case-insensitive.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "ignoreUriCase")]
    pub ignore_uri_case: Option<bool>,
    /// HTTP Method values are case-sensitive and formatted as follows: - `exact: "value"` for exact string match - `prefix: "value"` for prefix-based match - `regex: "value"` for [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub method: Option<VirtualServiceHttpMatchMethod>,
    /// The name assigned to a match.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Specifies the ports on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<i64>,
    /// Query parameters for matching.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "queryParams")]
    pub query_params: Option<BTreeMap<String, VirtualServiceHttpMatchQueryParams>>,
    /// URI Scheme values are case-sensitive and formatted as follows: - `exact: "value"` for exact string match - `prefix: "value"` for prefix-based match - `regex: "value"` for [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scheme: Option<VirtualServiceHttpMatchScheme>,
    /// One or more labels that constrain the applicability of a rule to source (client) workloads with the given labels.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceLabels")]
    pub source_labels: Option<BTreeMap<String, String>>,
    /// Source namespace constraining the applicability of a rule to workloads in that namespace.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceNamespace")]
    pub source_namespace: Option<String>,
    /// The human readable prefix to use when emitting statistics for this route.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "statPrefix")]
    pub stat_prefix: Option<String>,
    /// URI to match values are case-sensitive and formatted as follows: - `exact: "value"` for exact string match - `prefix: "value"` for prefix-based match - `regex: "value"` for [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub uri: Option<VirtualServiceHttpMatchUri>,
    /// withoutHeader has the same syntax with the header, but has opposite meaning.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "withoutHeaders")]
    pub without_headers: Option<BTreeMap<String, VirtualServiceHttpMatchWithoutHeaders>>,
}

/// HTTP Authority values are case-sensitive and formatted as follows: - `exact: "value"` for exact string match - `prefix: "value"` for prefix-based match - `regex: "value"` for [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMatchAuthority {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// The header keys must be lowercase and use hyphen as the separator, e.g.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMatchHeaders {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// HTTP Method values are case-sensitive and formatted as follows: - `exact: "value"` for exact string match - `prefix: "value"` for prefix-based match - `regex: "value"` for [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMatchMethod {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// Query parameters for matching.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMatchQueryParams {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// URI Scheme values are case-sensitive and formatted as follows: - `exact: "value"` for exact string match - `prefix: "value"` for prefix-based match - `regex: "value"` for [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMatchScheme {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// URI to match values are case-sensitive and formatted as follows: - `exact: "value"` for exact string match - `prefix: "value"` for prefix-based match - `regex: "value"` for [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMatchUri {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// withoutHeader has the same syntax with the header, but has opposite meaning.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMatchWithoutHeaders {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exact: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub prefix: Option<String>,
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub regex: Option<String>,
}

/// Mirror HTTP traffic to a another destination in addition to forwarding the requests to the intended destination.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMirror {
    /// The name of a service from the service registry.
    pub host: String,
    /// Specifies the port on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<VirtualServiceHttpMirrorPort>,
    /// The name of a subset within the service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subset: Option<String>,
}

/// Specifies the port on the host that is being addressed.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMirrorPort {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub number: Option<i64>,
}

/// Percentage of the traffic to be mirrored by the `mirror` field.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMirrorPercentage {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<f64>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMirrors {
    /// Destination specifies the target of the mirror operation.
    pub destination: VirtualServiceHttpMirrorsDestination,
    /// Percentage of the traffic to be mirrored by the `destination` field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub percentage: Option<VirtualServiceHttpMirrorsPercentage>,
}

/// Destination specifies the target of the mirror operation.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMirrorsDestination {
    /// The name of a service from the service registry.
    pub host: String,
    /// Specifies the port on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<VirtualServiceHttpMirrorsDestinationPort>,
    /// The name of a subset within the service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subset: Option<String>,
}

/// Specifies the port on the host that is being addressed.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMirrorsDestinationPort {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub number: Option<i64>,
}

/// Percentage of the traffic to be mirrored by the `destination` field.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpMirrorsPercentage {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<f64>,
}

/// A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRedirect {
    /// On a redirect, overwrite the Authority/Host portion of the URL with this value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub authority: Option<String>,
    /// On a redirect, dynamically set the port: * FROM_PROTOCOL_DEFAULT: automatically set to 80 for HTTP and 443 for HTTPS.
    /// 
    /// Valid Options: FROM_PROTOCOL_DEFAULT, FROM_REQUEST_PORT
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "derivePort")]
    pub derive_port: Option<VirtualServiceHttpRedirectDerivePort>,
    /// On a redirect, overwrite the port portion of the URL with this value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<i64>,
    /// On a redirect, Specifies the HTTP status code to use in the redirect response.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "redirectCode")]
    pub redirect_code: Option<i64>,
    /// On a redirect, overwrite the scheme portion of the URL with this value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scheme: Option<String>,
    /// On a redirect, overwrite the Path portion of the URL with this value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub uri: Option<String>,
}

/// A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum VirtualServiceHttpRedirectDerivePort {
    #[serde(rename = "FROM_PROTOCOL_DEFAULT")]
    FromProtocolDefault,
    #[serde(rename = "FROM_REQUEST_PORT")]
    FromRequestPort,
}

/// Retry policy for HTTP requests.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRetries {
    /// Number of retries to be allowed for a given request.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub attempts: Option<i32>,
    /// Timeout per attempt for a given request, including the initial call and any retries.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "perTryTimeout")]
    pub per_try_timeout: Option<String>,
    /// Specifies the conditions under which retry takes place.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "retryOn")]
    pub retry_on: Option<String>,
    /// Flag to specify whether the retries should retry to other localities.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "retryRemoteLocalities")]
    pub retry_remote_localities: Option<bool>,
}

/// Rewrite HTTP URIs and Authority headers.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRewrite {
    /// rewrite the Authority/Host header with this value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub authority: Option<String>,
    /// rewrite the path (or the prefix) portion of the URI with this value.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub uri: Option<String>,
    /// rewrite the path portion of the URI with the specified regex.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "uriRegexRewrite")]
    pub uri_regex_rewrite: Option<VirtualServiceHttpRewriteUriRegexRewrite>,
}

/// rewrite the path portion of the URI with the specified regex.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRewriteUriRegexRewrite {
    /// [RE2 style regex-based match](<https://github.com/google/re2/wiki/Syntax).>
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "match")]
    pub r#match: Option<String>,
    /// The string that should replace into matching portions of original URI.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub rewrite: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRoute {
    /// Destination uniquely identifies the instances of a service to which the request/connection should be forwarded to.
    pub destination: VirtualServiceHttpRouteDestination,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub headers: Option<VirtualServiceHttpRouteHeaders>,
    /// Weight specifies the relative proportion of traffic to be forwarded to the destination.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub weight: Option<i32>,
}

/// Destination uniquely identifies the instances of a service to which the request/connection should be forwarded to.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRouteDestination {
    /// The name of a service from the service registry.
    pub host: String,
    /// Specifies the port on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<VirtualServiceHttpRouteDestinationPort>,
    /// The name of a subset within the service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subset: Option<String>,
}

/// Specifies the port on the host that is being addressed.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRouteDestinationPort {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub number: Option<i64>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRouteHeaders {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub request: Option<VirtualServiceHttpRouteHeadersRequest>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub response: Option<VirtualServiceHttpRouteHeadersResponse>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRouteHeadersRequest {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub add: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub remove: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub set: Option<BTreeMap<String, String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceHttpRouteHeadersResponse {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub add: Option<BTreeMap<String, String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub remove: Option<Vec<String>>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub set: Option<BTreeMap<String, String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTcp {
    /// Match conditions to be satisfied for the rule to be activated.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "match")]
    pub r#match: Option<Vec<VirtualServiceTcpMatch>>,
    /// The destination to which the connection should be forwarded to.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub route: Option<Vec<VirtualServiceTcpRoute>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTcpMatch {
    /// IPv4 or IPv6 ip addresses of destination with optional subnet.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "destinationSubnets")]
    pub destination_subnets: Option<Vec<String>>,
    /// Names of gateways where the rule should be applied.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub gateways: Option<Vec<String>>,
    /// Specifies the port on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<i64>,
    /// One or more labels that constrain the applicability of a rule to workloads with the given labels.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceLabels")]
    pub source_labels: Option<BTreeMap<String, String>>,
    /// Source namespace constraining the applicability of a rule to workloads in that namespace.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceNamespace")]
    pub source_namespace: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceSubnet")]
    pub source_subnet: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTcpRoute {
    /// Destination uniquely identifies the instances of a service to which the request/connection should be forwarded to.
    pub destination: VirtualServiceTcpRouteDestination,
    /// Weight specifies the relative proportion of traffic to be forwarded to the destination.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub weight: Option<i32>,
}

/// Destination uniquely identifies the instances of a service to which the request/connection should be forwarded to.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTcpRouteDestination {
    /// The name of a service from the service registry.
    pub host: String,
    /// Specifies the port on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<VirtualServiceTcpRouteDestinationPort>,
    /// The name of a subset within the service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subset: Option<String>,
}

/// Specifies the port on the host that is being addressed.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTcpRouteDestinationPort {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub number: Option<i64>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTls {
    /// Match conditions to be satisfied for the rule to be activated.
    #[serde(rename = "match")]
    pub r#match: Vec<VirtualServiceTlsMatch>,
    /// The destination to which the connection should be forwarded to.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub route: Option<Vec<VirtualServiceTlsRoute>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTlsMatch {
    /// IPv4 or IPv6 ip addresses of destination with optional subnet.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "destinationSubnets")]
    pub destination_subnets: Option<Vec<String>>,
    /// Names of gateways where the rule should be applied.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub gateways: Option<Vec<String>>,
    /// Specifies the port on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<i64>,
    /// SNI (server name indicator) to match on.
    #[serde(rename = "sniHosts")]
    pub sni_hosts: Vec<String>,
    /// One or more labels that constrain the applicability of a rule to workloads with the given labels.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceLabels")]
    pub source_labels: Option<BTreeMap<String, String>>,
    /// Source namespace constraining the applicability of a rule to workloads in that namespace.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sourceNamespace")]
    pub source_namespace: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTlsRoute {
    /// Destination uniquely identifies the instances of a service to which the request/connection should be forwarded to.
    pub destination: VirtualServiceTlsRouteDestination,
    /// Weight specifies the relative proportion of traffic to be forwarded to the destination.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub weight: Option<i32>,
}

/// Destination uniquely identifies the instances of a service to which the request/connection should be forwarded to.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTlsRouteDestination {
    /// The name of a service from the service registry.
    pub host: String,
    /// Specifies the port on the host that is being addressed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<VirtualServiceTlsRouteDestinationPort>,
    /// The name of a subset within the service.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub subset: Option<String>,
}

/// Specifies the port on the host that is being addressed.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct VirtualServiceTlsRouteDestinationPort {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub number: Option<i64>,
}