use serde_json::Value;
use thiserror::Error;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HttpMethod {
Get,
Post,
Put,
Patch,
Delete,
}
impl HttpMethod {
#[must_use]
pub fn as_reqwest(self) -> reqwest::Method {
match self {
Self::Get => reqwest::Method::GET,
Self::Post => reqwest::Method::POST,
Self::Put => reqwest::Method::PUT,
Self::Patch => reqwest::Method::PATCH,
Self::Delete => reqwest::Method::DELETE,
}
}
#[must_use]
pub fn label(self) -> &'static str {
match self {
Self::Get => "GET",
Self::Post => "POST",
Self::Put => "PUT",
Self::Patch => "PATCH",
Self::Delete => "DELETE",
}
}
}
#[derive(Clone, Debug)]
pub struct Observation {
pub status: u16,
pub content_type: Option<String>,
pub json: Value,
}
impl Observation {
#[must_use]
pub fn is_success(&self) -> bool {
(200..300).contains(&self.status)
}
}
#[derive(Debug, Error)]
pub enum DiffError {
#[error("transport error against {side}: {source}")]
Transport {
side: &'static str,
#[source]
source: reqwest::Error,
},
#[error("kube error: {0}")]
Kube(String),
#[error("engenho boot error: {0}")]
Boot(String),
}