1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct OAuthClient {
6 pub access_token_inactivity_timeout_seconds: Option<i32>,
8
9 pub access_token_max_age_seconds: Option<i32>,
11
12 pub additional_secrets: Option<Vec<String>>,
14
15 pub grant_method: Option<String>,
20
21 pub metadata: k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta,
23
24 pub redirect_ur_is: Option<Vec<String>>,
26
27 pub respond_with_challenges: Option<bool>,
29
30 pub scope_restrictions: Option<Vec<crate::api::oauth::v1::ScopeRestriction>>,
32
33 pub secret: Option<String>,
35}
36
37impl OAuthClient {
42 #[cfg(feature = "api")]
54 pub fn create_o_auth_client(
55 body: &crate::api::oauth::v1::OAuthClient,
56 optional: k8s_openapi::CreateOptional<'_>,
57 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::CreateResponse<Self>>), k8s_openapi::RequestError> {
58 let __url = "/apis/oauth.openshift.io/v1/oauthclients?".to_owned();
59 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
60 optional.__serialize(&mut __query_pairs);
61 let __url = __query_pairs.finish();
62
63 let __request = http::Request::post(__url);
64 let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
65 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
66 match __request.body(__body) {
67 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
68 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
69 }
70 }
71}
72
73impl OAuthClient {
76 #[cfg(feature = "api")]
90 pub fn delete_collection_o_auth_client(
91 delete_optional: k8s_openapi::DeleteOptional<'_>,
92 list_optional: k8s_openapi::ListOptional<'_>,
93 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<k8s_openapi::List<Self>>>), k8s_openapi::RequestError> {
94 let __url = "/apis/oauth.openshift.io/v1/oauthclients?".to_owned();
95 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
96 list_optional.__serialize(&mut __query_pairs);
97 let __url = __query_pairs.finish();
98
99 let __request = http::Request::delete(__url);
100 let __body = serde_json::to_vec(&delete_optional).map_err(k8s_openapi::RequestError::Json)?;
101 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
102 match __request.body(__body) {
103 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
104 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
105 }
106 }
107}
108
109impl OAuthClient {
112 #[cfg(feature = "api")]
126 pub fn delete_o_auth_client(
127 name: &str,
128 optional: k8s_openapi::DeleteOptional<'_>,
129 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<Self>>), k8s_openapi::RequestError> {
130 let __url = format!("/apis/oauth.openshift.io/v1/oauthclients/{name}",
131 name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
132 );
133
134 let __request = http::Request::delete(__url);
135 let __body = serde_json::to_vec(&optional).map_err(k8s_openapi::RequestError::Json)?;
136 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
137 match __request.body(__body) {
138 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
139 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
140 }
141 }
142}
143
144impl OAuthClient {
147 #[cfg(feature = "api")]
159 pub fn list_o_auth_client(
160 optional: k8s_openapi::ListOptional<'_>,
161 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ListResponse<Self>>), k8s_openapi::RequestError> {
162 let __url = "/apis/oauth.openshift.io/v1/oauthclients?".to_owned();
163 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
164 optional.__serialize(&mut __query_pairs);
165 let __url = __query_pairs.finish();
166
167 let __request = http::Request::get(__url);
168 let __body = vec![];
169 match __request.body(__body) {
170 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
171 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
172 }
173 }
174}
175
176impl OAuthClient {
179 #[cfg(feature = "api")]
195 pub fn patch_o_auth_client(
196 name: &str,
197 body: &k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch,
198 optional: k8s_openapi::PatchOptional<'_>,
199 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::PatchResponse<Self>>), k8s_openapi::RequestError> {
200 let __url = format!("/apis/oauth.openshift.io/v1/oauthclients/{name}?",
201 name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
202 );
203 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
204 optional.__serialize(&mut __query_pairs);
205 let __url = __query_pairs.finish();
206
207 let __request = http::Request::patch(__url);
208 let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
209 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static(match body {
210 k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Json(_) => "application/json-patch+json",
211 k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Merge(_) => "application/merge-patch+json",
212 k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::StrategicMerge(_) => "application/strategic-merge-patch+json",
213 }));
214 match __request.body(__body) {
215 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
216 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
217 }
218 }
219}
220
221impl OAuthClient {
224 #[cfg(feature = "api")]
238 pub fn read_o_auth_client(
239 name: &str,
240 optional: ReadOAuthClientOptional<'_>,
241 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<ReadOAuthClientResponse>), k8s_openapi::RequestError> {
242 let ReadOAuthClientOptional {
243 exact,
244 export,
245 pretty,
246 } = optional;
247 let __url = format!("/apis/oauth.openshift.io/v1/oauthclients/{name}?",
248 name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
249 );
250 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
251 if let Some(exact) = exact {
252 __query_pairs.append_pair("exact", &exact.to_string());
253 }
254 if let Some(export) = export {
255 __query_pairs.append_pair("export", &export.to_string());
256 }
257 if let Some(pretty) = pretty {
258 __query_pairs.append_pair("pretty", pretty);
259 }
260 let __url = __query_pairs.finish();
261
262 let __request = http::Request::get(__url);
263 let __body = vec![];
264 match __request.body(__body) {
265 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
266 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
267 }
268 }
269}
270
271#[cfg(feature = "api")]
273#[derive(Clone, Copy, Debug, Default)]
274pub struct ReadOAuthClientOptional<'a> {
275 pub exact: Option<bool>,
277 pub export: Option<bool>,
279 pub pretty: Option<&'a str>,
281}
282
283#[cfg(feature = "api")]
285#[derive(Debug)]
286pub enum ReadOAuthClientResponse {
287 Ok(crate::api::oauth::v1::OAuthClient),
288 Other(Result<Option<serde_json::Value>, serde_json::Error>),
289}
290
291#[cfg(feature = "api")]
292impl k8s_openapi::Response for ReadOAuthClientResponse {
293 fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), k8s_openapi::ResponseError> {
294 match status_code {
295 http::StatusCode::OK => {
296 let result = match serde_json::from_slice(buf) {
297 Ok(value) => value,
298 Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
299 Err(err) => return Err(k8s_openapi::ResponseError::Json(err)),
300 };
301 Ok((ReadOAuthClientResponse::Ok(result), buf.len()))
302 },
303 _ => {
304 let (result, read) =
305 if buf.is_empty() {
306 (Ok(None), 0)
307 }
308 else {
309 match serde_json::from_slice(buf) {
310 Ok(value) => (Ok(Some(value)), buf.len()),
311 Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
312 Err(err) => (Err(err), 0),
313 }
314 };
315 Ok((ReadOAuthClientResponse::Other(result), read))
316 },
317 }
318 }
319}
320
321impl OAuthClient {
324 #[cfg(feature = "api")]
340 pub fn replace_o_auth_client(
341 name: &str,
342 body: &crate::api::oauth::v1::OAuthClient,
343 optional: k8s_openapi::ReplaceOptional<'_>,
344 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ReplaceResponse<Self>>), k8s_openapi::RequestError> {
345 let __url = format!("/apis/oauth.openshift.io/v1/oauthclients/{name}?",
346 name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
347 );
348 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
349 optional.__serialize(&mut __query_pairs);
350 let __url = __query_pairs.finish();
351
352 let __request = http::Request::put(__url);
353 let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
354 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
355 match __request.body(__body) {
356 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
357 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
358 }
359 }
360}
361
362impl OAuthClient {
365 #[cfg(feature = "api")]
377 pub fn watch_o_auth_client(
378 optional: k8s_openapi::WatchOptional<'_>,
379 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::WatchResponse<Self>>), k8s_openapi::RequestError> {
380 let __url = "/apis/oauth.openshift.io/v1/oauthclients?".to_owned();
381 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
382 optional.__serialize(&mut __query_pairs);
383 let __url = __query_pairs.finish();
384
385 let __request = http::Request::get(__url);
386 let __body = vec![];
387 match __request.body(__body) {
388 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
389 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
390 }
391 }
392}
393
394impl k8s_openapi::Resource for OAuthClient {
397 const API_VERSION: &'static str = "oauth.openshift.io/v1";
398 const GROUP: &'static str = "oauth.openshift.io";
399 const KIND: &'static str = "OAuthClient";
400 const VERSION: &'static str = "v1";
401}
402
403impl k8s_openapi::ListableResource for OAuthClient {
404 const LIST_KIND: &'static str = concat!("OAuthClient", "List");
405}
406
407impl k8s_openapi::Metadata for OAuthClient {
408 type Ty = k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
409
410 fn metadata(&self) -> &<Self as k8s_openapi::Metadata>::Ty {
411 &self.metadata
412 }
413
414 fn metadata_mut(&mut self) -> &mut<Self as k8s_openapi::Metadata>::Ty {
415 &mut self.metadata
416 }
417}
418
419impl<'de> serde::Deserialize<'de> for OAuthClient {
420 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
421 #[allow(non_camel_case_types)]
422 enum Field {
423 Key_api_version,
424 Key_kind,
425 Key_access_token_inactivity_timeout_seconds,
426 Key_access_token_max_age_seconds,
427 Key_additional_secrets,
428 Key_grant_method,
429 Key_metadata,
430 Key_redirect_ur_is,
431 Key_respond_with_challenges,
432 Key_scope_restrictions,
433 Key_secret,
434 Other,
435 }
436
437 impl<'de> serde::Deserialize<'de> for Field {
438 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
439 struct Visitor;
440
441 impl<'de> serde::de::Visitor<'de> for Visitor {
442 type Value = Field;
443
444 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
445 f.write_str("field identifier")
446 }
447
448 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
449 Ok(match v {
450 "apiVersion" => Field::Key_api_version,
451 "kind" => Field::Key_kind,
452 "accessTokenInactivityTimeoutSeconds" => Field::Key_access_token_inactivity_timeout_seconds,
453 "accessTokenMaxAgeSeconds" => Field::Key_access_token_max_age_seconds,
454 "additionalSecrets" => Field::Key_additional_secrets,
455 "grantMethod" => Field::Key_grant_method,
456 "metadata" => Field::Key_metadata,
457 "redirectURIs" => Field::Key_redirect_ur_is,
458 "respondWithChallenges" => Field::Key_respond_with_challenges,
459 "scopeRestrictions" => Field::Key_scope_restrictions,
460 "secret" => Field::Key_secret,
461 _ => Field::Other,
462 })
463 }
464 }
465
466 deserializer.deserialize_identifier(Visitor)
467 }
468 }
469
470 struct Visitor;
471
472 impl<'de> serde::de::Visitor<'de> for Visitor {
473 type Value = OAuthClient;
474
475 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
476 f.write_str(<Self::Value as k8s_openapi::Resource>::KIND)
477 }
478
479 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
480 let mut value_access_token_inactivity_timeout_seconds: Option<i32> = None;
481 let mut value_access_token_max_age_seconds: Option<i32> = None;
482 let mut value_additional_secrets: Option<Vec<String>> = None;
483 let mut value_grant_method: Option<String> = None;
484 let mut value_metadata: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
485 let mut value_redirect_ur_is: Option<Vec<String>> = None;
486 let mut value_respond_with_challenges: Option<bool> = None;
487 let mut value_scope_restrictions: Option<Vec<crate::api::oauth::v1::ScopeRestriction>> = None;
488 let mut value_secret: Option<String> = None;
489
490 while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
491 match key {
492 Field::Key_api_version => {
493 let value_api_version: String = serde::de::MapAccess::next_value(&mut map)?;
494 if value_api_version != <Self::Value as k8s_openapi::Resource>::API_VERSION {
495 return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_api_version), &<Self::Value as k8s_openapi::Resource>::API_VERSION));
496 }
497 },
498 Field::Key_kind => {
499 let value_kind: String = serde::de::MapAccess::next_value(&mut map)?;
500 if value_kind != <Self::Value as k8s_openapi::Resource>::KIND {
501 return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_kind), &<Self::Value as k8s_openapi::Resource>::KIND));
502 }
503 },
504 Field::Key_access_token_inactivity_timeout_seconds => value_access_token_inactivity_timeout_seconds = serde::de::MapAccess::next_value(&mut map)?,
505 Field::Key_access_token_max_age_seconds => value_access_token_max_age_seconds = serde::de::MapAccess::next_value(&mut map)?,
506 Field::Key_additional_secrets => value_additional_secrets = serde::de::MapAccess::next_value(&mut map)?,
507 Field::Key_grant_method => value_grant_method = serde::de::MapAccess::next_value(&mut map)?,
508 Field::Key_metadata => value_metadata = Some(serde::de::MapAccess::next_value(&mut map)?),
509 Field::Key_redirect_ur_is => value_redirect_ur_is = serde::de::MapAccess::next_value(&mut map)?,
510 Field::Key_respond_with_challenges => value_respond_with_challenges = serde::de::MapAccess::next_value(&mut map)?,
511 Field::Key_scope_restrictions => value_scope_restrictions = serde::de::MapAccess::next_value(&mut map)?,
512 Field::Key_secret => value_secret = serde::de::MapAccess::next_value(&mut map)?,
513 Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
514 }
515 }
516
517 Ok(OAuthClient {
518 access_token_inactivity_timeout_seconds: value_access_token_inactivity_timeout_seconds,
519 access_token_max_age_seconds: value_access_token_max_age_seconds,
520 additional_secrets: value_additional_secrets,
521 grant_method: value_grant_method,
522 metadata: value_metadata.ok_or_else(|| serde::de::Error::missing_field("metadata"))?,
523 redirect_ur_is: value_redirect_ur_is,
524 respond_with_challenges: value_respond_with_challenges,
525 scope_restrictions: value_scope_restrictions,
526 secret: value_secret,
527 })
528 }
529 }
530
531 deserializer.deserialize_struct(
532 <Self as k8s_openapi::Resource>::KIND,
533 &[
534 "apiVersion",
535 "kind",
536 "accessTokenInactivityTimeoutSeconds",
537 "accessTokenMaxAgeSeconds",
538 "additionalSecrets",
539 "grantMethod",
540 "metadata",
541 "redirectURIs",
542 "respondWithChallenges",
543 "scopeRestrictions",
544 "secret",
545 ],
546 Visitor,
547 )
548 }
549}
550
551impl serde::Serialize for OAuthClient {
552 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
553 let mut state = serializer.serialize_struct(
554 <Self as k8s_openapi::Resource>::KIND,
555 3 +
556 self.access_token_inactivity_timeout_seconds.as_ref().map_or(0, |_| 1) +
557 self.access_token_max_age_seconds.as_ref().map_or(0, |_| 1) +
558 self.additional_secrets.as_ref().map_or(0, |_| 1) +
559 self.grant_method.as_ref().map_or(0, |_| 1) +
560 self.redirect_ur_is.as_ref().map_or(0, |_| 1) +
561 self.respond_with_challenges.as_ref().map_or(0, |_| 1) +
562 self.scope_restrictions.as_ref().map_or(0, |_| 1) +
563 self.secret.as_ref().map_or(0, |_| 1),
564 )?;
565 serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as k8s_openapi::Resource>::API_VERSION)?;
566 serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as k8s_openapi::Resource>::KIND)?;
567 if let Some(value) = &self.access_token_inactivity_timeout_seconds {
568 serde::ser::SerializeStruct::serialize_field(&mut state, "accessTokenInactivityTimeoutSeconds", value)?;
569 }
570 if let Some(value) = &self.access_token_max_age_seconds {
571 serde::ser::SerializeStruct::serialize_field(&mut state, "accessTokenMaxAgeSeconds", value)?;
572 }
573 if let Some(value) = &self.additional_secrets {
574 serde::ser::SerializeStruct::serialize_field(&mut state, "additionalSecrets", value)?;
575 }
576 if let Some(value) = &self.grant_method {
577 serde::ser::SerializeStruct::serialize_field(&mut state, "grantMethod", value)?;
578 }
579 serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
580 if let Some(value) = &self.redirect_ur_is {
581 serde::ser::SerializeStruct::serialize_field(&mut state, "redirectURIs", value)?;
582 }
583 if let Some(value) = &self.respond_with_challenges {
584 serde::ser::SerializeStruct::serialize_field(&mut state, "respondWithChallenges", value)?;
585 }
586 if let Some(value) = &self.scope_restrictions {
587 serde::ser::SerializeStruct::serialize_field(&mut state, "scopeRestrictions", value)?;
588 }
589 if let Some(value) = &self.secret {
590 serde::ser::SerializeStruct::serialize_field(&mut state, "secret", value)?;
591 }
592 serde::ser::SerializeStruct::end(state)
593 }
594}