k8s_openapi/v1_36/api/batch/v1/
success_policy_rule.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct SuccessPolicyRule {
6 pub succeeded_count: Option<i32>,
8
9 pub succeeded_indexes: Option<std::string::String>,
11}
12
13impl crate::DeepMerge for SuccessPolicyRule {
14 fn merge_from(&mut self, other: Self) {
15 crate::DeepMerge::merge_from(&mut self.succeeded_count, other.succeeded_count);
16 crate::DeepMerge::merge_from(&mut self.succeeded_indexes, other.succeeded_indexes);
17 }
18}
19
20impl<'de> crate::serde::Deserialize<'de> for SuccessPolicyRule {
21 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
22 #[allow(non_camel_case_types)]
23 enum Field {
24 Key_succeeded_count,
25 Key_succeeded_indexes,
26 Other,
27 }
28
29 impl<'de> crate::serde::Deserialize<'de> for Field {
30 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
31 struct Visitor;
32
33 impl crate::serde::de::Visitor<'_> for Visitor {
34 type Value = Field;
35
36 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
37 f.write_str("field identifier")
38 }
39
40 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
41 Ok(match v {
42 "succeededCount" => Field::Key_succeeded_count,
43 "succeededIndexes" => Field::Key_succeeded_indexes,
44 _ => Field::Other,
45 })
46 }
47 }
48
49 deserializer.deserialize_identifier(Visitor)
50 }
51 }
52
53 struct Visitor;
54
55 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
56 type Value = SuccessPolicyRule;
57
58 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
59 f.write_str("SuccessPolicyRule")
60 }
61
62 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
63 let mut value_succeeded_count: Option<i32> = None;
64 let mut value_succeeded_indexes: Option<std::string::String> = None;
65
66 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
67 match key {
68 Field::Key_succeeded_count => value_succeeded_count = crate::serde::de::MapAccess::next_value(&mut map)?,
69 Field::Key_succeeded_indexes => value_succeeded_indexes = crate::serde::de::MapAccess::next_value(&mut map)?,
70 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
71 }
72 }
73
74 Ok(SuccessPolicyRule {
75 succeeded_count: value_succeeded_count,
76 succeeded_indexes: value_succeeded_indexes,
77 })
78 }
79 }
80
81 deserializer.deserialize_struct(
82 "SuccessPolicyRule",
83 &[
84 "succeededCount",
85 "succeededIndexes",
86 ],
87 Visitor,
88 )
89 }
90}
91
92impl crate::serde::Serialize for SuccessPolicyRule {
93 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
94 let mut state = serializer.serialize_struct(
95 "SuccessPolicyRule",
96 self.succeeded_count.as_ref().map_or(0, |_| 1) +
97 self.succeeded_indexes.as_ref().map_or(0, |_| 1),
98 )?;
99 if let Some(value) = &self.succeeded_count {
100 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "succeededCount", value)?;
101 }
102 if let Some(value) = &self.succeeded_indexes {
103 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "succeededIndexes", value)?;
104 }
105 crate::serde::ser::SerializeStruct::end(state)
106 }
107}
108
109#[cfg(feature = "schemars")]
110impl crate::schemars::JsonSchema for SuccessPolicyRule {
111 fn schema_name() -> std::borrow::Cow<'static, str> {
112 "io.k8s.api.batch.v1.SuccessPolicyRule".into()
113 }
114
115 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
116 crate::schemars::json_schema!({
117 "description": "SuccessPolicyRule describes rule for declaring a Job as succeeded. Each rule must have at least one of the \"succeededIndexes\" or \"succeededCount\" specified.",
118 "type": "object",
119 "properties": {
120 "succeededCount": {
121 "description": "succeededCount specifies the minimal required size of the actual set of the succeeded indexes for the Job. When succeededCount is used along with succeededIndexes, the check is constrained only to the set of indexes specified by succeededIndexes. For example, given that succeededIndexes is \"1-4\", succeededCount is \"3\", and completed indexes are \"1\", \"3\", and \"5\", the Job isn't declared as succeeded because only \"1\" and \"3\" indexes are considered in that rules. When this field is null, this doesn't default to any value and is never evaluated at any time. When specified it needs to be a positive integer.",
122 "type": "integer",
123 "format": "int32",
124 },
125 "succeededIndexes": {
126 "description": "succeededIndexes specifies the set of indexes which need to be contained in the actual set of the succeeded indexes for the Job. The list of indexes must be within 0 to \".spec.completions-1\" and must not contain duplicates. At least one element is required. The indexes are represented as intervals separated by commas. The intervals can be a decimal integer or a pair of decimal integers separated by a hyphen. The number are listed in represented by the first and last element of the series, separated by a hyphen. For example, if the completed indexes are 1, 3, 4, 5 and 7, they are represented as \"1,3-5,7\". When this field is null, this field doesn't default to any value and is never evaluated at any time.",
127 "type": "string",
128 },
129 },
130 })
131 }
132}
133
134#[cfg(feature = "schemars08")]
135impl crate::schemars08::JsonSchema for SuccessPolicyRule {
136 fn schema_name() -> std::string::String {
137 "io.k8s.api.batch.v1.SuccessPolicyRule".into()
138 }
139
140 fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
141 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
142 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
143 description: Some("SuccessPolicyRule describes rule for declaring a Job as succeeded. Each rule must have at least one of the \"succeededIndexes\" or \"succeededCount\" specified.".into()),
144 ..Default::default()
145 })),
146 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
147 object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
148 properties: [
149 (
150 "succeededCount".into(),
151 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
152 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
153 description: Some("succeededCount specifies the minimal required size of the actual set of the succeeded indexes for the Job. When succeededCount is used along with succeededIndexes, the check is constrained only to the set of indexes specified by succeededIndexes. For example, given that succeededIndexes is \"1-4\", succeededCount is \"3\", and completed indexes are \"1\", \"3\", and \"5\", the Job isn't declared as succeeded because only \"1\" and \"3\" indexes are considered in that rules. When this field is null, this doesn't default to any value and is never evaluated at any time. When specified it needs to be a positive integer.".into()),
154 ..Default::default()
155 })),
156 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
157 format: Some("int32".into()),
158 ..Default::default()
159 }),
160 ),
161 (
162 "succeededIndexes".into(),
163 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
164 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
165 description: Some("succeededIndexes specifies the set of indexes which need to be contained in the actual set of the succeeded indexes for the Job. The list of indexes must be within 0 to \".spec.completions-1\" and must not contain duplicates. At least one element is required. The indexes are represented as intervals separated by commas. The intervals can be a decimal integer or a pair of decimal integers separated by a hyphen. The number are listed in represented by the first and last element of the series, separated by a hyphen. For example, if the completed indexes are 1, 3, 4, 5 and 7, they are represented as \"1,3-5,7\". When this field is null, this field doesn't default to any value and is never evaluated at any time.".into()),
166 ..Default::default()
167 })),
168 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
169 ..Default::default()
170 }),
171 ),
172 ].into(),
173 ..Default::default()
174 })),
175 ..Default::default()
176 })
177 }
178}