#[derive(Clone, Debug, Default, PartialEq)]
pub struct Node {
pub metadata: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::ObjectMeta>,
pub spec: Option<crate::v1_13::api::core::v1::NodeSpec>,
pub status: Option<crate::v1_13::api::core::v1::NodeStatus>,
}
impl Node {
pub fn connect_delete_node_proxy(
name: &str,
optional: ConnectDeleteNodeProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectDeleteNodeProxyResponse>), crate::RequestError> {
let ConnectDeleteNodeProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy?", name = name);
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 ConnectDeleteNodeProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectDeleteNodeProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectDeleteNodeProxyResponse {
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((ConnectDeleteNodeProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectDeleteNodeProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectDeleteNodeProxyResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_delete_node_proxy_with_path(
name: &str,
path: &str,
optional: ConnectDeleteNodeProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectDeleteNodeProxyWithPathResponse>), crate::RequestError> {
let ConnectDeleteNodeProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy/{path}?", name = name, 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 ConnectDeleteNodeProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectDeleteNodeProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectDeleteNodeProxyWithPathResponse {
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((ConnectDeleteNodeProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectDeleteNodeProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectDeleteNodeProxyWithPathResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_get_node_proxy(
name: &str,
optional: ConnectGetNodeProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectGetNodeProxyResponse>), crate::RequestError> {
let ConnectGetNodeProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy?", name = name);
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 ConnectGetNodeProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectGetNodeProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectGetNodeProxyResponse {
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((ConnectGetNodeProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectGetNodeProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectGetNodeProxyResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_get_node_proxy_with_path(
name: &str,
path: &str,
optional: ConnectGetNodeProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectGetNodeProxyWithPathResponse>), crate::RequestError> {
let ConnectGetNodeProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy/{path}?", name = name, 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 ConnectGetNodeProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectGetNodeProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectGetNodeProxyWithPathResponse {
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((ConnectGetNodeProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectGetNodeProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectGetNodeProxyWithPathResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_patch_node_proxy(
name: &str,
optional: ConnectPatchNodeProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPatchNodeProxyResponse>), crate::RequestError> {
let ConnectPatchNodeProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy?", name = name);
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 ConnectPatchNodeProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPatchNodeProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPatchNodeProxyResponse {
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((ConnectPatchNodeProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPatchNodeProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectPatchNodeProxyResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_patch_node_proxy_with_path(
name: &str,
path: &str,
optional: ConnectPatchNodeProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPatchNodeProxyWithPathResponse>), crate::RequestError> {
let ConnectPatchNodeProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy/{path}?", name = name, 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 ConnectPatchNodeProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPatchNodeProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPatchNodeProxyWithPathResponse {
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((ConnectPatchNodeProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPatchNodeProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectPatchNodeProxyWithPathResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_post_node_proxy(
name: &str,
optional: ConnectPostNodeProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPostNodeProxyResponse>), crate::RequestError> {
let ConnectPostNodeProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy?", name = name);
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 ConnectPostNodeProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPostNodeProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPostNodeProxyResponse {
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((ConnectPostNodeProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPostNodeProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectPostNodeProxyResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_post_node_proxy_with_path(
name: &str,
path: &str,
optional: ConnectPostNodeProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPostNodeProxyWithPathResponse>), crate::RequestError> {
let ConnectPostNodeProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy/{path}?", name = name, 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 ConnectPostNodeProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPostNodeProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPostNodeProxyWithPathResponse {
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((ConnectPostNodeProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPostNodeProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectPostNodeProxyWithPathResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_put_node_proxy(
name: &str,
optional: ConnectPutNodeProxyOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPutNodeProxyResponse>), crate::RequestError> {
let ConnectPutNodeProxyOptional {
path,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy?", name = name);
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 ConnectPutNodeProxyOptional<'a> {
pub path: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPutNodeProxyResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPutNodeProxyResponse {
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((ConnectPutNodeProxyResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPutNodeProxyResponse::Unauthorized, 0)),
_ => Ok((ConnectPutNodeProxyResponse::Other, 0)),
}
}
}
impl Node {
pub fn connect_put_node_proxy_with_path(
name: &str,
path: &str,
optional: ConnectPutNodeProxyWithPathOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ConnectPutNodeProxyWithPathResponse>), crate::RequestError> {
let ConnectPutNodeProxyWithPathOptional {
path_,
} = optional;
let __url = format!("/api/v1/nodes/{name}/proxy/{path}?", name = name, 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 ConnectPutNodeProxyWithPathOptional<'a> {
pub path_: Option<&'a str>,
}
#[derive(Debug)]
pub enum ConnectPutNodeProxyWithPathResponse {
Ok(String),
Unauthorized,
Other,
}
impl crate::Response for ConnectPutNodeProxyWithPathResponse {
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((ConnectPutNodeProxyWithPathResponse::Ok(result.to_string()), len))
},
http::StatusCode::UNAUTHORIZED => Ok((ConnectPutNodeProxyWithPathResponse::Unauthorized, 0)),
_ => Ok((ConnectPutNodeProxyWithPathResponse::Other, 0)),
}
}
}
impl Node {
pub fn create_node(
body: &crate::v1_13::api::core::v1::Node,
optional: CreateNodeOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<CreateNodeResponse>), crate::RequestError> {
let CreateNodeOptional {
dry_run,
include_uninitialized,
pretty,
} = optional;
let __url = "/api/v1/nodes?".to_string();
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 CreateNodeOptional<'a> {
pub dry_run: Option<&'a str>,
pub include_uninitialized: Option<bool>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum CreateNodeResponse {
Ok(crate::v1_13::api::core::v1::Node),
Created(crate::v1_13::api::core::v1::Node),
Accepted(crate::v1_13::api::core::v1::Node),
Unauthorized,
Other,
}
impl crate::Response for CreateNodeResponse {
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((CreateNodeResponse::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((CreateNodeResponse::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((CreateNodeResponse::Accepted(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((CreateNodeResponse::Unauthorized, 0)),
_ => Ok((CreateNodeResponse::Other, 0)),
}
}
}
impl Node {
pub fn delete_collection_node(
optional: DeleteCollectionNodeOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<DeleteCollectionNodeResponse>), crate::RequestError> {
let DeleteCollectionNodeOptional {
continue_,
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
watch,
} = optional;
let __url = "/api/v1/nodes?".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());
}
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 DeleteCollectionNodeOptional<'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 DeleteCollectionNodeResponse {
OkStatus(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
OkValue(crate::v1_13::api::core::v1::Node),
Unauthorized,
Other,
}
impl crate::Response for DeleteCollectionNodeResponse {
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((DeleteCollectionNodeResponse::OkStatus(result), buf.len()))
}
else {
let result = serde::Deserialize::deserialize(serde_json::Value::Object(result));
let result = result.map_err(crate::ResponseError::Json)?;
Ok((DeleteCollectionNodeResponse::OkValue(result), buf.len()))
}
},
http::StatusCode::UNAUTHORIZED => Ok((DeleteCollectionNodeResponse::Unauthorized, 0)),
_ => Ok((DeleteCollectionNodeResponse::Other, 0)),
}
}
}
impl Node {
pub fn delete_node(
name: &str,
optional: DeleteNodeOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<DeleteNodeResponse>), crate::RequestError> {
let DeleteNodeOptional {
dry_run,
grace_period_seconds,
orphan_dependents,
pretty,
propagation_policy,
} = optional;
let __url = format!("/api/v1/nodes/{name}?", name = name);
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 DeleteNodeOptional<'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 DeleteNodeResponse {
OkStatus(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
OkValue(crate::v1_13::api::core::v1::Node),
Accepted(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
Unauthorized,
Other,
}
impl crate::Response for DeleteNodeResponse {
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((DeleteNodeResponse::OkStatus(result), buf.len()))
}
else {
let result = serde::Deserialize::deserialize(serde_json::Value::Object(result));
let result = result.map_err(crate::ResponseError::Json)?;
Ok((DeleteNodeResponse::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((DeleteNodeResponse::Accepted(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((DeleteNodeResponse::Unauthorized, 0)),
_ => Ok((DeleteNodeResponse::Other, 0)),
}
}
}
impl Node {
pub fn list_node(
optional: ListNodeOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ListNodeResponse>), crate::RequestError> {
let ListNodeOptional {
continue_,
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = "/api/v1/nodes?".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 ListNodeOptional<'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 ListNodeResponse {
Ok(crate::v1_13::api::core::v1::NodeList),
Unauthorized,
Other,
}
impl crate::Response for ListNodeResponse {
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((ListNodeResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ListNodeResponse::Unauthorized, 0)),
_ => Ok((ListNodeResponse::Other, 0)),
}
}
}
impl Node {
pub fn patch_node(
name: &str,
body: &crate::v1_13::apimachinery::pkg::apis::meta::v1::Patch,
optional: PatchNodeOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<PatchNodeResponse>), crate::RequestError> {
let PatchNodeOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/nodes/{name}?", name = name);
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 PatchNodeOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum PatchNodeResponse {
Ok(crate::v1_13::api::core::v1::Node),
Unauthorized,
Other,
}
impl crate::Response for PatchNodeResponse {
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((PatchNodeResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((PatchNodeResponse::Unauthorized, 0)),
_ => Ok((PatchNodeResponse::Other, 0)),
}
}
}
impl Node {
pub fn patch_node_status(
name: &str,
body: &crate::v1_13::apimachinery::pkg::apis::meta::v1::Patch,
optional: PatchNodeStatusOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<PatchNodeStatusResponse>), crate::RequestError> {
let PatchNodeStatusOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/nodes/{name}/status?", name = name);
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 PatchNodeStatusOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum PatchNodeStatusResponse {
Ok(crate::v1_13::api::core::v1::Node),
Unauthorized,
Other,
}
impl crate::Response for PatchNodeStatusResponse {
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((PatchNodeStatusResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((PatchNodeStatusResponse::Unauthorized, 0)),
_ => Ok((PatchNodeStatusResponse::Other, 0)),
}
}
}
impl Node {
pub fn read_node(
name: &str,
optional: ReadNodeOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNodeResponse>), crate::RequestError> {
let ReadNodeOptional {
exact,
export,
pretty,
} = optional;
let __url = format!("/api/v1/nodes/{name}?", name = name);
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 ReadNodeOptional<'a> {
pub exact: Option<bool>,
pub export: Option<bool>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReadNodeResponse {
Ok(crate::v1_13::api::core::v1::Node),
Unauthorized,
Other,
}
impl crate::Response for ReadNodeResponse {
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((ReadNodeResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNodeResponse::Unauthorized, 0)),
_ => Ok((ReadNodeResponse::Other, 0)),
}
}
}
impl Node {
pub fn read_node_status(
name: &str,
optional: ReadNodeStatusOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNodeStatusResponse>), crate::RequestError> {
let ReadNodeStatusOptional {
pretty,
} = optional;
let __url = format!("/api/v1/nodes/{name}/status?", name = name);
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 ReadNodeStatusOptional<'a> {
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReadNodeStatusResponse {
Ok(crate::v1_13::api::core::v1::Node),
Unauthorized,
Other,
}
impl crate::Response for ReadNodeStatusResponse {
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((ReadNodeStatusResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNodeStatusResponse::Unauthorized, 0)),
_ => Ok((ReadNodeStatusResponse::Other, 0)),
}
}
}
impl Node {
pub fn replace_node(
name: &str,
body: &crate::v1_13::api::core::v1::Node,
optional: ReplaceNodeOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReplaceNodeResponse>), crate::RequestError> {
let ReplaceNodeOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/nodes/{name}?", name = name);
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 ReplaceNodeOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReplaceNodeResponse {
Ok(crate::v1_13::api::core::v1::Node),
Created(crate::v1_13::api::core::v1::Node),
Unauthorized,
Other,
}
impl crate::Response for ReplaceNodeResponse {
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((ReplaceNodeResponse::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((ReplaceNodeResponse::Created(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReplaceNodeResponse::Unauthorized, 0)),
_ => Ok((ReplaceNodeResponse::Other, 0)),
}
}
}
impl Node {
pub fn replace_node_status(
name: &str,
body: &crate::v1_13::api::core::v1::Node,
optional: ReplaceNodeStatusOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReplaceNodeStatusResponse>), crate::RequestError> {
let ReplaceNodeStatusOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/nodes/{name}/status?", name = name);
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 ReplaceNodeStatusOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReplaceNodeStatusResponse {
Ok(crate::v1_13::api::core::v1::Node),
Created(crate::v1_13::api::core::v1::Node),
Unauthorized,
Other,
}
impl crate::Response for ReplaceNodeStatusResponse {
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((ReplaceNodeStatusResponse::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((ReplaceNodeStatusResponse::Created(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReplaceNodeStatusResponse::Unauthorized, 0)),
_ => Ok((ReplaceNodeStatusResponse::Other, 0)),
}
}
}
impl Node {
pub fn watch_node(
optional: WatchNodeOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<WatchNodeResponse>), crate::RequestError> {
let WatchNodeOptional {
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = "/api/v1/nodes?".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 WatchNodeOptional<'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 WatchNodeResponse {
Ok(crate::v1_13::apimachinery::pkg::apis::meta::v1::WatchEvent),
Unauthorized,
Other,
}
impl crate::Response for WatchNodeResponse {
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((WatchNodeResponse::Ok(result), byte_offset))
},
http::StatusCode::UNAUTHORIZED => Ok((WatchNodeResponse::Unauthorized, 0)),
_ => Ok((WatchNodeResponse::Other, 0)),
}
}
}
impl crate::Resource for Node {
fn api_version() -> &'static str {
"v1"
}
fn group() -> &'static str {
""
}
fn kind() -> &'static str {
"Node"
}
fn version() -> &'static str {
"v1"
}
}
impl crate::Metadata for Node {
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 Node {
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 = Node;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "struct Node")
}
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::NodeSpec> = None;
let mut value_status: Option<crate::v1_13::api::core::v1::NodeStatus> = 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(Node {
metadata: value_metadata,
spec: value_spec,
status: value_status,
})
}
}
deserializer.deserialize_struct(
"Node",
&[
"apiVersion",
"kind",
"metadata",
"spec",
"status",
],
Visitor,
)
}
}
impl serde::Serialize for Node {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
let mut state = serializer.serialize_struct(
"Node",
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)
}
}