Skip to main content

k8s_openapi/v1_36/api/authentication/v1/
token_review_status.rs

1// Generated from definition io.k8s.api.authentication.v1.TokenReviewStatus
2
3/// TokenReviewStatus is the result of the token authentication request.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct TokenReviewStatus {
6    /// audiences are audience identifiers chosen by the authenticator that are compatible with both the TokenReview and token. An identifier is any identifier in the intersection of the TokenReviewSpec audiences and the token's audiences. A client of the TokenReview API that sets the spec.audiences field should validate that a compatible audience identifier is returned in the status.audiences field to ensure that the TokenReview server is audience aware. If a TokenReview returns an empty status.audience field where status.authenticated is "true", the token is valid against the audience of the Kubernetes API server.
7    pub audiences: Option<std::vec::Vec<std::string::String>>,
8
9    /// authenticated indicates that the token was associated with a known user.
10    pub authenticated: Option<bool>,
11
12    /// error indicates that the token couldn't be checked
13    pub error: Option<std::string::String>,
14
15    /// user is the UserInfo associated with the provided token.
16    pub user: Option<crate::api::authentication::v1::UserInfo>,
17}
18
19impl crate::DeepMerge for TokenReviewStatus {
20    fn merge_from(&mut self, other: Self) {
21        crate::merge_strategies::list::atomic(&mut self.audiences, other.audiences);
22        crate::DeepMerge::merge_from(&mut self.authenticated, other.authenticated);
23        crate::DeepMerge::merge_from(&mut self.error, other.error);
24        crate::DeepMerge::merge_from(&mut self.user, other.user);
25    }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for TokenReviewStatus {
29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30        #[allow(non_camel_case_types)]
31        enum Field {
32            Key_audiences,
33            Key_authenticated,
34            Key_error,
35            Key_user,
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 core::fmt::Formatter<'_>) -> core::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                            "audiences" => Field::Key_audiences,
53                            "authenticated" => Field::Key_authenticated,
54                            "error" => Field::Key_error,
55                            "user" => Field::Key_user,
56                            _ => Field::Other,
57                        })
58                    }
59                }
60
61                deserializer.deserialize_identifier(Visitor)
62            }
63        }
64
65        struct Visitor;
66
67        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68            type Value = TokenReviewStatus;
69
70            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71                f.write_str("TokenReviewStatus")
72            }
73
74            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75                let mut value_audiences: Option<std::vec::Vec<std::string::String>> = None;
76                let mut value_authenticated: Option<bool> = None;
77                let mut value_error: Option<std::string::String> = None;
78                let mut value_user: Option<crate::api::authentication::v1::UserInfo> = None;
79
80                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81                    match key {
82                        Field::Key_audiences => value_audiences = crate::serde::de::MapAccess::next_value(&mut map)?,
83                        Field::Key_authenticated => value_authenticated = crate::serde::de::MapAccess::next_value(&mut map)?,
84                        Field::Key_error => value_error = crate::serde::de::MapAccess::next_value(&mut map)?,
85                        Field::Key_user => value_user = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
87                    }
88                }
89
90                Ok(TokenReviewStatus {
91                    audiences: value_audiences,
92                    authenticated: value_authenticated,
93                    error: value_error,
94                    user: value_user,
95                })
96            }
97        }
98
99        deserializer.deserialize_struct(
100            "TokenReviewStatus",
101            &[
102                "audiences",
103                "authenticated",
104                "error",
105                "user",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl crate::serde::Serialize for TokenReviewStatus {
113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114        let mut state = serializer.serialize_struct(
115            "TokenReviewStatus",
116            self.audiences.as_ref().map_or(0, |_| 1) +
117            self.authenticated.as_ref().map_or(0, |_| 1) +
118            self.error.as_ref().map_or(0, |_| 1) +
119            self.user.as_ref().map_or(0, |_| 1),
120        )?;
121        if let Some(value) = &self.audiences {
122            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "audiences", value)?;
123        }
124        if let Some(value) = &self.authenticated {
125            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "authenticated", value)?;
126        }
127        if let Some(value) = &self.error {
128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "error", value)?;
129        }
130        if let Some(value) = &self.user {
131            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "user", value)?;
132        }
133        crate::serde::ser::SerializeStruct::end(state)
134    }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for TokenReviewStatus {
139    fn schema_name() -> std::borrow::Cow<'static, str> {
140        "io.k8s.api.authentication.v1.TokenReviewStatus".into()
141    }
142
143    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
144        crate::schemars::json_schema!({
145            "description": "TokenReviewStatus is the result of the token authentication request.",
146            "type": "object",
147            "properties": {
148                "audiences": {
149                    "description": "audiences are audience identifiers chosen by the authenticator that are compatible with both the TokenReview and token. An identifier is any identifier in the intersection of the TokenReviewSpec audiences and the token's audiences. A client of the TokenReview API that sets the spec.audiences field should validate that a compatible audience identifier is returned in the status.audiences field to ensure that the TokenReview server is audience aware. If a TokenReview returns an empty status.audience field where status.authenticated is \"true\", the token is valid against the audience of the Kubernetes API server.",
150                    "type": "array",
151                    "items": {
152                        "type": "string",
153                    },
154                },
155                "authenticated": {
156                    "description": "authenticated indicates that the token was associated with a known user.",
157                    "type": "boolean",
158                },
159                "error": {
160                    "description": "error indicates that the token couldn't be checked",
161                    "type": "string",
162                },
163                "user": ({
164                    let mut schema_obj = __gen.subschema_for::<crate::api::authentication::v1::UserInfo>();
165                    schema_obj.ensure_object().insert("description".into(), "user is the UserInfo associated with the provided token.".into());
166                    schema_obj
167                }),
168            },
169        })
170    }
171}
172
173#[cfg(feature = "schemars08")]
174impl crate::schemars08::JsonSchema for TokenReviewStatus {
175    fn schema_name() -> std::string::String {
176        "io.k8s.api.authentication.v1.TokenReviewStatus".into()
177    }
178
179    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
180        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
181            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
182                description: Some("TokenReviewStatus is the result of the token authentication request.".into()),
183                ..Default::default()
184            })),
185            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
186            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
187                properties: [
188                    (
189                        "audiences".into(),
190                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
191                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
192                                description: Some("audiences are audience identifiers chosen by the authenticator that are compatible with both the TokenReview and token. An identifier is any identifier in the intersection of the TokenReviewSpec audiences and the token's audiences. A client of the TokenReview API that sets the spec.audiences field should validate that a compatible audience identifier is returned in the status.audiences field to ensure that the TokenReview server is audience aware. If a TokenReview returns an empty status.audience field where status.authenticated is \"true\", the token is valid against the audience of the Kubernetes API server.".into()),
193                                ..Default::default()
194                            })),
195                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
196                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
197                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
198                                    crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
199                                        instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
200                                        ..Default::default()
201                                    })
202                                ))),
203                                ..Default::default()
204                            })),
205                            ..Default::default()
206                        }),
207                    ),
208                    (
209                        "authenticated".into(),
210                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
211                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
212                                description: Some("authenticated indicates that the token was associated with a known user.".into()),
213                                ..Default::default()
214                            })),
215                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Boolean))),
216                            ..Default::default()
217                        }),
218                    ),
219                    (
220                        "error".into(),
221                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
222                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
223                                description: Some("error indicates that the token couldn't be checked".into()),
224                                ..Default::default()
225                            })),
226                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
227                            ..Default::default()
228                        }),
229                    ),
230                    (
231                        "user".into(),
232                        {
233                            let mut schema_obj = __gen.subschema_for::<crate::api::authentication::v1::UserInfo>().into_object();
234                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
235                                description: Some("user is the UserInfo associated with the provided token.".into()),
236                                ..Default::default()
237                            }));
238                            crate::schemars08::schema::Schema::Object(schema_obj)
239                        },
240                    ),
241                ].into(),
242                ..Default::default()
243            })),
244            ..Default::default()
245        })
246    }
247}