1// Generated from definition io.k8s.api.admissionregistration.v1.AuditAnnotation
23/// AuditAnnotation describes how to produce an audit annotation for an API request.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct AuditAnnotation {
6/// 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.
7 ///
8 /// The key is combined with the resource name of the ValidatingAdmissionPolicy to construct an audit annotation key: "{ValidatingAdmissionPolicy name}/{key}".
9 ///
10 /// If 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.
11 ///
12 /// Required.
13pub key: std::string::String,
1415/// 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.
16 ///
17 /// If 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.
18 ///
19 /// Required.
20pub value_expression: std::string::String,
21}
2223impl crate::DeepMerge for AuditAnnotation {
24fn merge_from(&mut self, other: Self) {
25crate::DeepMerge::merge_from(&mut self.key, other.key);
26crate::DeepMerge::merge_from(&mut self.value_expression, other.value_expression);
27 }
28}
2930impl<'de> crate::serde::Deserialize<'de> for AuditAnnotation {
31fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
32#[allow(non_camel_case_types)]
33enum Field {
34 Key_key,
35 Key_value_expression,
36 Other,
37 }
3839impl<'de> crate::serde::Deserialize<'de> for Field {
40fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41struct Visitor;
4243impl crate::serde::de::Visitor<'_> for Visitor {
44type Value = Field;
4546fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47 f.write_str("field identifier")
48 }
4950fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51Ok(match v {
52"key" => Field::Key_key,
53"valueExpression" => Field::Key_value_expression,
54_ => Field::Other,
55 })
56 }
57 }
5859 deserializer.deserialize_identifier(Visitor)
60 }
61 }
6263struct Visitor;
6465impl<'de> crate::serde::de::Visitor<'de> for Visitor {
66type Value = AuditAnnotation;
6768fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
69 f.write_str("AuditAnnotation")
70 }
7172fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
73let mut value_key: Option<std::string::String> = None;
74let mut value_value_expression: Option<std::string::String> = None;
7576while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
77match 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 }
8384Ok(AuditAnnotation {
85 key: value_key.unwrap_or_default(),
86 value_expression: value_value_expression.unwrap_or_default(),
87 })
88 }
89 }
9091 deserializer.deserialize_struct(
92"AuditAnnotation",
93&[
94"key",
95"valueExpression",
96 ],
97 Visitor,
98 )
99 }
100}
101102impl crate::serde::Serialize for AuditAnnotation {
103fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
104let mut state = serializer.serialize_struct(
105"AuditAnnotation",
1062,
107 )?;
108crate::serde::ser::SerializeStruct::serialize_field(&mut state, "key", &self.key)?;
109crate::serde::ser::SerializeStruct::serialize_field(&mut state, "valueExpression", &self.value_expression)?;
110crate::serde::ser::SerializeStruct::end(state)
111 }
112}
113114#[cfg(feature = "schemars")]
115impl crate::schemars::JsonSchema for AuditAnnotation {
116fn schema_name() -> std::string::String {
117"io.k8s.api.admissionregistration.v1.AuditAnnotation".into()
118 }
119120fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
121crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
122 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
123 description: Some("AuditAnnotation describes how to produce an audit annotation for an API request.".into()),
124 ..Default::default()
125 })),
126 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
127 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
128 properties: [
129 (
130"key".into(),
131crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
132 metadata: Some(std::boxed::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.".into()),
134 ..Default::default()
135 })),
136 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
137 ..Default::default()
138 }),
139 ),
140 (
141"valueExpression".into(),
142crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
143 metadata: Some(std::boxed::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.".into()),
145 ..Default::default()
146 })),
147 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
148 ..Default::default()
149 }),
150 ),
151 ].into(),
152 required: [
153"key".into(),
154"valueExpression".into(),
155 ].into(),
156 ..Default::default()
157 })),
158 ..Default::default()
159 })
160 }
161}