Skip to main content

k8s_openapi/v1_37/api/lifecycle/v1alpha1/
eviction_request_spec.rs

1// Generated from definition io.k8s.api.lifecycle.v1alpha1.EvictionRequestSpec
2
3/// EvictionRequestSpec is a specification of an EvictionRequest.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct EvictionRequestSpec {
6    /// intent specifies the action that should be taken for the specified target.
7    ///
8    /// - Eviction means that the requester is interested in the eviction of the target. - Withdrawn means that the requester is no longer interested in the eviction of the target.
9    ///   If all requesters' intents are withdrawn for a common target, the eviction will be canceled.
10    ///   Cancellation consequences:
11    ///   - Inactive responders will never run.
12    ///   - Active responders are expected to cancel the eviction.
13    ///   - Completed or Interrupted responders should not take any action.
14    pub intent: std::string::String,
15
16    /// requester allows you to identify the entity, that requested the eviction of the target.
17    ///
18    /// It must be a valid domain-prefixed key (such as "acme.io/foo"). Domain names *.k8s.io and *.kubernetes.io are reserved. This field is required and immutable.
19    pub requester: std::string::String,
20
21    /// target contains a reference to an object (e.g. a pod) that should be evicted. This field is required and immutable.
22    pub target: crate::api::lifecycle::v1alpha1::EvictionRequestTarget,
23}
24
25impl crate::DeepMerge for EvictionRequestSpec {
26    fn merge_from(&mut self, other: Self) {
27        crate::DeepMerge::merge_from(&mut self.intent, other.intent);
28        crate::DeepMerge::merge_from(&mut self.requester, other.requester);
29        crate::DeepMerge::merge_from(&mut self.target, other.target);
30    }
31}
32
33impl<'de> crate::serde::Deserialize<'de> for EvictionRequestSpec {
34    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
35        #[allow(non_camel_case_types)]
36        enum Field {
37            Key_intent,
38            Key_requester,
39            Key_target,
40            Other,
41        }
42
43        impl<'de> crate::serde::Deserialize<'de> for Field {
44            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
45                struct Visitor;
46
47                impl crate::serde::de::Visitor<'_> for Visitor {
48                    type Value = Field;
49
50                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
51                        f.write_str("field identifier")
52                    }
53
54                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
55                        Ok(match v {
56                            "intent" => Field::Key_intent,
57                            "requester" => Field::Key_requester,
58                            "target" => Field::Key_target,
59                            _ => Field::Other,
60                        })
61                    }
62                }
63
64                deserializer.deserialize_identifier(Visitor)
65            }
66        }
67
68        struct Visitor;
69
70        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
71            type Value = EvictionRequestSpec;
72
73            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
74                f.write_str("EvictionRequestSpec")
75            }
76
77            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
78                let mut value_intent: Option<std::string::String> = None;
79                let mut value_requester: Option<std::string::String> = None;
80                let mut value_target: Option<crate::api::lifecycle::v1alpha1::EvictionRequestTarget> = None;
81
82                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
83                    match key {
84                        Field::Key_intent => value_intent = crate::serde::de::MapAccess::next_value(&mut map)?,
85                        Field::Key_requester => value_requester = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Key_target => value_target = crate::serde::de::MapAccess::next_value(&mut map)?,
87                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
88                    }
89                }
90
91                Ok(EvictionRequestSpec {
92                    intent: value_intent.unwrap_or_default(),
93                    requester: value_requester.unwrap_or_default(),
94                    target: value_target.unwrap_or_default(),
95                })
96            }
97        }
98
99        deserializer.deserialize_struct(
100            "EvictionRequestSpec",
101            &[
102                "intent",
103                "requester",
104                "target",
105            ],
106            Visitor,
107        )
108    }
109}
110
111impl crate::serde::Serialize for EvictionRequestSpec {
112    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
113        let mut state = serializer.serialize_struct(
114            "EvictionRequestSpec",
115            3,
116        )?;
117        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "intent", &self.intent)?;
118        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "requester", &self.requester)?;
119        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "target", &self.target)?;
120        crate::serde::ser::SerializeStruct::end(state)
121    }
122}
123
124#[cfg(feature = "schemars")]
125impl crate::schemars::JsonSchema for EvictionRequestSpec {
126    fn schema_name() -> std::borrow::Cow<'static, str> {
127        "io.k8s.api.lifecycle.v1alpha1.EvictionRequestSpec".into()
128    }
129
130    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
131        crate::schemars::json_schema!({
132            "description": "EvictionRequestSpec is a specification of an EvictionRequest.",
133            "type": "object",
134            "properties": {
135                "intent": {
136                    "description": "intent specifies the action that should be taken for the specified target.\n\n- Eviction means that the requester is interested in the eviction of the target. - Withdrawn means that the requester is no longer interested in the eviction of the target.\n  If all requesters' intents are withdrawn for a common target, the eviction will be canceled.\n  Cancellation consequences:\n  - Inactive responders will never run.\n  - Active responders are expected to cancel the eviction.\n  - Completed or Interrupted responders should not take any action.",
137                    "type": "string",
138                },
139                "requester": {
140                    "description": "requester allows you to identify the entity, that requested the eviction of the target.\n\nIt must be a valid domain-prefixed key (such as \"acme.io/foo\"). Domain names *.k8s.io and *.kubernetes.io are reserved. This field is required and immutable.",
141                    "type": "string",
142                },
143                "target": ({
144                    let mut schema_obj = __gen.subschema_for::<crate::api::lifecycle::v1alpha1::EvictionRequestTarget>();
145                    schema_obj.ensure_object().insert("description".into(), "target contains a reference to an object (e.g. a pod) that should be evicted. This field is required and immutable.".into());
146                    schema_obj
147                }),
148            },
149            "required": [
150                "intent",
151                "requester",
152                "target",
153            ],
154        })
155    }
156}