k8s_openapi/v1_30/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<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<Vec<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<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<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<'de> crate::serde::de::Visitor<'de> for Visitor {
59                    type Value = Field;
60
61                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::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 std::fmt::Formatter<'_>) -> std::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<String> = None;
94                let mut value_dry_run: Option<Vec<String>> = None;
95                let mut value_grace_period_seconds: Option<i64> = None;
96                let mut value_kind: Option<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<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() -> String {
182        "io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions".to_owned()
183    }
184
185    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
186        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
187            metadata: Some(Box::new(crate::schemars::schema::Metadata {
188                description: Some("DeleteOptions may be provided when deleting an API object.".to_owned()),
189                ..Default::default()
190            })),
191            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
192            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
193                properties: [
194                    (
195                        "apiVersion".to_owned(),
196                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
197                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
198                                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".to_owned()),
199                                ..Default::default()
200                            })),
201                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
202                            ..Default::default()
203                        }),
204                    ),
205                    (
206                        "dryRun".to_owned(),
207                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
208                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
209                                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".to_owned()),
210                                ..Default::default()
211                            })),
212                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
213                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
214                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(
215                                    crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
216                                        instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
217                                        ..Default::default()
218                                    })
219                                ))),
220                                ..Default::default()
221                            })),
222                            ..Default::default()
223                        }),
224                    ),
225                    (
226                        "gracePeriodSeconds".to_owned(),
227                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
228                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
229                                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.".to_owned()),
230                                ..Default::default()
231                            })),
232                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
233                            format: Some("int64".to_owned()),
234                            ..Default::default()
235                        }),
236                    ),
237                    (
238                        "kind".to_owned(),
239                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
240                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
241                                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".to_owned()),
242                                ..Default::default()
243                            })),
244                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
245                            ..Default::default()
246                        }),
247                    ),
248                    (
249                        "orphanDependents".to_owned(),
250                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
251                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
252                                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.".to_owned()),
253                                ..Default::default()
254                            })),
255                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
256                            ..Default::default()
257                        }),
258                    ),
259                    (
260                        "preconditions".to_owned(),
261                        {
262                            let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Preconditions>().into_object();
263                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
264                                description: Some("Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.".to_owned()),
265                                ..Default::default()
266                            }));
267                            crate::schemars::schema::Schema::Object(schema_obj)
268                        },
269                    ),
270                    (
271                        "propagationPolicy".to_owned(),
272                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
273                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
274                                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.".to_owned()),
275                                ..Default::default()
276                            })),
277                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
278                            ..Default::default()
279                        }),
280                    ),
281                ].into(),
282                ..Default::default()
283            })),
284            ..Default::default()
285        })
286    }
287}