1// Generated from definition io.k8s.api.autoscaling.v2.ContainerResourceMetricStatus
23/// ContainerResourceMetricStatus indicates the current value of a resource metric known to Kubernetes, as specified in requests and limits, describing a single container in each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the "pods" source.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ContainerResourceMetricStatus {
6/// container is the name of the container in the pods of the scaling target
7pub container: String,
89/// current contains the current value for the given metric
10pub current: crate::api::autoscaling::v2::MetricValueStatus,
1112/// name is the name of the resource in question.
13pub name: String,
14}
1516impl crate::DeepMerge for ContainerResourceMetricStatus {
17fn merge_from(&mut self, other: Self) {
18crate::DeepMerge::merge_from(&mut self.container, other.container);
19crate::DeepMerge::merge_from(&mut self.current, other.current);
20crate::DeepMerge::merge_from(&mut self.name, other.name);
21 }
22}
2324impl<'de> crate::serde::Deserialize<'de> for ContainerResourceMetricStatus {
25fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26#[allow(non_camel_case_types)]
27enum Field {
28 Key_container,
29 Key_current,
30 Key_name,
31 Other,
32 }
3334impl<'de> crate::serde::Deserialize<'de> for Field {
35fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36struct Visitor;
3738impl<'de> crate::serde::de::Visitor<'de> for Visitor {
39type Value = Field;
4041fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 f.write_str("field identifier")
43 }
4445fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46Ok(match v {
47"container" => Field::Key_container,
48"current" => Field::Key_current,
49"name" => Field::Key_name,
50_ => Field::Other,
51 })
52 }
53 }
5455 deserializer.deserialize_identifier(Visitor)
56 }
57 }
5859struct Visitor;
6061impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62type Value = ContainerResourceMetricStatus;
6364fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
65 f.write_str("ContainerResourceMetricStatus")
66 }
6768fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69let mut value_container: Option<String> = None;
70let mut value_current: Option<crate::api::autoscaling::v2::MetricValueStatus> = None;
71let mut value_name: Option<String> = None;
7273while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74match key {
75 Field::Key_container => value_container = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Key_current => value_current = crate::serde::de::MapAccess::next_value(&mut map)?,
77 Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
78 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
79 }
80 }
8182Ok(ContainerResourceMetricStatus {
83 container: value_container.unwrap_or_default(),
84 current: value_current.unwrap_or_default(),
85 name: value_name.unwrap_or_default(),
86 })
87 }
88 }
8990 deserializer.deserialize_struct(
91"ContainerResourceMetricStatus",
92&[
93"container",
94"current",
95"name",
96 ],
97 Visitor,
98 )
99 }
100}
101102impl crate::serde::Serialize for ContainerResourceMetricStatus {
103fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104let mut state = serializer.serialize_struct(
105"ContainerResourceMetricStatus",
1063,
107 )?;
108crate::serde::ser::SerializeStruct::serialize_field(&mut state, "container", &self.container)?;
109crate::serde::ser::SerializeStruct::serialize_field(&mut state, "current", &self.current)?;
110crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
111crate::serde::ser::SerializeStruct::end(state)
112 }
113}
114115#[cfg(feature = "schemars")]
116impl crate::schemars::JsonSchema for ContainerResourceMetricStatus {
117fn schema_name() -> String {
118"io.k8s.api.autoscaling.v2.ContainerResourceMetricStatus".to_owned()
119 }
120121fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
122crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
123 metadata: Some(Box::new(crate::schemars::schema::Metadata {
124 description: Some("ContainerResourceMetricStatus indicates the current value of a resource metric known to Kubernetes, as specified in requests and limits, describing a single container in each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have special scaling options on top of those available to normal per-pod metrics using the \"pods\" source.".to_owned()),
125 ..Default::default()
126 })),
127 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
128 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
129 properties: [
130 (
131"container".to_owned(),
132crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
133 metadata: Some(Box::new(crate::schemars::schema::Metadata {
134 description: Some("container is the name of the container in the pods of the scaling target".to_owned()),
135 ..Default::default()
136 })),
137 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
138 ..Default::default()
139 }),
140 ),
141 (
142"current".to_owned(),
143 {
144let mut schema_obj = __gen.subschema_for::<crate::api::autoscaling::v2::MetricValueStatus>().into_object();
145 schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
146 description: Some("current contains the current value for the given metric".to_owned()),
147 ..Default::default()
148 }));
149crate::schemars::schema::Schema::Object(schema_obj)
150 },
151 ),
152 (
153"name".to_owned(),
154crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
155 metadata: Some(Box::new(crate::schemars::schema::Metadata {
156 description: Some("name is the name of the resource in question.".to_owned()),
157 ..Default::default()
158 })),
159 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
160 ..Default::default()
161 }),
162 ),
163 ].into(),
164 required: [
165"container".to_owned(),
166"current".to_owned(),
167"name".to_owned(),
168 ].into(),
169 ..Default::default()
170 })),
171 ..Default::default()
172 })
173 }
174}