k8s_openapi/v1_34/api/authentication/v1/
token_request_spec.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct TokenRequestSpec {
6 pub audiences: std::vec::Vec<std::string::String>,
8
9 pub bound_object_ref: Option<crate::api::authentication::v1::BoundObjectReference>,
11
12 pub expiration_seconds: Option<i64>,
14}
15
16impl crate::DeepMerge for TokenRequestSpec {
17 fn merge_from(&mut self, other: Self) {
18 crate::merge_strategies::list::atomic(&mut self.audiences, other.audiences);
19 crate::DeepMerge::merge_from(&mut self.bound_object_ref, other.bound_object_ref);
20 crate::DeepMerge::merge_from(&mut self.expiration_seconds, other.expiration_seconds);
21 }
22}
23
24impl<'de> crate::serde::Deserialize<'de> for TokenRequestSpec {
25 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26 #[allow(non_camel_case_types)]
27 enum Field {
28 Key_audiences,
29 Key_bound_object_ref,
30 Key_expiration_seconds,
31 Other,
32 }
33
34 impl<'de> crate::serde::Deserialize<'de> for Field {
35 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36 struct Visitor;
37
38 impl crate::serde::de::Visitor<'_> for Visitor {
39 type Value = Field;
40
41 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
42 f.write_str("field identifier")
43 }
44
45 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
46 Ok(match v {
47 "audiences" => Field::Key_audiences,
48 "boundObjectRef" => Field::Key_bound_object_ref,
49 "expirationSeconds" => Field::Key_expiration_seconds,
50 _ => Field::Other,
51 })
52 }
53 }
54
55 deserializer.deserialize_identifier(Visitor)
56 }
57 }
58
59 struct Visitor;
60
61 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62 type Value = TokenRequestSpec;
63
64 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 f.write_str("TokenRequestSpec")
66 }
67
68 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69 let mut value_audiences: Option<std::vec::Vec<std::string::String>> = None;
70 let mut value_bound_object_ref: Option<crate::api::authentication::v1::BoundObjectReference> = None;
71 let mut value_expiration_seconds: Option<i64> = None;
72
73 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
74 match key {
75 Field::Key_audiences => value_audiences = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Key_bound_object_ref => value_bound_object_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
77 Field::Key_expiration_seconds => value_expiration_seconds = 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 }
81
82 Ok(TokenRequestSpec {
83 audiences: value_audiences.unwrap_or_default(),
84 bound_object_ref: value_bound_object_ref,
85 expiration_seconds: value_expiration_seconds,
86 })
87 }
88 }
89
90 deserializer.deserialize_struct(
91 "TokenRequestSpec",
92 &[
93 "audiences",
94 "boundObjectRef",
95 "expirationSeconds",
96 ],
97 Visitor,
98 )
99 }
100}
101
102impl crate::serde::Serialize for TokenRequestSpec {
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 "TokenRequestSpec",
106 1 +
107 self.bound_object_ref.as_ref().map_or(0, |_| 1) +
108 self.expiration_seconds.as_ref().map_or(0, |_| 1),
109 )?;
110 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "audiences", &self.audiences)?;
111 if let Some(value) = &self.bound_object_ref {
112 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "boundObjectRef", value)?;
113 }
114 if let Some(value) = &self.expiration_seconds {
115 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "expirationSeconds", value)?;
116 }
117 crate::serde::ser::SerializeStruct::end(state)
118 }
119}
120
121#[cfg(feature = "schemars")]
122impl crate::schemars::JsonSchema for TokenRequestSpec {
123 fn schema_name() -> std::borrow::Cow<'static, str> {
124 "io.k8s.api.authentication.v1.TokenRequestSpec".into()
125 }
126
127 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
128 crate::schemars::json_schema!({
129 "description": "TokenRequestSpec contains client provided parameters of a token request.",
130 "type": "object",
131 "properties": {
132 "audiences": {
133 "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.",
134 "type": "array",
135 "items": {
136 "type": "string",
137 },
138 },
139 "boundObjectRef": ({
140 let mut schema_obj = __gen.subschema_for::<crate::api::authentication::v1::BoundObjectReference>();
141 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());
142 schema_obj
143 }),
144 "expirationSeconds": {
145 "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.",
146 "type": "integer",
147 "format": "int64",
148 },
149 },
150 "required": [
151 "audiences",
152 ],
153 })
154 }
155}