k8s_openapi/v1_37/api/authentication/v1/
token_request_spec.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct TokenRequestSpec {
6 pub attestations: Option<std::collections::BTreeMap<std::string::String, std::vec::Vec<std::string::String>>>,
8
9 pub audiences: Option<std::vec::Vec<std::string::String>>,
11
12 pub bound_object_ref: Option<crate::api::authentication::v1::BoundObjectReference>,
14
15 pub expiration_seconds: Option<i64>,
17}
18
19impl crate::DeepMerge for TokenRequestSpec {
20 fn merge_from(&mut self, other: Self) {
21 crate::merge_strategies::map::granular(&mut self.attestations, other.attestations, |current_item, other_item| {
22 crate::merge_strategies::list::atomic(current_item, other_item);
23 });
24 crate::merge_strategies::list::atomic(&mut self.audiences, other.audiences);
25 crate::DeepMerge::merge_from(&mut self.bound_object_ref, other.bound_object_ref);
26 crate::DeepMerge::merge_from(&mut self.expiration_seconds, other.expiration_seconds);
27 }
28}
29
30impl<'de> crate::serde::Deserialize<'de> for TokenRequestSpec {
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_attestations,
35 Key_audiences,
36 Key_bound_object_ref,
37 Key_expiration_seconds,
38 Other,
39 }
40
41 impl<'de> crate::serde::Deserialize<'de> for Field {
42 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
43 struct Visitor;
44
45 impl crate::serde::de::Visitor<'_> for Visitor {
46 type Value = Field;
47
48 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
49 f.write_str("field identifier")
50 }
51
52 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
53 Ok(match v {
54 "attestations" => Field::Key_attestations,
55 "audiences" => Field::Key_audiences,
56 "boundObjectRef" => Field::Key_bound_object_ref,
57 "expirationSeconds" => Field::Key_expiration_seconds,
58 _ => Field::Other,
59 })
60 }
61 }
62
63 deserializer.deserialize_identifier(Visitor)
64 }
65 }
66
67 struct Visitor;
68
69 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
70 type Value = TokenRequestSpec;
71
72 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
73 f.write_str("TokenRequestSpec")
74 }
75
76 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
77 let mut value_attestations: Option<std::collections::BTreeMap<std::string::String, std::vec::Vec<std::string::String>>> = None;
78 let mut value_audiences: Option<std::vec::Vec<std::string::String>> = None;
79 let mut value_bound_object_ref: Option<crate::api::authentication::v1::BoundObjectReference> = None;
80 let mut value_expiration_seconds: Option<i64> = None;
81
82 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
83 match key {
84 Field::Key_attestations => value_attestations = crate::serde::de::MapAccess::next_value(&mut map)?,
85 Field::Key_audiences => value_audiences = crate::serde::de::MapAccess::next_value(&mut map)?,
86 Field::Key_bound_object_ref => value_bound_object_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
87 Field::Key_expiration_seconds => value_expiration_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
88 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
89 }
90 }
91
92 Ok(TokenRequestSpec {
93 attestations: value_attestations,
94 audiences: value_audiences,
95 bound_object_ref: value_bound_object_ref,
96 expiration_seconds: value_expiration_seconds,
97 })
98 }
99 }
100
101 deserializer.deserialize_struct(
102 "TokenRequestSpec",
103 &[
104 "attestations",
105 "audiences",
106 "boundObjectRef",
107 "expirationSeconds",
108 ],
109 Visitor,
110 )
111 }
112}
113
114impl crate::serde::Serialize for TokenRequestSpec {
115 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
116 let mut state = serializer.serialize_struct(
117 "TokenRequestSpec",
118 self.attestations.as_ref().map_or(0, |_| 1) +
119 self.audiences.as_ref().map_or(0, |_| 1) +
120 self.bound_object_ref.as_ref().map_or(0, |_| 1) +
121 self.expiration_seconds.as_ref().map_or(0, |_| 1),
122 )?;
123 if let Some(value) = &self.attestations {
124 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "attestations", value)?;
125 }
126 if let Some(value) = &self.audiences {
127 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "audiences", value)?;
128 }
129 if let Some(value) = &self.bound_object_ref {
130 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "boundObjectRef", value)?;
131 }
132 if let Some(value) = &self.expiration_seconds {
133 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "expirationSeconds", value)?;
134 }
135 crate::serde::ser::SerializeStruct::end(state)
136 }
137}
138
139#[cfg(feature = "schemars")]
140impl crate::schemars::JsonSchema for TokenRequestSpec {
141 fn schema_name() -> std::borrow::Cow<'static, str> {
142 "io.k8s.api.authentication.v1.TokenRequestSpec".into()
143 }
144
145 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
146 crate::schemars::json_schema!({
147 "description": "TokenRequestSpec contains client provided parameters of a token request.",
148 "type": "object",
149 "properties": {
150 "attestations": {
151 "description": "attestations is a map of well-known keys to string-slice values. The values for each key have a specific semantic meaning, which is documented on the key definition. Requesters of tokens may ask the Kubernetes API Server to attest to certain claims. The API Server may perform authorization checks depending on the key of this map.",
152 "type": "object",
153 "additionalProperties": {
154 "type": "array",
155 "items": {
156 "type": "string",
157 },
158 },
159 },
160 "audiences": {
161 "description": "audiences are the intendend audiences of the token. A recipient of a token must identify themself with an identifier in the list of audiences of the token, and otherwise should reject the token. A token issued for multiple audiences may be used to authenticate against any of the audiences listed but implies a high degree of trust between the target audiences.",
162 "type": "array",
163 "items": {
164 "type": "string",
165 },
166 },
167 "boundObjectRef": ({
168 let mut schema_obj = __gen.subschema_for::<crate::api::authentication::v1::BoundObjectReference>();
169 schema_obj.ensure_object().insert("description".into(), "boundObjectRef is a reference to an object that the token will be bound to. The token will only be valid for as long as the bound object exists. NOTE: The API server's TokenReview endpoint will validate the BoundObjectRef, but other audiences may not. Keep ExpirationSeconds small if you want prompt revocation.".into());
170 schema_obj
171 }),
172 "expirationSeconds": {
173 "description": "expirationSeconds is the requested duration of validity of the request. The token issuer may return a token with a different validity duration so a client needs to check the 'expiration' field in a response.",
174 "type": "integer",
175 "format": "int64",
176 },
177 },
178 })
179 }
180}