#[cfg(feature = "json")]
use serde::{Deserialize, Serialize};
pub use super::Identifier as NewAuthorization;
#[cfg(feature = "json")]
impl NewAuthorization {
pub fn from_str(s: &str) -> Result<NewAuthorization, serde_json::error::Error> {
serde_json::from_str(s)
}
pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
serde_json::to_string(self)
}
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
pub struct Authorization {
pub identifier: super::Identifier,
pub status: AuthorizationStatus,
pub expires: Option<String>,
pub challenges: Vec<Challenge>,
pub wildcard: Option<bool>,
}
#[cfg(feature = "json")]
impl Authorization {
pub fn from_str(s: &str) -> Result<Authorization, serde_json::error::Error> {
serde_json::from_str(s)
}
pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
serde_json::to_string(self)
}
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
pub struct AuthorizationUpdate {
pub status: AuthorizationStatus,
}
#[cfg(feature = "json")]
impl AuthorizationUpdate {
pub fn from_str(s: &str) -> Result<AuthorizationUpdate, serde_json::error::Error> {
serde_json::from_str(s)
}
pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
serde_json::to_string(self)
}
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
pub struct Challenge {
pub url: String,
#[cfg_attr(feature = "json", serde(rename = "type"))]
pub type_: ChallengeType,
pub status: ChallengeStatus,
pub token: Option<String>,
pub validated: Option<String>,
pub error: Option<super::Error>,
}
#[cfg(feature = "json")]
impl Challenge {
pub fn from_str(s: &str) -> Result<Challenge, serde_json::error::Error> {
serde_json::from_str(s)
}
pub fn to_string(&self) -> Result<String, serde_json::error::Error> {
serde_json::to_string(self)
}
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
pub enum ChallengeStatus {
#[cfg_attr(feature = "json", serde(rename = "pending"))]
Pending,
#[cfg_attr(feature = "json", serde(rename = "processing"))]
Processing,
#[cfg_attr(feature = "json", serde(rename = "valid"))]
Valid,
#[cfg_attr(feature = "json", serde(rename = "invalid"))]
Invalid,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
pub enum ChallengeType {
#[cfg_attr(feature = "json", serde(rename = "http-01"))]
Http01,
#[cfg_attr(feature = "json", serde(rename = "dns-01"))]
Dns01,
}
#[derive(Clone, Debug)]
#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
pub enum AuthorizationStatus {
#[cfg_attr(feature = "json", serde(rename = "pending"))]
Pending,
#[cfg_attr(feature = "json", serde(rename = "expired"))]
Expired,
#[cfg_attr(feature = "json", serde(rename = "deactivated"))]
Deactivated,
#[cfg_attr(feature = "json", serde(rename = "revoked"))]
Revoked,
#[cfg_attr(feature = "json", serde(rename = "valid"))]
Valid,
#[cfg_attr(feature = "json", serde(rename = "invalid"))]
Invalid,
}