#[derive(Clone, Debug, Default, PartialEq)]
pub struct Scale {
pub metadata: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::ObjectMeta>,
pub spec: Option<crate::v1_13::api::extensions::v1beta1::ScaleSpec>,
pub status: Option<crate::v1_13::api::extensions::v1beta1::ScaleStatus>,
}
impl Scale {
pub fn patch_namespaced_deployment_scale(
name: &str,
namespace: &str,
body: &crate::v1_13::apimachinery::pkg::apis::meta::v1::Patch,
optional: PatchNamespacedDeploymentScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<PatchNamespacedDeploymentScaleResponse>), crate::RequestError> {
let PatchNamespacedDeploymentScaleOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale?", 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 PatchNamespacedDeploymentScaleOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum PatchNamespacedDeploymentScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for PatchNamespacedDeploymentScaleResponse {
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((PatchNamespacedDeploymentScaleResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((PatchNamespacedDeploymentScaleResponse::Unauthorized, 0)),
_ => Ok((PatchNamespacedDeploymentScaleResponse::Other, 0)),
}
}
}
impl Scale {
pub fn patch_namespaced_replica_set_scale(
name: &str,
namespace: &str,
body: &crate::v1_13::apimachinery::pkg::apis::meta::v1::Patch,
optional: PatchNamespacedReplicaSetScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<PatchNamespacedReplicaSetScaleResponse>), crate::RequestError> {
let PatchNamespacedReplicaSetScaleOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/replicasets/{name}/scale?", 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 PatchNamespacedReplicaSetScaleOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum PatchNamespacedReplicaSetScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for PatchNamespacedReplicaSetScaleResponse {
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((PatchNamespacedReplicaSetScaleResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((PatchNamespacedReplicaSetScaleResponse::Unauthorized, 0)),
_ => Ok((PatchNamespacedReplicaSetScaleResponse::Other, 0)),
}
}
}
impl Scale {
pub fn patch_namespaced_replication_controller_dummy_scale(
name: &str,
namespace: &str,
body: &crate::v1_13::apimachinery::pkg::apis::meta::v1::Patch,
optional: PatchNamespacedReplicationControllerDummyScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<PatchNamespacedReplicationControllerDummyScaleResponse>), crate::RequestError> {
let PatchNamespacedReplicationControllerDummyScaleOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/replicationcontrollers/{name}/scale?", 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 PatchNamespacedReplicationControllerDummyScaleOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum PatchNamespacedReplicationControllerDummyScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for PatchNamespacedReplicationControllerDummyScaleResponse {
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((PatchNamespacedReplicationControllerDummyScaleResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((PatchNamespacedReplicationControllerDummyScaleResponse::Unauthorized, 0)),
_ => Ok((PatchNamespacedReplicationControllerDummyScaleResponse::Other, 0)),
}
}
}
impl Scale {
pub fn read_namespaced_deployment_scale(
name: &str,
namespace: &str,
optional: ReadNamespacedDeploymentScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNamespacedDeploymentScaleResponse>), crate::RequestError> {
let ReadNamespacedDeploymentScaleOptional {
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale?", 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 ReadNamespacedDeploymentScaleOptional<'a> {
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReadNamespacedDeploymentScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for ReadNamespacedDeploymentScaleResponse {
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((ReadNamespacedDeploymentScaleResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNamespacedDeploymentScaleResponse::Unauthorized, 0)),
_ => Ok((ReadNamespacedDeploymentScaleResponse::Other, 0)),
}
}
}
impl Scale {
pub fn read_namespaced_replica_set_scale(
name: &str,
namespace: &str,
optional: ReadNamespacedReplicaSetScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNamespacedReplicaSetScaleResponse>), crate::RequestError> {
let ReadNamespacedReplicaSetScaleOptional {
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/replicasets/{name}/scale?", 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 ReadNamespacedReplicaSetScaleOptional<'a> {
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReadNamespacedReplicaSetScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for ReadNamespacedReplicaSetScaleResponse {
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((ReadNamespacedReplicaSetScaleResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNamespacedReplicaSetScaleResponse::Unauthorized, 0)),
_ => Ok((ReadNamespacedReplicaSetScaleResponse::Other, 0)),
}
}
}
impl Scale {
pub fn read_namespaced_replication_controller_dummy_scale(
name: &str,
namespace: &str,
optional: ReadNamespacedReplicationControllerDummyScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNamespacedReplicationControllerDummyScaleResponse>), crate::RequestError> {
let ReadNamespacedReplicationControllerDummyScaleOptional {
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/replicationcontrollers/{name}/scale?", 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 ReadNamespacedReplicationControllerDummyScaleOptional<'a> {
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReadNamespacedReplicationControllerDummyScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for ReadNamespacedReplicationControllerDummyScaleResponse {
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((ReadNamespacedReplicationControllerDummyScaleResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNamespacedReplicationControllerDummyScaleResponse::Unauthorized, 0)),
_ => Ok((ReadNamespacedReplicationControllerDummyScaleResponse::Other, 0)),
}
}
}
impl Scale {
pub fn replace_namespaced_deployment_scale(
name: &str,
namespace: &str,
body: &crate::v1_13::api::extensions::v1beta1::Scale,
optional: ReplaceNamespacedDeploymentScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReplaceNamespacedDeploymentScaleResponse>), crate::RequestError> {
let ReplaceNamespacedDeploymentScaleOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale?", 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 ReplaceNamespacedDeploymentScaleOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReplaceNamespacedDeploymentScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Created(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for ReplaceNamespacedDeploymentScaleResponse {
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((ReplaceNamespacedDeploymentScaleResponse::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((ReplaceNamespacedDeploymentScaleResponse::Created(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReplaceNamespacedDeploymentScaleResponse::Unauthorized, 0)),
_ => Ok((ReplaceNamespacedDeploymentScaleResponse::Other, 0)),
}
}
}
impl Scale {
pub fn replace_namespaced_replica_set_scale(
name: &str,
namespace: &str,
body: &crate::v1_13::api::extensions::v1beta1::Scale,
optional: ReplaceNamespacedReplicaSetScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReplaceNamespacedReplicaSetScaleResponse>), crate::RequestError> {
let ReplaceNamespacedReplicaSetScaleOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/replicasets/{name}/scale?", 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 ReplaceNamespacedReplicaSetScaleOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReplaceNamespacedReplicaSetScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Created(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for ReplaceNamespacedReplicaSetScaleResponse {
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((ReplaceNamespacedReplicaSetScaleResponse::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((ReplaceNamespacedReplicaSetScaleResponse::Created(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReplaceNamespacedReplicaSetScaleResponse::Unauthorized, 0)),
_ => Ok((ReplaceNamespacedReplicaSetScaleResponse::Other, 0)),
}
}
}
impl Scale {
pub fn replace_namespaced_replication_controller_dummy_scale(
name: &str,
namespace: &str,
body: &crate::v1_13::api::extensions::v1beta1::Scale,
optional: ReplaceNamespacedReplicationControllerDummyScaleOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReplaceNamespacedReplicationControllerDummyScaleResponse>), crate::RequestError> {
let ReplaceNamespacedReplicationControllerDummyScaleOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/apis/extensions/v1beta1/namespaces/{namespace}/replicationcontrollers/{name}/scale?", 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 ReplaceNamespacedReplicationControllerDummyScaleOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReplaceNamespacedReplicationControllerDummyScaleResponse {
Ok(crate::v1_13::api::extensions::v1beta1::Scale),
Created(crate::v1_13::api::extensions::v1beta1::Scale),
Unauthorized,
Other,
}
impl crate::Response for ReplaceNamespacedReplicationControllerDummyScaleResponse {
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((ReplaceNamespacedReplicationControllerDummyScaleResponse::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((ReplaceNamespacedReplicationControllerDummyScaleResponse::Created(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReplaceNamespacedReplicationControllerDummyScaleResponse::Unauthorized, 0)),
_ => Ok((ReplaceNamespacedReplicationControllerDummyScaleResponse::Other, 0)),
}
}
}
impl crate::Resource for Scale {
fn api_version() -> &'static str {
"extensions/v1beta1"
}
fn group() -> &'static str {
"extensions"
}
fn kind() -> &'static str {
"Scale"
}
fn version() -> &'static str {
"v1beta1"
}
}
impl crate::Metadata for Scale {
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 Scale {
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 = Scale;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "struct Scale")
}
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::extensions::v1beta1::ScaleSpec> = None;
let mut value_status: Option<crate::v1_13::api::extensions::v1beta1::ScaleStatus> = 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(Scale {
metadata: value_metadata,
spec: value_spec,
status: value_status,
})
}
}
deserializer.deserialize_struct(
"Scale",
&[
"apiVersion",
"kind",
"metadata",
"spec",
"status",
],
Visitor,
)
}
}
impl serde::Serialize for Scale {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
let mut state = serializer.serialize_struct(
"Scale",
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)
}
}