openshift_openapi/v4_5/api/template/v1/
template_instance.rs

1// Generated from definition com.github.openshift.api.template.v1.TemplateInstance
2
3/// TemplateInstance requests and records the instantiation of a Template. TemplateInstance is part of an experimental API.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct TemplateInstance {
6    /// Standard object metadata.
7    pub metadata: k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta,
8
9    /// spec describes the desired state of this TemplateInstance.
10    pub spec: crate::api::template::v1::TemplateInstanceSpec,
11
12    /// status describes the current state of this TemplateInstance.
13    pub status: crate::api::template::v1::TemplateInstanceStatus,
14}
15
16// Begin template.openshift.io/v1/TemplateInstance
17
18// Generated from operation createTemplateOpenshiftIoV1NamespacedTemplateInstance
19
20impl TemplateInstance {
21    /// create a TemplateInstance
22    ///
23    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::CreateResponse`]`<Self>>` constructor, or [`k8s_openapi::CreateResponse`]`<Self>` directly, to parse the HTTP response.
24    ///
25    /// # Arguments
26    ///
27    /// * `namespace`
28    ///
29    ///     object name and auth scope, such as for teams and projects
30    ///
31    /// * `body`
32    ///
33    /// * `optional`
34    ///
35    ///     Optional parameters. Use `Default::default()` to not pass any.
36    #[cfg(feature = "api")]
37    pub fn create_namespaced_template_instance(
38        namespace: &str,
39        body: &crate::api::template::v1::TemplateInstance,
40        optional: k8s_openapi::CreateOptional<'_>,
41    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::CreateResponse<Self>>), k8s_openapi::RequestError> {
42        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances?",
43            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
44        );
45        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
46        optional.__serialize(&mut __query_pairs);
47        let __url = __query_pairs.finish();
48
49        let __request = http::Request::post(__url);
50        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
51        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
52        match __request.body(__body) {
53            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
54            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
55        }
56    }
57}
58
59// Generated from operation deleteTemplateOpenshiftIoV1CollectionNamespacedTemplateInstance
60
61impl TemplateInstance {
62    /// delete collection of TemplateInstance
63    ///
64    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::DeleteResponse`]`<`[`k8s_openapi::List`]`<Self>>>` constructor, or [`k8s_openapi::DeleteResponse`]`<`[`k8s_openapi::List`]`<Self>>` directly, to parse the HTTP response.
65    ///
66    /// # Arguments
67    ///
68    /// * `namespace`
69    ///
70    ///     object name and auth scope, such as for teams and projects
71    ///
72    /// * `delete_optional`
73    ///
74    ///     Delete options. Use `Default::default()` to not pass any.
75    ///
76    /// * `list_optional`
77    ///
78    ///     List options. Use `Default::default()` to not pass any.
79    #[cfg(feature = "api")]
80    pub fn delete_collection_namespaced_template_instance(
81        namespace: &str,
82        delete_optional: k8s_openapi::DeleteOptional<'_>,
83        list_optional: k8s_openapi::ListOptional<'_>,
84    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<k8s_openapi::List<Self>>>), k8s_openapi::RequestError> {
85        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances?",
86            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
87        );
88        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
89        list_optional.__serialize(&mut __query_pairs);
90        let __url = __query_pairs.finish();
91
92        let __request = http::Request::delete(__url);
93        let __body = serde_json::to_vec(&delete_optional).map_err(k8s_openapi::RequestError::Json)?;
94        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
95        match __request.body(__body) {
96            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
97            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
98        }
99    }
100}
101
102// Generated from operation deleteTemplateOpenshiftIoV1NamespacedTemplateInstance
103
104impl TemplateInstance {
105    /// delete a TemplateInstance
106    ///
107    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::DeleteResponse`]`<Self>>` constructor, or [`k8s_openapi::DeleteResponse`]`<Self>` directly, to parse the HTTP response.
108    ///
109    /// # Arguments
110    ///
111    /// * `name`
112    ///
113    ///     name of the TemplateInstance
114    ///
115    /// * `namespace`
116    ///
117    ///     object name and auth scope, such as for teams and projects
118    ///
119    /// * `optional`
120    ///
121    ///     Optional parameters. Use `Default::default()` to not pass any.
122    #[cfg(feature = "api")]
123    pub fn delete_namespaced_template_instance(
124        name: &str,
125        namespace: &str,
126        optional: k8s_openapi::DeleteOptional<'_>,
127    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::DeleteResponse<Self>>), k8s_openapi::RequestError> {
128        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances/{name}",
129            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
130            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
131        );
132
133        let __request = http::Request::delete(__url);
134        let __body = serde_json::to_vec(&optional).map_err(k8s_openapi::RequestError::Json)?;
135        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
136        match __request.body(__body) {
137            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
138            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
139        }
140    }
141}
142
143// Generated from operation listTemplateOpenshiftIoV1NamespacedTemplateInstance
144
145impl TemplateInstance {
146    /// list or watch objects of kind TemplateInstance
147    ///
148    /// This operation only supports listing all items of this type.
149    ///
150    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ListResponse`]`<Self>>` constructor, or [`k8s_openapi::ListResponse`]`<Self>` directly, to parse the HTTP response.
151    ///
152    /// # Arguments
153    ///
154    /// * `namespace`
155    ///
156    ///     object name and auth scope, such as for teams and projects
157    ///
158    /// * `optional`
159    ///
160    ///     Optional parameters. Use `Default::default()` to not pass any.
161    #[cfg(feature = "api")]
162    pub fn list_namespaced_template_instance(
163        namespace: &str,
164        optional: k8s_openapi::ListOptional<'_>,
165    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ListResponse<Self>>), k8s_openapi::RequestError> {
166        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances?",
167            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
168        );
169        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
170        optional.__serialize(&mut __query_pairs);
171        let __url = __query_pairs.finish();
172
173        let __request = http::Request::get(__url);
174        let __body = vec![];
175        match __request.body(__body) {
176            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
177            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
178        }
179    }
180}
181
182// Generated from operation listTemplateOpenshiftIoV1TemplateInstanceForAllNamespaces
183
184impl TemplateInstance {
185    /// list or watch objects of kind TemplateInstance
186    ///
187    /// This operation only supports listing all items of this type.
188    ///
189    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ListResponse`]`<Self>>` constructor, or [`k8s_openapi::ListResponse`]`<Self>` directly, to parse the HTTP response.
190    ///
191    /// # Arguments
192    ///
193    /// * `optional`
194    ///
195    ///     Optional parameters. Use `Default::default()` to not pass any.
196    #[cfg(feature = "api")]
197    pub fn list_template_instance_for_all_namespaces(
198        optional: k8s_openapi::ListOptional<'_>,
199    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ListResponse<Self>>), k8s_openapi::RequestError> {
200        let __url = "/apis/template.openshift.io/v1/templateinstances?".to_owned();
201        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
202        optional.__serialize(&mut __query_pairs);
203        let __url = __query_pairs.finish();
204
205        let __request = http::Request::get(__url);
206        let __body = vec![];
207        match __request.body(__body) {
208            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
209            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
210        }
211    }
212}
213
214// Generated from operation patchTemplateOpenshiftIoV1NamespacedTemplateInstance
215
216impl TemplateInstance {
217    /// partially update the specified TemplateInstance
218    ///
219    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::PatchResponse`]`<Self>>` constructor, or [`k8s_openapi::PatchResponse`]`<Self>` directly, to parse the HTTP response.
220    ///
221    /// # Arguments
222    ///
223    /// * `name`
224    ///
225    ///     name of the TemplateInstance
226    ///
227    /// * `namespace`
228    ///
229    ///     object name and auth scope, such as for teams and projects
230    ///
231    /// * `body`
232    ///
233    /// * `optional`
234    ///
235    ///     Optional parameters. Use `Default::default()` to not pass any.
236    #[cfg(feature = "api")]
237    pub fn patch_namespaced_template_instance(
238        name: &str,
239        namespace: &str,
240        body: &k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch,
241        optional: k8s_openapi::PatchOptional<'_>,
242    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::PatchResponse<Self>>), k8s_openapi::RequestError> {
243        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances/{name}?",
244            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
245            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
246        );
247        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
248        optional.__serialize(&mut __query_pairs);
249        let __url = __query_pairs.finish();
250
251        let __request = http::Request::patch(__url);
252        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
253        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static(match body {
254            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Json(_) => "application/json-patch+json",
255            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Merge(_) => "application/merge-patch+json",
256            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::StrategicMerge(_) => "application/strategic-merge-patch+json",
257        }));
258        match __request.body(__body) {
259            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
260            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
261        }
262    }
263}
264
265// Generated from operation patchTemplateOpenshiftIoV1NamespacedTemplateInstanceStatus
266
267impl TemplateInstance {
268    /// partially update status of the specified TemplateInstance
269    ///
270    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::PatchResponse`]`<Self>>` constructor, or [`k8s_openapi::PatchResponse`]`<Self>` directly, to parse the HTTP response.
271    ///
272    /// # Arguments
273    ///
274    /// * `name`
275    ///
276    ///     name of the TemplateInstance
277    ///
278    /// * `namespace`
279    ///
280    ///     object name and auth scope, such as for teams and projects
281    ///
282    /// * `body`
283    ///
284    /// * `optional`
285    ///
286    ///     Optional parameters. Use `Default::default()` to not pass any.
287    #[cfg(feature = "api")]
288    pub fn patch_namespaced_template_instance_status(
289        name: &str,
290        namespace: &str,
291        body: &k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch,
292        optional: k8s_openapi::PatchOptional<'_>,
293    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::PatchResponse<Self>>), k8s_openapi::RequestError> {
294        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances/{name}/status?",
295            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
296            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
297        );
298        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
299        optional.__serialize(&mut __query_pairs);
300        let __url = __query_pairs.finish();
301
302        let __request = http::Request::patch(__url);
303        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
304        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static(match body {
305            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Json(_) => "application/json-patch+json",
306            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::Merge(_) => "application/merge-patch+json",
307            k8s_openapi::apimachinery::pkg::apis::meta::v1::Patch::StrategicMerge(_) => "application/strategic-merge-patch+json",
308        }));
309        match __request.body(__body) {
310            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
311            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
312        }
313    }
314}
315
316// Generated from operation readTemplateOpenshiftIoV1NamespacedTemplateInstance
317
318impl TemplateInstance {
319    /// read the specified TemplateInstance
320    ///
321    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`ReadNamespacedTemplateInstanceResponse`]`>` constructor, or [`ReadNamespacedTemplateInstanceResponse`] directly, to parse the HTTP response.
322    ///
323    /// # Arguments
324    ///
325    /// * `name`
326    ///
327    ///     name of the TemplateInstance
328    ///
329    /// * `namespace`
330    ///
331    ///     object name and auth scope, such as for teams and projects
332    ///
333    /// * `optional`
334    ///
335    ///     Optional parameters. Use `Default::default()` to not pass any.
336    #[cfg(feature = "api")]
337    pub fn read_namespaced_template_instance(
338        name: &str,
339        namespace: &str,
340        optional: ReadNamespacedTemplateInstanceOptional<'_>,
341    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<ReadNamespacedTemplateInstanceResponse>), k8s_openapi::RequestError> {
342        let ReadNamespacedTemplateInstanceOptional {
343            exact,
344            export,
345            pretty,
346        } = optional;
347        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances/{name}?",
348            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
349            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
350        );
351        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
352        if let Some(exact) = exact {
353            __query_pairs.append_pair("exact", &exact.to_string());
354        }
355        if let Some(export) = export {
356            __query_pairs.append_pair("export", &export.to_string());
357        }
358        if let Some(pretty) = pretty {
359            __query_pairs.append_pair("pretty", pretty);
360        }
361        let __url = __query_pairs.finish();
362
363        let __request = http::Request::get(__url);
364        let __body = vec![];
365        match __request.body(__body) {
366            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
367            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
368        }
369    }
370}
371
372/// Optional parameters of [`TemplateInstance::read_namespaced_template_instance`]
373#[cfg(feature = "api")]
374#[derive(Clone, Copy, Debug, Default)]
375pub struct ReadNamespacedTemplateInstanceOptional<'a> {
376    /// Should the export be exact.  Exact export maintains cluster-specific fields like 'Namespace'.
377    pub exact: Option<bool>,
378    /// Should this value be exported.  Export strips fields that a user can not specify.
379    pub export: Option<bool>,
380    /// If 'true', then the output is pretty printed.
381    pub pretty: Option<&'a str>,
382}
383
384/// Use `<ReadNamespacedTemplateInstanceResponse as Response>::try_from_parts` to parse the HTTP response body of [`TemplateInstance::read_namespaced_template_instance`]
385#[cfg(feature = "api")]
386#[derive(Debug)]
387pub enum ReadNamespacedTemplateInstanceResponse {
388    Ok(crate::api::template::v1::TemplateInstance),
389    Other(Result<Option<serde_json::Value>, serde_json::Error>),
390}
391
392#[cfg(feature = "api")]
393impl k8s_openapi::Response for ReadNamespacedTemplateInstanceResponse {
394    fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), k8s_openapi::ResponseError> {
395        match status_code {
396            http::StatusCode::OK => {
397                let result = match serde_json::from_slice(buf) {
398                    Ok(value) => value,
399                    Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
400                    Err(err) => return Err(k8s_openapi::ResponseError::Json(err)),
401                };
402                Ok((ReadNamespacedTemplateInstanceResponse::Ok(result), buf.len()))
403            },
404            _ => {
405                let (result, read) =
406                    if buf.is_empty() {
407                        (Ok(None), 0)
408                    }
409                    else {
410                        match serde_json::from_slice(buf) {
411                            Ok(value) => (Ok(Some(value)), buf.len()),
412                            Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
413                            Err(err) => (Err(err), 0),
414                        }
415                    };
416                Ok((ReadNamespacedTemplateInstanceResponse::Other(result), read))
417            },
418        }
419    }
420}
421
422// Generated from operation readTemplateOpenshiftIoV1NamespacedTemplateInstanceStatus
423
424impl TemplateInstance {
425    /// read status of the specified TemplateInstance
426    ///
427    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`ReadNamespacedTemplateInstanceStatusResponse`]`>` constructor, or [`ReadNamespacedTemplateInstanceStatusResponse`] directly, to parse the HTTP response.
428    ///
429    /// # Arguments
430    ///
431    /// * `name`
432    ///
433    ///     name of the TemplateInstance
434    ///
435    /// * `namespace`
436    ///
437    ///     object name and auth scope, such as for teams and projects
438    ///
439    /// * `optional`
440    ///
441    ///     Optional parameters. Use `Default::default()` to not pass any.
442    #[cfg(feature = "api")]
443    pub fn read_namespaced_template_instance_status(
444        name: &str,
445        namespace: &str,
446        optional: ReadNamespacedTemplateInstanceStatusOptional<'_>,
447    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<ReadNamespacedTemplateInstanceStatusResponse>), k8s_openapi::RequestError> {
448        let ReadNamespacedTemplateInstanceStatusOptional {
449            pretty,
450        } = optional;
451        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances/{name}/status?",
452            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
453            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
454        );
455        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
456        if let Some(pretty) = pretty {
457            __query_pairs.append_pair("pretty", pretty);
458        }
459        let __url = __query_pairs.finish();
460
461        let __request = http::Request::get(__url);
462        let __body = vec![];
463        match __request.body(__body) {
464            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
465            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
466        }
467    }
468}
469
470/// Optional parameters of [`TemplateInstance::read_namespaced_template_instance_status`]
471#[cfg(feature = "api")]
472#[derive(Clone, Copy, Debug, Default)]
473pub struct ReadNamespacedTemplateInstanceStatusOptional<'a> {
474    /// If 'true', then the output is pretty printed.
475    pub pretty: Option<&'a str>,
476}
477
478/// Use `<ReadNamespacedTemplateInstanceStatusResponse as Response>::try_from_parts` to parse the HTTP response body of [`TemplateInstance::read_namespaced_template_instance_status`]
479#[cfg(feature = "api")]
480#[derive(Debug)]
481pub enum ReadNamespacedTemplateInstanceStatusResponse {
482    Ok(crate::api::template::v1::TemplateInstance),
483    Other(Result<Option<serde_json::Value>, serde_json::Error>),
484}
485
486#[cfg(feature = "api")]
487impl k8s_openapi::Response for ReadNamespacedTemplateInstanceStatusResponse {
488    fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), k8s_openapi::ResponseError> {
489        match status_code {
490            http::StatusCode::OK => {
491                let result = match serde_json::from_slice(buf) {
492                    Ok(value) => value,
493                    Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
494                    Err(err) => return Err(k8s_openapi::ResponseError::Json(err)),
495                };
496                Ok((ReadNamespacedTemplateInstanceStatusResponse::Ok(result), buf.len()))
497            },
498            _ => {
499                let (result, read) =
500                    if buf.is_empty() {
501                        (Ok(None), 0)
502                    }
503                    else {
504                        match serde_json::from_slice(buf) {
505                            Ok(value) => (Ok(Some(value)), buf.len()),
506                            Err(ref err) if err.is_eof() => return Err(k8s_openapi::ResponseError::NeedMoreData),
507                            Err(err) => (Err(err), 0),
508                        }
509                    };
510                Ok((ReadNamespacedTemplateInstanceStatusResponse::Other(result), read))
511            },
512        }
513    }
514}
515
516// Generated from operation replaceTemplateOpenshiftIoV1NamespacedTemplateInstance
517
518impl TemplateInstance {
519    /// replace the specified TemplateInstance
520    ///
521    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ReplaceResponse`]`<Self>>` constructor, or [`k8s_openapi::ReplaceResponse`]`<Self>` directly, to parse the HTTP response.
522    ///
523    /// # Arguments
524    ///
525    /// * `name`
526    ///
527    ///     name of the TemplateInstance
528    ///
529    /// * `namespace`
530    ///
531    ///     object name and auth scope, such as for teams and projects
532    ///
533    /// * `body`
534    ///
535    /// * `optional`
536    ///
537    ///     Optional parameters. Use `Default::default()` to not pass any.
538    #[cfg(feature = "api")]
539    pub fn replace_namespaced_template_instance(
540        name: &str,
541        namespace: &str,
542        body: &crate::api::template::v1::TemplateInstance,
543        optional: k8s_openapi::ReplaceOptional<'_>,
544    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ReplaceResponse<Self>>), k8s_openapi::RequestError> {
545        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances/{name}?",
546            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
547            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
548        );
549        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
550        optional.__serialize(&mut __query_pairs);
551        let __url = __query_pairs.finish();
552
553        let __request = http::Request::put(__url);
554        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
555        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
556        match __request.body(__body) {
557            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
558            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
559        }
560    }
561}
562
563// Generated from operation replaceTemplateOpenshiftIoV1NamespacedTemplateInstanceStatus
564
565impl TemplateInstance {
566    /// replace status of the specified TemplateInstance
567    ///
568    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::ReplaceResponse`]`<Self>>` constructor, or [`k8s_openapi::ReplaceResponse`]`<Self>` directly, to parse the HTTP response.
569    ///
570    /// # Arguments
571    ///
572    /// * `name`
573    ///
574    ///     name of the TemplateInstance
575    ///
576    /// * `namespace`
577    ///
578    ///     object name and auth scope, such as for teams and projects
579    ///
580    /// * `body`
581    ///
582    /// * `optional`
583    ///
584    ///     Optional parameters. Use `Default::default()` to not pass any.
585    #[cfg(feature = "api")]
586    pub fn replace_namespaced_template_instance_status(
587        name: &str,
588        namespace: &str,
589        body: &crate::api::template::v1::TemplateInstance,
590        optional: k8s_openapi::ReplaceOptional<'_>,
591    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::ReplaceResponse<Self>>), k8s_openapi::RequestError> {
592        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances/{name}/status?",
593            name = k8s_openapi::percent_encoding::percent_encode(name.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
594            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
595        );
596        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
597        optional.__serialize(&mut __query_pairs);
598        let __url = __query_pairs.finish();
599
600        let __request = http::Request::put(__url);
601        let __body = serde_json::to_vec(body).map_err(k8s_openapi::RequestError::Json)?;
602        let __request = __request.header(http::header::CONTENT_TYPE, http::header::HeaderValue::from_static("application/json"));
603        match __request.body(__body) {
604            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
605            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
606        }
607    }
608}
609
610// Generated from operation watchTemplateOpenshiftIoV1NamespacedTemplateInstance
611
612impl TemplateInstance {
613    /// list or watch objects of kind TemplateInstance
614    ///
615    /// This operation only supports watching one item, or a list of items, of this type for changes.
616    ///
617    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::WatchResponse`]`<Self>>` constructor, or [`k8s_openapi::WatchResponse`]`<Self>` directly, to parse the HTTP response.
618    ///
619    /// # Arguments
620    ///
621    /// * `namespace`
622    ///
623    ///     object name and auth scope, such as for teams and projects
624    ///
625    /// * `optional`
626    ///
627    ///     Optional parameters. Use `Default::default()` to not pass any.
628    #[cfg(feature = "api")]
629    pub fn watch_namespaced_template_instance(
630        namespace: &str,
631        optional: k8s_openapi::WatchOptional<'_>,
632    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::WatchResponse<Self>>), k8s_openapi::RequestError> {
633        let __url = format!("/apis/template.openshift.io/v1/namespaces/{namespace}/templateinstances?",
634            namespace = k8s_openapi::percent_encoding::percent_encode(namespace.as_bytes(), k8s_openapi::percent_encoding2::PATH_SEGMENT_ENCODE_SET),
635        );
636        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
637        optional.__serialize(&mut __query_pairs);
638        let __url = __query_pairs.finish();
639
640        let __request = http::Request::get(__url);
641        let __body = vec![];
642        match __request.body(__body) {
643            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
644            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
645        }
646    }
647}
648
649// Generated from operation watchTemplateOpenshiftIoV1TemplateInstanceForAllNamespaces
650
651impl TemplateInstance {
652    /// list or watch objects of kind TemplateInstance
653    ///
654    /// This operation only supports watching one item, or a list of items, of this type for changes.
655    ///
656    /// Use the returned [`k8s_openapi::ResponseBody`]`<`[`k8s_openapi::WatchResponse`]`<Self>>` constructor, or [`k8s_openapi::WatchResponse`]`<Self>` directly, to parse the HTTP response.
657    ///
658    /// # Arguments
659    ///
660    /// * `optional`
661    ///
662    ///     Optional parameters. Use `Default::default()` to not pass any.
663    #[cfg(feature = "api")]
664    pub fn watch_template_instance_for_all_namespaces(
665        optional: k8s_openapi::WatchOptional<'_>,
666    ) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> k8s_openapi::ResponseBody<k8s_openapi::WatchResponse<Self>>), k8s_openapi::RequestError> {
667        let __url = "/apis/template.openshift.io/v1/templateinstances?".to_owned();
668        let mut __query_pairs = k8s_openapi::url::form_urlencoded::Serializer::new(__url);
669        optional.__serialize(&mut __query_pairs);
670        let __url = __query_pairs.finish();
671
672        let __request = http::Request::get(__url);
673        let __body = vec![];
674        match __request.body(__body) {
675            Ok(request) => Ok((request, k8s_openapi::ResponseBody::new)),
676            Err(err) => Err(k8s_openapi::RequestError::Http(err)),
677        }
678    }
679}
680
681// End template.openshift.io/v1/TemplateInstance
682
683impl k8s_openapi::Resource for TemplateInstance {
684    const API_VERSION: &'static str = "template.openshift.io/v1";
685    const GROUP: &'static str = "template.openshift.io";
686    const KIND: &'static str = "TemplateInstance";
687    const VERSION: &'static str = "v1";
688}
689
690impl k8s_openapi::ListableResource for TemplateInstance {
691    const LIST_KIND: &'static str = concat!("TemplateInstance", "List");
692}
693
694impl k8s_openapi::Metadata for TemplateInstance {
695    type Ty = k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
696
697    fn metadata(&self) -> &<Self as k8s_openapi::Metadata>::Ty {
698        &self.metadata
699    }
700
701    fn metadata_mut(&mut self) -> &mut<Self as k8s_openapi::Metadata>::Ty {
702        &mut self.metadata
703    }
704}
705
706impl<'de> serde::Deserialize<'de> for TemplateInstance {
707    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
708        #[allow(non_camel_case_types)]
709        enum Field {
710            Key_api_version,
711            Key_kind,
712            Key_metadata,
713            Key_spec,
714            Key_status,
715            Other,
716        }
717
718        impl<'de> serde::Deserialize<'de> for Field {
719            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
720                struct Visitor;
721
722                impl<'de> serde::de::Visitor<'de> for Visitor {
723                    type Value = Field;
724
725                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
726                        f.write_str("field identifier")
727                    }
728
729                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
730                        Ok(match v {
731                            "apiVersion" => Field::Key_api_version,
732                            "kind" => Field::Key_kind,
733                            "metadata" => Field::Key_metadata,
734                            "spec" => Field::Key_spec,
735                            "status" => Field::Key_status,
736                            _ => Field::Other,
737                        })
738                    }
739                }
740
741                deserializer.deserialize_identifier(Visitor)
742            }
743        }
744
745        struct Visitor;
746
747        impl<'de> serde::de::Visitor<'de> for Visitor {
748            type Value = TemplateInstance;
749
750            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
751                f.write_str(<Self::Value as k8s_openapi::Resource>::KIND)
752            }
753
754            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
755                let mut value_metadata: Option<k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
756                let mut value_spec: Option<crate::api::template::v1::TemplateInstanceSpec> = None;
757                let mut value_status: Option<crate::api::template::v1::TemplateInstanceStatus> = None;
758
759                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
760                    match key {
761                        Field::Key_api_version => {
762                            let value_api_version: String = serde::de::MapAccess::next_value(&mut map)?;
763                            if value_api_version != <Self::Value as k8s_openapi::Resource>::API_VERSION {
764                                return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_api_version), &<Self::Value as k8s_openapi::Resource>::API_VERSION));
765                            }
766                        },
767                        Field::Key_kind => {
768                            let value_kind: String = serde::de::MapAccess::next_value(&mut map)?;
769                            if value_kind != <Self::Value as k8s_openapi::Resource>::KIND {
770                                return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_kind), &<Self::Value as k8s_openapi::Resource>::KIND));
771                            }
772                        },
773                        Field::Key_metadata => value_metadata = Some(serde::de::MapAccess::next_value(&mut map)?),
774                        Field::Key_spec => value_spec = Some(serde::de::MapAccess::next_value(&mut map)?),
775                        Field::Key_status => value_status = Some(serde::de::MapAccess::next_value(&mut map)?),
776                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
777                    }
778                }
779
780                Ok(TemplateInstance {
781                    metadata: value_metadata.ok_or_else(|| serde::de::Error::missing_field("metadata"))?,
782                    spec: value_spec.ok_or_else(|| serde::de::Error::missing_field("spec"))?,
783                    status: value_status.ok_or_else(|| serde::de::Error::missing_field("status"))?,
784                })
785            }
786        }
787
788        deserializer.deserialize_struct(
789            <Self as k8s_openapi::Resource>::KIND,
790            &[
791                "apiVersion",
792                "kind",
793                "metadata",
794                "spec",
795                "status",
796            ],
797            Visitor,
798        )
799    }
800}
801
802impl serde::Serialize for TemplateInstance {
803    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
804        let mut state = serializer.serialize_struct(
805            <Self as k8s_openapi::Resource>::KIND,
806            5,
807        )?;
808        serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as k8s_openapi::Resource>::API_VERSION)?;
809        serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as k8s_openapi::Resource>::KIND)?;
810        serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
811        serde::ser::SerializeStruct::serialize_field(&mut state, "spec", &self.spec)?;
812        serde::ser::SerializeStruct::serialize_field(&mut state, "status", &self.status)?;
813        serde::ser::SerializeStruct::end(state)
814    }
815}