openshift_openapi/v4_5/api/authorization/v1/
role_binding.rs

1// Generated from definition com.github.openshift.api.authorization.v1.RoleBinding
2
3/// RoleBinding references a Role, but not contain it.  It can reference any Role in the same namespace or in the global namespace. It adds who information via (Users and Groups) OR Subjects and namespace information by which namespace it exists in. RoleBindings in a given namespace only have effect in that namespace (excepting the master namespace which has power in all namespaces).
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct RoleBinding {
6    /// GroupNames holds all the groups directly bound to the role. This field should only be specified when supporting legacy clients and servers. See Subjects for further details.
7    pub group_names: Vec<String>,
8
9    /// Standard object's metadata.
10    pub metadata: k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta,
11
12    /// RoleRef can only reference the current namespace and the global namespace. If the RoleRef cannot be resolved, the Authorizer must return an error. Since Policy is a singleton, this is sufficient knowledge to locate a role.
13    pub role_ref: k8s_openapi::api::core::v1::ObjectReference,
14
15    /// Subjects hold object references to authorize with this rule. This field is ignored if UserNames or GroupNames are specified to support legacy clients and servers. Thus newer clients that do not need to support backwards compatibility should send only fully qualified Subjects and should omit the UserNames and GroupNames fields. Clients that need to support backwards compatibility can use this field to build the UserNames and GroupNames.
16    pub subjects: Vec<k8s_openapi::api::core::v1::ObjectReference>,
17
18    /// UserNames holds all the usernames directly bound to the role. This field should only be specified when supporting legacy clients and servers. See Subjects for further details.
19    pub user_names: Vec<String>,
20}
21
22// Begin authorization.openshift.io/v1/RoleBinding
23
24// Generated from operation createAuthorizationOpenshiftIoV1NamespacedRoleBinding
25
26impl RoleBinding {
27    /// create a RoleBinding
28    ///
29    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::CreateResponse`]`<Self>>` constructor, or [`k8s_openapi::CreateResponse`]`<Self>` directly, to parse the HTTP response.
30    ///
31    /// # Arguments
32    ///
33    /// * `namespace`
34    ///
35    ///     object name and auth scope, such as for teams and projects
36    ///
37    /// * `body`
38    ///
39    /// * `optional`
40    ///
41    ///     Optional parameters. Use `Default::default()` to not pass any.
42    #[cfg(feature = "api")]
43    pub fn create_namespaced_role_binding(
44        namespace: &str,
45        body: &crate::api::authorization::v1::RoleBinding,
46        optional: k8s_openapi::CreateOptional<'_>,
47    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::CreateResponse<Self>>), k8s_openapi::RequestError> {
48        let __url = format!("/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindings?",
49            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
50        );
51        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
52        optional.__serialize(&mut __query_pairs);
53        let __url = __query_pairs.finish();
54
55        let __request = http::Request::post(__url);
56        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
57        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
58        match __request.body(__body) {
59            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
60            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
61        }
62    }
63}
64
65// Generated from operation deleteAuthorizationOpenshiftIoV1NamespacedRoleBinding
66
67impl RoleBinding {
68    /// delete a RoleBinding
69    ///
70    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::DeleteResponse`]`<Self>>` constructor, or [`k8s_openapi::DeleteResponse`]`<Self>` directly, to parse the HTTP response.
71    ///
72    /// # Arguments
73    ///
74    /// * `name`
75    ///
76    ///     name of the RoleBinding
77    ///
78    /// * `namespace`
79    ///
80    ///     object name and auth scope, such as for teams and projects
81    ///
82    /// * `optional`
83    ///
84    ///     Optional parameters. Use `Default::default()` to not pass any.
85    #[cfg(feature = "api")]
86    pub fn delete_namespaced_role_binding(
87        name: &str,
88        namespace: &str,
89        optional: k8s_openapi::DeleteOptional<'_>,
90    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<Self>>), k8s_openapi::RequestError> {
91        let __url = format!("/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindings/{name}",
92            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
93            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
94        );
95
96        let __request = http::Request::delete(__url);
97        let __body = serde_json::to_vec(&optional).map_err(k8s_openapi::RequestError::Json)?;
98        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
99        match __request.body(__body) {
100            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
101            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
102        }
103    }
104}
105
106// Generated from operation listAuthorizationOpenshiftIoV1NamespacedRoleBinding
107
108impl RoleBinding {
109    /// list objects of kind RoleBinding
110    ///
111    /// This operation only supports listing all items of this type.
112    ///
113    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ListResponse`]`<Self>>` constructor, or [`k8s_openapi::ListResponse`]`<Self>` directly, to parse the HTTP response.
114    ///
115    /// # Arguments
116    ///
117    /// * `namespace`
118    ///
119    ///     object name and auth scope, such as for teams and projects
120    ///
121    /// * `optional`
122    ///
123    ///     Optional parameters. Use `Default::default()` to not pass any.
124    #[cfg(feature = "api")]
125    pub fn list_namespaced_role_binding(
126        namespace: &str,
127        optional: k8s_openapi::ListOptional<'_>,
128    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ListResponse<Self>>), k8s_openapi::RequestError> {
129        let __url = format!("/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindings?",
130            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
131        );
132        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
133        optional.__serialize(&mut __query_pairs);
134        let __url = __query_pairs.finish();
135
136        let __request = http::Request::get(__url);
137        let __body = vec![];
138        match __request.body(__body) {
139            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
140            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
141        }
142    }
143}
144
145// Generated from operation listAuthorizationOpenshiftIoV1RoleBindingForAllNamespaces
146
147impl RoleBinding {
148    /// list objects of kind RoleBinding
149    ///
150    /// This operation only supports listing all items of this type.
151    ///
152    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ListResponse`]`<Self>>` constructor, or [`k8s_openapi::ListResponse`]`<Self>` directly, to parse the HTTP response.
153    ///
154    /// # Arguments
155    ///
156    /// * `optional`
157    ///
158    ///     Optional parameters. Use `Default::default()` to not pass any.
159    #[cfg(feature = "api")]
160    pub fn list_role_binding_for_all_namespaces(
161        optional: k8s_openapi::ListOptional<'_>,
162    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ListResponse<Self>>), k8s_openapi::RequestError> {
163        let __url = "/apis/authorization.openshift.io/v1/rolebindings?".to_owned();
164        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
165        optional.__serialize(&mut __query_pairs);
166        let __url = __query_pairs.finish();
167
168        let __request = http::Request::get(__url);
169        let __body = vec![];
170        match __request.body(__body) {
171            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
172            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
173        }
174    }
175}
176
177// Generated from operation patchAuthorizationOpenshiftIoV1NamespacedRoleBinding
178
179impl RoleBinding {
180    /// partially update the specified RoleBinding
181    ///
182    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::PatchResponse`]`<Self>>` constructor, or [`k8s_openapi::PatchResponse`]`<Self>` directly, to parse the HTTP response.
183    ///
184    /// # Arguments
185    ///
186    /// * `name`
187    ///
188    ///     name of the RoleBinding
189    ///
190    /// * `namespace`
191    ///
192    ///     object name and auth scope, such as for teams and projects
193    ///
194    /// * `body`
195    ///
196    /// * `optional`
197    ///
198    ///     Optional parameters. Use `Default::default()` to not pass any.
199    #[cfg(feature = "api")]
200    pub fn patch_namespaced_role_binding(
201        name: &str,
202        namespace: &str,
203        body: &k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch,
204        optional: k8s_openapi::PatchOptional<'_>,
205    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::PatchResponse<Self>>), k8s_openapi::RequestError> {
206        let __url = format!("/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindings/{name}?",
207            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
208            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
209        );
210        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
211        optional.__serialize(&mut __query_pairs);
212        let __url = __query_pairs.finish();
213
214        let __request = http::Request::patch(__url);
215        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
216        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static(match body {
217            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Json(_) => "application/json-patch+json",
218            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Merge(_) => "application/merge-patch+json",
219            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::StrategicMerge(_) => "application/strategic-merge-patch+json",
220        }));
221        match __request.body(__body) {
222            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
223            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
224        }
225    }
226}
227
228// Generated from operation readAuthorizationOpenshiftIoV1NamespacedRoleBinding
229
230impl RoleBinding {
231    /// read the specified RoleBinding
232    ///
233    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`ReadNamespacedRoleBindingResponse`]`>` constructor, or [`ReadNamespacedRoleBindingResponse`] directly, to parse the HTTP response.
234    ///
235    /// # Arguments
236    ///
237    /// * `name`
238    ///
239    ///     name of the RoleBinding
240    ///
241    /// * `namespace`
242    ///
243    ///     object name and auth scope, such as for teams and projects
244    ///
245    /// * `optional`
246    ///
247    ///     Optional parameters. Use `Default::default()` to not pass any.
248    #[cfg(feature = "api")]
249    pub fn read_namespaced_role_binding(
250        name: &str,
251        namespace: &str,
252        optional: ReadNamespacedRoleBindingOptional<'_>,
253    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<ReadNamespacedRoleBindingResponse>), k8s_openapi::RequestError> {
254        let ReadNamespacedRoleBindingOptional {
255            pretty,
256        } = optional;
257        let __url = format!("/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindings/{name}?",
258            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
259            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
260        );
261        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
262        if let Some(pretty) = pretty {
263            __query_pairs.append_pair("pretty", pretty);
264        }
265        let __url = __query_pairs.finish();
266
267        let __request = http::Request::get(__url);
268        let __body = vec![];
269        match __request.body(__body) {
270            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
271            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
272        }
273    }
274}
275
276/// Optional parameters of [`RoleBinding::read_namespaced_role_binding`]
277#[cfg(feature = "api")]
278#[derive(Clone, Copy, Debug, Default)]
279pub struct ReadNamespacedRoleBindingOptional<'a> {
280    /// If 'true', then the output is pretty printed.
281    pub pretty: Option<&'a str>,
282}
283
284/// Use `<ReadNamespacedRoleBindingResponse as Response>::try_from_parts` to parse the HTTP response body of [`RoleBinding::read_namespaced_role_binding`]
285#[cfg(feature = "api")]
286#[derive(Debug)]
287pub enum ReadNamespacedRoleBindingResponse {
288    Ok(crate::api::authorization::v1::RoleBinding),
289    Other(Result<Option<serde_json::Value>, serde_json::Error>),
290}
291
292#[cfg(feature = "api")]
293impl k8s_openapi::Response for ReadNamespacedRoleBindingResponse {
294    fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), k8s_openapi::ResponseError> {
295        match status_code {
296            http::StatusCode::OK => {
297                let result = match serde_json::from_slice(buf) {
298                    Ok(value) => value,
299                    Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
300                    Err(err) => return Err(k8s_openapi::ResponseError::Json(err)),
301                };
302                Ok((ReadNamespacedRoleBindingResponse::Ok(result), buf.len()))
303            },
304            _ => {
305                let (result, read) =
306                    if buf.is_empty() {
307                        (Ok(None), 0)
308                    }
309                    else {
310                        match serde_json::from_slice(buf) {
311                            Ok(value) => (Ok(Some(value)), buf.len()),
312                            Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
313                            Err(err) => (Err(err), 0),
314                        }
315                    };
316                Ok((ReadNamespacedRoleBindingResponse::Other(result), read))
317            },
318        }
319    }
320}
321
322// Generated from operation replaceAuthorizationOpenshiftIoV1NamespacedRoleBinding
323
324impl RoleBinding {
325    /// replace the specified RoleBinding
326    ///
327    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ReplaceResponse`]`<Self>>` constructor, or [`k8s_openapi::ReplaceResponse`]`<Self>` directly, to parse the HTTP response.
328    ///
329    /// # Arguments
330    ///
331    /// * `name`
332    ///
333    ///     name of the RoleBinding
334    ///
335    /// * `namespace`
336    ///
337    ///     object name and auth scope, such as for teams and projects
338    ///
339    /// * `body`
340    ///
341    /// * `optional`
342    ///
343    ///     Optional parameters. Use `Default::default()` to not pass any.
344    #[cfg(feature = "api")]
345    pub fn replace_namespaced_role_binding(
346        name: &str,
347        namespace: &str,
348        body: &crate::api::authorization::v1::RoleBinding,
349        optional: k8s_openapi::ReplaceOptional<'_>,
350    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ReplaceResponse<Self>>), k8s_openapi::RequestError> {
351        let __url = format!("/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindings/{name}?",
352            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
353            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
354        );
355        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
356        optional.__serialize(&mut __query_pairs);
357        let __url = __query_pairs.finish();
358
359        let __request = http::Request::put(__url);
360        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
361        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
362        match __request.body(__body) {
363            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
364            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
365        }
366    }
367}
368
369// Generated from operation watchAuthorizationOpenshiftIoV1NamespacedRoleBinding
370
371impl RoleBinding {
372    /// list objects of kind RoleBinding
373    ///
374    /// This operation only supports watching one item, or a list of items, of this type for changes.
375    ///
376    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::WatchResponse`]`<Self>>` constructor, or [`k8s_openapi::WatchResponse`]`<Self>` directly, to parse the HTTP response.
377    ///
378    /// # Arguments
379    ///
380    /// * `namespace`
381    ///
382    ///     object name and auth scope, such as for teams and projects
383    ///
384    /// * `optional`
385    ///
386    ///     Optional parameters. Use `Default::default()` to not pass any.
387    #[cfg(feature = "api")]
388    pub fn watch_namespaced_role_binding(
389        namespace: &str,
390        optional: k8s_openapi::WatchOptional<'_>,
391    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::WatchResponse<Self>>), k8s_openapi::RequestError> {
392        let __url = format!("/apis/authorization.openshift.io/v1/namespaces/{namespace}/rolebindings?",
393            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
394        );
395        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
396        optional.__serialize(&mut __query_pairs);
397        let __url = __query_pairs.finish();
398
399        let __request = http::Request::get(__url);
400        let __body = vec![];
401        match __request.body(__body) {
402            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
403            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
404        }
405    }
406}
407
408// Generated from operation watchAuthorizationOpenshiftIoV1RoleBindingForAllNamespaces
409
410impl RoleBinding {
411    /// list objects of kind RoleBinding
412    ///
413    /// This operation only supports watching one item, or a list of items, of this type for changes.
414    ///
415    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::WatchResponse`]`<Self>>` constructor, or [`k8s_openapi::WatchResponse`]`<Self>` directly, to parse the HTTP response.
416    ///
417    /// # Arguments
418    ///
419    /// * `optional`
420    ///
421    ///     Optional parameters. Use `Default::default()` to not pass any.
422    #[cfg(feature = "api")]
423    pub fn watch_role_binding_for_all_namespaces(
424        optional: k8s_openapi::WatchOptional<'_>,
425    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::WatchResponse<Self>>), k8s_openapi::RequestError> {
426        let __url = "/apis/authorization.openshift.io/v1/rolebindings?".to_owned();
427        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
428        optional.__serialize(&mut __query_pairs);
429        let __url = __query_pairs.finish();
430
431        let __request = http::Request::get(__url);
432        let __body = vec![];
433        match __request.body(__body) {
434            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
435            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
436        }
437    }
438}
439
440// End authorization.openshift.io/v1/RoleBinding
441
442impl k8s_openapi::Resource for RoleBinding {
443    const API_VERSION: &'static str = "authorization.openshift.io/v1";
444    const GROUP: &'static str = "authorization.openshift.io";
445    const KIND: &'static str = "RoleBinding";
446    const VERSION: &'static str = "v1";
447}
448
449impl k8s_openapi::ListableResource for RoleBinding {
450    const LIST_KIND: &'static str = concat!("RoleBinding", "List");
451}
452
453impl k8s_openapi::Metadata for RoleBinding {
454    type Ty = k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
455
456    fn metadata(&self) -> &<Self as k8s_openapi::Metadata>::Ty {
457        &self.metadata
458    }
459
460    fn metadata_mut(&mut self) -> &mut<Self as k8s_openapi::Metadata>::Ty {
461        &mut self.metadata
462    }
463}
464
465impl<'de> serde::Deserialize<'de> for RoleBinding {
466    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
467        #[allow(non_camel_case_types)]
468        enum Field {
469            Key_api_version,
470            Key_kind,
471            Key_group_names,
472            Key_metadata,
473            Key_role_ref,
474            Key_subjects,
475            Key_user_names,
476            Other,
477        }
478
479        impl<'de> serde::Deserialize<'de> for Field {
480            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
481                struct Visitor;
482
483                impl<'de> serde::de::Visitor<'de> for Visitor {
484                    type Value = Field;
485
486                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
487                        f.write_str("field identifier")
488                    }
489
490                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
491                        Ok(match v {
492                            "apiVersion" => Field::Key_api_version,
493                            "kind" => Field::Key_kind,
494                            "groupNames" => Field::Key_group_names,
495                            "metadata" => Field::Key_metadata,
496                            "roleRef" => Field::Key_role_ref,
497                            "subjects" => Field::Key_subjects,
498                            "userNames" => Field::Key_user_names,
499                            _ => Field::Other,
500                        })
501                    }
502                }
503
504                deserializer.deserialize_identifier(Visitor)
505            }
506        }
507
508        struct Visitor;
509
510        impl<'de> serde::de::Visitor<'de> for Visitor {
511            type Value = RoleBinding;
512
513            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
514                f.write_str(<Self::Value as k8s_openapi::Resource>::KIND)
515            }
516
517            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
518                let mut value_group_names: Option<Vec<String>> = None;
519                let mut value_metadata: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
520                let mut value_role_ref: Option<k8s_openapi::api::core::v1::ObjectReference> = None;
521                let mut value_subjects: Option<Vec<k8s_openapi::api::core::v1::ObjectReference>> = None;
522                let mut value_user_names: Option<Vec<String>> = None;
523
524                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
525                    match key {
526                        Field::Key_api_version => {
527                            let value_api_version: String = serde::de::MapAccess::next_value(&mut map)?;
528                            if value_api_version != <Self::Value as k8s_openapi::Resource>::API_VERSION {
529                                return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_api_version), &<Self::Value as k8s_openapi::Resource>::API_VERSION));
530                            }
531                        },
532                        Field::Key_kind => {
533                            let value_kind: String = serde::de::MapAccess::next_value(&mut map)?;
534                            if value_kind != <Self::Value as k8s_openapi::Resource>::KIND {
535                                return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_kind), &<Self::Value as k8s_openapi::Resource>::KIND));
536                            }
537                        },
538                        Field::Key_group_names => value_group_names = Some(serde::de::MapAccess::next_value(&mut map)?),
539                        Field::Key_metadata => value_metadata = Some(serde::de::MapAccess::next_value(&mut map)?),
540                        Field::Key_role_ref => value_role_ref = Some(serde::de::MapAccess::next_value(&mut map)?),
541                        Field::Key_subjects => value_subjects = Some(serde::de::MapAccess::next_value(&mut map)?),
542                        Field::Key_user_names => value_user_names = Some(serde::de::MapAccess::next_value(&mut map)?),
543                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
544                    }
545                }
546
547                Ok(RoleBinding {
548                    group_names: value_group_names.ok_or_else(|| serde::de::Error::missing_field("groupNames"))?,
549                    metadata: value_metadata.ok_or_else(|| serde::de::Error::missing_field("metadata"))?,
550                    role_ref: value_role_ref.ok_or_else(|| serde::de::Error::missing_field("roleRef"))?,
551                    subjects: value_subjects.ok_or_else(|| serde::de::Error::missing_field("subjects"))?,
552                    user_names: value_user_names.ok_or_else(|| serde::de::Error::missing_field("userNames"))?,
553                })
554            }
555        }
556
557        deserializer.deserialize_struct(
558            <Self as k8s_openapi::Resource>::KIND,
559            &[
560                "apiVersion",
561                "kind",
562                "groupNames",
563                "metadata",
564                "roleRef",
565                "subjects",
566                "userNames",
567            ],
568            Visitor,
569        )
570    }
571}
572
573impl serde::Serialize for RoleBinding {
574    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
575        let mut state = serializer.serialize_struct(
576            <Self as k8s_openapi::Resource>::KIND,
577            7,
578        )?;
579        serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as k8s_openapi::Resource>::API_VERSION)?;
580        serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as k8s_openapi::Resource>::KIND)?;
581        serde::ser::SerializeStruct::serialize_field(&mut state, "groupNames", &self.group_names)?;
582        serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
583        serde::ser::SerializeStruct::serialize_field(&mut state, "roleRef", &self.role_ref)?;
584        serde::ser::SerializeStruct::serialize_field(&mut state, "subjects", &self.subjects)?;
585        serde::ser::SerializeStruct::serialize_field(&mut state, "userNames", &self.user_names)?;
586        serde::ser::SerializeStruct::end(state)
587    }
588}