k8s_openapi/v1_32/api/admissionregistration/v1/
audit_annotation.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct AuditAnnotation {
6 pub key: String,
14
15 pub value_expression: String,
21}
22
23impl crate::DeepMerge for AuditAnnotation {
24 fn merge_from(&mut self, other: Self) {
25 crate::DeepMerge::merge_from(&mut self.key, other.key);
26 crate::DeepMerge::merge_from(&mut self.value_expression, other.value_expression);
27 }
28}
29
30impl<'de> crate::serde::Deserialize<'de> for AuditAnnotation {
31 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
32 #[allow(non_camel_case_types)]
33 enum Field {
34 Key_key,
35 Key_value_expression,
36 Other,
37 }
38
39 impl<'de> crate::serde::Deserialize<'de> for Field {
40 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41 struct Visitor;
42
43 impl crate::serde::de::Visitor<'_> for Visitor {
44 type Value = Field;
45
46 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47 f.write_str("field identifier")
48 }
49
50 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51 Ok(match v {
52 "key" => Field::Key_key,
53 "valueExpression" => Field::Key_value_expression,
54 _ => Field::Other,
55 })
56 }
57 }
58
59 deserializer.deserialize_identifier(Visitor)
60 }
61 }
62
63 struct Visitor;
64
65 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
66 type Value = AuditAnnotation;
67
68 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69 f.write_str("AuditAnnotation")
70 }
71
72 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
73 let mut value_key: Option<String> = None;
74 let mut value_value_expression: Option<String> = None;
75
76 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
77 match key {
78 Field::Key_key => value_key = crate::serde::de::MapAccess::next_value(&mut map)?,
79 Field::Key_value_expression => value_value_expression = crate::serde::de::MapAccess::next_value(&mut map)?,
80 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
81 }
82 }
83
84 Ok(AuditAnnotation {
85 key: value_key.unwrap_or_default(),
86 value_expression: value_value_expression.unwrap_or_default(),
87 })
88 }
89 }
90
91 deserializer.deserialize_struct(
92 "AuditAnnotation",
93 &[
94 "key",
95 "valueExpression",
96 ],
97 Visitor,
98 )
99 }
100}
101
102impl crate::serde::Serialize for AuditAnnotation {
103 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104 let mut state = serializer.serialize_struct(
105 "AuditAnnotation",
106 2,
107 )?;
108 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "key", &self.key)?;
109 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "valueExpression", &self.value_expression)?;
110 crate::serde::ser::SerializeStruct::end(state)
111 }
112}
113
114#[cfg(feature = "schemars")]
115impl crate::schemars::JsonSchema for AuditAnnotation {
116 fn schema_name() -> String {
117 "io.k8s.api.admissionregistration.v1.AuditAnnotation".to_owned()
118 }
119
120 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
121 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
122 metadata: Some(Box::new(crate::schemars::schema::Metadata {
123 description: Some("AuditAnnotation describes how to produce an audit annotation for an API request.".to_owned()),
124 ..Default::default()
125 })),
126 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
127 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
128 properties: [
129 (
130 "key".to_owned(),
131 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
132 metadata: Some(Box::new(crate::schemars::schema::Metadata {
133 description: Some("key specifies the audit annotation key. The audit annotation keys of a ValidatingAdmissionPolicy must be unique. The key must be a qualified name ([A-Za-z0-9][-A-Za-z0-9_.]*) no more than 63 bytes in length.\n\nThe key is combined with the resource name of the ValidatingAdmissionPolicy to construct an audit annotation key: \"{ValidatingAdmissionPolicy name}/{key}\".\n\nIf an admission webhook uses the same resource name as this ValidatingAdmissionPolicy and the same audit annotation key, the annotation key will be identical. In this case, the first annotation written with the key will be included in the audit event and all subsequent annotations with the same key will be discarded.\n\nRequired.".to_owned()),
134 ..Default::default()
135 })),
136 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
137 ..Default::default()
138 }),
139 ),
140 (
141 "valueExpression".to_owned(),
142 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
143 metadata: Some(Box::new(crate::schemars::schema::Metadata {
144 description: Some("valueExpression represents the expression which is evaluated by CEL to produce an audit annotation value. The expression must evaluate to either a string or null value. If the expression evaluates to a string, the audit annotation is included with the string value. If the expression evaluates to null or empty string the audit annotation will be omitted. The valueExpression may be no longer than 5kb in length. If the result of the valueExpression is more than 10kb in length, it will be truncated to 10kb.\n\nIf multiple ValidatingAdmissionPolicyBinding resources match an API request, then the valueExpression will be evaluated for each binding. All unique values produced by the valueExpressions will be joined together in a comma-separated list.\n\nRequired.".to_owned()),
145 ..Default::default()
146 })),
147 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
148 ..Default::default()
149 }),
150 ),
151 ].into(),
152 required: [
153 "key".to_owned(),
154 "valueExpression".to_owned(),
155 ].into(),
156 ..Default::default()
157 })),
158 ..Default::default()
159 })
160 }
161}