#[derive(Clone, Debug, Default, PartialEq)]
pub struct Pod {
pub metadata: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::ObjectMeta>,
pub spec: Option<crate::v1_13::api::core::v1::PodSpec>,
pub status: Option<crate::v1_13::api::core::v1::PodStatus>,
}
impl Pod {
pub fn connect_delete_namespaced_pod_proxy(
name: &str,
namespace: &str,
optional: ConnectDeleteNamespacedPodProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectDeleteNamespacedPodProxyResponse>), crate::RequestError> {
let ConnectDeleteNamespacedPodProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path) = path {
__query_pairs.append_pair("path", path);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::delete(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectDeleteNamespacedPodProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectDeleteNamespacedPodProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectDeleteNamespacedPodProxyResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectDeleteNamespacedPodProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectDeleteNamespacedPodProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectDeleteNamespacedPodProxyResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_delete_namespaced_pod_proxy_with_path(
name: &str,
namespace: &str,
path: &str,
optional: ConnectDeleteNamespacedPodProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectDeleteNamespacedPodProxyWithPathResponse>), crate::RequestError> {
let ConnectDeleteNamespacedPodProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}?", name = name, namespace = namespace, path = path);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path_) = path_ {
__query_pairs.append_pair("path", path_);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::delete(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectDeleteNamespacedPodProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectDeleteNamespacedPodProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectDeleteNamespacedPodProxyWithPathResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectDeleteNamespacedPodProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectDeleteNamespacedPodProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectDeleteNamespacedPodProxyWithPathResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_get_namespaced_pod_attach(
name: &str,
namespace: &str,
optional: ConnectGetNamespacedPodAttachOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectGetNamespacedPodAttachResponse>), crate::RequestError> {
let ConnectGetNamespacedPodAttachOptional {
container,
stderr,
stdin,
stdout,
tty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/attach?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(container) = container {
__query_pairs.append_pair("container", container);
}
if let Some(stderr) = stderr {
__query_pairs.append_pair("stderr", &stderr.to_string());
}
if let Some(stdin) = stdin {
__query_pairs.append_pair("stdin", &stdin.to_string());
}
if let Some(stdout) = stdout {
__query_pairs.append_pair("stdout", &stdout.to_string());
}
if let Some(tty) = tty {
__query_pairs.append_pair("tty", &tty.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectGetNamespacedPodAttachOptional<'a> {
pub container: Option<&'a str>,
pub stderr: Option<bool>,
pub stdin: Option<bool>,
pub stdout: Option<bool>,
pub tty: Option<bool>,
}
#[derive(Debug)]
pub enum ConnectGetNamespacedPodAttachResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectGetNamespacedPodAttachResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectGetNamespacedPodAttachResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectGetNamespacedPodAttachResponse::Unauthorized, 0)),
_ => Ok((ConnectGetNamespacedPodAttachResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_get_namespaced_pod_exec(
name: &str,
namespace: &str,
optional: ConnectGetNamespacedPodExecOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectGetNamespacedPodExecResponse>), crate::RequestError> {
let ConnectGetNamespacedPodExecOptional {
command,
container,
stderr,
stdin,
stdout,
tty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/exec?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(command) = command {
__query_pairs.append_pair("command", command);
}
if let Some(container) = container {
__query_pairs.append_pair("container", container);
}
if let Some(stderr) = stderr {
__query_pairs.append_pair("stderr", &stderr.to_string());
}
if let Some(stdin) = stdin {
__query_pairs.append_pair("stdin", &stdin.to_string());
}
if let Some(stdout) = stdout {
__query_pairs.append_pair("stdout", &stdout.to_string());
}
if let Some(tty) = tty {
__query_pairs.append_pair("tty", &tty.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectGetNamespacedPodExecOptional<'a> {
pub command: Option<&'a str>,
pub container: Option<&'a str>,
pub stderr: Option<bool>,
pub stdin: Option<bool>,
pub stdout: Option<bool>,
pub tty: Option<bool>,
}
#[derive(Debug)]
pub enum ConnectGetNamespacedPodExecResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectGetNamespacedPodExecResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectGetNamespacedPodExecResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectGetNamespacedPodExecResponse::Unauthorized, 0)),
_ => Ok((ConnectGetNamespacedPodExecResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_get_namespaced_pod_portforward(
name: &str,
namespace: &str,
optional: ConnectGetNamespacedPodPortforwardOptional,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectGetNamespacedPodPortforwardResponse>), crate::RequestError> {
let ConnectGetNamespacedPodPortforwardOptional {
ports,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/portforward?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(ports) = ports {
__query_pairs.append_pair("ports", &ports.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectGetNamespacedPodPortforwardOptional {
pub ports: Option<i64>,
}
#[derive(Debug)]
pub enum ConnectGetNamespacedPodPortforwardResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectGetNamespacedPodPortforwardResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectGetNamespacedPodPortforwardResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectGetNamespacedPodPortforwardResponse::Unauthorized, 0)),
_ => Ok((ConnectGetNamespacedPodPortforwardResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_get_namespaced_pod_proxy(
name: &str,
namespace: &str,
optional: ConnectGetNamespacedPodProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectGetNamespacedPodProxyResponse>), crate::RequestError> {
let ConnectGetNamespacedPodProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path) = path {
__query_pairs.append_pair("path", path);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectGetNamespacedPodProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectGetNamespacedPodProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectGetNamespacedPodProxyResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectGetNamespacedPodProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectGetNamespacedPodProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectGetNamespacedPodProxyResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_get_namespaced_pod_proxy_with_path(
name: &str,
namespace: &str,
path: &str,
optional: ConnectGetNamespacedPodProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectGetNamespacedPodProxyWithPathResponse>), crate::RequestError> {
let ConnectGetNamespacedPodProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}?", name = name, namespace = namespace, path = path);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path_) = path_ {
__query_pairs.append_pair("path", path_);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectGetNamespacedPodProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectGetNamespacedPodProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectGetNamespacedPodProxyWithPathResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectGetNamespacedPodProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectGetNamespacedPodProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectGetNamespacedPodProxyWithPathResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_patch_namespaced_pod_proxy(
name: &str,
namespace: &str,
optional: ConnectPatchNamespacedPodProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPatchNamespacedPodProxyResponse>), crate::RequestError> {
let ConnectPatchNamespacedPodProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path) = path {
__query_pairs.append_pair("path", path);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::patch(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPatchNamespacedPodProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPatchNamespacedPodProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPatchNamespacedPodProxyResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPatchNamespacedPodProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPatchNamespacedPodProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectPatchNamespacedPodProxyResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_patch_namespaced_pod_proxy_with_path(
name: &str,
namespace: &str,
path: &str,
optional: ConnectPatchNamespacedPodProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPatchNamespacedPodProxyWithPathResponse>), crate::RequestError> {
let ConnectPatchNamespacedPodProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}?", name = name, namespace = namespace, path = path);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path_) = path_ {
__query_pairs.append_pair("path", path_);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::patch(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPatchNamespacedPodProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPatchNamespacedPodProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPatchNamespacedPodProxyWithPathResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPatchNamespacedPodProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPatchNamespacedPodProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectPatchNamespacedPodProxyWithPathResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_post_namespaced_pod_attach(
name: &str,
namespace: &str,
optional: ConnectPostNamespacedPodAttachOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPostNamespacedPodAttachResponse>), crate::RequestError> {
let ConnectPostNamespacedPodAttachOptional {
container,
stderr,
stdin,
stdout,
tty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/attach?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(container) = container {
__query_pairs.append_pair("container", container);
}
if let Some(stderr) = stderr {
__query_pairs.append_pair("stderr", &stderr.to_string());
}
if let Some(stdin) = stdin {
__query_pairs.append_pair("stdin", &stdin.to_string());
}
if let Some(stdout) = stdout {
__query_pairs.append_pair("stdout", &stdout.to_string());
}
if let Some(tty) = tty {
__query_pairs.append_pair("tty", &tty.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::post(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPostNamespacedPodAttachOptional<'a> {
pub container: Option<&'a str>,
pub stderr: Option<bool>,
pub stdin: Option<bool>,
pub stdout: Option<bool>,
pub tty: Option<bool>,
}
#[derive(Debug)]
pub enum ConnectPostNamespacedPodAttachResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPostNamespacedPodAttachResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPostNamespacedPodAttachResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPostNamespacedPodAttachResponse::Unauthorized, 0)),
_ => Ok((ConnectPostNamespacedPodAttachResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_post_namespaced_pod_exec(
name: &str,
namespace: &str,
optional: ConnectPostNamespacedPodExecOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPostNamespacedPodExecResponse>), crate::RequestError> {
let ConnectPostNamespacedPodExecOptional {
command,
container,
stderr,
stdin,
stdout,
tty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/exec?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(command) = command {
__query_pairs.append_pair("command", command);
}
if let Some(container) = container {
__query_pairs.append_pair("container", container);
}
if let Some(stderr) = stderr {
__query_pairs.append_pair("stderr", &stderr.to_string());
}
if let Some(stdin) = stdin {
__query_pairs.append_pair("stdin", &stdin.to_string());
}
if let Some(stdout) = stdout {
__query_pairs.append_pair("stdout", &stdout.to_string());
}
if let Some(tty) = tty {
__query_pairs.append_pair("tty", &tty.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::post(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPostNamespacedPodExecOptional<'a> {
pub command: Option<&'a str>,
pub container: Option<&'a str>,
pub stderr: Option<bool>,
pub stdin: Option<bool>,
pub stdout: Option<bool>,
pub tty: Option<bool>,
}
#[derive(Debug)]
pub enum ConnectPostNamespacedPodExecResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPostNamespacedPodExecResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPostNamespacedPodExecResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPostNamespacedPodExecResponse::Unauthorized, 0)),
_ => Ok((ConnectPostNamespacedPodExecResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_post_namespaced_pod_portforward(
name: &str,
namespace: &str,
optional: ConnectPostNamespacedPodPortforwardOptional,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPostNamespacedPodPortforwardResponse>), crate::RequestError> {
let ConnectPostNamespacedPodPortforwardOptional {
ports,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/portforward?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(ports) = ports {
__query_pairs.append_pair("ports", &ports.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::post(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPostNamespacedPodPortforwardOptional {
pub ports: Option<i64>,
}
#[derive(Debug)]
pub enum ConnectPostNamespacedPodPortforwardResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPostNamespacedPodPortforwardResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPostNamespacedPodPortforwardResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPostNamespacedPodPortforwardResponse::Unauthorized, 0)),
_ => Ok((ConnectPostNamespacedPodPortforwardResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_post_namespaced_pod_proxy(
name: &str,
namespace: &str,
optional: ConnectPostNamespacedPodProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPostNamespacedPodProxyResponse>), crate::RequestError> {
let ConnectPostNamespacedPodProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path) = path {
__query_pairs.append_pair("path", path);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::post(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPostNamespacedPodProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPostNamespacedPodProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPostNamespacedPodProxyResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPostNamespacedPodProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPostNamespacedPodProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectPostNamespacedPodProxyResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_post_namespaced_pod_proxy_with_path(
name: &str,
namespace: &str,
path: &str,
optional: ConnectPostNamespacedPodProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPostNamespacedPodProxyWithPathResponse>), crate::RequestError> {
let ConnectPostNamespacedPodProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}?", name = name, namespace = namespace, path = path);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path_) = path_ {
__query_pairs.append_pair("path", path_);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::post(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPostNamespacedPodProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPostNamespacedPodProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPostNamespacedPodProxyWithPathResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPostNamespacedPodProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPostNamespacedPodProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectPostNamespacedPodProxyWithPathResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_put_namespaced_pod_proxy(
name: &str,
namespace: &str,
optional: ConnectPutNamespacedPodProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPutNamespacedPodProxyResponse>), crate::RequestError> {
let ConnectPutNamespacedPodProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path) = path {
__query_pairs.append_pair("path", path);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::put(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPutNamespacedPodProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPutNamespacedPodProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPutNamespacedPodProxyResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPutNamespacedPodProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPutNamespacedPodProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectPutNamespacedPodProxyResponse::Other, 0)),
}
}
}
impl Pod {
pub fn connect_put_namespaced_pod_proxy_with_path(
name: &str,
namespace: &str,
path: &str,
optional: ConnectPutNamespacedPodProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPutNamespacedPodProxyWithPathResponse>), crate::RequestError> {
let ConnectPutNamespacedPodProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}?", name = name, namespace = namespace, path = path);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(path_) = path_ {
__query_pairs.append_pair("path", path_);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::put(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ConnectPutNamespacedPodProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPutNamespacedPodProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPutNamespacedPodProxyWithPathResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ConnectPutNamespacedPodProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPutNamespacedPodProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectPutNamespacedPodProxyWithPathResponse::Other, 0)),
}
}
}
impl Pod {
pub fn create_namespaced_pod(
namespace: &str,
body: &crate::v1_13::api::core::v1::Pod,
optional: CreateNamespacedPodOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<CreateNamespacedPodResponse>), crate::RequestError> {
let CreateNamespacedPodOptional {
dry_run,
include_uninitialized,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods?", namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(dry_run) = dry_run {
__query_pairs.append_pair("dryRun", dry_run);
}
if let Some(include_uninitialized) = include_uninitialized {
__query_pairs.append_pair("includeUninitialized", &include_uninitialized.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::post(__url);
let __body = serde_json::to_vec(&body).map_err(crate::RequestError::Json)?;
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct CreateNamespacedPodOptional<'a> {
pub dry_run: Option<&'a str>,
pub include_uninitialized: Option<bool>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum CreateNamespacedPodResponse {
Ok(crate::v1_13::api::core::v1::Pod),
Created(crate::v1_13::api::core::v1::Pod),
Accepted(crate::v1_13::api::core::v1::Pod),
Unauthorized,
Other,
}
impl crate::Response for CreateNamespacedPodResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((CreateNamespacedPodResponse::Ok(result), buf.len()))
},
http::StatusCode::CREATED => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((CreateNamespacedPodResponse::Created(result), buf.len()))
},
http::StatusCode::ACCEPTED => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((CreateNamespacedPodResponse::Accepted(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((CreateNamespacedPodResponse::Unauthorized, 0)),
_ => Ok((CreateNamespacedPodResponse::Other, 0)),
}
}
}
impl Pod {
pub fn delete_collection_namespaced_pod(
namespace: &str,
optional: DeleteCollectionNamespacedPodOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<DeleteCollectionNamespacedPodResponse>), crate::RequestError> {
let DeleteCollectionNamespacedPodOptional {
continue_,
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
watch,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods?", namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(continue_) = continue_ {
__query_pairs.append_pair("continue", continue_);
}
if let Some(field_selector) = field_selector {
__query_pairs.append_pair("fieldSelector", field_selector);
}
if let Some(include_uninitialized) = include_uninitialized {
__query_pairs.append_pair("includeUninitialized", &include_uninitialized.to_string());
}
if let Some(label_selector) = label_selector {
__query_pairs.append_pair("labelSelector", label_selector);
}
if let Some(limit) = limit {
__query_pairs.append_pair("limit", &limit.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
if let Some(resource_version) = resource_version {
__query_pairs.append_pair("resourceVersion", resource_version);
}
if let Some(timeout_seconds) = timeout_seconds {
__query_pairs.append_pair("timeoutSeconds", &timeout_seconds.to_string());
}
if let Some(watch) = watch {
__query_pairs.append_pair("watch", &watch.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::delete(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct DeleteCollectionNamespacedPodOptional<'a> {
pub continue_: Option<&'a str>,
pub field_selector: Option<&'a str>,
pub include_uninitialized: Option<bool>,
pub label_selector: Option<&'a str>,
pub limit: Option<i64>,
pub pretty: Option<&'a str>,
pub resource_version: Option<&'a str>,
pub timeout_seconds: Option<i64>,
pub watch: Option<bool>,
}
#[derive(Debug)]
pub enum DeleteCollectionNamespacedPodResponse {
OkStatus(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
OkValue(crate::v1_13::api::core::v1::Pod),
Unauthorized,
Other,
}
impl crate::Response for DeleteCollectionNamespacedPodResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result: serde_json::Map<String, serde_json::Value> = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
let is_status = match result.get("kind") {
Some(serde_json::Value::String(s)) if s == "Status" => true,
_ => false,
};
if is_status {
let result = serde::Deserialize::deserialize(serde_json::Value::Object(result));
let result = result.map_err(crate::ResponseError::Json)?;
Ok((DeleteCollectionNamespacedPodResponse::OkStatus(result), buf.len()))
}
else {
let result = serde::Deserialize::deserialize(serde_json::Value::Object(result));
let result = result.map_err(crate::ResponseError::Json)?;
Ok((DeleteCollectionNamespacedPodResponse::OkValue(result), buf.len()))
}
},
http::StatusCode::UNAUTHORIZED => Ok((DeleteCollectionNamespacedPodResponse::Unauthorized, 0)),
_ => Ok((DeleteCollectionNamespacedPodResponse::Other, 0)),
}
}
}
impl Pod {
pub fn delete_namespaced_pod(
name: &str,
namespace: &str,
optional: DeleteNamespacedPodOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<DeleteNamespacedPodResponse>), crate::RequestError> {
let DeleteNamespacedPodOptional {
dry_run,
grace_period_seconds,
orphan_dependents,
pretty,
propagation_policy,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(dry_run) = dry_run {
__query_pairs.append_pair("dryRun", dry_run);
}
if let Some(grace_period_seconds) = grace_period_seconds {
__query_pairs.append_pair("gracePeriodSeconds", &grace_period_seconds.to_string());
}
if let Some(orphan_dependents) = orphan_dependents {
__query_pairs.append_pair("orphanDependents", &orphan_dependents.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
if let Some(propagation_policy) = propagation_policy {
__query_pairs.append_pair("propagationPolicy", propagation_policy);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::delete(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct DeleteNamespacedPodOptional<'a> {
pub dry_run: Option<&'a str>,
pub grace_period_seconds: Option<i64>,
pub orphan_dependents: Option<bool>,
pub pretty: Option<&'a str>,
pub propagation_policy: Option<&'a str>,
}
#[derive(Debug)]
pub enum DeleteNamespacedPodResponse {
OkStatus(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
OkValue(crate::v1_13::api::core::v1::Pod),
Accepted(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
Unauthorized,
Other,
}
impl crate::Response for DeleteNamespacedPodResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result: serde_json::Map<String, serde_json::Value> = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
let is_status = match result.get("kind") {
Some(serde_json::Value::String(s)) if s == "Status" => true,
_ => false,
};
if is_status {
let result = serde::Deserialize::deserialize(serde_json::Value::Object(result));
let result = result.map_err(crate::ResponseError::Json)?;
Ok((DeleteNamespacedPodResponse::OkStatus(result), buf.len()))
}
else {
let result = serde::Deserialize::deserialize(serde_json::Value::Object(result));
let result = result.map_err(crate::ResponseError::Json)?;
Ok((DeleteNamespacedPodResponse::OkValue(result), buf.len()))
}
},
http::StatusCode::ACCEPTED => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((DeleteNamespacedPodResponse::Accepted(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((DeleteNamespacedPodResponse::Unauthorized, 0)),
_ => Ok((DeleteNamespacedPodResponse::Other, 0)),
}
}
}
impl Pod {
pub fn list_namespaced_pod(
namespace: &str,
optional: ListNamespacedPodOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ListNamespacedPodResponse>), crate::RequestError> {
let ListNamespacedPodOptional {
continue_,
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods?", namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(continue_) = continue_ {
__query_pairs.append_pair("continue", continue_);
}
if let Some(field_selector) = field_selector {
__query_pairs.append_pair("fieldSelector", field_selector);
}
if let Some(include_uninitialized) = include_uninitialized {
__query_pairs.append_pair("includeUninitialized", &include_uninitialized.to_string());
}
if let Some(label_selector) = label_selector {
__query_pairs.append_pair("labelSelector", label_selector);
}
if let Some(limit) = limit {
__query_pairs.append_pair("limit", &limit.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
if let Some(resource_version) = resource_version {
__query_pairs.append_pair("resourceVersion", resource_version);
}
if let Some(timeout_seconds) = timeout_seconds {
__query_pairs.append_pair("timeoutSeconds", &timeout_seconds.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ListNamespacedPodOptional<'a> {
pub continue_: Option<&'a str>,
pub field_selector: Option<&'a str>,
pub include_uninitialized: Option<bool>,
pub label_selector: Option<&'a str>,
pub limit: Option<i64>,
pub pretty: Option<&'a str>,
pub resource_version: Option<&'a str>,
pub timeout_seconds: Option<i64>,
}
#[derive(Debug)]
pub enum ListNamespacedPodResponse {
Ok(crate::v1_13::api::core::v1::PodList),
Unauthorized,
Other,
}
impl crate::Response for ListNamespacedPodResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((ListNamespacedPodResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ListNamespacedPodResponse::Unauthorized, 0)),
_ => Ok((ListNamespacedPodResponse::Other, 0)),
}
}
}
impl Pod {
pub fn list_pod_for_all_namespaces(
optional: ListPodForAllNamespacesOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ListPodForAllNamespacesResponse>), crate::RequestError> {
let ListPodForAllNamespacesOptional {
continue_,
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = "/api/v1/pods?".to_string();
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(continue_) = continue_ {
__query_pairs.append_pair("continue", continue_);
}
if let Some(field_selector) = field_selector {
__query_pairs.append_pair("fieldSelector", field_selector);
}
if let Some(include_uninitialized) = include_uninitialized {
__query_pairs.append_pair("includeUninitialized", &include_uninitialized.to_string());
}
if let Some(label_selector) = label_selector {
__query_pairs.append_pair("labelSelector", label_selector);
}
if let Some(limit) = limit {
__query_pairs.append_pair("limit", &limit.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
if let Some(resource_version) = resource_version {
__query_pairs.append_pair("resourceVersion", resource_version);
}
if let Some(timeout_seconds) = timeout_seconds {
__query_pairs.append_pair("timeoutSeconds", &timeout_seconds.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ListPodForAllNamespacesOptional<'a> {
pub continue_: Option<&'a str>,
pub field_selector: Option<&'a str>,
pub include_uninitialized: Option<bool>,
pub label_selector: Option<&'a str>,
pub limit: Option<i64>,
pub pretty: Option<&'a str>,
pub resource_version: Option<&'a str>,
pub timeout_seconds: Option<i64>,
}
#[derive(Debug)]
pub enum ListPodForAllNamespacesResponse {
Ok(crate::v1_13::api::core::v1::PodList),
Unauthorized,
Other,
}
impl crate::Response for ListPodForAllNamespacesResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((ListPodForAllNamespacesResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ListPodForAllNamespacesResponse::Unauthorized, 0)),
_ => Ok((ListPodForAllNamespacesResponse::Other, 0)),
}
}
}
impl Pod {
pub fn patch_namespaced_pod(
name: &str,
namespace: &str,
body: &crate::v1_13::apimachinery::pkg::apis::meta::v1::Patch,
optional: PatchNamespacedPodOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<PatchNamespacedPodResponse>), crate::RequestError> {
let PatchNamespacedPodOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(dry_run) = dry_run {
__query_pairs.append_pair("dryRun", dry_run);
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::patch(__url);
let __body = serde_json::to_vec(&body).map_err(crate::RequestError::Json)?;
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct PatchNamespacedPodOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum PatchNamespacedPodResponse {
Ok(crate::v1_13::api::core::v1::Pod),
Unauthorized,
Other,
}
impl crate::Response for PatchNamespacedPodResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((PatchNamespacedPodResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((PatchNamespacedPodResponse::Unauthorized, 0)),
_ => Ok((PatchNamespacedPodResponse::Other, 0)),
}
}
}
impl Pod {
pub fn patch_namespaced_pod_status(
name: &str,
namespace: &str,
body: &crate::v1_13::apimachinery::pkg::apis::meta::v1::Patch,
optional: PatchNamespacedPodStatusOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<PatchNamespacedPodStatusResponse>), crate::RequestError> {
let PatchNamespacedPodStatusOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/status?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(dry_run) = dry_run {
__query_pairs.append_pair("dryRun", dry_run);
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::patch(__url);
let __body = serde_json::to_vec(&body).map_err(crate::RequestError::Json)?;
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct PatchNamespacedPodStatusOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum PatchNamespacedPodStatusResponse {
Ok(crate::v1_13::api::core::v1::Pod),
Unauthorized,
Other,
}
impl crate::Response for PatchNamespacedPodStatusResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((PatchNamespacedPodStatusResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((PatchNamespacedPodStatusResponse::Unauthorized, 0)),
_ => Ok((PatchNamespacedPodStatusResponse::Other, 0)),
}
}
}
impl Pod {
pub fn read_namespaced_pod(
name: &str,
namespace: &str,
optional: ReadNamespacedPodOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNamespacedPodResponse>), crate::RequestError> {
let ReadNamespacedPodOptional {
exact,
export,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(exact) = exact {
__query_pairs.append_pair("exact", &exact.to_string());
}
if let Some(export) = export {
__query_pairs.append_pair("export", &export.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ReadNamespacedPodOptional<'a> {
pub exact: Option<bool>,
pub export: Option<bool>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReadNamespacedPodResponse {
Ok(crate::v1_13::api::core::v1::Pod),
Unauthorized,
Other,
}
impl crate::Response for ReadNamespacedPodResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((ReadNamespacedPodResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNamespacedPodResponse::Unauthorized, 0)),
_ => Ok((ReadNamespacedPodResponse::Other, 0)),
}
}
}
impl Pod {
pub fn read_namespaced_pod_log(
name: &str,
namespace: &str,
optional: ReadNamespacedPodLogOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNamespacedPodLogResponse>), crate::RequestError> {
let ReadNamespacedPodLogOptional {
container,
follow,
limit_bytes,
pretty,
previous,
since_seconds,
tail_lines,
timestamps,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/log?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(container) = container {
__query_pairs.append_pair("container", container);
}
if let Some(follow) = follow {
__query_pairs.append_pair("follow", &follow.to_string());
}
if let Some(limit_bytes) = limit_bytes {
__query_pairs.append_pair("limitBytes", &limit_bytes.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
if let Some(previous) = previous {
__query_pairs.append_pair("previous", &previous.to_string());
}
if let Some(since_seconds) = since_seconds {
__query_pairs.append_pair("sinceSeconds", &since_seconds.to_string());
}
if let Some(tail_lines) = tail_lines {
__query_pairs.append_pair("tailLines", &tail_lines.to_string());
}
if let Some(timestamps) = timestamps {
__query_pairs.append_pair("timestamps", ×tamps.to_string());
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ReadNamespacedPodLogOptional<'a> {
pub container: Option<&'a str>,
pub follow: Option<bool>,
pub limit_bytes: Option<i64>,
pub pretty: Option<&'a str>,
pub previous: Option<bool>,
pub since_seconds: Option<i64>,
pub tail_lines: Option<i64>,
pub timestamps: Option<bool>,
}
#[derive(Debug)]
pub enum ReadNamespacedPodLogResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ReadNamespacedPodLogResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
if buf.is_empty() {
return Err(crate::ResponseError::NeedMoreData);
}
let (result, len) = match std::str::from_utf8(buf) {
Ok(s) => (s, buf.len()),
Err(err) => match (err.valid_up_to(), err.error_len()) {
(0, Some(_)) => return Err(crate::ResponseError::Utf8(err)),
(0, None) => return Err(crate::ResponseError::NeedMoreData),
(valid_up_to, _) => (
unsafe { std::str::from_utf8_unchecked(buf.get_unchecked(..valid_up_to)) },
valid_up_to,
),
},
};
Ok((ReadNamespacedPodLogResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNamespacedPodLogResponse::Unauthorized, 0)),
_ => Ok((ReadNamespacedPodLogResponse::Other, 0)),
}
}
}
impl Pod {
pub fn read_namespaced_pod_status(
name: &str,
namespace: &str,
optional: ReadNamespacedPodStatusOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNamespacedPodStatusResponse>), crate::RequestError> {
let ReadNamespacedPodStatusOptional {
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/status?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ReadNamespacedPodStatusOptional<'a> {
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReadNamespacedPodStatusResponse {
Ok(crate::v1_13::api::core::v1::Pod),
Unauthorized,
Other,
}
impl crate::Response for ReadNamespacedPodStatusResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((ReadNamespacedPodStatusResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNamespacedPodStatusResponse::Unauthorized, 0)),
_ => Ok((ReadNamespacedPodStatusResponse::Other, 0)),
}
}
}
impl Pod {
pub fn replace_namespaced_pod(
name: &str,
namespace: &str,
body: &crate::v1_13::api::core::v1::Pod,
optional: ReplaceNamespacedPodOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReplaceNamespacedPodResponse>), crate::RequestError> {
let ReplaceNamespacedPodOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(dry_run) = dry_run {
__query_pairs.append_pair("dryRun", dry_run);
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::put(__url);
let __body = serde_json::to_vec(&body).map_err(crate::RequestError::Json)?;
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ReplaceNamespacedPodOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReplaceNamespacedPodResponse {
Ok(crate::v1_13::api::core::v1::Pod),
Created(crate::v1_13::api::core::v1::Pod),
Unauthorized,
Other,
}
impl crate::Response for ReplaceNamespacedPodResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((ReplaceNamespacedPodResponse::Ok(result), buf.len()))
},
http::StatusCode::CREATED => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((ReplaceNamespacedPodResponse::Created(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReplaceNamespacedPodResponse::Unauthorized, 0)),
_ => Ok((ReplaceNamespacedPodResponse::Other, 0)),
}
}
}
impl Pod {
pub fn replace_namespaced_pod_status(
name: &str,
namespace: &str,
body: &crate::v1_13::api::core::v1::Pod,
optional: ReplaceNamespacedPodStatusOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReplaceNamespacedPodStatusResponse>), crate::RequestError> {
let ReplaceNamespacedPodStatusOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods/{name}/status?", name = name, namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(dry_run) = dry_run {
__query_pairs.append_pair("dryRun", dry_run);
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
let __url = __query_pairs.finish();
let mut __request = http::Request::put(__url);
let __body = serde_json::to_vec(&body).map_err(crate::RequestError::Json)?;
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct ReplaceNamespacedPodStatusOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReplaceNamespacedPodStatusResponse {
Ok(crate::v1_13::api::core::v1::Pod),
Created(crate::v1_13::api::core::v1::Pod),
Unauthorized,
Other,
}
impl crate::Response for ReplaceNamespacedPodStatusResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((ReplaceNamespacedPodStatusResponse::Ok(result), buf.len()))
},
http::StatusCode::CREATED => {
let result = match serde_json::from_slice(buf) {
Ok(value) => value,
Err(ref err) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Err(err) => return Err(crate::ResponseError::Json(err)),
};
Ok((ReplaceNamespacedPodStatusResponse::Created(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReplaceNamespacedPodStatusResponse::Unauthorized, 0)),
_ => Ok((ReplaceNamespacedPodStatusResponse::Other, 0)),
}
}
}
impl Pod {
pub fn watch_namespaced_pod(
namespace: &str,
optional: WatchNamespacedPodOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<WatchNamespacedPodResponse>), crate::RequestError> {
let WatchNamespacedPodOptional {
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/pods?", namespace = namespace);
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(field_selector) = field_selector {
__query_pairs.append_pair("fieldSelector", field_selector);
}
if let Some(include_uninitialized) = include_uninitialized {
__query_pairs.append_pair("includeUninitialized", &include_uninitialized.to_string());
}
if let Some(label_selector) = label_selector {
__query_pairs.append_pair("labelSelector", label_selector);
}
if let Some(limit) = limit {
__query_pairs.append_pair("limit", &limit.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
if let Some(resource_version) = resource_version {
__query_pairs.append_pair("resourceVersion", resource_version);
}
if let Some(timeout_seconds) = timeout_seconds {
__query_pairs.append_pair("timeoutSeconds", &timeout_seconds.to_string());
}
__query_pairs.append_pair("watch", "true");
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct WatchNamespacedPodOptional<'a> {
pub field_selector: Option<&'a str>,
pub include_uninitialized: Option<bool>,
pub label_selector: Option<&'a str>,
pub limit: Option<i64>,
pub pretty: Option<&'a str>,
pub resource_version: Option<&'a str>,
pub timeout_seconds: Option<i64>,
}
#[derive(Debug)]
pub enum WatchNamespacedPodResponse {
Ok(crate::v1_13::apimachinery::pkg::apis::meta::v1::WatchEvent),
Unauthorized,
Other,
}
impl crate::Response for WatchNamespacedPodResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let mut deserializer = serde_json::Deserializer::from_slice(buf).into_iter();
let (result, byte_offset) = match deserializer.next() {
Some(Ok(value)) => (value, deserializer.byte_offset()),
Some(Err(ref err)) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Some(Err(err)) => return Err(crate::ResponseError::Json(err)),
None => return Err(crate::ResponseError::NeedMoreData),
};
Ok((WatchNamespacedPodResponse::Ok(result), byte_offset))
},
http::StatusCode::UNAUTHORIZED => Ok((WatchNamespacedPodResponse::Unauthorized, 0)),
_ => Ok((WatchNamespacedPodResponse::Other, 0)),
}
}
}
impl Pod {
pub fn watch_pod_for_all_namespaces(
optional: WatchPodForAllNamespacesOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<WatchPodForAllNamespacesResponse>), crate::RequestError> {
let WatchPodForAllNamespacesOptional {
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = "/api/v1/pods?".to_string();
let mut __query_pairs = url::form_urlencoded::Serializer::new(__url);
if let Some(field_selector) = field_selector {
__query_pairs.append_pair("fieldSelector", field_selector);
}
if let Some(include_uninitialized) = include_uninitialized {
__query_pairs.append_pair("includeUninitialized", &include_uninitialized.to_string());
}
if let Some(label_selector) = label_selector {
__query_pairs.append_pair("labelSelector", label_selector);
}
if let Some(limit) = limit {
__query_pairs.append_pair("limit", &limit.to_string());
}
if let Some(pretty) = pretty {
__query_pairs.append_pair("pretty", pretty);
}
if let Some(resource_version) = resource_version {
__query_pairs.append_pair("resourceVersion", resource_version);
}
if let Some(timeout_seconds) = timeout_seconds {
__query_pairs.append_pair("timeoutSeconds", &timeout_seconds.to_string());
}
__query_pairs.append_pair("watch", "true");
let __url = __query_pairs.finish();
let mut __request = http::Request::get(__url);
let __body = vec![];
match __request.body(__body) {
Ok(body) => Ok((body, crate::ResponseBody::new)),
Err(err) => Err(crate::RequestError::Http(err)),
}
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct WatchPodForAllNamespacesOptional<'a> {
pub field_selector: Option<&'a str>,
pub include_uninitialized: Option<bool>,
pub label_selector: Option<&'a str>,
pub limit: Option<i64>,
pub pretty: Option<&'a str>,
pub resource_version: Option<&'a str>,
pub timeout_seconds: Option<i64>,
}
#[derive(Debug)]
pub enum WatchPodForAllNamespacesResponse {
Ok(crate::v1_13::apimachinery::pkg::apis::meta::v1::WatchEvent),
Unauthorized,
Other,
}
impl crate::Response for WatchPodForAllNamespacesResponse {
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) -> Result<(Self, usize), crate::ResponseError> {
match status_code {
http::StatusCode::OK => {
let mut deserializer = serde_json::Deserializer::from_slice(buf).into_iter();
let (result, byte_offset) = match deserializer.next() {
Some(Ok(value)) => (value, deserializer.byte_offset()),
Some(Err(ref err)) if err.is_eof() => return Err(crate::ResponseError::NeedMoreData),
Some(Err(err)) => return Err(crate::ResponseError::Json(err)),
None => return Err(crate::ResponseError::NeedMoreData),
};
Ok((WatchPodForAllNamespacesResponse::Ok(result), byte_offset))
},
http::StatusCode::UNAUTHORIZED => Ok((WatchPodForAllNamespacesResponse::Unauthorized, 0)),
_ => Ok((WatchPodForAllNamespacesResponse::Other, 0)),
}
}
}
impl crate::Resource for Pod {
fn api_version() -> &'static str {
"v1"
}
fn group() -> &'static str {
""
}
fn kind() -> &'static str {
"Pod"
}
fn version() -> &'static str {
"v1"
}
}
impl crate::Metadata for Pod {
type Ty = crate::v1_13::apimachinery::pkg::apis::meta::v1::ObjectMeta;
fn metadata(&self) -> Option<&<Self as crate::Metadata>::Ty> {
self.metadata.as_ref()
}
}
impl<'de> serde::Deserialize<'de> for Pod {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
#[allow(non_camel_case_types)]
enum Field {
Key_api_version,
Key_kind,
Key_metadata,
Key_spec,
Key_status,
Other,
}
impl<'de> serde::Deserialize<'de> for Field {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = Field;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "field identifier")
}
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
Ok(match v {
"apiVersion" => Field::Key_api_version,
"kind" => Field::Key_kind,
"metadata" => Field::Key_metadata,
"spec" => Field::Key_spec,
"status" => Field::Key_status,
_ => Field::Other,
})
}
}
deserializer.deserialize_identifier(Visitor)
}
}
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = Pod;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "struct Pod")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
let mut value_metadata: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
let mut value_spec: Option<crate::v1_13::api::core::v1::PodSpec> = None;
let mut value_status: Option<crate::v1_13::api::core::v1::PodStatus> = None;
while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
match key {
Field::Key_api_version => {
let value_api_version: String = serde::de::MapAccess::next_value(&mut map)?;
if value_api_version != <Self::Value as crate::Resource>::api_version() {
return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::api_version()));
}
},
Field::Key_kind => {
let value_kind: String = serde::de::MapAccess::next_value(&mut map)?;
if value_kind != <Self::Value as crate::Resource>::kind() {
return Err(serde::de::Error::invalid_value(serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::kind()));
}
},
Field::Key_metadata => value_metadata = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_spec => value_spec = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_status => value_status = serde::de::MapAccess::next_value(&mut map)?,
Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
}
}
Ok(Pod {
metadata: value_metadata,
spec: value_spec,
status: value_status,
})
}
}
deserializer.deserialize_struct(
"Pod",
&[
"apiVersion",
"kind",
"metadata",
"spec",
"status",
],
Visitor,
)
}
}
impl serde::Serialize for Pod {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
let mut state = serializer.serialize_struct(
"Pod",
2 +
self.metadata.as_ref().map_or(0, |_| 1) +
self.spec.as_ref().map_or(0, |_| 1) +
self.status.as_ref().map_or(0, |_| 1),
)?;
serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::api_version())?;
serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::kind())?;
if let Some(value) = &self.metadata {
serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", value)?;
}
if let Some(value) = &self.spec {
serde::ser::SerializeStruct::serialize_field(&mut state, "spec", value)?;
}
if let Some(value) = &self.status {
serde::ser::SerializeStruct::serialize_field(&mut state, "status", value)?;
}
serde::ser::SerializeStruct::end(state)
}
}