Skip to main content

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

1// Generated from definition io.k8s.api.lifecycle.v1alpha1.Requester
2
3/// Requester allows you to identify the entity, that requested the eviction of the target.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Requester {
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, 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    /// name 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"). This field must be unique for each requester. This field is required.
19    pub name: std::string::String,
20}
21
22impl crate::DeepMerge for Requester {
23    fn merge_from(&mut self, other: Self) {
24        crate::DeepMerge::merge_from(&mut self.intent, other.intent);
25        crate::DeepMerge::merge_from(&mut self.name, other.name);
26    }
27}
28
29impl<'de> crate::serde::Deserialize<'de> for Requester {
30    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
31        #[allow(non_camel_case_types)]
32        enum Field {
33            Key_intent,
34            Key_name,
35            Other,
36        }
37
38        impl<'de> crate::serde::Deserialize<'de> for Field {
39            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
40                struct Visitor;
41
42                impl crate::serde::de::Visitor<'_> for Visitor {
43                    type Value = Field;
44
45                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
46                        f.write_str("field identifier")
47                    }
48
49                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
50                        Ok(match v {
51                            "intent" => Field::Key_intent,
52                            "name" => Field::Key_name,
53                            _ => Field::Other,
54                        })
55                    }
56                }
57
58                deserializer.deserialize_identifier(Visitor)
59            }
60        }
61
62        struct Visitor;
63
64        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
65            type Value = Requester;
66
67            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
68                f.write_str("Requester")
69            }
70
71            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
72                let mut value_intent: Option<std::string::String> = None;
73                let mut value_name: Option<std::string::String> = None;
74
75                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
76                    match key {
77                        Field::Key_intent => value_intent = crate::serde::de::MapAccess::next_value(&mut map)?,
78                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
79                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
80                    }
81                }
82
83                Ok(Requester {
84                    intent: value_intent.unwrap_or_default(),
85                    name: value_name.unwrap_or_default(),
86                })
87            }
88        }
89
90        deserializer.deserialize_struct(
91            "Requester",
92            &[
93                "intent",
94                "name",
95            ],
96            Visitor,
97        )
98    }
99}
100
101impl crate::serde::Serialize for Requester {
102    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
103        let mut state = serializer.serialize_struct(
104            "Requester",
105            2,
106        )?;
107        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "intent", &self.intent)?;
108        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
109        crate::serde::ser::SerializeStruct::end(state)
110    }
111}
112
113#[cfg(feature = "schemars")]
114impl crate::schemars::JsonSchema for Requester {
115    fn schema_name() -> std::borrow::Cow<'static, str> {
116        "io.k8s.api.lifecycle.v1alpha1.Requester".into()
117    }
118
119    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
120        crate::schemars::json_schema!({
121            "description": "Requester allows you to identify the entity, that requested the eviction of the target.",
122            "type": "object",
123            "properties": {
124                "intent": {
125                    "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, 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.",
126                    "type": "string",
127                },
128                "name": {
129                    "description": "name 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\"). This field must be unique for each requester. This field is required.",
130                    "type": "string",
131                },
132            },
133            "required": [
134                "intent",
135                "name",
136            ],
137        })
138    }
139}