#
k8s_openapi/v1_35/apimachinery/pkg/apis/meta/v1/
status.rs

    1// Generated from definition io.k8s.apimachinery.pkg.apis.meta.v1.Status
    2
    3/// Status is a return value for calls that don't return other objects.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct Status {
    6    /// Suggested HTTP return code for this status, 0 if not set.
    7    pub code: Option<i32>,
    8
    9    /// Extended data associated with the reason.  Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.
    10    pub details: Option<crate::apimachinery::pkg::apis::meta::v1::StatusDetails>,
    11
    12    /// A human-readable description of the status of this operation.
    13    pub message: Option<std::string::String>,
    14
    15    /// Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
    16    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ListMeta,
    17
    18    /// A machine-readable description of why this operation is in the "Failure" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.
    19    pub reason: Option<std::string::String>,
    20
    21    /// Status of the operation. One of: "Success" or "Failure". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
    22    pub status: Option<std::string::String>,
    23}
    24
    25impl crate::Resource for Status {
    26    const API_VERSION: &'static str = "v1";
    27    const GROUP: &'static str = "";
    28    const KIND: &'static str = "Status";
    29    const VERSION: &'static str = "v1";
    30    const URL_PATH_SEGMENT: &'static str = "status";
    31    type Scope = crate::SubResourceScope;
    32}
    33
    34impl crate::Metadata for Status {
    35    type Ty = crate::apimachinery::pkg::apis::meta::v1::ListMeta;
    36
    37    fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
    38        &self.metadata
    39    }
    40
    41    fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
    42        &mut self.metadata
    43    }
    44}
    45
    46impl crate::DeepMerge for Status {
    47    fn merge_from(&mut self, other: Self) {
    48        crate::DeepMerge::merge_from(&mut self.code, other.code);
    49        crate::DeepMerge::merge_from(&mut self.details, other.details);
    50        crate::DeepMerge::merge_from(&mut self.message, other.message);
    51        crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
    52        crate::DeepMerge::merge_from(&mut self.reason, other.reason);
    53        crate::DeepMerge::merge_from(&mut self.status, other.status);
    54    }
    55}
    56
    57impl<'de> crate::serde::Deserialize<'de> for Status {
    58    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    59        #[allow(non_camel_case_types)]
    60        enum Field {
    61            Key_api_version,
    62            Key_kind,
    63            Key_code,
    64            Key_details,
    65            Key_message,
    66            Key_metadata,
    67            Key_reason,
    68            Key_status,
    69            Other,
    70        }
    71
    72        impl<'de> crate::serde::Deserialize<'de> for Field {
    73            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    74                struct Visitor;
    75
    76                impl crate::serde::de::Visitor<'_> for Visitor {
    77                    type Value = Field;
    78
    79                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    80                        f.write_str("field identifier")
    81                    }
    82
    83                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    84                        Ok(match v {
    85                            "apiVersion" => Field::Key_api_version,
    86                            "kind" => Field::Key_kind,
    87                            "code" => Field::Key_code,
    88                            "details" => Field::Key_details,
    89                            "message" => Field::Key_message,
    90                            "metadata" => Field::Key_metadata,
    91                            "reason" => Field::Key_reason,
    92                            "status" => Field::Key_status,
    93                            _ => Field::Other,
    94                        })
    95                    }
    96                }
    97
    98                deserializer.deserialize_identifier(Visitor)
    99            }
    100        }
    101
    102        struct Visitor;
    103
    104        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    105            type Value = Status;
    106
    107            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    108                f.write_str(<Self::Value as crate::Resource>::KIND)
    109            }
    110
    111            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    112                let mut value_code: Option<i32> = None;
    113                let mut value_details: Option<crate::apimachinery::pkg::apis::meta::v1::StatusDetails> = None;
    114                let mut value_message: Option<std::string::String> = None;
    115                let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ListMeta> = None;
    116                let mut value_reason: Option<std::string::String> = None;
    117                let mut value_status: Option<std::string::String> = None;
    118
    119                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    120                    match key {
    121                        Field::Key_api_version => {
    122                            let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    123                            if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
    124                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
    125                            }
    126                        },
    127                        Field::Key_kind => {
    128                            let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    129                            if value_kind != <Self::Value as crate::Resource>::KIND {
    130                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
    131                            }
    132                        },
    133                        Field::Key_code => value_code = crate::serde::de::MapAccess::next_value(&mut map)?,
    134                        Field::Key_details => value_details = crate::serde::de::MapAccess::next_value(&mut map)?,
    135                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
    136                        Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
    137                        Field::Key_reason => value_reason = crate::serde::de::MapAccess::next_value(&mut map)?,
    138                        Field::Key_status => value_status = crate::serde::de::MapAccess::next_value(&mut map)?,
    139                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    140                    }
    141                }
    142
    143                Ok(Status {
    144                    code: value_code,
    145                    details: value_details,
    146                    message: value_message,
    147                    metadata: value_metadata.unwrap_or_default(),
    148                    reason: value_reason,
    149                    status: value_status,
    150                })
    151            }
    152        }
    153
    154        deserializer.deserialize_struct(
    155            <Self as crate::Resource>::KIND,
    156            &[
    157                "apiVersion",
    158                "kind",
    159                "code",
    160                "details",
    161                "message",
    162                "metadata",
    163                "reason",
    164                "status",
    165            ],
    166            Visitor,
    167        )
    168    }
    169}
    170
    171impl crate::serde::Serialize for Status {
    172    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    173        let mut state = serializer.serialize_struct(
    174            <Self as crate::Resource>::KIND,
    175            3 +
    176            self.code.as_ref().map_or(0, |_| 1) +
    177            self.details.as_ref().map_or(0, |_| 1) +
    178            self.message.as_ref().map_or(0, |_| 1) +
    179            self.reason.as_ref().map_or(0, |_| 1) +
    180            self.status.as_ref().map_or(0, |_| 1),
    181        )?;
    182        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
    183        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
    184        if let Some(value) = &self.code {
    185            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "code", value)?;
    186        }
    187        if let Some(value) = &self.details {
    188            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "details", value)?;
    189        }
    190        if let Some(value) = &self.message {
    191            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
    192        }
    193        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
    194        if let Some(value) = &self.reason {
    195            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
    196        }
    197        if let Some(value) = &self.status {
    198            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "status", value)?;
    199        }
    200        crate::serde::ser::SerializeStruct::end(state)
    201    }
    202}
    203
    204#[cfg(feature = "schemars")]
    205impl crate::schemars::JsonSchema for Status {
    206    fn schema_name() -> std::borrow::Cow<'static, str> {
    207        "io.k8s.apimachinery.pkg.apis.meta.v1.Status".into()
    208    }
    209
    210    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    211        crate::schemars::json_schema!({
    212            "description": "Status is a return value for calls that don't return other objects.",
    213            "type": "object",
    214            "properties": {
    215                "apiVersion": {
    216                    "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
    217                    "type": "string",
    218                },
    219                "code": {
    220                    "description": "Suggested HTTP return code for this status, 0 if not set.",
    221                    "type": "integer",
    222                    "format": "int32",
    223                },
    224                "details": ({
    225                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::StatusDetails>();
    226                    schema_obj.ensure_object().insert("description".into(), "Extended data associated with the reason.  Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.".into());
    227                    schema_obj
    228                }),
    229                "kind": {
    230                    "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
    231                    "type": "string",
    232                },
    233                "message": {
    234                    "description": "A human-readable description of the status of this operation.",
    235                    "type": "string",
    236                },
    237                "metadata": ({
    238                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ListMeta>();
    239                    schema_obj.ensure_object().insert("description".into(), "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds".into());
    240                    schema_obj
    241                }),
    242                "reason": {
    243                    "description": "A machine-readable description of why this operation is in the \"Failure\" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.",
    244                    "type": "string",
    245                },
    246                "status": {
    247                    "description": "Status of the operation. One of: \"Success\" or \"Failure\". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status",
    248                    "type": "string",
    249                },
    250            },
    251            "required": [
    252                "metadata",
    253            ],
    254        })
    255    }
    256}