1// Generated from definition io.k8s.api.batch.v1.SuccessPolicyRule
23/// SuccessPolicyRule describes rule for declaring a Job as succeeded. Each rule must have at least one of the "succeededIndexes" or "succeededCount" specified.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct SuccessPolicyRule {
6/// 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.
7pub succeeded_count: Option<i32>,
89/// 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.
10pub succeeded_indexes: Option<std::string::String>,
11}
1213impl crate::DeepMerge for SuccessPolicyRule {
14fn merge_from(&mut self, other: Self) {
15crate::DeepMerge::merge_from(&mut self.succeeded_count, other.succeeded_count);
16crate::DeepMerge::merge_from(&mut self.succeeded_indexes, other.succeeded_indexes);
17 }
18}
1920impl<'de> crate::serde::Deserialize<'de> for SuccessPolicyRule {
21fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
22#[allow(non_camel_case_types)]
23enum Field {
24 Key_succeeded_count,
25 Key_succeeded_indexes,
26 Other,
27 }
2829impl<'de> crate::serde::Deserialize<'de> for Field {
30fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
31struct Visitor;
3233impl crate::serde::de::Visitor<'_> for Visitor {
34type Value = Field;
3536fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
37 f.write_str("field identifier")
38 }
3940fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
41Ok(match v {
42"succeededCount" => Field::Key_succeeded_count,
43"succeededIndexes" => Field::Key_succeeded_indexes,
44_ => Field::Other,
45 })
46 }
47 }
4849 deserializer.deserialize_identifier(Visitor)
50 }
51 }
5253struct Visitor;
5455impl<'de> crate::serde::de::Visitor<'de> for Visitor {
56type Value = SuccessPolicyRule;
5758fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
59 f.write_str("SuccessPolicyRule")
60 }
6162fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
63let mut value_succeeded_count: Option<i32> = None;
64let mut value_succeeded_indexes: Option<std::string::String> = None;
6566while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
67match 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 }
7374Ok(SuccessPolicyRule {
75 succeeded_count: value_succeeded_count,
76 succeeded_indexes: value_succeeded_indexes,
77 })
78 }
79 }
8081 deserializer.deserialize_struct(
82"SuccessPolicyRule",
83&[
84"succeededCount",
85"succeededIndexes",
86 ],
87 Visitor,
88 )
89 }
90}
9192impl crate::serde::Serialize for SuccessPolicyRule {
93fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
94let mut state = serializer.serialize_struct(
95"SuccessPolicyRule",
96self.succeeded_count.as_ref().map_or(0, |_| 1) +
97self.succeeded_indexes.as_ref().map_or(0, |_| 1),
98 )?;
99if let Some(value) = &self.succeeded_count {
100crate::serde::ser::SerializeStruct::serialize_field(&mut state, "succeededCount", value)?;
101 }
102if let Some(value) = &self.succeeded_indexes {
103crate::serde::ser::SerializeStruct::serialize_field(&mut state, "succeededIndexes", value)?;
104 }
105crate::serde::ser::SerializeStruct::end(state)
106 }
107}
108109#[cfg(feature = "schemars")]
110impl crate::schemars::JsonSchema for SuccessPolicyRule {
111fn schema_name() -> std::string::String {
112"io.k8s.api.batch.v1.SuccessPolicyRule".into()
113 }
114115fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
116crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
117 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
118 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()),
119 ..Default::default()
120 })),
121 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
122 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
123 properties: [
124 (
125"succeededCount".into(),
126crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
127 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
128 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()),
129 ..Default::default()
130 })),
131 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
132 format: Some("int32".into()),
133 ..Default::default()
134 }),
135 ),
136 (
137"succeededIndexes".into(),
138crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
139 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
140 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()),
141 ..Default::default()
142 })),
143 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
144 ..Default::default()
145 }),
146 ),
147 ].into(),
148 ..Default::default()
149 })),
150 ..Default::default()
151 })
152 }
153}