kcr_dataprotection_kubeblocks_io 3.20260114.105424

Kubernetes Custom Resource Bindings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium --docs --derive=Default --derive=PartialEq --smart-derive-elision --filename crd-catalog/apecloud/kubeblocks/dataprotection.kubeblocks.io/v1alpha1/backuppolicies.yaml
// kopium version: 0.22.5

#[allow(unused_imports)]
mod prelude {
    pub use kube::CustomResource;
    pub use serde::{Serialize, Deserialize};
    pub use std::collections::BTreeMap;
    pub use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString;
}
use self::prelude::*;

/// BackupPolicySpec defines the desired state of BackupPolicy
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[kube(group = "dataprotection.kubeblocks.io", version = "v1alpha1", kind = "BackupPolicy", plural = "backuppolicies")]
#[kube(namespaced)]
#[kube(status = "BackupPolicyStatus")]
#[kube(schema = "disabled")]
#[kube(derive="Default")]
#[kube(derive="PartialEq")]
pub struct BackupPolicySpec {
    /// Specifies the number of retries before marking the backup as failed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "backoffLimit")]
    pub backoff_limit: Option<i32>,
    /// Defines the backup methods.
    #[serde(rename = "backupMethods")]
    pub backup_methods: Vec<BackupPolicyBackupMethods>,
    /// Specifies the name of BackupRepo where the backup data will be stored.
    /// If not set, data will be stored in the default backup repository.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "backupRepoName")]
    pub backup_repo_name: Option<String>,
    /// Specifies the parameters for encrypting backup data.
    /// Encryption will be disabled if the field is not set.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "encryptionConfig")]
    pub encryption_config: Option<BackupPolicyEncryptionConfig>,
    /// Specifies the directory inside the backup repository to store the backup.
    /// This path is relative to the path of the backup repository.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "pathPrefix")]
    pub path_prefix: Option<String>,
    /// Specifies the backup retention policy. This has a precedence over `backup.spec.retentionPeriod`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "retentionPolicy")]
    pub retention_policy: Option<BackupPolicyRetentionPolicy>,
    /// Specifies the target information to back up, such as the target pod, the
    /// cluster connection credential.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub target: Option<BackupPolicyTarget>,
    /// Specifies multiple target information for backup operations. This includes details
    /// such as the target pod and cluster connection credentials. All specified targets
    /// will be backed up collectively.
    /// optional
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub targets: Option<Vec<BackupPolicyTargets>>,
    /// Specifies whether backup data should be stored in a Kopia repository.
    /// 
    /// 
    /// Data within the Kopia repository is both compressed and encrypted. Furthermore,
    /// data deduplication is implemented across various backups of the same cluster.
    /// This approach significantly reduces the actual storage usage, particularly
    /// for clusters with a low update frequency.
    /// 
    /// 
    /// NOTE: This feature should NOT be enabled when using KubeBlocks Community Edition, otherwise the backup will not be processed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useKopia")]
    pub use_kopia: Option<bool>,
}

/// BackupMethod defines the backup method.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethods {
    /// Refers to the ActionSet object that defines the backup actions.
    /// For volume snapshot backup, the actionSet is not required, the controller
    /// will use the CSI volume snapshotter to create the snapshot.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "actionSetName")]
    pub action_set_name: Option<String>,
    /// The name of the compatible full backup method, used by incremental backups.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "compatibleMethod")]
    pub compatible_method: Option<String>,
    /// Specifies the environment variables for the backup workload.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub env: Option<Vec<BackupPolicyBackupMethodsEnv>>,
    /// The name of backup method.
    pub name: String,
    /// Specifies runtime settings for the backup workload container.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "runtimeSettings")]
    pub runtime_settings: Option<BackupPolicyBackupMethodsRuntimeSettings>,
    /// Specifies whether to take snapshots of persistent volumes. If true,
    /// the ActionSetName is not required, the controller will use the CSI volume
    /// snapshotter to create the snapshot.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "snapshotVolumes")]
    pub snapshot_volumes: Option<bool>,
    /// Specifies the target information to back up, it will override the target in backup policy.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub target: Option<BackupPolicyBackupMethodsTarget>,
    /// Specifies which volumes from the target should be mounted in the backup workload.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "targetVolumes")]
    pub target_volumes: Option<BackupPolicyBackupMethodsTargetVolumes>,
    /// Specifies multiple target information for backup operations. This includes details
    /// such as the target pod and cluster connection credentials. All specified targets
    /// will be backed up collectively.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub targets: Option<Vec<BackupPolicyBackupMethodsTargets>>,
}

/// EnvVar represents an environment variable present in a Container.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsEnv {
    /// Name of the environment variable. Must be a C_IDENTIFIER.
    pub name: String,
    /// Variable references $(VAR_NAME) are expanded
    /// using the previously defined environment variables in the container and
    /// any service environment variables. If a variable cannot be resolved,
    /// the reference in the input string will be unchanged. Double $$ are reduced
    /// to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e.
    /// "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
    /// Escaped references will never be expanded, regardless of whether the variable
    /// exists or not.
    /// Defaults to "".
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,
    /// Source for the environment variable's value. Cannot be used if value is not empty.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "valueFrom")]
    pub value_from: Option<BackupPolicyBackupMethodsEnvValueFrom>,
}

/// Source for the environment variable's value. Cannot be used if value is not empty.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsEnvValueFrom {
    /// Selects a key of a ConfigMap.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "configMapKeyRef")]
    pub config_map_key_ref: Option<BackupPolicyBackupMethodsEnvValueFromConfigMapKeyRef>,
    /// Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`,
    /// spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "fieldRef")]
    pub field_ref: Option<BackupPolicyBackupMethodsEnvValueFromFieldRef>,
    /// Selects a resource of the container: only resources limits and requests
    /// (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "resourceFieldRef")]
    pub resource_field_ref: Option<BackupPolicyBackupMethodsEnvValueFromResourceFieldRef>,
    /// Selects a key of a secret in the pod's namespace
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "secretKeyRef")]
    pub secret_key_ref: Option<BackupPolicyBackupMethodsEnvValueFromSecretKeyRef>,
}

/// Selects a key of a ConfigMap.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsEnvValueFromConfigMapKeyRef {
    /// The key to select.
    pub key: String,
    /// Name of the referent.
    /// More info: <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names>
    /// TODO: Add other useful fields. apiVersion, kind, uid?
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Specify whether the ConfigMap or its key must be defined
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub optional: Option<bool>,
}

/// Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`,
/// spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsEnvValueFromFieldRef {
    /// Version of the schema the FieldPath is written in terms of, defaults to "v1".
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "apiVersion")]
    pub api_version: Option<String>,
    /// Path of the field to select in the specified API version.
    #[serde(rename = "fieldPath")]
    pub field_path: String,
}

/// Selects a resource of the container: only resources limits and requests
/// (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsEnvValueFromResourceFieldRef {
    /// Container name: required for volumes, optional for env vars
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerName")]
    pub container_name: Option<String>,
    /// Specifies the output format of the exposed resources, defaults to "1"
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub divisor: Option<IntOrString>,
    /// Required: resource to select
    pub resource: String,
}

/// Selects a key of a secret in the pod's namespace
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsEnvValueFromSecretKeyRef {
    /// The key of the secret to select from.  Must be a valid secret key.
    pub key: String,
    /// Name of the referent.
    /// More info: <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names>
    /// TODO: Add other useful fields. apiVersion, kind, uid?
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Specify whether the Secret or its key must be defined
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub optional: Option<bool>,
}

/// Specifies runtime settings for the backup workload container.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsRuntimeSettings {
    /// Specifies the resource required by container.
    /// More info: <https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resources: Option<BackupPolicyBackupMethodsRuntimeSettingsResources>,
}

/// Specifies the resource required by container.
/// More info: <https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/>
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsRuntimeSettingsResources {
    /// Claims lists the names of resources, defined in spec.resourceClaims,
    /// that are used by this container.
    /// 
    /// 
    /// This is an alpha field and requires enabling the
    /// DynamicResourceAllocation feature gate.
    /// 
    /// 
    /// This field is immutable. It can only be set for containers.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub claims: Option<Vec<BackupPolicyBackupMethodsRuntimeSettingsResourcesClaims>>,
    /// Limits describes the maximum amount of compute resources allowed.
    /// More info: <https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub limits: Option<BTreeMap<String, IntOrString>>,
    /// Requests describes the minimum amount of compute resources required.
    /// If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
    /// otherwise to an implementation-defined value. Requests cannot exceed Limits.
    /// More info: <https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub requests: Option<BTreeMap<String, IntOrString>>,
}

/// ResourceClaim references one entry in PodSpec.ResourceClaims.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsRuntimeSettingsResourcesClaims {
    /// Name must match the name of one entry in pod.spec.resourceClaims of
    /// the Pod where this field is used. It makes that resource available
    /// inside a container.
    pub name: String,
}

/// Specifies the target information to back up, it will override the target in backup policy.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTarget {
    /// Specifies the connection credential to connect to the target database cluster.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionCredential")]
    pub connection_credential: Option<BackupPolicyBackupMethodsTargetConnectionCredential>,
    /// Specifies the container port in the target pod.
    /// If not specified, the first container and its first port will be used.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerPort")]
    pub container_port: Option<BackupPolicyBackupMethodsTargetContainerPort>,
    /// Specifies a mandatory and unique identifier for each target when using the "targets" field.
    /// The backup data for the current target is stored in a uniquely named subdirectory.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Used to find the target pod. The volumes of the target pod will be backed up.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "podSelector")]
    pub pod_selector: Option<BackupPolicyBackupMethodsTargetPodSelector>,
    /// Specifies the kubernetes resources to back up.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resources: Option<BackupPolicyBackupMethodsTargetResources>,
    /// Specifies the service account to run the backup workload.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "serviceAccountName")]
    pub service_account_name: Option<String>,
}

/// Specifies the connection credential to connect to the target database cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetConnectionCredential {
    /// Specifies the map key of the host in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "hostKey")]
    pub host_key: Option<String>,
    /// Specifies the map key of the password in the connection credential secret.
    /// This password will be saved in the backup annotation for full backup.
    /// You can use the environment variable DP_ENCRYPTION_KEY to specify encryption key.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "passwordKey")]
    pub password_key: Option<String>,
    /// Specifies the map key of the port in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portKey")]
    pub port_key: Option<String>,
    /// Refers to the Secret object that contains the connection credential.
    #[serde(rename = "secretName")]
    pub secret_name: String,
    /// Specifies the map key of the user in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "usernameKey")]
    pub username_key: Option<String>,
}

/// Specifies the container port in the target pod.
/// If not specified, the first container and its first port will be used.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetContainerPort {
    /// Specifies the name of container with the port.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerName")]
    pub container_name: Option<String>,
    /// Specifies the port name.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portName")]
    pub port_name: Option<String>,
}

/// Used to find the target pod. The volumes of the target pod will be backed up.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetPodSelector {
    /// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
    /// This only takes effect when the `strategy` field below is set to `Any`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "fallbackLabelSelector")]
    pub fallback_label_selector: Option<BackupPolicyBackupMethodsTargetPodSelectorFallbackLabelSelector>,
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyBackupMethodsTargetPodSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
    /// Specifies the strategy to select the target pod when multiple pods are selected.
    /// Valid values are:
    /// 
    /// 
    /// - `Any`: select any one pod that match the labelsSelector.
    /// - `All`: select all pods that match the labelsSelector. The backup data for the current pod
    /// will be stored in a subdirectory named after the pod.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub strategy: Option<BackupPolicyBackupMethodsTargetPodSelectorStrategy>,
    /// UseParentSelectedPods indicates whether to use the pods selected by the parent for backup.
    /// If set to true, the backup will use the same pods selected by the parent.
    /// And only takes effect when the 'strategy' is set to 'Any'.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useParentSelectedPods")]
    pub use_parent_selected_pods: Option<bool>,
}

/// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
/// This only takes effect when the `strategy` field below is set to `Any`.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetPodSelectorFallbackLabelSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyBackupMethodsTargetPodSelectorFallbackLabelSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetPodSelectorFallbackLabelSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetPodSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// Used to find the target pod. The volumes of the target pod will be backed up.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum BackupPolicyBackupMethodsTargetPodSelectorStrategy {
    Any,
    All,
}

/// Specifies the kubernetes resources to back up.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetResources {
    /// excluded is a slice of namespaced-scoped resource type names to exclude in
    /// the kubernetes resources.
    /// The default value is empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub excluded: Option<Vec<String>>,
    /// included is a slice of namespaced-scoped resource type names to include in
    /// the kubernetes resources.
    /// The default value is empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub included: Option<Vec<String>>,
    /// A metav1.LabelSelector to filter the target kubernetes resources that need
    /// to be backed up. If not set, will do not back up any kubernetes resources.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub selector: Option<BackupPolicyBackupMethodsTargetResourcesSelector>,
}

/// A metav1.LabelSelector to filter the target kubernetes resources that need
/// to be backed up. If not set, will do not back up any kubernetes resources.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetResourcesSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyBackupMethodsTargetResourcesSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetResourcesSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// Specifies which volumes from the target should be mounted in the backup workload.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetVolumes {
    /// Specifies the mount for the volumes specified in `volumes` section.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "volumeMounts")]
    pub volume_mounts: Option<Vec<BackupPolicyBackupMethodsTargetVolumesVolumeMounts>>,
    /// Specifies the list of volumes of targeted application that should be mounted
    /// on the backup workload.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub volumes: Option<Vec<String>>,
}

/// VolumeMount describes a mounting of a Volume within a container.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetVolumesVolumeMounts {
    /// Path within the container at which the volume should be mounted.  Must
    /// not contain ':'.
    #[serde(rename = "mountPath")]
    pub mount_path: String,
    /// mountPropagation determines how mounts are propagated from the host
    /// to container and the other way around.
    /// When not set, MountPropagationNone is used.
    /// This field is beta in 1.10.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "mountPropagation")]
    pub mount_propagation: Option<String>,
    /// This must match the Name of a Volume.
    pub name: String,
    /// Mounted read-only if true, read-write otherwise (false or unspecified).
    /// Defaults to false.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "readOnly")]
    pub read_only: Option<bool>,
    /// Path within the volume from which the container's volume should be mounted.
    /// Defaults to "" (volume's root).
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "subPath")]
    pub sub_path: Option<String>,
    /// Expanded path within the volume from which the container's volume should be mounted.
    /// Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment.
    /// Defaults to "" (volume's root).
    /// SubPathExpr and SubPath are mutually exclusive.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "subPathExpr")]
    pub sub_path_expr: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargets {
    /// Specifies the connection credential to connect to the target database cluster.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionCredential")]
    pub connection_credential: Option<BackupPolicyBackupMethodsTargetsConnectionCredential>,
    /// Specifies the container port in the target pod.
    /// If not specified, the first container and its first port will be used.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerPort")]
    pub container_port: Option<BackupPolicyBackupMethodsTargetsContainerPort>,
    /// Specifies a mandatory and unique identifier for each target when using the "targets" field.
    /// The backup data for the current target is stored in a uniquely named subdirectory.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Used to find the target pod. The volumes of the target pod will be backed up.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "podSelector")]
    pub pod_selector: Option<BackupPolicyBackupMethodsTargetsPodSelector>,
    /// Specifies the kubernetes resources to back up.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resources: Option<BackupPolicyBackupMethodsTargetsResources>,
    /// Specifies the service account to run the backup workload.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "serviceAccountName")]
    pub service_account_name: Option<String>,
}

/// Specifies the connection credential to connect to the target database cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsConnectionCredential {
    /// Specifies the map key of the host in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "hostKey")]
    pub host_key: Option<String>,
    /// Specifies the map key of the password in the connection credential secret.
    /// This password will be saved in the backup annotation for full backup.
    /// You can use the environment variable DP_ENCRYPTION_KEY to specify encryption key.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "passwordKey")]
    pub password_key: Option<String>,
    /// Specifies the map key of the port in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portKey")]
    pub port_key: Option<String>,
    /// Refers to the Secret object that contains the connection credential.
    #[serde(rename = "secretName")]
    pub secret_name: String,
    /// Specifies the map key of the user in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "usernameKey")]
    pub username_key: Option<String>,
}

/// Specifies the container port in the target pod.
/// If not specified, the first container and its first port will be used.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsContainerPort {
    /// Specifies the name of container with the port.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerName")]
    pub container_name: Option<String>,
    /// Specifies the port name.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portName")]
    pub port_name: Option<String>,
}

/// Used to find the target pod. The volumes of the target pod will be backed up.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsPodSelector {
    /// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
    /// This only takes effect when the `strategy` field below is set to `Any`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "fallbackLabelSelector")]
    pub fallback_label_selector: Option<BackupPolicyBackupMethodsTargetsPodSelectorFallbackLabelSelector>,
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyBackupMethodsTargetsPodSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
    /// Specifies the strategy to select the target pod when multiple pods are selected.
    /// Valid values are:
    /// 
    /// 
    /// - `Any`: select any one pod that match the labelsSelector.
    /// - `All`: select all pods that match the labelsSelector. The backup data for the current pod
    /// will be stored in a subdirectory named after the pod.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub strategy: Option<BackupPolicyBackupMethodsTargetsPodSelectorStrategy>,
    /// UseParentSelectedPods indicates whether to use the pods selected by the parent for backup.
    /// If set to true, the backup will use the same pods selected by the parent.
    /// And only takes effect when the 'strategy' is set to 'Any'.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useParentSelectedPods")]
    pub use_parent_selected_pods: Option<bool>,
}

/// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
/// This only takes effect when the `strategy` field below is set to `Any`.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsPodSelectorFallbackLabelSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyBackupMethodsTargetsPodSelectorFallbackLabelSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsPodSelectorFallbackLabelSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsPodSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// Used to find the target pod. The volumes of the target pod will be backed up.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum BackupPolicyBackupMethodsTargetsPodSelectorStrategy {
    Any,
    All,
}

/// Specifies the kubernetes resources to back up.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsResources {
    /// excluded is a slice of namespaced-scoped resource type names to exclude in
    /// the kubernetes resources.
    /// The default value is empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub excluded: Option<Vec<String>>,
    /// included is a slice of namespaced-scoped resource type names to include in
    /// the kubernetes resources.
    /// The default value is empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub included: Option<Vec<String>>,
    /// A metav1.LabelSelector to filter the target kubernetes resources that need
    /// to be backed up. If not set, will do not back up any kubernetes resources.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub selector: Option<BackupPolicyBackupMethodsTargetsResourcesSelector>,
}

/// A metav1.LabelSelector to filter the target kubernetes resources that need
/// to be backed up. If not set, will do not back up any kubernetes resources.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsResourcesSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyBackupMethodsTargetsResourcesSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyBackupMethodsTargetsResourcesSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// Specifies the parameters for encrypting backup data.
/// Encryption will be disabled if the field is not set.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct BackupPolicyEncryptionConfig {
    /// Specifies the encryption algorithm. Currently supported algorithms are:
    /// 
    /// 
    /// - AES-128-CFB
    /// - AES-192-CFB
    /// - AES-256-CFB
    pub algorithm: BackupPolicyEncryptionConfigAlgorithm,
    /// Selects the key of a secret in the current namespace, the value of the secret
    /// is used as the encryption key.
    #[serde(rename = "passPhraseSecretKeyRef")]
    pub pass_phrase_secret_key_ref: BackupPolicyEncryptionConfigPassPhraseSecretKeyRef,
}

/// Specifies the parameters for encrypting backup data.
/// Encryption will be disabled if the field is not set.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum BackupPolicyEncryptionConfigAlgorithm {
    #[serde(rename = "AES-128-CFB")]
    Aes128Cfb,
    #[serde(rename = "AES-192-CFB")]
    Aes192Cfb,
    #[serde(rename = "AES-256-CFB")]
    Aes256Cfb,
}

/// Selects the key of a secret in the current namespace, the value of the secret
/// is used as the encryption key.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyEncryptionConfigPassPhraseSecretKeyRef {
    /// The key of the secret to select from.  Must be a valid secret key.
    pub key: String,
    /// Name of the referent.
    /// More info: <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names>
    /// TODO: Add other useful fields. apiVersion, kind, uid?
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Specify whether the Secret or its key must be defined
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub optional: Option<bool>,
}

/// BackupPolicySpec defines the desired state of BackupPolicy
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum BackupPolicyRetentionPolicy {
    #[serde(rename = "retainLatestBackup")]
    RetainLatestBackup,
    #[serde(rename = "none")]
    None,
}

/// Specifies the target information to back up, such as the target pod, the
/// cluster connection credential.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTarget {
    /// Specifies the connection credential to connect to the target database cluster.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionCredential")]
    pub connection_credential: Option<BackupPolicyTargetConnectionCredential>,
    /// Specifies the container port in the target pod.
    /// If not specified, the first container and its first port will be used.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerPort")]
    pub container_port: Option<BackupPolicyTargetContainerPort>,
    /// Specifies a mandatory and unique identifier for each target when using the "targets" field.
    /// The backup data for the current target is stored in a uniquely named subdirectory.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Used to find the target pod. The volumes of the target pod will be backed up.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "podSelector")]
    pub pod_selector: Option<BackupPolicyTargetPodSelector>,
    /// Specifies the kubernetes resources to back up.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resources: Option<BackupPolicyTargetResources>,
    /// Specifies the service account to run the backup workload.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "serviceAccountName")]
    pub service_account_name: Option<String>,
}

/// Specifies the connection credential to connect to the target database cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetConnectionCredential {
    /// Specifies the map key of the host in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "hostKey")]
    pub host_key: Option<String>,
    /// Specifies the map key of the password in the connection credential secret.
    /// This password will be saved in the backup annotation for full backup.
    /// You can use the environment variable DP_ENCRYPTION_KEY to specify encryption key.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "passwordKey")]
    pub password_key: Option<String>,
    /// Specifies the map key of the port in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portKey")]
    pub port_key: Option<String>,
    /// Refers to the Secret object that contains the connection credential.
    #[serde(rename = "secretName")]
    pub secret_name: String,
    /// Specifies the map key of the user in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "usernameKey")]
    pub username_key: Option<String>,
}

/// Specifies the container port in the target pod.
/// If not specified, the first container and its first port will be used.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetContainerPort {
    /// Specifies the name of container with the port.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerName")]
    pub container_name: Option<String>,
    /// Specifies the port name.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portName")]
    pub port_name: Option<String>,
}

/// Used to find the target pod. The volumes of the target pod will be backed up.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetPodSelector {
    /// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
    /// This only takes effect when the `strategy` field below is set to `Any`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "fallbackLabelSelector")]
    pub fallback_label_selector: Option<BackupPolicyTargetPodSelectorFallbackLabelSelector>,
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyTargetPodSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
    /// Specifies the strategy to select the target pod when multiple pods are selected.
    /// Valid values are:
    /// 
    /// 
    /// - `Any`: select any one pod that match the labelsSelector.
    /// - `All`: select all pods that match the labelsSelector. The backup data for the current pod
    /// will be stored in a subdirectory named after the pod.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub strategy: Option<BackupPolicyTargetPodSelectorStrategy>,
    /// UseParentSelectedPods indicates whether to use the pods selected by the parent for backup.
    /// If set to true, the backup will use the same pods selected by the parent.
    /// And only takes effect when the 'strategy' is set to 'Any'.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useParentSelectedPods")]
    pub use_parent_selected_pods: Option<bool>,
}

/// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
/// This only takes effect when the `strategy` field below is set to `Any`.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetPodSelectorFallbackLabelSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyTargetPodSelectorFallbackLabelSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetPodSelectorFallbackLabelSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetPodSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// Used to find the target pod. The volumes of the target pod will be backed up.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum BackupPolicyTargetPodSelectorStrategy {
    Any,
    All,
}

/// Specifies the kubernetes resources to back up.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetResources {
    /// excluded is a slice of namespaced-scoped resource type names to exclude in
    /// the kubernetes resources.
    /// The default value is empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub excluded: Option<Vec<String>>,
    /// included is a slice of namespaced-scoped resource type names to include in
    /// the kubernetes resources.
    /// The default value is empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub included: Option<Vec<String>>,
    /// A metav1.LabelSelector to filter the target kubernetes resources that need
    /// to be backed up. If not set, will do not back up any kubernetes resources.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub selector: Option<BackupPolicyTargetResourcesSelector>,
}

/// A metav1.LabelSelector to filter the target kubernetes resources that need
/// to be backed up. If not set, will do not back up any kubernetes resources.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetResourcesSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyTargetResourcesSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetResourcesSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargets {
    /// Specifies the connection credential to connect to the target database cluster.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "connectionCredential")]
    pub connection_credential: Option<BackupPolicyTargetsConnectionCredential>,
    /// Specifies the container port in the target pod.
    /// If not specified, the first container and its first port will be used.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerPort")]
    pub container_port: Option<BackupPolicyTargetsContainerPort>,
    /// Specifies a mandatory and unique identifier for each target when using the "targets" field.
    /// The backup data for the current target is stored in a uniquely named subdirectory.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Used to find the target pod. The volumes of the target pod will be backed up.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "podSelector")]
    pub pod_selector: Option<BackupPolicyTargetsPodSelector>,
    /// Specifies the kubernetes resources to back up.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resources: Option<BackupPolicyTargetsResources>,
    /// Specifies the service account to run the backup workload.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "serviceAccountName")]
    pub service_account_name: Option<String>,
}

/// Specifies the connection credential to connect to the target database cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsConnectionCredential {
    /// Specifies the map key of the host in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "hostKey")]
    pub host_key: Option<String>,
    /// Specifies the map key of the password in the connection credential secret.
    /// This password will be saved in the backup annotation for full backup.
    /// You can use the environment variable DP_ENCRYPTION_KEY to specify encryption key.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "passwordKey")]
    pub password_key: Option<String>,
    /// Specifies the map key of the port in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portKey")]
    pub port_key: Option<String>,
    /// Refers to the Secret object that contains the connection credential.
    #[serde(rename = "secretName")]
    pub secret_name: String,
    /// Specifies the map key of the user in the connection credential secret.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "usernameKey")]
    pub username_key: Option<String>,
}

/// Specifies the container port in the target pod.
/// If not specified, the first container and its first port will be used.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsContainerPort {
    /// Specifies the name of container with the port.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "containerName")]
    pub container_name: Option<String>,
    /// Specifies the port name.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "portName")]
    pub port_name: Option<String>,
}

/// Used to find the target pod. The volumes of the target pod will be backed up.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsPodSelector {
    /// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
    /// This only takes effect when the `strategy` field below is set to `Any`.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "fallbackLabelSelector")]
    pub fallback_label_selector: Option<BackupPolicyTargetsPodSelectorFallbackLabelSelector>,
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyTargetsPodSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
    /// Specifies the strategy to select the target pod when multiple pods are selected.
    /// Valid values are:
    /// 
    /// 
    /// - `Any`: select any one pod that match the labelsSelector.
    /// - `All`: select all pods that match the labelsSelector. The backup data for the current pod
    /// will be stored in a subdirectory named after the pod.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub strategy: Option<BackupPolicyTargetsPodSelectorStrategy>,
    /// UseParentSelectedPods indicates whether to use the pods selected by the parent for backup.
    /// If set to true, the backup will use the same pods selected by the parent.
    /// And only takes effect when the 'strategy' is set to 'Any'.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "useParentSelectedPods")]
    pub use_parent_selected_pods: Option<bool>,
}

/// fallbackLabelSelector is used to filter available pods when the labelSelector fails.
/// This only takes effect when the `strategy` field below is set to `Any`.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsPodSelectorFallbackLabelSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyTargetsPodSelectorFallbackLabelSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsPodSelectorFallbackLabelSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsPodSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// Used to find the target pod. The volumes of the target pod will be backed up.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum BackupPolicyTargetsPodSelectorStrategy {
    Any,
    All,
}

/// Specifies the kubernetes resources to back up.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsResources {
    /// excluded is a slice of namespaced-scoped resource type names to exclude in
    /// the kubernetes resources.
    /// The default value is empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub excluded: Option<Vec<String>>,
    /// included is a slice of namespaced-scoped resource type names to include in
    /// the kubernetes resources.
    /// The default value is empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub included: Option<Vec<String>>,
    /// A metav1.LabelSelector to filter the target kubernetes resources that need
    /// to be backed up. If not set, will do not back up any kubernetes resources.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub selector: Option<BackupPolicyTargetsResourcesSelector>,
}

/// A metav1.LabelSelector to filter the target kubernetes resources that need
/// to be backed up. If not set, will do not back up any kubernetes resources.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsResourcesSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchExpressions")]
    pub match_expressions: Option<Vec<BackupPolicyTargetsResourcesSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "matchLabels")]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyTargetsResourcesSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// BackupPolicyStatus defines the observed state of BackupPolicy
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct BackupPolicyStatus {
    /// A human-readable message indicating details about why the BackupPolicy
    /// is in this phase.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub message: Option<String>,
    /// ObservedGeneration is the most recent generation observed for this BackupPolicy.
    /// It refers to the BackupPolicy's generation, which is updated on mutation by the API Server.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "observedGeneration")]
    pub observed_generation: Option<i64>,
    /// Phase - in list of [Available,Unavailable]
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub phase: Option<BackupPolicyStatusPhase>,
}

/// BackupPolicyStatus defines the observed state of BackupPolicy
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum BackupPolicyStatusPhase {
    Available,
    Unavailable,
}