1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct RangeAllocation {
6 pub data: k8s_openapi::ByteString,
8
9 pub metadata: k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta,
11
12 pub range: String,
14}
15
16impl RangeAllocation {
21 #[cfg(feature = "api")]
33 pub fn create_range_allocation(
34 body: &crate::api::security::v1::RangeAllocation,
35 optional: k8s_openapi::CreateOptional<'_>,
36 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::CreateResponse<Self>>), k8s_openapi::RequestError> {
37 let __url = "/apis/security.openshift.io/v1/rangeallocations?".to_owned();
38 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
39 optional.__serialize(&mut __query_pairs);
40 let __url = __query_pairs.finish();
41
42 let __request = http::Request::post(__url);
43 let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
44 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
45 match __request.body(__body) {
46 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
47 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
48 }
49 }
50}
51
52impl RangeAllocation {
55 #[cfg(feature = "api")]
69 pub fn delete_collection_range_allocation(
70 delete_optional: k8s_openapi::DeleteOptional<'_>,
71 list_optional: k8s_openapi::ListOptional<'_>,
72 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<k8s_openapi::List<Self>>>), k8s_openapi::RequestError> {
73 let __url = "/apis/security.openshift.io/v1/rangeallocations?".to_owned();
74 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
75 list_optional.__serialize(&mut __query_pairs);
76 let __url = __query_pairs.finish();
77
78 let __request = http::Request::delete(__url);
79 let __body = serde_json::to_vec(&delete_optional).map_err(k8s_openapi::RequestError::Json)?;
80 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
81 match __request.body(__body) {
82 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
83 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
84 }
85 }
86}
87
88impl RangeAllocation {
91 #[cfg(feature = "api")]
105 pub fn delete_range_allocation(
106 name: &str,
107 optional: k8s_openapi::DeleteOptional<'_>,
108 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<Self>>), k8s_openapi::RequestError> {
109 let __url = format!("/apis/security.openshift.io/v1/rangeallocations/{name}",
110 name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
111 );
112
113 let __request = http::Request::delete(__url);
114 let __body = serde_json::to_vec(&optional).map_err(k8s_openapi::RequestError::Json)?;
115 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
116 match __request.body(__body) {
117 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
118 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
119 }
120 }
121}
122
123impl RangeAllocation {
126 #[cfg(feature = "api")]
138 pub fn list_range_allocation(
139 optional: k8s_openapi::ListOptional<'_>,
140 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ListResponse<Self>>), k8s_openapi::RequestError> {
141 let __url = "/apis/security.openshift.io/v1/rangeallocations?".to_owned();
142 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
143 optional.__serialize(&mut __query_pairs);
144 let __url = __query_pairs.finish();
145
146 let __request = http::Request::get(__url);
147 let __body = vec![];
148 match __request.body(__body) {
149 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
150 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
151 }
152 }
153}
154
155impl RangeAllocation {
158 #[cfg(feature = "api")]
174 pub fn patch_range_allocation(
175 name: &str,
176 body: &k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch,
177 optional: k8s_openapi::PatchOptional<'_>,
178 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::PatchResponse<Self>>), k8s_openapi::RequestError> {
179 let __url = format!("/apis/security.openshift.io/v1/rangeallocations/{name}?",
180 name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
181 );
182 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
183 optional.__serialize(&mut __query_pairs);
184 let __url = __query_pairs.finish();
185
186 let __request = http::Request::patch(__url);
187 let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
188 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static(match body {
189 k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Json(_) => "application/json-patch+json",
190 k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Merge(_) => "application/merge-patch+json",
191 k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::StrategicMerge(_) => "application/strategic-merge-patch+json",
192 }));
193 match __request.body(__body) {
194 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
195 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
196 }
197 }
198}
199
200impl RangeAllocation {
203 #[cfg(feature = "api")]
217 pub fn read_range_allocation(
218 name: &str,
219 optional: ReadRangeAllocationOptional<'_>,
220 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<ReadRangeAllocationResponse>), k8s_openapi::RequestError> {
221 let ReadRangeAllocationOptional {
222 exact,
223 export,
224 pretty,
225 } = optional;
226 let __url = format!("/apis/security.openshift.io/v1/rangeallocations/{name}?",
227 name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
228 );
229 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
230 if let Some(exact) = exact {
231 __query_pairs.append_pair("exact", &exact.to_string());
232 }
233 if let Some(export) = export {
234 __query_pairs.append_pair("export", &export.to_string());
235 }
236 if let Some(pretty) = pretty {
237 __query_pairs.append_pair("pretty", pretty);
238 }
239 let __url = __query_pairs.finish();
240
241 let __request = http::Request::get(__url);
242 let __body = vec![];
243 match __request.body(__body) {
244 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
245 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
246 }
247 }
248}
249
250#[cfg(feature = "api")]
252#[derive(Clone, Copy, Debug, Default)]
253pub struct ReadRangeAllocationOptional<'a> {
254 pub exact: Option<bool>,
256 pub export: Option<bool>,
258 pub pretty: Option<&'a str>,
260}
261
262#[cfg(feature = "api")]
264#[derive(Debug)]
265pub enum ReadRangeAllocationResponse {
266 Ok(crate::api::security::v1::RangeAllocation),
267 Other(Result<Option<serde_json::Value>, serde_json::Error>),
268}
269
270#[cfg(feature = "api")]
271impl k8s_openapi::Response for ReadRangeAllocationResponse {
272 fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), k8s_openapi::ResponseError> {
273 match status_code {
274 http::StatusCode::OK => {
275 let result = match serde_json::from_slice(buf) {
276 Ok(value) => value,
277 Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
278 Err(err) => return Err(k8s_openapi::ResponseError::Json(err)),
279 };
280 Ok((ReadRangeAllocationResponse::Ok(result), buf.len()))
281 },
282 _ => {
283 let (result, read) =
284 if buf.is_empty() {
285 (Ok(None), 0)
286 }
287 else {
288 match serde_json::from_slice(buf) {
289 Ok(value) => (Ok(Some(value)), buf.len()),
290 Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
291 Err(err) => (Err(err), 0),
292 }
293 };
294 Ok((ReadRangeAllocationResponse::Other(result), read))
295 },
296 }
297 }
298}
299
300impl RangeAllocation {
303 #[cfg(feature = "api")]
319 pub fn replace_range_allocation(
320 name: &str,
321 body: &crate::api::security::v1::RangeAllocation,
322 optional: k8s_openapi::ReplaceOptional<'_>,
323 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ReplaceResponse<Self>>), k8s_openapi::RequestError> {
324 let __url = format!("/apis/security.openshift.io/v1/rangeallocations/{name}?",
325 name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
326 );
327 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
328 optional.__serialize(&mut __query_pairs);
329 let __url = __query_pairs.finish();
330
331 let __request = http::Request::put(__url);
332 let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
333 let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
334 match __request.body(__body) {
335 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
336 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
337 }
338 }
339}
340
341impl RangeAllocation {
344 #[cfg(feature = "api")]
356 pub fn watch_range_allocation(
357 optional: k8s_openapi::WatchOptional<'_>,
358 ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::WatchResponse<Self>>), k8s_openapi::RequestError> {
359 let __url = "/apis/security.openshift.io/v1/rangeallocations?".to_owned();
360 let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
361 optional.__serialize(&mut __query_pairs);
362 let __url = __query_pairs.finish();
363
364 let __request = http::Request::get(__url);
365 let __body = vec![];
366 match __request.body(__body) {
367 Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
368 Err(err) => Err(k8s_openapi::RequestError::Http(err)),
369 }
370 }
371}
372
373impl k8s_openapi::Resource for RangeAllocation {
376 const API_VERSION: &'static str = "security.openshift.io/v1";
377 const GROUP: &'static str = "security.openshift.io";
378 const KIND: &'static str = "RangeAllocation";
379 const VERSION: &'static str = "v1";
380}
381
382impl k8s_openapi::ListableResource for RangeAllocation {
383 const LIST_KIND: &'static str = concat!("RangeAllocation", "List");
384}
385
386impl k8s_openapi::Metadata for RangeAllocation {
387 type Ty = k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
388
389 fn metadata(&self) -> &<Self as k8s_openapi::Metadata>::Ty {
390 &self.metadata
391 }
392
393 fn metadata_mut(&mut self) -> &mut<Self as k8s_openapi::Metadata>::Ty {
394 &mut self.metadata
395 }
396}
397
398impl<'de> serde::Deserialize<'de> for RangeAllocation {
399 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
400 #[allow(non_camel_case_types)]
401 enum Field {
402 Key_api_version,
403 Key_kind,
404 Key_data,
405 Key_metadata,
406 Key_range,
407 Other,
408 }
409
410 impl<'de> serde::Deserialize<'de> for Field {
411 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
412 struct Visitor;
413
414 impl<'de> serde::de::Visitor<'de> for Visitor {
415 type Value = Field;
416
417 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
418 f.write_str("field identifier")
419 }
420
421 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
422 Ok(match v {
423 "apiVersion" => Field::Key_api_version,
424 "kind" => Field::Key_kind,
425 "data" => Field::Key_data,
426 "metadata" => Field::Key_metadata,
427 "range" => Field::Key_range,
428 _ => Field::Other,
429 })
430 }
431 }
432
433 deserializer.deserialize_identifier(Visitor)
434 }
435 }
436
437 struct Visitor;
438
439 impl<'de> serde::de::Visitor<'de> for Visitor {
440 type Value = RangeAllocation;
441
442 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
443 f.write_str(<Self::Value as k8s_openapi::Resource>::KIND)
444 }
445
446 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
447 let mut value_data: Option<k8s_openapi::ByteString> = None;
448 let mut value_metadata: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
449 let mut value_range: Option<String> = None;
450
451 while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
452 match key {
453 Field::Key_api_version => {
454 let value_api_version: String = serde::de::MapAccess::next_value(&mut map)?;
455 if value_api_version != <Self::Value as k8s_openapi::Resource>::API_VERSION {
456 return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_api_version), &<Self::Value as k8s_openapi::Resource>::API_VERSION));
457 }
458 },
459 Field::Key_kind => {
460 let value_kind: String = serde::de::MapAccess::next_value(&mut map)?;
461 if value_kind != <Self::Value as k8s_openapi::Resource>::KIND {
462 return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_kind), &<Self::Value as k8s_openapi::Resource>::KIND));
463 }
464 },
465 Field::Key_data => value_data = Some(serde::de::MapAccess::next_value(&mut map)?),
466 Field::Key_metadata => value_metadata = Some(serde::de::MapAccess::next_value(&mut map)?),
467 Field::Key_range => value_range = Some(serde::de::MapAccess::next_value(&mut map)?),
468 Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
469 }
470 }
471
472 Ok(RangeAllocation {
473 data: value_data.ok_or_else(|| serde::de::Error::missing_field("data"))?,
474 metadata: value_metadata.ok_or_else(|| serde::de::Error::missing_field("metadata"))?,
475 range: value_range.ok_or_else(|| serde::de::Error::missing_field("range"))?,
476 })
477 }
478 }
479
480 deserializer.deserialize_struct(
481 <Self as k8s_openapi::Resource>::KIND,
482 &[
483 "apiVersion",
484 "kind",
485 "data",
486 "metadata",
487 "range",
488 ],
489 Visitor,
490 )
491 }
492}
493
494impl serde::Serialize for RangeAllocation {
495 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
496 let mut state = serializer.serialize_struct(
497 <Self as k8s_openapi::Resource>::KIND,
498 5,
499 )?;
500 serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as k8s_openapi::Resource>::API_VERSION)?;
501 serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as k8s_openapi::Resource>::KIND)?;
502 serde::ser::SerializeStruct::serialize_field(&mut state, "data", &self.data)?;
503 serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
504 serde::ser::SerializeStruct::serialize_field(&mut state, "range", &self.range)?;
505 serde::ser::SerializeStruct::end(state)
506 }
507}