k8s_openapi/v1_33/apimachinery/pkg/apis/meta/v1/
delete_options.rs

1// Generated from definition io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions
2
3/// DeleteOptions may be provided when deleting an API object.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeleteOptions {
6    /// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
7    pub api_version: Option<std::string::String>,
8
9    /// When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
10    pub dry_run: Option<std::vec::Vec<std::string::String>>,
11
12    /// The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.
13    pub grace_period_seconds: Option<i64>,
14
15    /// if set to true, it will trigger an unsafe deletion of the resource in case the normal deletion flow fails with a corrupt object error. A resource is considered corrupt if it can not be retrieved from the underlying storage successfully because of a) its data can not be transformed e.g. decryption failure, or b) it fails to decode into an object. NOTE: unsafe deletion ignores finalizer constraints, skips precondition checks, and removes the object from the storage. WARNING: This may potentially break the cluster if the workload associated with the resource being unsafe-deleted relies on normal deletion flow. Use only if you REALLY know what you are doing. The default value is false, and the user must opt in to enable it
16    pub ignore_store_read_error_with_cluster_breaking_potential: Option<bool>,
17
18    /// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
19    pub kind: Option<std::string::String>,
20
21    /// Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.
22    pub orphan_dependents: Option<bool>,
23
24    /// Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.
25    pub preconditions: Option<crate::apimachinery::pkg::apis::meta::v1::Preconditions>,
26
27    /// Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.
28    pub propagation_policy: Option<std::string::String>,
29}
30
31impl crate::DeepMerge for DeleteOptions {
32    fn merge_from(&mut self, other: Self) {
33        crate::DeepMerge::merge_from(&mut self.api_version, other.api_version);
34        crate::merge_strategies::list::atomic(&mut self.dry_run, other.dry_run);
35        crate::DeepMerge::merge_from(&mut self.grace_period_seconds, other.grace_period_seconds);
36        crate::DeepMerge::merge_from(&mut self.ignore_store_read_error_with_cluster_breaking_potential, other.ignore_store_read_error_with_cluster_breaking_potential);
37        crate::DeepMerge::merge_from(&mut self.kind, other.kind);
38        crate::DeepMerge::merge_from(&mut self.orphan_dependents, other.orphan_dependents);
39        crate::DeepMerge::merge_from(&mut self.preconditions, other.preconditions);
40        crate::DeepMerge::merge_from(&mut self.propagation_policy, other.propagation_policy);
41    }
42}
43
44impl<'de> crate::serde::Deserialize<'de> for DeleteOptions {
45    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
46        #[allow(non_camel_case_types)]
47        enum Field {
48            Key_api_version,
49            Key_dry_run,
50            Key_grace_period_seconds,
51            Key_ignore_store_read_error_with_cluster_breaking_potential,
52            Key_kind,
53            Key_orphan_dependents,
54            Key_preconditions,
55            Key_propagation_policy,
56            Other,
57        }
58
59        impl<'de> crate::serde::Deserialize<'de> for Field {
60            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
61                struct Visitor;
62
63                impl crate::serde::de::Visitor<'_> for Visitor {
64                    type Value = Field;
65
66                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67                        f.write_str("field identifier")
68                    }
69
70                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
71                        Ok(match v {
72                            "apiVersion" => Field::Key_api_version,
73                            "dryRun" => Field::Key_dry_run,
74                            "gracePeriodSeconds" => Field::Key_grace_period_seconds,
75                            "ignoreStoreReadErrorWithClusterBreakingPotential" => Field::Key_ignore_store_read_error_with_cluster_breaking_potential,
76                            "kind" => Field::Key_kind,
77                            "orphanDependents" => Field::Key_orphan_dependents,
78                            "preconditions" => Field::Key_preconditions,
79                            "propagationPolicy" => Field::Key_propagation_policy,
80                            _ => Field::Other,
81                        })
82                    }
83                }
84
85                deserializer.deserialize_identifier(Visitor)
86            }
87        }
88
89        struct Visitor;
90
91        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
92            type Value = DeleteOptions;
93
94            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
95                f.write_str("DeleteOptions")
96            }
97
98            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
99                let mut value_api_version: Option<std::string::String> = None;
100                let mut value_dry_run: Option<std::vec::Vec<std::string::String>> = None;
101                let mut value_grace_period_seconds: Option<i64> = None;
102                let mut value_ignore_store_read_error_with_cluster_breaking_potential: Option<bool> = None;
103                let mut value_kind: Option<std::string::String> = None;
104                let mut value_orphan_dependents: Option<bool> = None;
105                let mut value_preconditions: Option<crate::apimachinery::pkg::apis::meta::v1::Preconditions> = None;
106                let mut value_propagation_policy: Option<std::string::String> = None;
107
108                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
109                    match key {
110                        Field::Key_api_version => value_api_version = crate::serde::de::MapAccess::next_value(&mut map)?,
111                        Field::Key_dry_run => value_dry_run = crate::serde::de::MapAccess::next_value(&mut map)?,
112                        Field::Key_grace_period_seconds => value_grace_period_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
113                        Field::Key_ignore_store_read_error_with_cluster_breaking_potential => value_ignore_store_read_error_with_cluster_breaking_potential = crate::serde::de::MapAccess::next_value(&mut map)?,
114                        Field::Key_kind => value_kind = crate::serde::de::MapAccess::next_value(&mut map)?,
115                        Field::Key_orphan_dependents => value_orphan_dependents = crate::serde::de::MapAccess::next_value(&mut map)?,
116                        Field::Key_preconditions => value_preconditions = crate::serde::de::MapAccess::next_value(&mut map)?,
117                        Field::Key_propagation_policy => value_propagation_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
118                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
119                    }
120                }
121
122                Ok(DeleteOptions {
123                    api_version: value_api_version,
124                    dry_run: value_dry_run,
125                    grace_period_seconds: value_grace_period_seconds,
126                    ignore_store_read_error_with_cluster_breaking_potential: value_ignore_store_read_error_with_cluster_breaking_potential,
127                    kind: value_kind,
128                    orphan_dependents: value_orphan_dependents,
129                    preconditions: value_preconditions,
130                    propagation_policy: value_propagation_policy,
131                })
132            }
133        }
134
135        deserializer.deserialize_struct(
136            "DeleteOptions",
137            &[
138                "apiVersion",
139                "dryRun",
140                "gracePeriodSeconds",
141                "ignoreStoreReadErrorWithClusterBreakingPotential",
142                "kind",
143                "orphanDependents",
144                "preconditions",
145                "propagationPolicy",
146            ],
147            Visitor,
148        )
149    }
150}
151
152impl crate::serde::Serialize for DeleteOptions {
153    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
154        let mut state = serializer.serialize_struct(
155            "DeleteOptions",
156            self.api_version.as_ref().map_or(0, |_| 1) +
157            self.dry_run.as_ref().map_or(0, |_| 1) +
158            self.grace_period_seconds.as_ref().map_or(0, |_| 1) +
159            self.ignore_store_read_error_with_cluster_breaking_potential.as_ref().map_or(0, |_| 1) +
160            self.kind.as_ref().map_or(0, |_| 1) +
161            self.orphan_dependents.as_ref().map_or(0, |_| 1) +
162            self.preconditions.as_ref().map_or(0, |_| 1) +
163            self.propagation_policy.as_ref().map_or(0, |_| 1),
164        )?;
165        if let Some(value) = &self.api_version {
166            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", value)?;
167        }
168        if let Some(value) = &self.dry_run {
169            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "dryRun", value)?;
170        }
171        if let Some(value) = &self.grace_period_seconds {
172            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gracePeriodSeconds", value)?;
173        }
174        if let Some(value) = &self.ignore_store_read_error_with_cluster_breaking_potential {
175            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ignoreStoreReadErrorWithClusterBreakingPotential", value)?;
176        }
177        if let Some(value) = &self.kind {
178            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", value)?;
179        }
180        if let Some(value) = &self.orphan_dependents {
181            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "orphanDependents", value)?;
182        }
183        if let Some(value) = &self.preconditions {
184            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preconditions", value)?;
185        }
186        if let Some(value) = &self.propagation_policy {
187            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "propagationPolicy", value)?;
188        }
189        crate::serde::ser::SerializeStruct::end(state)
190    }
191}
192
193#[cfg(feature = "schemars")]
194impl crate::schemars::JsonSchema for DeleteOptions {
195    fn schema_name() -> std::string::String {
196        "io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions".into()
197    }
198
199    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
200        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
201            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
202                description: Some("DeleteOptions may be provided when deleting an API object.".into()),
203                ..Default::default()
204            })),
205            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
206            object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
207                properties: [
208                    (
209                        "apiVersion".into(),
210                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
211                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
212                                description: Some("APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources".into()),
213                                ..Default::default()
214                            })),
215                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
216                            ..Default::default()
217                        }),
218                    ),
219                    (
220                        "dryRun".into(),
221                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
222                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
223                                description: Some("When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed".into()),
224                                ..Default::default()
225                            })),
226                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
227                            array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
228                                items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(
229                                    crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
230                                        instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
231                                        ..Default::default()
232                                    })
233                                ))),
234                                ..Default::default()
235                            })),
236                            ..Default::default()
237                        }),
238                    ),
239                    (
240                        "gracePeriodSeconds".into(),
241                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
242                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
243                                description: Some("The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.".into()),
244                                ..Default::default()
245                            })),
246                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
247                            format: Some("int64".into()),
248                            ..Default::default()
249                        }),
250                    ),
251                    (
252                        "ignoreStoreReadErrorWithClusterBreakingPotential".into(),
253                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
254                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
255                                description: Some("if set to true, it will trigger an unsafe deletion of the resource in case the normal deletion flow fails with a corrupt object error. A resource is considered corrupt if it can not be retrieved from the underlying storage successfully because of a) its data can not be transformed e.g. decryption failure, or b) it fails to decode into an object. NOTE: unsafe deletion ignores finalizer constraints, skips precondition checks, and removes the object from the storage. WARNING: This may potentially break the cluster if the workload associated with the resource being unsafe-deleted relies on normal deletion flow. Use only if you REALLY know what you are doing. The default value is false, and the user must opt in to enable it".into()),
256                                ..Default::default()
257                            })),
258                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Boolean))),
259                            ..Default::default()
260                        }),
261                    ),
262                    (
263                        "kind".into(),
264                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
265                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
266                                description: Some("Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds".into()),
267                                ..Default::default()
268                            })),
269                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
270                            ..Default::default()
271                        }),
272                    ),
273                    (
274                        "orphanDependents".into(),
275                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
276                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
277                                description: Some("Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.".into()),
278                                ..Default::default()
279                            })),
280                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Boolean))),
281                            ..Default::default()
282                        }),
283                    ),
284                    (
285                        "preconditions".into(),
286                        {
287                            let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Preconditions>().into_object();
288                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
289                                description: Some("Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.".into()),
290                                ..Default::default()
291                            }));
292                            crate::schemars::schema::Schema::Object(schema_obj)
293                        },
294                    ),
295                    (
296                        "propagationPolicy".into(),
297                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
298                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
299                                description: Some("Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.".into()),
300                                ..Default::default()
301                            })),
302                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
303                            ..Default::default()
304                        }),
305                    ),
306                ].into(),
307                ..Default::default()
308            })),
309            ..Default::default()
310        })
311    }
312}