#[derive(Clone, Debug, Default, PartialEq)]
pub struct Event {
pub action: Option<String>,
pub count: Option<i32>,
pub event_time: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::MicroTime>,
pub first_timestamp: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::Time>,
pub involved_object: crate::v1_13::api::core::v1::ObjectReference,
pub last_timestamp: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::Time>,
pub message: Option<String>,
pub metadata: crate::v1_13::apimachinery::pkg::apis::meta::v1::ObjectMeta,
pub reason: Option<String>,
pub related: Option<crate::v1_13::api::core::v1::ObjectReference>,
pub reporting_component: Option<String>,
pub reporting_instance: Option<String>,
pub series: Option<crate::v1_13::api::core::v1::EventSeries>,
pub source: Option<crate::v1_13::api::core::v1::EventSource>,
pub type_: Option<String>,
}
impl Event {
pub fn create_namespaced_event(
namespace: &str,
body: &crate::v1_13::api::core::v1::Event,
optional: CreateNamespacedEventOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<CreateNamespacedEventResponse>), crate::RequestError> {
let CreateNamespacedEventOptional {
dry_run,
include_uninitialized,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/events?", 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 CreateNamespacedEventOptional<'a> {
pub dry_run: Option<&'a str>,
pub include_uninitialized: Option<bool>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum CreateNamespacedEventResponse {
Ok(crate::v1_13::api::core::v1::Event),
Created(crate::v1_13::api::core::v1::Event),
Accepted(crate::v1_13::api::core::v1::Event),
Unauthorized,
Other,
}
impl crate::Response for CreateNamespacedEventResponse {
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((CreateNamespacedEventResponse::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((CreateNamespacedEventResponse::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((CreateNamespacedEventResponse::Accepted(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((CreateNamespacedEventResponse::Unauthorized, 0)),
_ => Ok((CreateNamespacedEventResponse::Other, 0)),
}
}
}
impl Event {
pub fn delete_collection_namespaced_event(
namespace: &str,
optional: DeleteCollectionNamespacedEventOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<DeleteCollectionNamespacedEventResponse>), crate::RequestError> {
let DeleteCollectionNamespacedEventOptional {
continue_,
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
watch,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/events?", 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 DeleteCollectionNamespacedEventOptional<'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 DeleteCollectionNamespacedEventResponse {
OkStatus(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
OkValue(crate::v1_13::api::core::v1::Event),
Unauthorized,
Other,
}
impl crate::Response for DeleteCollectionNamespacedEventResponse {
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((DeleteCollectionNamespacedEventResponse::OkStatus(result), buf.len()))
}
else {
let result = serde::Deserialize::deserialize(serde_json::Value::Object(result));
let result = result.map_err(crate::ResponseError::Json)?;
Ok((DeleteCollectionNamespacedEventResponse::OkValue(result), buf.len()))
}
},
http::StatusCode::UNAUTHORIZED => Ok((DeleteCollectionNamespacedEventResponse::Unauthorized, 0)),
_ => Ok((DeleteCollectionNamespacedEventResponse::Other, 0)),
}
}
}
impl Event {
pub fn delete_namespaced_event(
name: &str,
namespace: &str,
optional: DeleteNamespacedEventOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<DeleteNamespacedEventResponse>), crate::RequestError> {
let DeleteNamespacedEventOptional {
dry_run,
grace_period_seconds,
orphan_dependents,
pretty,
propagation_policy,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/events/{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 DeleteNamespacedEventOptional<'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 DeleteNamespacedEventResponse {
OkStatus(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
OkValue(crate::v1_13::api::core::v1::Event),
Accepted(crate::v1_13::apimachinery::pkg::apis::meta::v1::Status),
Unauthorized,
Other,
}
impl crate::Response for DeleteNamespacedEventResponse {
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((DeleteNamespacedEventResponse::OkStatus(result), buf.len()))
}
else {
let result = serde::Deserialize::deserialize(serde_json::Value::Object(result));
let result = result.map_err(crate::ResponseError::Json)?;
Ok((DeleteNamespacedEventResponse::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((DeleteNamespacedEventResponse::Accepted(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((DeleteNamespacedEventResponse::Unauthorized, 0)),
_ => Ok((DeleteNamespacedEventResponse::Other, 0)),
}
}
}
impl Event {
pub fn list_event_for_all_namespaces(
optional: ListEventForAllNamespacesOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ListEventForAllNamespacesResponse>), crate::RequestError> {
let ListEventForAllNamespacesOptional {
continue_,
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = "/api/v1/events?".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 ListEventForAllNamespacesOptional<'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 ListEventForAllNamespacesResponse {
Ok(crate::v1_13::api::core::v1::EventList),
Unauthorized,
Other,
}
impl crate::Response for ListEventForAllNamespacesResponse {
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((ListEventForAllNamespacesResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ListEventForAllNamespacesResponse::Unauthorized, 0)),
_ => Ok((ListEventForAllNamespacesResponse::Other, 0)),
}
}
}
impl Event {
pub fn list_namespaced_event(
namespace: &str,
optional: ListNamespacedEventOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ListNamespacedEventResponse>), crate::RequestError> {
let ListNamespacedEventOptional {
continue_,
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/events?", 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 ListNamespacedEventOptional<'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 ListNamespacedEventResponse {
Ok(crate::v1_13::api::core::v1::EventList),
Unauthorized,
Other,
}
impl crate::Response for ListNamespacedEventResponse {
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((ListNamespacedEventResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ListNamespacedEventResponse::Unauthorized, 0)),
_ => Ok((ListNamespacedEventResponse::Other, 0)),
}
}
}
impl Event {
pub fn patch_namespaced_event(
name: &str,
namespace: &str,
body: &crate::v1_13::apimachinery::pkg::apis::meta::v1::Patch,
optional: PatchNamespacedEventOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<PatchNamespacedEventResponse>), crate::RequestError> {
let PatchNamespacedEventOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/events/{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 PatchNamespacedEventOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum PatchNamespacedEventResponse {
Ok(crate::v1_13::api::core::v1::Event),
Unauthorized,
Other,
}
impl crate::Response for PatchNamespacedEventResponse {
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((PatchNamespacedEventResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((PatchNamespacedEventResponse::Unauthorized, 0)),
_ => Ok((PatchNamespacedEventResponse::Other, 0)),
}
}
}
impl Event {
pub fn read_namespaced_event(
name: &str,
namespace: &str,
optional: ReadNamespacedEventOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReadNamespacedEventResponse>), crate::RequestError> {
let ReadNamespacedEventOptional {
exact,
export,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/events/{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 ReadNamespacedEventOptional<'a> {
pub exact: Option<bool>,
pub export: Option<bool>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReadNamespacedEventResponse {
Ok(crate::v1_13::api::core::v1::Event),
Unauthorized,
Other,
}
impl crate::Response for ReadNamespacedEventResponse {
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((ReadNamespacedEventResponse::Ok(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReadNamespacedEventResponse::Unauthorized, 0)),
_ => Ok((ReadNamespacedEventResponse::Other, 0)),
}
}
}
impl Event {
pub fn replace_namespaced_event(
name: &str,
namespace: &str,
body: &crate::v1_13::api::core::v1::Event,
optional: ReplaceNamespacedEventOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<ReplaceNamespacedEventResponse>), crate::RequestError> {
let ReplaceNamespacedEventOptional {
dry_run,
pretty,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/events/{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 ReplaceNamespacedEventOptional<'a> {
pub dry_run: Option<&'a str>,
pub pretty: Option<&'a str>,
}
#[derive(Debug)]
pub enum ReplaceNamespacedEventResponse {
Ok(crate::v1_13::api::core::v1::Event),
Created(crate::v1_13::api::core::v1::Event),
Unauthorized,
Other,
}
impl crate::Response for ReplaceNamespacedEventResponse {
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((ReplaceNamespacedEventResponse::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((ReplaceNamespacedEventResponse::Created(result), buf.len()))
},
http::StatusCode::UNAUTHORIZED => Ok((ReplaceNamespacedEventResponse::Unauthorized, 0)),
_ => Ok((ReplaceNamespacedEventResponse::Other, 0)),
}
}
}
impl Event {
pub fn watch_event_for_all_namespaces(
optional: WatchEventForAllNamespacesOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<WatchEventForAllNamespacesResponse>), crate::RequestError> {
let WatchEventForAllNamespacesOptional {
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = "/api/v1/events?".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 WatchEventForAllNamespacesOptional<'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 WatchEventForAllNamespacesResponse {
Ok(crate::v1_13::apimachinery::pkg::apis::meta::v1::WatchEvent),
Unauthorized,
Other,
}
impl crate::Response for WatchEventForAllNamespacesResponse {
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((WatchEventForAllNamespacesResponse::Ok(result), byte_offset))
},
http::StatusCode::UNAUTHORIZED => Ok((WatchEventForAllNamespacesResponse::Unauthorized, 0)),
_ => Ok((WatchEventForAllNamespacesResponse::Other, 0)),
}
}
}
impl Event {
pub fn watch_namespaced_event(
namespace: &str,
optional: WatchNamespacedEventOptional<'_>,
) -> Result<(http::Request<Vec<u8>>, fn(http::StatusCode) -> crate::ResponseBody<WatchNamespacedEventResponse>), crate::RequestError> {
let WatchNamespacedEventOptional {
field_selector,
include_uninitialized,
label_selector,
limit,
pretty,
resource_version,
timeout_seconds,
} = optional;
let __url = format!("/api/v1/namespaces/{namespace}/events?", 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 WatchNamespacedEventOptional<'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 WatchNamespacedEventResponse {
Ok(crate::v1_13::apimachinery::pkg::apis::meta::v1::WatchEvent),
Unauthorized,
Other,
}
impl crate::Response for WatchNamespacedEventResponse {
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((WatchNamespacedEventResponse::Ok(result), byte_offset))
},
http::StatusCode::UNAUTHORIZED => Ok((WatchNamespacedEventResponse::Unauthorized, 0)),
_ => Ok((WatchNamespacedEventResponse::Other, 0)),
}
}
}
impl crate::Resource for Event {
fn api_version() -> &'static str {
"v1"
}
fn group() -> &'static str {
""
}
fn kind() -> &'static str {
"Event"
}
fn version() -> &'static str {
"v1"
}
}
impl crate::Metadata for Event {
type Ty = crate::v1_13::apimachinery::pkg::apis::meta::v1::ObjectMeta;
fn metadata(&self) -> Option<&<Self as crate::Metadata>::Ty> {
Some(&self.metadata)
}
}
impl<'de> serde::Deserialize<'de> for Event {
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_action,
Key_count,
Key_event_time,
Key_first_timestamp,
Key_involved_object,
Key_last_timestamp,
Key_message,
Key_metadata,
Key_reason,
Key_related,
Key_reporting_component,
Key_reporting_instance,
Key_series,
Key_source,
Key_type_,
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,
"action" => Field::Key_action,
"count" => Field::Key_count,
"eventTime" => Field::Key_event_time,
"firstTimestamp" => Field::Key_first_timestamp,
"involvedObject" => Field::Key_involved_object,
"lastTimestamp" => Field::Key_last_timestamp,
"message" => Field::Key_message,
"metadata" => Field::Key_metadata,
"reason" => Field::Key_reason,
"related" => Field::Key_related,
"reportingComponent" => Field::Key_reporting_component,
"reportingInstance" => Field::Key_reporting_instance,
"series" => Field::Key_series,
"source" => Field::Key_source,
"type" => Field::Key_type_,
_ => Field::Other,
})
}
}
deserializer.deserialize_identifier(Visitor)
}
}
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = Event;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "struct Event")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
let mut value_action: Option<String> = None;
let mut value_count: Option<i32> = None;
let mut value_event_time: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::MicroTime> = None;
let mut value_first_timestamp: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::Time> = None;
let mut value_involved_object: Option<crate::v1_13::api::core::v1::ObjectReference> = None;
let mut value_last_timestamp: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::Time> = None;
let mut value_message: Option<String> = None;
let mut value_metadata: Option<crate::v1_13::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
let mut value_reason: Option<String> = None;
let mut value_related: Option<crate::v1_13::api::core::v1::ObjectReference> = None;
let mut value_reporting_component: Option<String> = None;
let mut value_reporting_instance: Option<String> = None;
let mut value_series: Option<crate::v1_13::api::core::v1::EventSeries> = None;
let mut value_source: Option<crate::v1_13::api::core::v1::EventSource> = None;
let mut value_type_: Option<String> = 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_action => value_action = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_count => value_count = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_event_time => value_event_time = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_first_timestamp => value_first_timestamp = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_involved_object => value_involved_object = Some(serde::de::MapAccess::next_value(&mut map)?),
Field::Key_last_timestamp => value_last_timestamp = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_message => value_message = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_metadata => value_metadata = Some(serde::de::MapAccess::next_value(&mut map)?),
Field::Key_reason => value_reason = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_related => value_related = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_reporting_component => value_reporting_component = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_reporting_instance => value_reporting_instance = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_series => value_series = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_source => value_source = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_type_ => value_type_ = serde::de::MapAccess::next_value(&mut map)?,
Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
}
}
Ok(Event {
action: value_action,
count: value_count,
event_time: value_event_time,
first_timestamp: value_first_timestamp,
involved_object: value_involved_object.ok_or_else(|| serde::de::Error::missing_field("involvedObject"))?,
last_timestamp: value_last_timestamp,
message: value_message,
metadata: value_metadata.ok_or_else(|| serde::de::Error::missing_field("metadata"))?,
reason: value_reason,
related: value_related,
reporting_component: value_reporting_component,
reporting_instance: value_reporting_instance,
series: value_series,
source: value_source,
type_: value_type_,
})
}
}
deserializer.deserialize_struct(
"Event",
&[
"apiVersion",
"kind",
"action",
"count",
"eventTime",
"firstTimestamp",
"involvedObject",
"lastTimestamp",
"message",
"metadata",
"reason",
"related",
"reportingComponent",
"reportingInstance",
"series",
"source",
"type",
],
Visitor,
)
}
}
impl serde::Serialize for Event {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
let mut state = serializer.serialize_struct(
"Event",
4 +
self.action.as_ref().map_or(0, |_| 1) +
self.count.as_ref().map_or(0, |_| 1) +
self.event_time.as_ref().map_or(0, |_| 1) +
self.first_timestamp.as_ref().map_or(0, |_| 1) +
self.last_timestamp.as_ref().map_or(0, |_| 1) +
self.message.as_ref().map_or(0, |_| 1) +
self.reason.as_ref().map_or(0, |_| 1) +
self.related.as_ref().map_or(0, |_| 1) +
self.reporting_component.as_ref().map_or(0, |_| 1) +
self.reporting_instance.as_ref().map_or(0, |_| 1) +
self.series.as_ref().map_or(0, |_| 1) +
self.source.as_ref().map_or(0, |_| 1) +
self.type_.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.action {
serde::ser::SerializeStruct::serialize_field(&mut state, "action", value)?;
}
if let Some(value) = &self.count {
serde::ser::SerializeStruct::serialize_field(&mut state, "count", value)?;
}
if let Some(value) = &self.event_time {
serde::ser::SerializeStruct::serialize_field(&mut state, "eventTime", value)?;
}
if let Some(value) = &self.first_timestamp {
serde::ser::SerializeStruct::serialize_field(&mut state, "firstTimestamp", value)?;
}
serde::ser::SerializeStruct::serialize_field(&mut state, "involvedObject", &self.involved_object)?;
if let Some(value) = &self.last_timestamp {
serde::ser::SerializeStruct::serialize_field(&mut state, "lastTimestamp", value)?;
}
if let Some(value) = &self.message {
serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
}
serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
if let Some(value) = &self.reason {
serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
}
if let Some(value) = &self.related {
serde::ser::SerializeStruct::serialize_field(&mut state, "related", value)?;
}
if let Some(value) = &self.reporting_component {
serde::ser::SerializeStruct::serialize_field(&mut state, "reportingComponent", value)?;
}
if let Some(value) = &self.reporting_instance {
serde::ser::SerializeStruct::serialize_field(&mut state, "reportingInstance", value)?;
}
if let Some(value) = &self.series {
serde::ser::SerializeStruct::serialize_field(&mut state, "series", value)?;
}
if let Some(value) = &self.source {
serde::ser::SerializeStruct::serialize_field(&mut state, "source", value)?;
}
if let Some(value) = &self.type_ {
serde::ser::SerializeStruct::serialize_field(&mut state, "type", value)?;
}
serde::ser::SerializeStruct::end(state)
}
}