k8s_openapi/v1_31/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    /// 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
16    pub kind: Option<std::string::String>,
17
18    /// 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.
19    pub orphan_dependents: Option<bool>,
20
21    /// Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.
22    pub preconditions: Option<crate::apimachinery::pkg::apis::meta::v1::Preconditions>,
23
24    /// 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.
25    pub propagation_policy: Option<std::string::String>,
26}
27
28impl crate::DeepMerge for DeleteOptions {
29    fn merge_from(&mut self, other: Self) {
30        crate::DeepMerge::merge_from(&mut self.api_version, other.api_version);
31        crate::merge_strategies::list::atomic(&mut self.dry_run, other.dry_run);
32        crate::DeepMerge::merge_from(&mut self.grace_period_seconds, other.grace_period_seconds);
33        crate::DeepMerge::merge_from(&mut self.kind, other.kind);
34        crate::DeepMerge::merge_from(&mut self.orphan_dependents, other.orphan_dependents);
35        crate::DeepMerge::merge_from(&mut self.preconditions, other.preconditions);
36        crate::DeepMerge::merge_from(&mut self.propagation_policy, other.propagation_policy);
37    }
38}
39
40impl<'de> crate::serde::Deserialize<'de> for DeleteOptions {
41    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
42        #[allow(non_camel_case_types)]
43        enum Field {
44            Key_api_version,
45            Key_dry_run,
46            Key_grace_period_seconds,
47            Key_kind,
48            Key_orphan_dependents,
49            Key_preconditions,
50            Key_propagation_policy,
51            Other,
52        }
53
54        impl<'de> crate::serde::Deserialize<'de> for Field {
55            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
56                struct Visitor;
57
58                impl crate::serde::de::Visitor<'_> for Visitor {
59                    type Value = Field;
60
61                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
62                        f.write_str("field identifier")
63                    }
64
65                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
66                        Ok(match v {
67                            "apiVersion" => Field::Key_api_version,
68                            "dryRun" => Field::Key_dry_run,
69                            "gracePeriodSeconds" => Field::Key_grace_period_seconds,
70                            "kind" => Field::Key_kind,
71                            "orphanDependents" => Field::Key_orphan_dependents,
72                            "preconditions" => Field::Key_preconditions,
73                            "propagationPolicy" => Field::Key_propagation_policy,
74                            _ => Field::Other,
75                        })
76                    }
77                }
78
79                deserializer.deserialize_identifier(Visitor)
80            }
81        }
82
83        struct Visitor;
84
85        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
86            type Value = DeleteOptions;
87
88            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
89                f.write_str("DeleteOptions")
90            }
91
92            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
93                let mut value_api_version: Option<std::string::String> = None;
94                let mut value_dry_run: Option<std::vec::Vec<std::string::String>> = None;
95                let mut value_grace_period_seconds: Option<i64> = None;
96                let mut value_kind: Option<std::string::String> = None;
97                let mut value_orphan_dependents: Option<bool> = None;
98                let mut value_preconditions: Option<crate::apimachinery::pkg::apis::meta::v1::Preconditions> = None;
99                let mut value_propagation_policy: Option<std::string::String> = None;
100
101                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
102                    match key {
103                        Field::Key_api_version => value_api_version = crate::serde::de::MapAccess::next_value(&mut map)?,
104                        Field::Key_dry_run => value_dry_run = crate::serde::de::MapAccess::next_value(&mut map)?,
105                        Field::Key_grace_period_seconds => value_grace_period_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
106                        Field::Key_kind => value_kind = crate::serde::de::MapAccess::next_value(&mut map)?,
107                        Field::Key_orphan_dependents => value_orphan_dependents = crate::serde::de::MapAccess::next_value(&mut map)?,
108                        Field::Key_preconditions => value_preconditions = crate::serde::de::MapAccess::next_value(&mut map)?,
109                        Field::Key_propagation_policy => value_propagation_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
110                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
111                    }
112                }
113
114                Ok(DeleteOptions {
115                    api_version: value_api_version,
116                    dry_run: value_dry_run,
117                    grace_period_seconds: value_grace_period_seconds,
118                    kind: value_kind,
119                    orphan_dependents: value_orphan_dependents,
120                    preconditions: value_preconditions,
121                    propagation_policy: value_propagation_policy,
122                })
123            }
124        }
125
126        deserializer.deserialize_struct(
127            "DeleteOptions",
128            &[
129                "apiVersion",
130                "dryRun",
131                "gracePeriodSeconds",
132                "kind",
133                "orphanDependents",
134                "preconditions",
135                "propagationPolicy",
136            ],
137            Visitor,
138        )
139    }
140}
141
142impl crate::serde::Serialize for DeleteOptions {
143    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
144        let mut state = serializer.serialize_struct(
145            "DeleteOptions",
146            self.api_version.as_ref().map_or(0, |_| 1) +
147            self.dry_run.as_ref().map_or(0, |_| 1) +
148            self.grace_period_seconds.as_ref().map_or(0, |_| 1) +
149            self.kind.as_ref().map_or(0, |_| 1) +
150            self.orphan_dependents.as_ref().map_or(0, |_| 1) +
151            self.preconditions.as_ref().map_or(0, |_| 1) +
152            self.propagation_policy.as_ref().map_or(0, |_| 1),
153        )?;
154        if let Some(value) = &self.api_version {
155            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", value)?;
156        }
157        if let Some(value) = &self.dry_run {
158            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "dryRun", value)?;
159        }
160        if let Some(value) = &self.grace_period_seconds {
161            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gracePeriodSeconds", value)?;
162        }
163        if let Some(value) = &self.kind {
164            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", value)?;
165        }
166        if let Some(value) = &self.orphan_dependents {
167            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "orphanDependents", value)?;
168        }
169        if let Some(value) = &self.preconditions {
170            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preconditions", value)?;
171        }
172        if let Some(value) = &self.propagation_policy {
173            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "propagationPolicy", value)?;
174        }
175        crate::serde::ser::SerializeStruct::end(state)
176    }
177}
178
179#[cfg(feature = "schemars")]
180impl crate::schemars::JsonSchema for DeleteOptions {
181    fn schema_name() -> std::borrow::Cow<'static, str> {
182        "io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions".into()
183    }
184
185    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
186        crate::schemars::json_schema!({
187            "description": "DeleteOptions may be provided when deleting an API object.",
188            "type": "object",
189            "properties": {
190                "apiVersion": {
191                    "description": "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",
192                    "type": "string",
193                },
194                "dryRun": {
195                    "description": "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",
196                    "type": "array",
197                    "items": {
198                        "type": "string",
199                    },
200                },
201                "gracePeriodSeconds": {
202                    "description": "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.",
203                    "type": "integer",
204                    "format": "int64",
205                },
206                "kind": {
207                    "description": "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",
208                    "type": "string",
209                },
210                "orphanDependents": {
211                    "description": "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.",
212                    "type": "boolean",
213                },
214                "preconditions": ({
215                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Preconditions>();
216                    schema_obj.ensure_object().insert("description".into(), "Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.".into());
217                    schema_obj
218                }),
219                "propagationPolicy": {
220                    "description": "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.",
221                    "type": "string",
222                },
223            },
224        })
225    }
226}